@@ -27,7 +27,6 @@ mod attrs;
27
27
mod has_source;
28
28
29
29
pub mod diagnostics;
30
- pub mod diagnostics_sink;
31
30
pub mod db;
32
31
33
32
mod display;
@@ -78,16 +77,13 @@ use syntax::{
78
77
} ;
79
78
use tt:: { Ident , Leaf , Literal , TokenTree } ;
80
79
81
- use crate :: {
82
- db:: { DefDatabase , HirDatabase } ,
83
- diagnostics_sink:: DiagnosticSink ,
84
- } ;
80
+ use crate :: db:: { DefDatabase , HirDatabase } ;
85
81
86
82
pub use crate :: {
87
83
attrs:: { HasAttrs , Namespace } ,
88
84
diagnostics:: {
89
- AnyDiagnostic , BreakOutsideOfLoop , InactiveCode , IncorrectCase , InternalBailedOut ,
90
- MacroError , MismatchedArgCount , MissingFields , MissingMatchArms , MissingOkOrSomeInTailExpr ,
85
+ AnyDiagnostic , BreakOutsideOfLoop , InactiveCode , IncorrectCase , MacroError ,
86
+ MismatchedArgCount , MissingFields , MissingMatchArms , MissingOkOrSomeInTailExpr ,
91
87
MissingUnsafe , NoSuchField , RemoveThisSemicolon , ReplaceFilterMapNextWithFindMap ,
92
88
UnimplementedBuiltinMacro , UnresolvedExternCrate , UnresolvedImport , UnresolvedMacroCall ,
93
89
UnresolvedModule , UnresolvedProcMacro ,
@@ -457,16 +453,10 @@ impl Module {
457
453
self . id . def_map ( db. upcast ( ) ) [ self . id . local_id ] . scope . visibility_of ( ( * def) . into ( ) )
458
454
}
459
455
460
- pub fn diagnostics (
461
- self ,
462
- db : & dyn HirDatabase ,
463
- sink : & mut DiagnosticSink ,
464
- internal_diagnostics : bool ,
465
- ) -> Vec < AnyDiagnostic > {
456
+ pub fn diagnostics ( self , db : & dyn HirDatabase , acc : & mut Vec < AnyDiagnostic > ) {
466
457
let _p = profile:: span ( "Module::diagnostics" ) . detail ( || {
467
458
format ! ( "{:?}" , self . name( db) . map_or( "<unknown>" . into( ) , |name| name. to_string( ) ) )
468
459
} ) ;
469
- let mut acc: Vec < AnyDiagnostic > = Vec :: new ( ) ;
470
460
let def_map = self . id . def_map ( db. upcast ( ) ) ;
471
461
for diag in def_map. diagnostics ( ) {
472
462
if diag. in_module != self . id . local_id {
@@ -619,11 +609,11 @@ impl Module {
619
609
}
620
610
for decl in self . declarations ( db) {
621
611
match decl {
622
- ModuleDef :: Function ( f) => acc . extend ( f. diagnostics ( db, sink , internal_diagnostics ) ) ,
612
+ ModuleDef :: Function ( f) => f. diagnostics ( db, acc ) ,
623
613
ModuleDef :: Module ( m) => {
624
614
// Only add diagnostics from inline modules
625
615
if def_map[ m. id . local_id ] . origin . is_inline ( ) {
626
- acc . extend ( m. diagnostics ( db, sink , internal_diagnostics ) )
616
+ m. diagnostics ( db, acc )
627
617
}
628
618
}
629
619
_ => acc. extend ( decl. diagnostics ( db) ) ,
@@ -633,11 +623,10 @@ impl Module {
633
623
for impl_def in self . impl_defs ( db) {
634
624
for item in impl_def. items ( db) {
635
625
if let AssocItem :: Function ( f) = item {
636
- acc . extend ( f. diagnostics ( db, sink , internal_diagnostics ) ) ;
626
+ f. diagnostics ( db, acc ) ;
637
627
}
638
628
}
639
629
}
640
- acc
641
630
}
642
631
643
632
pub fn declarations ( self , db : & dyn HirDatabase ) -> Vec < ModuleDef > {
@@ -1036,13 +1025,7 @@ impl Function {
1036
1025
db. function_data ( self . id ) . is_async ( )
1037
1026
}
1038
1027
1039
- pub fn diagnostics (
1040
- self ,
1041
- db : & dyn HirDatabase ,
1042
- sink : & mut DiagnosticSink ,
1043
- internal_diagnostics : bool ,
1044
- ) -> Vec < AnyDiagnostic > {
1045
- let mut acc: Vec < AnyDiagnostic > = Vec :: new ( ) ;
1028
+ pub fn diagnostics ( self , db : & dyn HirDatabase , acc : & mut Vec < AnyDiagnostic > ) {
1046
1029
let krate = self . module ( db) . id . krate ( ) ;
1047
1030
1048
1031
let source_map = db. body_with_source_map ( self . id . into ( ) ) . 1 ;
@@ -1100,9 +1083,7 @@ impl Function {
1100
1083
}
1101
1084
}
1102
1085
1103
- for diagnostic in
1104
- BodyValidationDiagnostic :: collect ( db, self . id . into ( ) , internal_diagnostics)
1105
- {
1086
+ for diagnostic in BodyValidationDiagnostic :: collect ( db, self . id . into ( ) ) {
1106
1087
match diagnostic {
1107
1088
BodyValidationDiagnostic :: RecordMissingFields {
1108
1089
record,
@@ -1209,36 +1190,26 @@ impl Function {
1209
1190
if let ( Some ( match_expr) , Some ( arms) ) =
1210
1191
( match_expr. expr ( ) , match_expr. match_arm_list ( ) )
1211
1192
{
1212
- sink. push ( MissingMatchArms {
1213
- file : source_ptr. file_id ,
1214
- match_expr : AstPtr :: new ( & match_expr) ,
1215
- arms : AstPtr :: new ( & arms) ,
1216
- } )
1193
+ acc. push (
1194
+ MissingMatchArms {
1195
+ file : source_ptr. file_id ,
1196
+ match_expr : AstPtr :: new ( & match_expr) ,
1197
+ arms : AstPtr :: new ( & arms) ,
1198
+ }
1199
+ . into ( ) ,
1200
+ )
1217
1201
}
1218
1202
}
1219
1203
}
1220
1204
Err ( SyntheticSyntax ) => ( ) ,
1221
1205
}
1222
1206
}
1223
- BodyValidationDiagnostic :: InternalBailedOut { pat } => {
1224
- match source_map. pat_syntax ( pat) {
1225
- Ok ( source_ptr) => {
1226
- let pat_syntax_ptr = source_ptr. value . either ( Into :: into, Into :: into) ;
1227
- sink. push ( InternalBailedOut {
1228
- file : source_ptr. file_id ,
1229
- pat_syntax_ptr,
1230
- } ) ;
1231
- }
1232
- Err ( SyntheticSyntax ) => ( ) ,
1233
- }
1234
- }
1235
1207
}
1236
1208
}
1237
1209
1238
1210
for diag in hir_ty:: diagnostics:: validate_module_item ( db, krate, self . id . into ( ) ) {
1239
1211
acc. push ( diag. into ( ) )
1240
1212
}
1241
- acc
1242
1213
}
1243
1214
1244
1215
/// Whether this function declaration has a definition.
0 commit comments