File tree Expand file tree Collapse file tree 3 files changed +58
-3
lines changed Expand file tree Collapse file tree 3 files changed +58
-3
lines changed Original file line number Diff line number Diff line change @@ -247,13 +247,27 @@ impl<'a> LintLevelsBuilder<'a> {
247247 self . cur ,
248248 Some ( & specs) ) ;
249249 let msg = format ! ( "unknown lint: `{}`" , name) ;
250- lint:: struct_lint_level ( self . sess ,
250+ let mut db = lint:: struct_lint_level ( self . sess ,
251251 lint,
252252 level,
253253 src,
254254 Some ( li. span . into ( ) ) ,
255- & msg)
256- . emit ( ) ;
255+ & msg) ;
256+ if name. as_str ( ) . chars ( ) . any ( |c| c. is_uppercase ( ) ) {
257+ let name_lower = name. as_str ( ) . to_lowercase ( ) ;
258+ if let CheckLintNameResult :: NoLint =
259+ store. check_lint_name ( & name_lower) {
260+ db. emit ( ) ;
261+ } else {
262+ db. span_suggestion (
263+ li. span ,
264+ "lowercase the lint name" ,
265+ name_lower
266+ ) . emit ( ) ;
267+ }
268+ } else {
269+ db. emit ( ) ;
270+ }
257271 }
258272 }
259273 }
Original file line number Diff line number Diff line change 1+ // Copyright 2014–2017 The Rust Project Developers. See the COPYRIGHT
2+ // file at the top-level directory of this distribution and at
3+ // http://rust-lang.org/COPYRIGHT.
4+ //
5+ // Licensed under the Apache License, Version 2.0 <LICENSE-APACHE or
6+ // http://www.apache.org/licenses/LICENSE-2.0> or the MIT license
7+ // <LICENSE-MIT or http://opensource.org/licenses/MIT>, at your
8+ // option. This file may not be copied, modified, or distributed
9+ // except according to those terms.
10+
11+ // this tests the `unknown_lint` lint, especially the suggestions
12+
13+ // the suggestion only appears if a lint with the lowercase name exists
14+ #[ allow( FOO_BAR ) ]
15+ // the suggestion appears on all-uppercase names
16+ #[ warn( DEAD_CODE ) ]
17+ // the suggestion appears also on mixed-case names
18+ #[ deny( Warnings ) ]
19+ fn main ( ) {
20+ unimplemented ! ( ) ;
21+ }
Original file line number Diff line number Diff line change 1+ warning: unknown lint: `FOO_BAR`
2+ --> $DIR/not_found.rs:14:9
3+ |
4+ 14 | #[allow(FOO_BAR)]
5+ | ^^^^^^^
6+ |
7+ = note: #[warn(unknown_lints)] on by default
8+
9+ warning: unknown lint: `DEAD_CODE`
10+ --> $DIR/not_found.rs:16:8
11+ |
12+ 16 | #[warn(DEAD_CODE)]
13+ | ^^^^^^^^^ help: lowercase the lint name: `dead_code`
14+
15+ warning: unknown lint: `Warnings`
16+ --> $DIR/not_found.rs:18:8
17+ |
18+ 18 | #[deny(Warnings)]
19+ | ^^^^^^^^ help: lowercase the lint name: `warnings`
20+
You can’t perform that action at this time.
0 commit comments