@@ -36,15 +36,15 @@ pub use hir_ty::{
3636} ;
3737
3838macro_rules! diagnostics {
39- ( $( $diag: ident, ) * ) => {
39+ ( $( $diag: ident $ ( <$lt : lifetime> ) ? , ) * ) => {
4040 #[ derive( Debug ) ]
41- pub enum AnyDiagnostic { $(
42- $diag( Box <$diag>) ,
41+ pub enum AnyDiagnostic < ' db> { $(
42+ $diag( Box <$diag $ ( <$lt> ) ? >) ,
4343 ) * }
4444
4545 $(
46- impl From <$diag> for AnyDiagnostic {
47- fn from( d: $diag) -> AnyDiagnostic {
46+ impl < ' db> From <$diag $ ( <$lt> ) ?> for AnyDiagnostic < ' db> {
47+ fn from( d: $diag $ ( <$lt> ) ? ) -> AnyDiagnostic < ' db> {
4848 AnyDiagnostic :: $diag( Box :: new( d) )
4949 }
5050 }
@@ -69,12 +69,12 @@ macro_rules! diagnostics {
6969diagnostics ! [
7070 AwaitOutsideOfAsync ,
7171 BreakOutsideOfLoop ,
72- CastToUnsized ,
73- ExpectedFunction ,
72+ CastToUnsized < ' db> ,
73+ ExpectedFunction < ' db> ,
7474 InactiveCode ,
7575 IncoherentImpl ,
7676 IncorrectCase ,
77- InvalidCast ,
77+ InvalidCast < ' db> ,
7878 InvalidDeriveTarget ,
7979 MacroDefError ,
8080 MacroError ,
@@ -85,7 +85,7 @@ diagnostics![
8585 MissingFields ,
8686 MissingMatchArms ,
8787 MissingUnsafe ,
88- MovedOutOfRef ,
88+ MovedOutOfRef < ' db> ,
8989 NeedMut ,
9090 NonExhaustiveLet ,
9191 NoSuchField ,
@@ -98,17 +98,17 @@ diagnostics![
9898 TraitImplMissingAssocItems ,
9999 TraitImplOrphan ,
100100 TraitImplRedundantAssocItems ,
101- TypedHole ,
102- TypeMismatch ,
101+ TypedHole < ' db> ,
102+ TypeMismatch < ' db> ,
103103 UndeclaredLabel ,
104104 UnimplementedBuiltinMacro ,
105105 UnreachableLabel ,
106106 UnresolvedAssocItem ,
107107 UnresolvedExternCrate ,
108- UnresolvedField ,
108+ UnresolvedField < ' db> ,
109109 UnresolvedImport ,
110110 UnresolvedMacroCall ,
111- UnresolvedMethodCall ,
111+ UnresolvedMethodCall < ' db> ,
112112 UnresolvedModule ,
113113 UnresolvedIdent ,
114114 UnusedMut ,
@@ -130,9 +130,9 @@ pub struct BreakOutsideOfLoop {
130130}
131131
132132#[ derive( Debug ) ]
133- pub struct TypedHole {
133+ pub struct TypedHole < ' db > {
134134 pub expr : InFile < ExprOrPatPtr > ,
135- pub expected : Type ,
135+ pub expected : Type < ' db > ,
136136}
137137
138138#[ derive( Debug ) ]
@@ -242,25 +242,25 @@ pub struct MismatchedTupleStructPatArgCount {
242242}
243243
244244#[ derive( Debug ) ]
245- pub struct ExpectedFunction {
245+ pub struct ExpectedFunction < ' db > {
246246 pub call : InFile < ExprOrPatPtr > ,
247- pub found : Type ,
247+ pub found : Type < ' db > ,
248248}
249249
250250#[ derive( Debug ) ]
251- pub struct UnresolvedField {
251+ pub struct UnresolvedField < ' db > {
252252 pub expr : InFile < ExprOrPatPtr > ,
253- pub receiver : Type ,
253+ pub receiver : Type < ' db > ,
254254 pub name : Name ,
255255 pub method_with_same_name_exists : bool ,
256256}
257257
258258#[ derive( Debug ) ]
259- pub struct UnresolvedMethodCall {
259+ pub struct UnresolvedMethodCall < ' db > {
260260 pub expr : InFile < ExprOrPatPtr > ,
261- pub receiver : Type ,
261+ pub receiver : Type < ' db > ,
262262 pub name : Name ,
263- pub field_with_same_name : Option < Type > ,
263+ pub field_with_same_name : Option < Type < ' db > > ,
264264 pub assoc_func_with_same_name : Option < Function > ,
265265}
266266
@@ -329,10 +329,10 @@ pub struct NonExhaustiveLet {
329329}
330330
331331#[ derive( Debug ) ]
332- pub struct TypeMismatch {
332+ pub struct TypeMismatch < ' db > {
333333 pub expr_or_pat : InFile < ExprOrPatPtr > ,
334- pub expected : Type ,
335- pub actual : Type ,
334+ pub expected : Type < ' db > ,
335+ pub actual : Type < ' db > ,
336336}
337337
338338#[ derive( Debug ) ]
@@ -352,8 +352,8 @@ pub struct UnusedVariable {
352352}
353353
354354#[ derive( Debug ) ]
355- pub struct MovedOutOfRef {
356- pub ty : Type ,
355+ pub struct MovedOutOfRef < ' db > {
356+ pub ty : Type < ' db > ,
357357 pub span : InFile < SyntaxNodePtr > ,
358358}
359359
@@ -403,17 +403,17 @@ pub struct RemoveUnnecessaryElse {
403403}
404404
405405#[ derive( Debug ) ]
406- pub struct CastToUnsized {
406+ pub struct CastToUnsized < ' db > {
407407 pub expr : InFile < ExprOrPatPtr > ,
408- pub cast_ty : Type ,
408+ pub cast_ty : Type < ' db > ,
409409}
410410
411411#[ derive( Debug ) ]
412- pub struct InvalidCast {
412+ pub struct InvalidCast < ' db > {
413413 pub expr : InFile < ExprOrPatPtr > ,
414414 pub error : CastError ,
415- pub expr_ty : Type ,
416- pub cast_ty : Type ,
415+ pub expr_ty : Type < ' db > ,
416+ pub cast_ty : Type < ' db > ,
417417}
418418
419419#[ derive( Debug ) ]
@@ -482,12 +482,12 @@ pub struct IncorrectGenericsOrder {
482482 pub expected_kind : GenericArgKind ,
483483}
484484
485- impl AnyDiagnostic {
485+ impl < ' db > AnyDiagnostic < ' db > {
486486 pub ( crate ) fn body_validation_diagnostic (
487- db : & dyn HirDatabase ,
487+ db : & ' db dyn HirDatabase ,
488488 diagnostic : BodyValidationDiagnostic ,
489489 source_map : & hir_def:: expr_store:: BodySourceMap ,
490- ) -> Option < AnyDiagnostic > {
490+ ) -> Option < AnyDiagnostic < ' db > > {
491491 match diagnostic {
492492 BodyValidationDiagnostic :: RecordMissingFields { record, variant, missed_fields } => {
493493 let variant_data = variant. variant_data ( db) ;
@@ -618,12 +618,12 @@ impl AnyDiagnostic {
618618 }
619619
620620 pub ( crate ) fn inference_diagnostic (
621- db : & dyn HirDatabase ,
621+ db : & ' db dyn HirDatabase ,
622622 def : DefWithBodyId ,
623623 d : & InferenceDiagnostic ,
624624 source_map : & hir_def:: expr_store:: BodySourceMap ,
625625 sig_map : & hir_def:: expr_store:: ExpressionStoreSourceMap ,
626- ) -> Option < AnyDiagnostic > {
626+ ) -> Option < AnyDiagnostic < ' db > > {
627627 let expr_syntax = |expr| {
628628 source_map
629629 . expr_syntax ( expr)
@@ -819,7 +819,7 @@ impl AnyDiagnostic {
819819 fn path_diagnostic (
820820 diag : & PathLoweringDiagnostic ,
821821 path : InFile < ast:: Path > ,
822- ) -> Option < AnyDiagnostic > {
822+ ) -> Option < AnyDiagnostic < ' db > > {
823823 Some ( match * diag {
824824 PathLoweringDiagnostic :: GenericArgsProhibited { segment, reason } => {
825825 let segment = hir_segment_to_ast_segment ( & path. value , segment) ?;
@@ -912,8 +912,8 @@ impl AnyDiagnostic {
912912 pub ( crate ) fn ty_diagnostic (
913913 diag : & TyLoweringDiagnostic ,
914914 source_map : & ExpressionStoreSourceMap ,
915- db : & dyn HirDatabase ,
916- ) -> Option < AnyDiagnostic > {
915+ db : & ' db dyn HirDatabase ,
916+ ) -> Option < AnyDiagnostic < ' db > > {
917917 let Ok ( source) = source_map. type_syntax ( diag. source ) else {
918918 stdx:: never!( "error on synthetic type syntax" ) ;
919919 return None ;
0 commit comments