@@ -354,10 +354,23 @@ impl LintStore {
354
354
lint_name. to_string ( )
355
355
} ;
356
356
// If the lint was scoped with `tool::` check if the tool lint exists
357
- if tool_name . is_some ( ) {
357
+ if let Some ( tool_name ) = tool_name {
358
358
match self . by_name . get ( & complete_name) {
359
359
None => match self . lint_groups . get ( & * complete_name) {
360
- None => return CheckLintNameResult :: Tool ( Err ( ( None , String :: new ( ) ) ) ) ,
360
+ // If the lint isn't registered, there are two possibilities:
361
+ None => {
362
+ // 1. The tool is currently running, so this lint really doesn't exist.
363
+ // FIXME: should this handle tools that never register a lint, like rustfmt?
364
+ tracing:: debug!( "lints={:?}" , self . by_name. keys( ) . collect:: <Vec <_>>( ) ) ;
365
+ let tool_prefix = format ! ( "{}::" , tool_name) ;
366
+ return if self . by_name . keys ( ) . any ( |lint| lint. starts_with ( & tool_prefix) ) {
367
+ self . no_lint_suggestion ( & complete_name)
368
+ } else {
369
+ // 2. The tool isn't currently running, so no lints will be registered.
370
+ // To avoid giving a false positive, ignore all unknown lints.
371
+ CheckLintNameResult :: Tool ( Err ( ( None , String :: new ( ) ) ) )
372
+ } ;
373
+ }
361
374
Some ( LintGroup { lint_ids, .. } ) => {
362
375
return CheckLintNameResult :: Tool ( Ok ( & lint_ids) ) ;
363
376
}
@@ -398,6 +411,15 @@ impl LintStore {
398
411
}
399
412
}
400
413
414
+ fn no_lint_suggestion ( & self , lint_name : & str ) -> CheckLintNameResult < ' _ > {
415
+ let symbols = self . by_name . keys ( ) . map ( |name| Symbol :: intern ( & name) ) . collect :: < Vec < _ > > ( ) ;
416
+
417
+ let suggestion =
418
+ find_best_match_for_name ( & symbols, Symbol :: intern ( & lint_name. to_lowercase ( ) ) , None ) ;
419
+
420
+ CheckLintNameResult :: NoLint ( suggestion)
421
+ }
422
+
401
423
fn check_tool_name_for_backwards_compat (
402
424
& self ,
403
425
lint_name : & str ,
@@ -407,18 +429,7 @@ impl LintStore {
407
429
match self . by_name . get ( & complete_name) {
408
430
None => match self . lint_groups . get ( & * complete_name) {
409
431
// Now we are sure, that this lint exists nowhere
410
- None => {
411
- let symbols =
412
- self . by_name . keys ( ) . map ( |name| Symbol :: intern ( & name) ) . collect :: < Vec < _ > > ( ) ;
413
-
414
- let suggestion = find_best_match_for_name (
415
- & symbols,
416
- Symbol :: intern ( & lint_name. to_lowercase ( ) ) ,
417
- None ,
418
- ) ;
419
-
420
- CheckLintNameResult :: NoLint ( suggestion)
421
- }
432
+ None => self . no_lint_suggestion ( lint_name) ,
422
433
Some ( LintGroup { lint_ids, depr, .. } ) => {
423
434
// Reaching this would be weird, but let's cover this case anyway
424
435
if let Some ( LintAlias { name, silent } ) = depr {
0 commit comments