@@ -365,7 +365,7 @@ impl ModuleDef {
365
365
Some ( name)
366
366
}
367
367
368
- pub fn diagnostics ( self , db : & dyn HirDatabase ) -> Vec < AnyDiagnostic > {
368
+ pub fn diagnostics ( self , db : & dyn HirDatabase , style_lints : bool ) -> Vec < AnyDiagnostic > {
369
369
let id = match self {
370
370
ModuleDef :: Adt ( it) => match it {
371
371
Adt :: Struct ( it) => it. id . into ( ) ,
@@ -387,7 +387,7 @@ impl ModuleDef {
387
387
388
388
match self . as_def_with_body ( ) {
389
389
Some ( def) => {
390
- def. diagnostics ( db, & mut acc) ;
390
+ def. diagnostics ( db, & mut acc, style_lints ) ;
391
391
}
392
392
None => {
393
393
for diag in hir_ty:: diagnostics:: incorrect_case ( db, id) {
@@ -541,7 +541,12 @@ impl Module {
541
541
}
542
542
543
543
/// 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
+ ) {
545
550
let name = self . name ( db) ;
546
551
let _p = tracing:: span!( tracing:: Level :: INFO , "Module::diagnostics" , ?name) ;
547
552
let def_map = self . id . def_map ( db. upcast ( ) ) ;
@@ -558,20 +563,20 @@ impl Module {
558
563
ModuleDef :: Module ( m) => {
559
564
// Only add diagnostics from inline modules
560
565
if def_map[ m. id . local_id ] . origin . is_inline ( ) {
561
- m. diagnostics ( db, acc)
566
+ m. diagnostics ( db, acc, style_lints )
562
567
}
563
- acc. extend ( def. diagnostics ( db) )
568
+ acc. extend ( def. diagnostics ( db, style_lints ) )
564
569
}
565
570
ModuleDef :: Trait ( t) => {
566
571
for diag in db. trait_data_with_diagnostics ( t. id ) . 1 . iter ( ) {
567
572
emit_def_diagnostic ( db, acc, diag) ;
568
573
}
569
574
570
575
for item in t. items ( db) {
571
- item. diagnostics ( db, acc) ;
576
+ item. diagnostics ( db, acc, style_lints ) ;
572
577
}
573
578
574
- acc. extend ( def. diagnostics ( db) )
579
+ acc. extend ( def. diagnostics ( db, style_lints ) )
575
580
}
576
581
ModuleDef :: Adt ( adt) => {
577
582
match adt {
@@ -587,17 +592,17 @@ impl Module {
587
592
}
588
593
Adt :: Enum ( e) => {
589
594
for v in e. variants ( db) {
590
- acc. extend ( ModuleDef :: Variant ( v) . diagnostics ( db) ) ;
595
+ acc. extend ( ModuleDef :: Variant ( v) . diagnostics ( db, style_lints ) ) ;
591
596
for diag in db. enum_variant_data_with_diagnostics ( v. id ) . 1 . iter ( ) {
592
597
emit_def_diagnostic ( db, acc, diag) ;
593
598
}
594
599
}
595
600
}
596
601
}
597
- acc. extend ( def. diagnostics ( db) )
602
+ acc. extend ( def. diagnostics ( db, style_lints ) )
598
603
}
599
604
ModuleDef :: Macro ( m) => emit_macro_def_diagnostics ( db, acc, m) ,
600
- _ => acc. extend ( def. diagnostics ( db) ) ,
605
+ _ => acc. extend ( def. diagnostics ( db, style_lints ) ) ,
601
606
}
602
607
}
603
608
self . legacy_macros ( db) . into_iter ( ) . for_each ( |m| emit_macro_def_diagnostics ( db, acc, m) ) ;
@@ -738,7 +743,7 @@ impl Module {
738
743
}
739
744
740
745
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 ) ;
742
747
}
743
748
}
744
749
}
@@ -1616,14 +1621,19 @@ impl DefWithBody {
1616
1621
}
1617
1622
}
1618
1623
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
+ ) {
1620
1630
db. unwind_if_cancelled ( ) ;
1621
1631
let krate = self . module ( db) . id . krate ( ) ;
1622
1632
1623
1633
let ( body, source_map) = db. body_with_source_map ( self . into ( ) ) ;
1624
1634
1625
1635
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 ) ;
1627
1637
}
1628
1638
1629
1639
for diag in source_map. diagnostics ( ) {
@@ -1784,7 +1794,7 @@ impl DefWithBody {
1784
1794
}
1785
1795
}
1786
1796
1787
- for diagnostic in BodyValidationDiagnostic :: collect ( db, self . into ( ) ) {
1797
+ for diagnostic in BodyValidationDiagnostic :: collect ( db, self . into ( ) , style_lints ) {
1788
1798
acc. extend ( AnyDiagnostic :: body_validation_diagnostic ( db, diagnostic, & source_map) ) ;
1789
1799
}
1790
1800
@@ -2897,13 +2907,18 @@ impl AssocItem {
2897
2907
}
2898
2908
}
2899
2909
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
+ ) {
2901
2916
match self {
2902
2917
AssocItem :: Function ( func) => {
2903
- DefWithBody :: from ( func) . diagnostics ( db, acc) ;
2918
+ DefWithBody :: from ( func) . diagnostics ( db, acc, style_lints ) ;
2904
2919
}
2905
2920
AssocItem :: Const ( const_) => {
2906
- DefWithBody :: from ( const_) . diagnostics ( db, acc) ;
2921
+ DefWithBody :: from ( const_) . diagnostics ( db, acc, style_lints ) ;
2907
2922
}
2908
2923
AssocItem :: TypeAlias ( type_alias) => {
2909
2924
for diag in hir_ty:: diagnostics:: incorrect_case ( db, type_alias. id . into ( ) ) {
0 commit comments