@@ -372,35 +372,37 @@ pub fn late_lint_mod<'tcx, T: LateLintPass<'tcx> + 'tcx>(
372372 store. late_module_passes . iter ( ) . map ( |mk_pass| ( mk_pass) ( tcx) ) . collect ( ) ;
373373
374374 // Filter unused lints
375- let lints_allowed = & * * tcx. lints_that_can_emit ( ( ) ) ;
375+ let ( lints_to_emit , lints_allowed) = & * * tcx. lints_that_can_emit ( ( ) ) ;
376376 // let lints_to_emit = &lints_that_can_emit.0;
377377 // let lints_allowed = &lints_that_can_emit.1;
378378
379379 // Now, we'll filtered passes in a way that discards any lint that
380380 let mut filtered_passes: Vec < Box < dyn LateLintPass < ' tcx > > > = passes
381- . into_iter ( )
382- . filter ( |pass| {
383- let pass = LintPass :: get_lints ( pass) ;
384- pass. iter ( ) . any ( |& lint| {
385- let lint_name = & lint. name . to_lowercase ( )
381+ . into_iter ( )
382+ . filter ( |pass| {
383+ let pass = LintPass :: get_lints ( pass) ;
384+ pass. iter ( ) . any ( |& lint| {
385+ let lint_name =
386+ & lint. name . to_lowercase ( )
386387 // Doing some calculations here to account for those separators
387- [ lint. name . find ( "::" ) . unwrap_or ( lint. name . len ( ) - 2 ) + 2 ..] ;
388- !lints_allowed. contains ( & lint_name. to_string ( ) )
389- && lint. default_level != crate :: Level :: Allow
390- } )
391- // if passes_lints[i].iter().any(|&lint| {
392- // let symbol =
393- // &lint.name.to_lowercase()
394- // // Doing some calculations here to account for those separators
395- // [lint.name.find("::").unwrap_or(lint.name.len() - 2) + 2..]
396-
397- // // ^^^ Expensive, but more expensive would be having to
398- // // cast every element to &str
399-
400- // (!lints_allowed.contains(&lint.name)
401- // && lint.default_level != crate::Level::Allow)
388+ [ lint. name . find ( "::" ) . unwrap_or ( lint. name . len ( ) - 2 ) + 2 ..] . to_string ( ) ;
389+ lints_to_emit. contains ( & lint_name) || ( !lints_allowed. contains ( & lint_name) && lint. default_level != crate :: Level :: Allow )
390+ } )
391+ // if passes_lints[i].iter().any(|&lint| {
392+ // let symbol =
393+ // &lint.name.to_lowercase()
394+ // // Doing some calculations here to account for those separators
395+ // [lint.name.find("::").unwrap_or(lint.name.len() - 2) + 2..]
396+
397+ // // ^^^ Expensive, but more expensive would be having to
398+ // // cast every element to &str
399+
400+
401+
402+ // (!lints_allowed.contains(&lint.name)
403+ // && lint.default_level != crate::Level::Allow)
402404 } )
403- . collect ( ) ;
405+ . collect ( ) ;
404406
405407 filtered_passes. push ( Box :: new ( builtin_lints) ) ;
406408
@@ -453,24 +455,35 @@ fn late_lint_crate<'tcx>(tcx: TyCtxt<'tcx>) {
453455 only_module : false ,
454456 } ;
455457
456- let lints_allowed = & * * tcx. lints_that_can_emit ( ( ) ) ;
457- // let lints_to_emit = &lints_that_can_emit.0;
458- // let lints_allowed = &lints_that_can_emit.1;
458+ let ( lints_to_emit, lints_allowed) = & * * tcx. lints_that_can_emit ( ( ) ) ;
459459
460460 // Now, we'll filtered passes in a way that discards any lint that
461461 let mut filtered_passes: Vec < Box < dyn LateLintPass < ' tcx > > > = passes
462462 . into_iter ( )
463463 . filter ( |pass| {
464464 let pass = LintPass :: get_lints ( pass) ;
465465 pass. iter ( ) . any ( |& lint| {
466- let lint_name = & lint. name . to_lowercase ( )
466+ let lint_name =
467+ & lint. name . to_lowercase ( )
467468 // Doing some calculations here to account for those separators
468- [ lint. name . find ( "::" ) . unwrap_or ( lint. name . len ( ) - 2 ) + 2 ..] ;
469- !lints_allowed . contains ( & lint_name. to_string ( ) )
470- && lint. default_level != crate :: Level :: Allow
469+ [ lint. name . find ( "::" ) . unwrap_or ( lint. name . len ( ) - 2 ) + 2 ..] . to_string ( ) ;
470+ lints_to_emit . contains ( & lint_name) ||
471+ ( !lints_allowed . contains ( lint_name ) && lint. default_level != crate :: Level :: Allow )
471472 } )
472- } )
473- . collect ( ) ;
473+ // if passes_lints[i].iter().any(|&lint| {
474+ // let symbol =
475+ // &lint.name.to_lowercase()
476+ // // Doing some calculations here to account for those separators
477+ // [lint.name.find("::").unwrap_or(lint.name.len() - 2) + 2..]
478+
479+ // // ^^^ Expensive, but more expensive would be having to
480+ // // cast every element to &str
481+
482+
483+
484+ // (!lints_allowed.contains(&lint.name)
485+ // && lint.default_level != crate::Level::Allow)
486+ } ) . collect ( ) ;
474487
475488 let pass = RuntimeCombinedLateLintPass { passes : & mut filtered_passes[ ..] } ;
476489 late_lint_crate_inner ( tcx, context, pass) ;
0 commit comments