]> git.lizzy.rs Git - rust.git/commit
Rollup merge of #99935 - CAD97:unstable-syntax-lints, r=petrochenkov
authorMatthias Krüger <matthias.krueger@famsik.de>
Sat, 20 Aug 2022 17:45:10 +0000 (19:45 +0200)
committerGitHub <noreply@github.com>
Sat, 20 Aug 2022 17:45:10 +0000 (19:45 +0200)
commit8828af4d88f69a3fce63e7ea6420f3363127802c
treed9395a73d00d8b8881655f26d3728c1ddacc04fc
parentd9789b6903482459ae97114a649b1a53e9b6101a
parent944c6b6d760d392552fc60ec4e3ba3ad84598350
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)
compiler/rustc_errors/src/lib.rs