@@ -36,15 +36,15 @@ pub use hir_ty::{
36
36
} ;
37
37
38
38
macro_rules! diagnostics {
39
- ( $( $diag: ident, ) * ) => {
39
+ ( $( $diag: ident $ ( <$lt : lifetime> ) ? , ) * ) => {
40
40
#[ derive( Debug ) ]
41
- pub enum AnyDiagnostic { $(
42
- $diag( Box <$diag>) ,
41
+ pub enum AnyDiagnostic < ' db> { $(
42
+ $diag( Box <$diag $ ( <$lt> ) ? >) ,
43
43
) * }
44
44
45
45
$(
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> {
48
48
AnyDiagnostic :: $diag( Box :: new( d) )
49
49
}
50
50
}
@@ -69,12 +69,12 @@ macro_rules! diagnostics {
69
69
diagnostics ! [
70
70
AwaitOutsideOfAsync ,
71
71
BreakOutsideOfLoop ,
72
- CastToUnsized ,
73
- ExpectedFunction ,
72
+ CastToUnsized < ' db> ,
73
+ ExpectedFunction < ' db> ,
74
74
InactiveCode ,
75
75
IncoherentImpl ,
76
76
IncorrectCase ,
77
- InvalidCast ,
77
+ InvalidCast < ' db> ,
78
78
InvalidDeriveTarget ,
79
79
MacroDefError ,
80
80
MacroError ,
@@ -85,7 +85,7 @@ diagnostics![
85
85
MissingFields ,
86
86
MissingMatchArms ,
87
87
MissingUnsafe ,
88
- MovedOutOfRef ,
88
+ MovedOutOfRef < ' db> ,
89
89
NeedMut ,
90
90
NonExhaustiveLet ,
91
91
NoSuchField ,
@@ -98,17 +98,17 @@ diagnostics![
98
98
TraitImplMissingAssocItems ,
99
99
TraitImplOrphan ,
100
100
TraitImplRedundantAssocItems ,
101
- TypedHole ,
102
- TypeMismatch ,
101
+ TypedHole < ' db> ,
102
+ TypeMismatch < ' db> ,
103
103
UndeclaredLabel ,
104
104
UnimplementedBuiltinMacro ,
105
105
UnreachableLabel ,
106
106
UnresolvedAssocItem ,
107
107
UnresolvedExternCrate ,
108
- UnresolvedField ,
108
+ UnresolvedField < ' db> ,
109
109
UnresolvedImport ,
110
110
UnresolvedMacroCall ,
111
- UnresolvedMethodCall ,
111
+ UnresolvedMethodCall < ' db> ,
112
112
UnresolvedModule ,
113
113
UnresolvedIdent ,
114
114
UnusedMut ,
@@ -130,9 +130,9 @@ pub struct BreakOutsideOfLoop {
130
130
}
131
131
132
132
#[ derive( Debug ) ]
133
- pub struct TypedHole {
133
+ pub struct TypedHole < ' db > {
134
134
pub expr : InFile < ExprOrPatPtr > ,
135
- pub expected : Type ,
135
+ pub expected : Type < ' db > ,
136
136
}
137
137
138
138
#[ derive( Debug ) ]
@@ -242,25 +242,25 @@ pub struct MismatchedTupleStructPatArgCount {
242
242
}
243
243
244
244
#[ derive( Debug ) ]
245
- pub struct ExpectedFunction {
245
+ pub struct ExpectedFunction < ' db > {
246
246
pub call : InFile < ExprOrPatPtr > ,
247
- pub found : Type ,
247
+ pub found : Type < ' db > ,
248
248
}
249
249
250
250
#[ derive( Debug ) ]
251
- pub struct UnresolvedField {
251
+ pub struct UnresolvedField < ' db > {
252
252
pub expr : InFile < ExprOrPatPtr > ,
253
- pub receiver : Type ,
253
+ pub receiver : Type < ' db > ,
254
254
pub name : Name ,
255
255
pub method_with_same_name_exists : bool ,
256
256
}
257
257
258
258
#[ derive( Debug ) ]
259
- pub struct UnresolvedMethodCall {
259
+ pub struct UnresolvedMethodCall < ' db > {
260
260
pub expr : InFile < ExprOrPatPtr > ,
261
- pub receiver : Type ,
261
+ pub receiver : Type < ' db > ,
262
262
pub name : Name ,
263
- pub field_with_same_name : Option < Type > ,
263
+ pub field_with_same_name : Option < Type < ' db > > ,
264
264
pub assoc_func_with_same_name : Option < Function > ,
265
265
}
266
266
@@ -329,10 +329,10 @@ pub struct NonExhaustiveLet {
329
329
}
330
330
331
331
#[ derive( Debug ) ]
332
- pub struct TypeMismatch {
332
+ pub struct TypeMismatch < ' db > {
333
333
pub expr_or_pat : InFile < ExprOrPatPtr > ,
334
- pub expected : Type ,
335
- pub actual : Type ,
334
+ pub expected : Type < ' db > ,
335
+ pub actual : Type < ' db > ,
336
336
}
337
337
338
338
#[ derive( Debug ) ]
@@ -352,8 +352,8 @@ pub struct UnusedVariable {
352
352
}
353
353
354
354
#[ derive( Debug ) ]
355
- pub struct MovedOutOfRef {
356
- pub ty : Type ,
355
+ pub struct MovedOutOfRef < ' db > {
356
+ pub ty : Type < ' db > ,
357
357
pub span : InFile < SyntaxNodePtr > ,
358
358
}
359
359
@@ -403,17 +403,17 @@ pub struct RemoveUnnecessaryElse {
403
403
}
404
404
405
405
#[ derive( Debug ) ]
406
- pub struct CastToUnsized {
406
+ pub struct CastToUnsized < ' db > {
407
407
pub expr : InFile < ExprOrPatPtr > ,
408
- pub cast_ty : Type ,
408
+ pub cast_ty : Type < ' db > ,
409
409
}
410
410
411
411
#[ derive( Debug ) ]
412
- pub struct InvalidCast {
412
+ pub struct InvalidCast < ' db > {
413
413
pub expr : InFile < ExprOrPatPtr > ,
414
414
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 > ,
417
417
}
418
418
419
419
#[ derive( Debug ) ]
@@ -482,12 +482,12 @@ pub struct IncorrectGenericsOrder {
482
482
pub expected_kind : GenericArgKind ,
483
483
}
484
484
485
- impl AnyDiagnostic {
485
+ impl < ' db > AnyDiagnostic < ' db > {
486
486
pub ( crate ) fn body_validation_diagnostic (
487
- db : & dyn HirDatabase ,
487
+ db : & ' db dyn HirDatabase ,
488
488
diagnostic : BodyValidationDiagnostic ,
489
489
source_map : & hir_def:: expr_store:: BodySourceMap ,
490
- ) -> Option < AnyDiagnostic > {
490
+ ) -> Option < AnyDiagnostic < ' db > > {
491
491
match diagnostic {
492
492
BodyValidationDiagnostic :: RecordMissingFields { record, variant, missed_fields } => {
493
493
let variant_data = variant. variant_data ( db) ;
@@ -618,12 +618,12 @@ impl AnyDiagnostic {
618
618
}
619
619
620
620
pub ( crate ) fn inference_diagnostic (
621
- db : & dyn HirDatabase ,
621
+ db : & ' db dyn HirDatabase ,
622
622
def : DefWithBodyId ,
623
623
d : & InferenceDiagnostic ,
624
624
source_map : & hir_def:: expr_store:: BodySourceMap ,
625
625
sig_map : & hir_def:: expr_store:: ExpressionStoreSourceMap ,
626
- ) -> Option < AnyDiagnostic > {
626
+ ) -> Option < AnyDiagnostic < ' db > > {
627
627
let expr_syntax = |expr| {
628
628
source_map
629
629
. expr_syntax ( expr)
@@ -819,7 +819,7 @@ impl AnyDiagnostic {
819
819
fn path_diagnostic (
820
820
diag : & PathLoweringDiagnostic ,
821
821
path : InFile < ast:: Path > ,
822
- ) -> Option < AnyDiagnostic > {
822
+ ) -> Option < AnyDiagnostic < ' db > > {
823
823
Some ( match * diag {
824
824
PathLoweringDiagnostic :: GenericArgsProhibited { segment, reason } => {
825
825
let segment = hir_segment_to_ast_segment ( & path. value , segment) ?;
@@ -912,8 +912,8 @@ impl AnyDiagnostic {
912
912
pub ( crate ) fn ty_diagnostic (
913
913
diag : & TyLoweringDiagnostic ,
914
914
source_map : & ExpressionStoreSourceMap ,
915
- db : & dyn HirDatabase ,
916
- ) -> Option < AnyDiagnostic > {
915
+ db : & ' db dyn HirDatabase ,
916
+ ) -> Option < AnyDiagnostic < ' db > > {
917
917
let Ok ( source) = source_map. type_syntax ( diag. source ) else {
918
918
stdx:: never!( "error on synthetic type syntax" ) ;
919
919
return None ;
0 commit comments