@@ -88,7 +88,7 @@ impl<'s> LintLevelsBuilder<'s> {
88
88
self . sets . lint_cap = sess. opts . lint_cap . unwrap_or ( Level :: Forbid ) ;
89
89
90
90
for & ( ref lint_name, level) in & sess. opts . lint_opts {
91
- store. check_lint_name_cmdline ( sess, & lint_name, level) ;
91
+ store. check_lint_name_cmdline ( sess, & lint_name, level, self . crate_attrs ) ;
92
92
let orig_level = level;
93
93
94
94
// If the cap is less than this specified level, e.g., if we've got
@@ -110,7 +110,7 @@ impl<'s> LintLevelsBuilder<'s> {
110
110
}
111
111
112
112
for lint_name in & sess. opts . force_warns {
113
- store. check_lint_name_cmdline ( sess, lint_name, Level :: ForceWarn ) ;
113
+ store. check_lint_name_cmdline ( sess, lint_name, Level :: ForceWarn , self . crate_attrs ) ;
114
114
let lints = store
115
115
. find_lints ( lint_name)
116
116
. unwrap_or_else ( |_| bug ! ( "A valid lint failed to produce a lint ids" ) ) ;
@@ -321,33 +321,15 @@ impl<'s> LintLevelsBuilder<'s> {
321
321
continue ;
322
322
}
323
323
} ;
324
- let tool_name = if meta_item. path . segments . len ( ) > 1 {
325
- let tool_ident = meta_item. path . segments [ 0 ] . ident ;
326
- if !is_known_lint_tool ( tool_ident. name , sess, & self . crate_attrs ) {
327
- let mut err = struct_span_err ! (
328
- sess,
329
- tool_ident. span,
330
- E0710 ,
331
- "unknown tool name `{}` found in scoped lint: `{}`" ,
332
- tool_ident. name,
333
- pprust:: path_to_string( & meta_item. path) ,
334
- ) ;
335
- if sess. is_nightly_build ( ) {
336
- err. help ( & format ! (
337
- "add `#![register_tool({})]` to the crate root" ,
338
- tool_ident. name
339
- ) ) ;
340
- }
341
- err. emit ( ) ;
342
- continue ;
343
- }
344
-
345
- Some ( meta_item. path . segments . remove ( 0 ) . ident . name )
324
+ let tool_ident = if meta_item. path . segments . len ( ) > 1 {
325
+ Some ( meta_item. path . segments . remove ( 0 ) . ident )
346
326
} else {
347
327
None
348
328
} ;
329
+ let tool_name = tool_ident. map ( |ident| ident. name ) ;
349
330
let name = pprust:: path_to_string ( & meta_item. path ) ;
350
- let lint_result = store. check_lint_name ( & name, tool_name) ;
331
+ let lint_result =
332
+ store. check_lint_and_tool_name ( sess, tool_name, & name, self . crate_attrs ) ;
351
333
match & lint_result {
352
334
CheckLintNameResult :: Ok ( ids) => {
353
335
let src = LintLevelSource :: Node (
@@ -364,7 +346,8 @@ impl<'s> LintLevelsBuilder<'s> {
364
346
CheckLintNameResult :: Tool ( result) => {
365
347
match * result {
366
348
Ok ( ids) => {
367
- let complete_name = & format ! ( "{}::{}" , tool_name. unwrap( ) , name) ;
349
+ let complete_name =
350
+ & format ! ( "{}::{}" , tool_ident. unwrap( ) . name, name) ;
368
351
let src = LintLevelSource :: Node (
369
352
Symbol :: intern ( complete_name) ,
370
353
sp,
@@ -419,6 +402,26 @@ impl<'s> LintLevelsBuilder<'s> {
419
402
}
420
403
}
421
404
405
+ & CheckLintNameResult :: NoTool => {
406
+ let mut err = struct_span_err ! (
407
+ sess,
408
+ tool_ident. map_or( DUMMY_SP , |ident| ident. span) ,
409
+ E0710 ,
410
+ "unknown tool name `{}` found in scoped lint: `{}::{}`" ,
411
+ tool_name. unwrap( ) ,
412
+ tool_name. unwrap( ) ,
413
+ pprust:: path_to_string( & meta_item. path) ,
414
+ ) ;
415
+ if sess. is_nightly_build ( ) {
416
+ err. help ( & format ! (
417
+ "add `#![register_tool({})]` to the crate root" ,
418
+ tool_name. unwrap( )
419
+ ) ) ;
420
+ }
421
+ err. emit ( ) ;
422
+ continue ;
423
+ }
424
+
422
425
_ if !self . warn_about_weird_lints => { }
423
426
424
427
CheckLintNameResult :: Warning ( msg, renamed) => {
@@ -450,8 +453,8 @@ impl<'s> LintLevelsBuilder<'s> {
450
453
let ( level, src) =
451
454
self . sets . get_lint_level ( lint, self . cur , Some ( & specs) , self . sess ) ;
452
455
struct_lint_level ( self . sess , lint, level, src, Some ( sp. into ( ) ) , |lint| {
453
- let name = if let Some ( tool_name ) = tool_name {
454
- format ! ( "{}::{}" , tool_name , name)
456
+ let name = if let Some ( tool_ident ) = tool_ident {
457
+ format ! ( "{}::{}" , tool_ident . name , name)
455
458
} else {
456
459
name. to_string ( )
457
460
} ;
@@ -578,7 +581,7 @@ impl<'s> LintLevelsBuilder<'s> {
578
581
}
579
582
}
580
583
581
- fn is_known_lint_tool ( m_item : Symbol , sess : & Session , attrs : & [ ast:: Attribute ] ) -> bool {
584
+ pub fn is_known_lint_tool ( m_item : Symbol , sess : & Session , attrs : & [ ast:: Attribute ] ) -> bool {
582
585
if [ sym:: clippy, sym:: rustc, sym:: rustdoc] . contains ( & m_item) {
583
586
return true ;
584
587
}
0 commit comments