@@ -35,15 +35,15 @@ pub use hir_ty::{
35
35
} ;
36
36
37
37
macro_rules! diagnostics {
38
- ( $( $diag: ident, ) * ) => {
38
+ ( $( $diag: ident $ ( <$lt : lifetime> ) ? , ) * ) => {
39
39
#[ derive( Debug ) ]
40
- pub enum AnyDiagnostic { $(
41
- $diag( Box <$diag>) ,
40
+ pub enum AnyDiagnostic < ' db> { $(
41
+ $diag( Box <$diag $ ( <$lt> ) ? >) ,
42
42
) * }
43
43
44
44
$(
45
- impl From <$diag> for AnyDiagnostic {
46
- fn from( d: $diag) -> AnyDiagnostic {
45
+ impl < ' db> From <$diag $ ( <$lt> ) ?> for AnyDiagnostic < ' db> {
46
+ fn from( d: $diag $ ( <$lt> ) ? ) -> AnyDiagnostic < ' db> {
47
47
AnyDiagnostic :: $diag( Box :: new( d) )
48
48
}
49
49
}
@@ -68,12 +68,12 @@ macro_rules! diagnostics {
68
68
diagnostics ! [
69
69
AwaitOutsideOfAsync ,
70
70
BreakOutsideOfLoop ,
71
- CastToUnsized ,
72
- ExpectedFunction ,
71
+ CastToUnsized < ' db> ,
72
+ ExpectedFunction < ' db> ,
73
73
InactiveCode ,
74
74
IncoherentImpl ,
75
75
IncorrectCase ,
76
- InvalidCast ,
76
+ InvalidCast < ' db> ,
77
77
InvalidDeriveTarget ,
78
78
MacroDefError ,
79
79
MacroError ,
@@ -84,7 +84,7 @@ diagnostics![
84
84
MissingFields ,
85
85
MissingMatchArms ,
86
86
MissingUnsafe ,
87
- MovedOutOfRef ,
87
+ MovedOutOfRef < ' db> ,
88
88
NeedMut ,
89
89
NonExhaustiveLet ,
90
90
NoSuchField ,
@@ -97,17 +97,17 @@ diagnostics![
97
97
TraitImplMissingAssocItems ,
98
98
TraitImplOrphan ,
99
99
TraitImplRedundantAssocItems ,
100
- TypedHole ,
101
- TypeMismatch ,
100
+ TypedHole < ' db> ,
101
+ TypeMismatch < ' db> ,
102
102
UndeclaredLabel ,
103
103
UnimplementedBuiltinMacro ,
104
104
UnreachableLabel ,
105
105
UnresolvedAssocItem ,
106
106
UnresolvedExternCrate ,
107
- UnresolvedField ,
107
+ UnresolvedField < ' db> ,
108
108
UnresolvedImport ,
109
109
UnresolvedMacroCall ,
110
- UnresolvedMethodCall ,
110
+ UnresolvedMethodCall < ' db> ,
111
111
UnresolvedModule ,
112
112
UnresolvedIdent ,
113
113
UnusedMut ,
@@ -125,9 +125,9 @@ pub struct BreakOutsideOfLoop {
125
125
}
126
126
127
127
#[ derive( Debug ) ]
128
- pub struct TypedHole {
128
+ pub struct TypedHole < ' db > {
129
129
pub expr : InFile < ExprOrPatPtr > ,
130
- pub expected : Type ,
130
+ pub expected : Type < ' db > ,
131
131
}
132
132
133
133
#[ derive( Debug ) ]
@@ -237,25 +237,25 @@ pub struct MismatchedTupleStructPatArgCount {
237
237
}
238
238
239
239
#[ derive( Debug ) ]
240
- pub struct ExpectedFunction {
240
+ pub struct ExpectedFunction < ' db > {
241
241
pub call : InFile < ExprOrPatPtr > ,
242
- pub found : Type ,
242
+ pub found : Type < ' db > ,
243
243
}
244
244
245
245
#[ derive( Debug ) ]
246
- pub struct UnresolvedField {
246
+ pub struct UnresolvedField < ' db > {
247
247
pub expr : InFile < ExprOrPatPtr > ,
248
- pub receiver : Type ,
248
+ pub receiver : Type < ' db > ,
249
249
pub name : Name ,
250
250
pub method_with_same_name_exists : bool ,
251
251
}
252
252
253
253
#[ derive( Debug ) ]
254
- pub struct UnresolvedMethodCall {
254
+ pub struct UnresolvedMethodCall < ' db > {
255
255
pub expr : InFile < ExprOrPatPtr > ,
256
- pub receiver : Type ,
256
+ pub receiver : Type < ' db > ,
257
257
pub name : Name ,
258
- pub field_with_same_name : Option < Type > ,
258
+ pub field_with_same_name : Option < Type < ' db > > ,
259
259
pub assoc_func_with_same_name : Option < Function > ,
260
260
}
261
261
@@ -324,10 +324,10 @@ pub struct NonExhaustiveLet {
324
324
}
325
325
326
326
#[ derive( Debug ) ]
327
- pub struct TypeMismatch {
327
+ pub struct TypeMismatch < ' db > {
328
328
pub expr_or_pat : InFile < ExprOrPatPtr > ,
329
- pub expected : Type ,
330
- pub actual : Type ,
329
+ pub expected : Type < ' db > ,
330
+ pub actual : Type < ' db > ,
331
331
}
332
332
333
333
#[ derive( Debug ) ]
@@ -347,8 +347,8 @@ pub struct UnusedVariable {
347
347
}
348
348
349
349
#[ derive( Debug ) ]
350
- pub struct MovedOutOfRef {
351
- pub ty : Type ,
350
+ pub struct MovedOutOfRef < ' db > {
351
+ pub ty : Type < ' db > ,
352
352
pub span : InFile < SyntaxNodePtr > ,
353
353
}
354
354
@@ -398,17 +398,17 @@ pub struct RemoveUnnecessaryElse {
398
398
}
399
399
400
400
#[ derive( Debug ) ]
401
- pub struct CastToUnsized {
401
+ pub struct CastToUnsized < ' db > {
402
402
pub expr : InFile < ExprOrPatPtr > ,
403
- pub cast_ty : Type ,
403
+ pub cast_ty : Type < ' db > ,
404
404
}
405
405
406
406
#[ derive( Debug ) ]
407
- pub struct InvalidCast {
407
+ pub struct InvalidCast < ' db > {
408
408
pub expr : InFile < ExprOrPatPtr > ,
409
409
pub error : CastError ,
410
- pub expr_ty : Type ,
411
- pub cast_ty : Type ,
410
+ pub expr_ty : Type < ' db > ,
411
+ pub cast_ty : Type < ' db > ,
412
412
}
413
413
414
414
#[ derive( Debug ) ]
@@ -427,12 +427,12 @@ pub struct BadRtn {
427
427
pub rtn : InFile < AstPtr < ast:: ReturnTypeSyntax > > ,
428
428
}
429
429
430
- impl AnyDiagnostic {
430
+ impl < ' db > AnyDiagnostic < ' db > {
431
431
pub ( crate ) fn body_validation_diagnostic (
432
- db : & dyn HirDatabase ,
432
+ db : & ' db dyn HirDatabase ,
433
433
diagnostic : BodyValidationDiagnostic ,
434
434
source_map : & hir_def:: expr_store:: BodySourceMap ,
435
- ) -> Option < AnyDiagnostic > {
435
+ ) -> Option < AnyDiagnostic < ' db > > {
436
436
match diagnostic {
437
437
BodyValidationDiagnostic :: RecordMissingFields { record, variant, missed_fields } => {
438
438
let variant_data = variant. variant_data ( db. upcast ( ) ) ;
@@ -563,12 +563,12 @@ impl AnyDiagnostic {
563
563
}
564
564
565
565
pub ( crate ) fn inference_diagnostic (
566
- db : & dyn HirDatabase ,
566
+ db : & ' db dyn HirDatabase ,
567
567
def : DefWithBodyId ,
568
568
d : & InferenceDiagnostic ,
569
569
outer_types_source_map : & TypesSourceMap ,
570
570
source_map : & hir_def:: expr_store:: BodySourceMap ,
571
- ) -> Option < AnyDiagnostic > {
571
+ ) -> Option < AnyDiagnostic < ' db > > {
572
572
let expr_syntax = |expr| {
573
573
source_map
574
574
. expr_syntax ( expr)
@@ -722,7 +722,7 @@ impl AnyDiagnostic {
722
722
fn path_diagnostic (
723
723
diag : & PathLoweringDiagnostic ,
724
724
path : InFile < ast:: Path > ,
725
- ) -> Option < AnyDiagnostic > {
725
+ ) -> Option < AnyDiagnostic < ' db > > {
726
726
Some ( match * diag {
727
727
PathLoweringDiagnostic :: GenericArgsProhibited { segment, reason } => {
728
728
let segment = hir_segment_to_ast_segment ( & path. value , segment) ?;
@@ -758,8 +758,8 @@ impl AnyDiagnostic {
758
758
pub ( crate ) fn ty_diagnostic (
759
759
diag : & TyLoweringDiagnostic ,
760
760
source_map : & TypesSourceMap ,
761
- db : & dyn HirDatabase ,
762
- ) -> Option < AnyDiagnostic > {
761
+ db : & ' db dyn HirDatabase ,
762
+ ) -> Option < AnyDiagnostic < ' db > > {
763
763
let source = match diag. source {
764
764
Either :: Left ( type_ref_id) => {
765
765
let Ok ( source) = source_map. type_syntax ( type_ref_id) else {
0 commit comments