@@ -27,7 +27,6 @@ mod attrs;
2727mod has_source;
2828
2929pub mod diagnostics;
30- pub mod diagnostics_sink;
3130pub mod db;
3231
3332mod display;
@@ -78,16 +77,13 @@ use syntax::{
7877} ;
7978use tt:: { Ident , Leaf , Literal , TokenTree } ;
8079
81- use crate :: {
82- db:: { DefDatabase , HirDatabase } ,
83- diagnostics_sink:: DiagnosticSink ,
84- } ;
80+ use crate :: db:: { DefDatabase , HirDatabase } ;
8581
8682pub use crate :: {
8783 attrs:: { HasAttrs , Namespace } ,
8884 diagnostics:: {
89- AnyDiagnostic , BreakOutsideOfLoop , InactiveCode , IncorrectCase , InternalBailedOut ,
90- MacroError , MismatchedArgCount , MissingFields , MissingMatchArms , MissingOkOrSomeInTailExpr ,
85+ AnyDiagnostic , BreakOutsideOfLoop , InactiveCode , IncorrectCase , MacroError ,
86+ MismatchedArgCount , MissingFields , MissingMatchArms , MissingOkOrSomeInTailExpr ,
9187 MissingUnsafe , NoSuchField , RemoveThisSemicolon , ReplaceFilterMapNextWithFindMap ,
9288 UnimplementedBuiltinMacro , UnresolvedExternCrate , UnresolvedImport , UnresolvedMacroCall ,
9389 UnresolvedModule , UnresolvedProcMacro ,
@@ -457,16 +453,10 @@ impl Module {
457453 self . id . def_map ( db. upcast ( ) ) [ self . id . local_id ] . scope . visibility_of ( ( * def) . into ( ) )
458454 }
459455
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 > ) {
466457 let _p = profile:: span ( "Module::diagnostics" ) . detail ( || {
467458 format ! ( "{:?}" , self . name( db) . map_or( "<unknown>" . into( ) , |name| name. to_string( ) ) )
468459 } ) ;
469- let mut acc: Vec < AnyDiagnostic > = Vec :: new ( ) ;
470460 let def_map = self . id . def_map ( db. upcast ( ) ) ;
471461 for diag in def_map. diagnostics ( ) {
472462 if diag. in_module != self . id . local_id {
@@ -619,11 +609,11 @@ impl Module {
619609 }
620610 for decl in self . declarations ( db) {
621611 match decl {
622- ModuleDef :: Function ( f) => acc . extend ( f. diagnostics ( db, sink , internal_diagnostics ) ) ,
612+ ModuleDef :: Function ( f) => f. diagnostics ( db, acc ) ,
623613 ModuleDef :: Module ( m) => {
624614 // Only add diagnostics from inline modules
625615 if def_map[ m. id . local_id ] . origin . is_inline ( ) {
626- acc . extend ( m. diagnostics ( db, sink , internal_diagnostics ) )
616+ m. diagnostics ( db, acc )
627617 }
628618 }
629619 _ => acc. extend ( decl. diagnostics ( db) ) ,
@@ -633,11 +623,10 @@ impl Module {
633623 for impl_def in self . impl_defs ( db) {
634624 for item in impl_def. items ( db) {
635625 if let AssocItem :: Function ( f) = item {
636- acc . extend ( f. diagnostics ( db, sink , internal_diagnostics ) ) ;
626+ f. diagnostics ( db, acc ) ;
637627 }
638628 }
639629 }
640- acc
641630 }
642631
643632 pub fn declarations ( self , db : & dyn HirDatabase ) -> Vec < ModuleDef > {
@@ -1036,13 +1025,7 @@ impl Function {
10361025 db. function_data ( self . id ) . is_async ( )
10371026 }
10381027
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 > ) {
10461029 let krate = self . module ( db) . id . krate ( ) ;
10471030
10481031 let source_map = db. body_with_source_map ( self . id . into ( ) ) . 1 ;
@@ -1100,9 +1083,7 @@ impl Function {
11001083 }
11011084 }
11021085
1103- for diagnostic in
1104- BodyValidationDiagnostic :: collect ( db, self . id . into ( ) , internal_diagnostics)
1105- {
1086+ for diagnostic in BodyValidationDiagnostic :: collect ( db, self . id . into ( ) ) {
11061087 match diagnostic {
11071088 BodyValidationDiagnostic :: RecordMissingFields {
11081089 record,
@@ -1209,36 +1190,26 @@ impl Function {
12091190 if let ( Some ( match_expr) , Some ( arms) ) =
12101191 ( match_expr. expr ( ) , match_expr. match_arm_list ( ) )
12111192 {
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+ )
12171201 }
12181202 }
12191203 }
12201204 Err ( SyntheticSyntax ) => ( ) ,
12211205 }
12221206 }
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- }
12351207 }
12361208 }
12371209
12381210 for diag in hir_ty:: diagnostics:: validate_module_item ( db, krate, self . id . into ( ) ) {
12391211 acc. push ( diag. into ( ) )
12401212 }
1241- acc
12421213 }
12431214
12441215 /// Whether this function declaration has a definition.
0 commit comments