@@ -31,7 +31,7 @@ use crate::errors::{
3131 OverruledAttributeSub , RequestedLevel , UnknownToolInScopedLint , UnsupportedGroup ,
3232} ;
3333use crate :: fluent_generated as fluent;
34- use crate :: late:: { unerased_lint_store /*name_without_tool*/ } ;
34+ use crate :: late:: unerased_lint_store;
3535use crate :: lints:: {
3636 DeprecatedLintName , DeprecatedLintNameFromCommandLine , IgnoredUnlessCrateSpecified ,
3737 OverruledAttributeLint , RemovedLint , RemovedLintFromCommandLine , RenamedLint ,
@@ -122,7 +122,7 @@ fn lints_that_dont_need_to_run(tcx: TyCtxt<'_>, (): ()) -> FxIndexSet<LintId> {
122122 . get_lints ( )
123123 . into_iter ( )
124124 . filter_map ( |lint| {
125- if !lint. loadbearing && lint. default_level ( tcx. sess . edition ( ) ) == Level :: Allow {
125+ if !lint. eval_always && lint. default_level ( tcx. sess . edition ( ) ) == Level :: Allow {
126126 Some ( LintId :: of ( lint) )
127127 } else {
128128 None
@@ -134,21 +134,6 @@ fn lints_that_dont_need_to_run(tcx: TyCtxt<'_>, (): ()) -> FxIndexSet<LintId> {
134134 visitor. process_opts ( ) ;
135135 tcx. hir ( ) . walk_attributes ( & mut visitor) ;
136136
137- // let lint_groups = store.get_lint_groups();
138- // for group in lint_groups {
139- // let binding = group.0.to_lowercase();
140- // let group_name = name_without_tool(&binding).to_string();
141- // if visitor.lints_that_actually_run.contains(&group_name) {
142- // for lint in group.1 {
143- // visitor.lints_that_actually_run.insert(name_without_tool(&lint.to_string()).to_string());
144- // }
145- // } else if visitor.lints_allowed.contains(&group_name) {
146- // for lint in &group.1 {
147- // visitor.lints_allowed.insert(name_without_tool(&lint.to_string()).to_string());
148- // }
149- // }
150- // }
151-
152137 visitor. dont_need_to_run
153138}
154139
@@ -372,83 +357,44 @@ impl<'tcx> Visitor<'tcx> for LintLevelMaximum<'tcx> {
372357 self . tcx . hir ( )
373358 }
374359
360+ /// FIXME(blyxyas): In a future revision, we should also graph #![allow]s,
361+ /// but that is handled with more care
375362 fn visit_attribute ( & mut self , attribute : & ' tcx ast:: Attribute ) {
376- match Level :: from_attr ( attribute) {
363+ if matches ! (
364+ Level :: from_attr( attribute) ,
377365 Some (
378366 Level :: Warn
379- | Level :: Deny
380- | Level :: Forbid
381- | Level :: Expect ( ..)
382- | Level :: ForceWarn ( ..) ,
383- ) => {
384- let store = unerased_lint_store ( self . tcx . sess ) ;
385- let Some ( meta) = attribute. meta ( ) else { return } ;
386- // SAFETY: Lint attributes are always a metalist inside a
387- // metalist (even with just one lint).
388- let Some ( meta_item_list) = meta. meta_item_list ( ) else { return } ;
389-
390- for meta_list in meta_item_list {
391- // Convert Path to String
392- let Some ( meta_item) = meta_list. meta_item ( ) else { return } ;
393- let ident: & str = & meta_item
394- . path
395- . segments
396- . iter ( )
397- . map ( |segment| segment. ident . as_str ( ) )
398- . collect :: < Vec < & str > > ( )
399- . join ( "::" ) ;
400- let Ok ( lints) = store. find_lints (
401- // SAFETY: Lint attributes can only have literals
402- ident,
403- ) else {
404- return ;
405- } ;
406- for lint in lints {
407- self . dont_need_to_run . swap_remove ( & lint) ;
408- }
409- // // If it's a tool lint (e.g. clippy::my_clippy_lint)
410- // if let ast::NestedMetaItem::MetaItem(meta_item) = meta_list {
411- // if meta_item.path.segments.len() == 1 {
412- // let Ok(lints) = store.find_lints(
413- // // SAFETY: Lint attributes can only have literals
414- // meta_list.ident().unwrap().name.as_str(),
415- // ) else {
416- // return;
417- // };
418- // for lint in lints {
419- // dbg!("LINT REMOVED", &lint);
420- // self.dont_need_to_run.swap_remove(&lint);
421- // }
422- // } else {
423- // let Ok(lints) = store.find_lints(
424- // // SAFETY: Lint attributes can only have literals
425- // meta_item.path.segments[1].ident.name.as_str(),
426- // ) else {
427- // return;
428- // };
429- // for lint in lints {
430- // dbg!("LINT REMOVED", &lint);
431- // self.dont_need_to_run.swap_remove(&lint);
432- // }
433- // }
367+ | Level :: Deny
368+ | Level :: Forbid
369+ | Level :: Expect ( ..)
370+ | Level :: ForceWarn ( ..) ,
371+ )
372+ ) {
373+ let store = unerased_lint_store ( self . tcx . sess ) ;
374+ let Some ( meta) = attribute. meta ( ) else { return } ;
375+ // SAFETY: Lint attributes are always a metalist inside a
376+ // metalist (even with just one lint).
377+ let Some ( meta_item_list) = meta. meta_item_list ( ) else { return } ;
378+
379+ for meta_list in meta_item_list {
380+ // Convert Path to String
381+ let Some ( meta_item) = meta_list. meta_item ( ) else { return } ;
382+ let ident: & str = & meta_item
383+ . path
384+ . segments
385+ . iter ( )
386+ . map ( |segment| segment. ident . as_str ( ) )
387+ . collect :: < Vec < & str > > ( )
388+ . join ( "::" ) ;
389+ let Ok ( lints) = store. find_lints (
390+ // SAFETY: Lint attributes can only have literals
391+ ident,
392+ ) else {
393+ return ;
394+ } ;
395+ for lint in lints {
396+ self . dont_need_to_run . swap_remove ( & lint) ;
434397 }
435- // We handle #![allow]s differently, as these remove checking rather than adding.
436- } // Some(Level::Allow) if ast::AttrStyle::Inner == attribute.style => {
437- // for meta_list in meta.meta_item_list().unwrap() {
438- // // If it's a tool lint (e.g. clippy::my_clippy_lint)
439- // if let ast::NestedMetaItem::MetaItem(meta_item) = meta_list {
440- // if meta_item.path.segments.len() == 1 {
441- // self.lints_allowed
442- // .insert(meta_list.name_or_empty().as_str().to_string());
443- // } else {
444- // self.lints_allowed
445- // .insert(meta_item.path.segments[1].ident.name.as_str().to_string());
446- // }
447- // }
448- // }
449- // }
450- _ => {
451- return ;
452398 }
453399 }
454400 }
0 commit comments