@@ -365,7 +365,7 @@ impl ModuleDef {
365365 Some ( name)
366366 }
367367
368- pub fn diagnostics ( self , db : & dyn HirDatabase ) -> Vec < AnyDiagnostic > {
368+ pub fn diagnostics ( self , db : & dyn HirDatabase , style_lints : bool ) -> Vec < AnyDiagnostic > {
369369 let id = match self {
370370 ModuleDef :: Adt ( it) => match it {
371371 Adt :: Struct ( it) => it. id . into ( ) ,
@@ -387,7 +387,7 @@ impl ModuleDef {
387387
388388 match self . as_def_with_body ( ) {
389389 Some ( def) => {
390- def. diagnostics ( db, & mut acc) ;
390+ def. diagnostics ( db, & mut acc, style_lints ) ;
391391 }
392392 None => {
393393 for diag in hir_ty:: diagnostics:: incorrect_case ( db, id) {
@@ -541,7 +541,12 @@ impl Module {
541541 }
542542
543543 /// Fills `acc` with the module's diagnostics.
544- pub fn diagnostics ( self , db : & dyn HirDatabase , acc : & mut Vec < AnyDiagnostic > ) {
544+ pub fn diagnostics (
545+ self ,
546+ db : & dyn HirDatabase ,
547+ acc : & mut Vec < AnyDiagnostic > ,
548+ style_lints : bool ,
549+ ) {
545550 let name = self . name ( db) ;
546551 let _p = tracing:: span!( tracing:: Level :: INFO , "Module::diagnostics" , ?name) ;
547552 let def_map = self . id . def_map ( db. upcast ( ) ) ;
@@ -558,20 +563,20 @@ impl Module {
558563 ModuleDef :: Module ( m) => {
559564 // Only add diagnostics from inline modules
560565 if def_map[ m. id . local_id ] . origin . is_inline ( ) {
561- m. diagnostics ( db, acc)
566+ m. diagnostics ( db, acc, style_lints )
562567 }
563- acc. extend ( def. diagnostics ( db) )
568+ acc. extend ( def. diagnostics ( db, style_lints ) )
564569 }
565570 ModuleDef :: Trait ( t) => {
566571 for diag in db. trait_data_with_diagnostics ( t. id ) . 1 . iter ( ) {
567572 emit_def_diagnostic ( db, acc, diag) ;
568573 }
569574
570575 for item in t. items ( db) {
571- item. diagnostics ( db, acc) ;
576+ item. diagnostics ( db, acc, style_lints ) ;
572577 }
573578
574- acc. extend ( def. diagnostics ( db) )
579+ acc. extend ( def. diagnostics ( db, style_lints ) )
575580 }
576581 ModuleDef :: Adt ( adt) => {
577582 match adt {
@@ -587,17 +592,17 @@ impl Module {
587592 }
588593 Adt :: Enum ( e) => {
589594 for v in e. variants ( db) {
590- acc. extend ( ModuleDef :: Variant ( v) . diagnostics ( db) ) ;
595+ acc. extend ( ModuleDef :: Variant ( v) . diagnostics ( db, style_lints ) ) ;
591596 for diag in db. enum_variant_data_with_diagnostics ( v. id ) . 1 . iter ( ) {
592597 emit_def_diagnostic ( db, acc, diag) ;
593598 }
594599 }
595600 }
596601 }
597- acc. extend ( def. diagnostics ( db) )
602+ acc. extend ( def. diagnostics ( db, style_lints ) )
598603 }
599604 ModuleDef :: Macro ( m) => emit_macro_def_diagnostics ( db, acc, m) ,
600- _ => acc. extend ( def. diagnostics ( db) ) ,
605+ _ => acc. extend ( def. diagnostics ( db, style_lints ) ) ,
601606 }
602607 }
603608 self . legacy_macros ( db) . into_iter ( ) . for_each ( |m| emit_macro_def_diagnostics ( db, acc, m) ) ;
@@ -738,7 +743,7 @@ impl Module {
738743 }
739744
740745 for & item in & db. impl_data ( impl_def. id ) . items {
741- AssocItem :: from ( item) . diagnostics ( db, acc) ;
746+ AssocItem :: from ( item) . diagnostics ( db, acc, style_lints ) ;
742747 }
743748 }
744749 }
@@ -1616,14 +1621,19 @@ impl DefWithBody {
16161621 }
16171622 }
16181623
1619- pub fn diagnostics ( self , db : & dyn HirDatabase , acc : & mut Vec < AnyDiagnostic > ) {
1624+ pub fn diagnostics (
1625+ self ,
1626+ db : & dyn HirDatabase ,
1627+ acc : & mut Vec < AnyDiagnostic > ,
1628+ style_lints : bool ,
1629+ ) {
16201630 db. unwind_if_cancelled ( ) ;
16211631 let krate = self . module ( db) . id . krate ( ) ;
16221632
16231633 let ( body, source_map) = db. body_with_source_map ( self . into ( ) ) ;
16241634
16251635 for ( _, def_map) in body. blocks ( db. upcast ( ) ) {
1626- Module { id : def_map. module_id ( DefMap :: ROOT ) } . diagnostics ( db, acc) ;
1636+ Module { id : def_map. module_id ( DefMap :: ROOT ) } . diagnostics ( db, acc, style_lints ) ;
16271637 }
16281638
16291639 for diag in source_map. diagnostics ( ) {
@@ -1784,7 +1794,7 @@ impl DefWithBody {
17841794 }
17851795 }
17861796
1787- for diagnostic in BodyValidationDiagnostic :: collect ( db, self . into ( ) ) {
1797+ for diagnostic in BodyValidationDiagnostic :: collect ( db, self . into ( ) , style_lints ) {
17881798 acc. extend ( AnyDiagnostic :: body_validation_diagnostic ( db, diagnostic, & source_map) ) ;
17891799 }
17901800
@@ -2897,13 +2907,18 @@ impl AssocItem {
28972907 }
28982908 }
28992909
2900- pub fn diagnostics ( self , db : & dyn HirDatabase , acc : & mut Vec < AnyDiagnostic > ) {
2910+ pub fn diagnostics (
2911+ self ,
2912+ db : & dyn HirDatabase ,
2913+ acc : & mut Vec < AnyDiagnostic > ,
2914+ style_lints : bool ,
2915+ ) {
29012916 match self {
29022917 AssocItem :: Function ( func) => {
2903- DefWithBody :: from ( func) . diagnostics ( db, acc) ;
2918+ DefWithBody :: from ( func) . diagnostics ( db, acc, style_lints ) ;
29042919 }
29052920 AssocItem :: Const ( const_) => {
2906- DefWithBody :: from ( const_) . diagnostics ( db, acc) ;
2921+ DefWithBody :: from ( const_) . diagnostics ( db, acc, style_lints ) ;
29072922 }
29082923 AssocItem :: TypeAlias ( type_alias) => {
29092924 for diag in hir_ty:: diagnostics:: incorrect_case ( db, type_alias. id . into ( ) ) {
0 commit comments