rust/compiler/rustc_errors/src
Matthias Krüger 8828af4d88
Rollup merge of #99935 - CAD97:unstable-syntax-lints, r=petrochenkov
Reenable disabled early syntax gates as future-incompatibility lints

- MCP: https://github.com/rust-lang/compiler-team/issues/535

The approach taken by this PR is

- Introduce a new lint, `unstable_syntax_pre_expansion`, and reenable the early syntax gates to emit it
- Use the diagnostic stashing mechanism to stash warnings the early warnings
- When the hard error occurs post expansion, steal and cancel the early warning
- Don't display any stashed warnings if errors are present to avoid the same noise problem that hiding type ascription errors is avoiding

Commits are working commits, but in a coherent steps-to-implement manner. Can be squashed if desired.

The preexisting `soft_unstable` lint seems like it would've been a good fit, but it is deny-by-default (appropriate for `#[bench]`) and these gates should be introduced as warn-by-default.

It may be desirable to change the stash mechanism's behavior to not flush lint errors in the presence of other errors either (like is done for warnings here), but upgrading a stash-using lint from warn to error perhaps is enough of a request to see the lint that they shouldn't be hidden; additionally, fixing the last error to get new errors thrown at you always feels bad, so if we know the lint errors are present, we should show them.

Using a new flag/mechanism for a "weak diagnostic" which is suppressed by other errors may also be desirable over assuming any stashed warnings are "weak," but this is the first user of stashing warnings and seems an appropriate use of stashing (it follows the "know more later to refine the diagnostic" pattern; here we learn that it's in a compiled position) so we get to define what it means to stash a non-hard-error diagnostic.

cc `````@petrochenkov````` (seconded MCP)
2022-08-20 19:45:10 +02:00
..
json Use serde_json for json error messages 2022-06-03 16:46:19 +00:00
annotate_snippet_emitter_writer.rs errors: move translation logic into module 2022-08-15 12:26:35 +01:00
diagnostic_builder.rs never consider unsafe blocks unused if they would be required with unsafe_op_in_unsafe_fn 2022-08-02 17:09:41 -04:00
diagnostic.rs Moved structs to rustc_expand::errors, added several more migrations, fixed slug name 2022-08-17 11:18:19 -03:00
emitter.rs errors: move translation logic into module 2022-08-15 12:26:35 +01:00
json.rs errors: move translation logic into module 2022-08-15 12:26:35 +01:00
lib.rs Rollup merge of #99935 - CAD97:unstable-syntax-lints, r=petrochenkov 2022-08-20 19:45:10 +02:00
lock.rs mv compiler to compiler/ 2020-08-30 18:45:07 +03:00
registry.rs Remove (lots of) dead code 2021-03-27 22:16:33 -04:00
snippet.rs Compute most of Public/Exported access level in rustc_resolve 2022-01-09 21:33:14 +00:00
styled_buffer.rs Spellchecking some comments 2022-03-30 01:39:38 -04:00
translation.rs errors: move translation logic into module 2022-08-15 12:26:35 +01:00