diff options
| author | Manish Goregaokar <manishsmail@gmail.com> | 2021-03-08 15:43:18 -0800 |
|---|---|---|
| committer | Manish Goregaokar <manishsmail@gmail.com> | 2021-04-12 09:45:59 -0700 |
| commit | 664c3e71b8eebf824f5e652e0f0511acda99394c (patch) | |
| tree | c79297deeb720f22d3db668cad5d686c3251a1f5 /compiler/rustc_lint/src | |
| parent | c18c0ad2bc5988ca7953459e5a35ece8e69e35e7 (diff) | |
| download | rust-664c3e71b8eebf824f5e652e0f0511acda99394c.tar.gz rust-664c3e71b8eebf824f5e652e0f0511acda99394c.zip | |
Turn old edition lints (anonymous-parameters, keyword-idents) into warn-by-default on 2015
Diffstat (limited to 'compiler/rustc_lint/src')
| -rw-r--r-- | compiler/rustc_lint/src/builtin.rs | 11 |
1 files changed, 7 insertions, 4 deletions
diff --git a/compiler/rustc_lint/src/builtin.rs b/compiler/rustc_lint/src/builtin.rs index 0b49e6562f9..c4acaef21dd 100644 --- a/compiler/rustc_lint/src/builtin.rs +++ b/compiler/rustc_lint/src/builtin.rs @@ -857,11 +857,10 @@ declare_lint! { /// ``` /// /// This syntax is now a hard error in the 2018 edition. In the 2015 - /// edition, this lint is "allow" by default, because the old code is - /// still valid, and warning for all old code can be noisy. This lint + /// edition, this lint is "warn" by default. This lint /// enables the [`cargo fix`] tool with the `--edition` flag to /// automatically transition old code from the 2015 edition to 2018. The - /// tool will switch this lint to "warn" and will automatically apply the + /// tool will run this lint and automatically apply the /// suggested fix from the compiler (which is to add `_` to each /// parameter). This provides a completely automated way to update old /// code for a new edition. See [issue #41686] for more details. @@ -869,7 +868,7 @@ declare_lint! { /// [issue #41686]: https://github.com/rust-lang/rust/issues/41686 /// [`cargo fix`]: https://doc.rust-lang.org/cargo/commands/cargo-fix.html pub ANONYMOUS_PARAMETERS, - Allow, + Warn, "detects anonymous parameters", @future_incompatible = FutureIncompatibleInfo { reference: "issue #41686 <https://github.com/rust-lang/rust/issues/41686>", @@ -884,6 +883,10 @@ declare_lint_pass!( impl EarlyLintPass for AnonymousParameters { fn check_trait_item(&mut self, cx: &EarlyContext<'_>, it: &ast::AssocItem) { + if cx.sess.edition() != Edition::Edition2015 { + // This is a hard error in future editions; avoid linting and erroring + return; + } if let ast::AssocItemKind::Fn(box FnKind(_, ref sig, _, _)) = it.kind { for arg in sig.decl.inputs.iter() { if let ast::PatKind::Ident(_, ident, None) = arg.pat.kind { |
