@@ -88,7 +88,7 @@ impl<'s> LintLevelsBuilder<'s> {
8888 self . sets . lint_cap = sess. opts . lint_cap . unwrap_or ( Level :: Forbid ) ;
8989
9090 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 ) ;
9292 let orig_level = level;
9393
9494 // If the cap is less than this specified level, e.g., if we've got
@@ -110,7 +110,7 @@ impl<'s> LintLevelsBuilder<'s> {
110110 }
111111
112112 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 ) ;
114114 let lints = store
115115 . find_lints ( lint_name)
116116 . unwrap_or_else ( |_| bug ! ( "A valid lint failed to produce a lint ids" ) ) ;
@@ -321,33 +321,15 @@ impl<'s> LintLevelsBuilder<'s> {
321321 continue ;
322322 }
323323 } ;
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 )
346326 } else {
347327 None
348328 } ;
329+ let tool_name = tool_ident. map ( |ident| ident. name ) ;
349330 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 ) ;
351333 match & lint_result {
352334 CheckLintNameResult :: Ok ( ids) => {
353335 let src = LintLevelSource :: Node (
@@ -364,7 +346,8 @@ impl<'s> LintLevelsBuilder<'s> {
364346 CheckLintNameResult :: Tool ( result) => {
365347 match * result {
366348 Ok ( ids) => {
367- let complete_name = & format ! ( "{}::{}" , tool_name. unwrap( ) , name) ;
349+ let complete_name =
350+ & format ! ( "{}::{}" , tool_ident. unwrap( ) . name, name) ;
368351 let src = LintLevelSource :: Node (
369352 Symbol :: intern ( complete_name) ,
370353 sp,
@@ -419,6 +402,26 @@ impl<'s> LintLevelsBuilder<'s> {
419402 }
420403 }
421404
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+
422425 _ if !self . warn_about_weird_lints => { }
423426
424427 CheckLintNameResult :: Warning ( msg, renamed) => {
@@ -450,8 +453,8 @@ impl<'s> LintLevelsBuilder<'s> {
450453 let ( level, src) =
451454 self . sets . get_lint_level ( lint, self . cur , Some ( & specs) , self . sess ) ;
452455 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)
455458 } else {
456459 name. to_string ( )
457460 } ;
@@ -578,7 +581,7 @@ impl<'s> LintLevelsBuilder<'s> {
578581 }
579582}
580583
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 {
582585 if [ sym:: clippy, sym:: rustc, sym:: rustdoc] . contains ( & m_item) {
583586 return true ;
584587 }
0 commit comments