77use rustc_ast:: ptr:: P ;
88use rustc_ast:: visit:: { self as ast_visit, Visitor , walk_list} ;
99use rustc_ast:: { self as ast, HasAttrs } ;
10- use rustc_data_structures:: fx:: FxHashSet ;
1110use rustc_data_structures:: stack:: ensure_sufficient_stack;
1211use rustc_feature:: Features ;
13- use rustc_hir:: { HirId , ItemLocalId , OwnerId } ;
14- use rustc_middle:: hir;
15- use rustc_middle:: lint:: LintLevelSource ;
1612use rustc_middle:: ty:: { RegisteredTools , TyCtxt } ;
1713use rustc_session:: lint:: { BufferedEarlyLint , LintBuffer , LintPass } ;
1814use rustc_session:: { Session , lint} ;
19- use rustc_span:: def_id:: CRATE_DEF_ID ;
2015use rustc_span:: { Ident , Span } ;
2116use tracing:: debug;
2217
23- use crate :: builtin:: UnsafeCode ;
2418use crate :: context:: { EarlyContext , LintContext , LintStore } ;
2519use crate :: passes:: { EarlyLintPass , EarlyLintPassObject } ;
26- use crate :: { Level , LintId } ;
2720
2821pub ( super ) mod diagnostics;
2922
@@ -326,6 +319,7 @@ pub fn check_ast_node<'a>(
326319 registered_tools : & RegisteredTools ,
327320 lint_buffer : Option < LintBuffer > ,
328321 builtin_lints : impl EarlyLintPass + ' static ,
322+ builtin_lints_2 : Option < impl EarlyLintPass + ' static > ,
329323 check_node : impl EarlyCheckNode < ' a > ,
330324) {
331325 let context = EarlyContext :: new (
@@ -343,33 +337,22 @@ pub fn check_ast_node<'a>(
343337 let passes =
344338 if pre_expansion { & lint_store. pre_expansion_passes } else { & lint_store. early_passes } ;
345339 if passes. is_empty ( ) {
346- if let Some ( tcx) = tcx {
347- if sess. opts . lint_cap . is_some_and ( |cap| cap == lint:: Allow ) {
348- let lints_that_must_run = builtin_lints
349- . get_lints ( )
350- . into_iter ( )
351- . filter ( |lint| {
352- let has_future_breakage = lint
353- . future_incompatible
354- . is_some_and ( |fut| fut. reason . has_future_breakage ( ) ) ;
355- has_future_breakage || lint. eval_always
356- } )
357- . collect :: < Vec < _ > > ( ) ;
358- eprintln ! (
359- "LINT: must_run: {}, total: {}" ,
360- lints_that_must_run. len( ) ,
361- builtin_lints. get_lints( ) . len( )
362- ) ;
363- if !lints_that_must_run. is_empty ( ) {
364- check_ast_node_inner ( sess, Some ( tcx) , check_node, context, UnsafeCode ) ;
365- return ;
366- }
367- }
340+ if let Some ( builtin_lints_2) = builtin_lints_2
341+ && sess. opts . lint_cap . is_some_and ( |cap| cap == lint:: Allow )
342+ {
343+ check_ast_node_inner ( sess, tcx, check_node, context, builtin_lints_2) ;
344+ } else {
345+ check_ast_node_inner ( sess, tcx, check_node, context, builtin_lints) ;
368346 }
369- check_ast_node_inner ( sess, tcx, check_node, context, builtin_lints) ;
370347 } else {
371348 let mut passes: Vec < _ > = passes. iter ( ) . map ( |mk_pass| ( mk_pass) ( ) ) . collect ( ) ;
372- passes. push ( Box :: new ( builtin_lints) ) ;
349+ if let Some ( builtin_lints_2) = builtin_lints_2
350+ && sess. opts . lint_cap . is_some_and ( |cap| cap == lint:: Allow )
351+ {
352+ passes. push ( Box :: new ( builtin_lints_2) ) ;
353+ } else {
354+ passes. push ( Box :: new ( builtin_lints) ) ;
355+ }
373356 let pass = RuntimeCombinedEarlyLintPass { passes : & mut passes[ ..] } ;
374357 check_ast_node_inner ( sess, tcx, check_node, context, pass) ;
375358 }
0 commit comments