Skip to content

Commit 03c8508

Browse files
committed
chore: Start infesting ide crates with 'db lifetime
1 parent 588948f commit 03c8508

Some content is hidden

Large Commits have some content hidden by default. Use the searchbox below for content that may be hidden.

78 files changed

+1222
-831
lines changed

crates/hir/src/attrs.rs

+6-6
Original file line numberDiff line numberDiff line change
@@ -226,9 +226,9 @@ fn resolve_assoc_or_field(
226226
resolve_field(db, variant_def, name, ns)
227227
}
228228

229-
fn resolve_assoc_item(
230-
db: &dyn HirDatabase,
231-
ty: &Type,
229+
fn resolve_assoc_item<'db>(
230+
db: &'db dyn HirDatabase,
231+
ty: &Type<'db>,
232232
name: &Name,
233233
ns: Option<Namespace>,
234234
) -> Option<DocLinkDef> {
@@ -240,10 +240,10 @@ fn resolve_assoc_item(
240240
})
241241
}
242242

243-
fn resolve_impl_trait_item(
244-
db: &dyn HirDatabase,
243+
fn resolve_impl_trait_item<'db>(
244+
db: &'db dyn HirDatabase,
245245
resolver: Resolver,
246-
ty: &Type,
246+
ty: &Type<'db>,
247247
name: &Name,
248248
ns: Option<Namespace>,
249249
) -> Option<DocLinkDef> {

crates/hir/src/diagnostics.rs

+40-40
Original file line numberDiff line numberDiff line change
@@ -35,15 +35,15 @@ pub use hir_ty::{
3535
};
3636

3737
macro_rules! diagnostics {
38-
($($diag:ident,)*) => {
38+
($($diag:ident $(<$lt:lifetime>)?,)*) => {
3939
#[derive(Debug)]
40-
pub enum AnyDiagnostic {$(
41-
$diag(Box<$diag>),
40+
pub enum AnyDiagnostic<'db> {$(
41+
$diag(Box<$diag $(<$lt>)?>),
4242
)*}
4343

4444
$(
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> {
4747
AnyDiagnostic::$diag(Box::new(d))
4848
}
4949
}
@@ -68,12 +68,12 @@ macro_rules! diagnostics {
6868
diagnostics![
6969
AwaitOutsideOfAsync,
7070
BreakOutsideOfLoop,
71-
CastToUnsized,
72-
ExpectedFunction,
71+
CastToUnsized<'db>,
72+
ExpectedFunction<'db>,
7373
InactiveCode,
7474
IncoherentImpl,
7575
IncorrectCase,
76-
InvalidCast,
76+
InvalidCast<'db>,
7777
InvalidDeriveTarget,
7878
MacroDefError,
7979
MacroError,
@@ -84,7 +84,7 @@ diagnostics![
8484
MissingFields,
8585
MissingMatchArms,
8686
MissingUnsafe,
87-
MovedOutOfRef,
87+
MovedOutOfRef<'db>,
8888
NeedMut,
8989
NonExhaustiveLet,
9090
NoSuchField,
@@ -97,17 +97,17 @@ diagnostics![
9797
TraitImplMissingAssocItems,
9898
TraitImplOrphan,
9999
TraitImplRedundantAssocItems,
100-
TypedHole,
101-
TypeMismatch,
100+
TypedHole<'db>,
101+
TypeMismatch<'db>,
102102
UndeclaredLabel,
103103
UnimplementedBuiltinMacro,
104104
UnreachableLabel,
105105
UnresolvedAssocItem,
106106
UnresolvedExternCrate,
107-
UnresolvedField,
107+
UnresolvedField<'db>,
108108
UnresolvedImport,
109109
UnresolvedMacroCall,
110-
UnresolvedMethodCall,
110+
UnresolvedMethodCall<'db>,
111111
UnresolvedModule,
112112
UnresolvedIdent,
113113
UnusedMut,
@@ -125,9 +125,9 @@ pub struct BreakOutsideOfLoop {
125125
}
126126

127127
#[derive(Debug)]
128-
pub struct TypedHole {
128+
pub struct TypedHole<'db> {
129129
pub expr: InFile<ExprOrPatPtr>,
130-
pub expected: Type,
130+
pub expected: Type<'db>,
131131
}
132132

133133
#[derive(Debug)]
@@ -237,25 +237,25 @@ pub struct MismatchedTupleStructPatArgCount {
237237
}
238238

239239
#[derive(Debug)]
240-
pub struct ExpectedFunction {
240+
pub struct ExpectedFunction<'db> {
241241
pub call: InFile<ExprOrPatPtr>,
242-
pub found: Type,
242+
pub found: Type<'db>,
243243
}
244244

245245
#[derive(Debug)]
246-
pub struct UnresolvedField {
246+
pub struct UnresolvedField<'db> {
247247
pub expr: InFile<ExprOrPatPtr>,
248-
pub receiver: Type,
248+
pub receiver: Type<'db>,
249249
pub name: Name,
250250
pub method_with_same_name_exists: bool,
251251
}
252252

253253
#[derive(Debug)]
254-
pub struct UnresolvedMethodCall {
254+
pub struct UnresolvedMethodCall<'db> {
255255
pub expr: InFile<ExprOrPatPtr>,
256-
pub receiver: Type,
256+
pub receiver: Type<'db>,
257257
pub name: Name,
258-
pub field_with_same_name: Option<Type>,
258+
pub field_with_same_name: Option<Type<'db>>,
259259
pub assoc_func_with_same_name: Option<Function>,
260260
}
261261

@@ -324,10 +324,10 @@ pub struct NonExhaustiveLet {
324324
}
325325

326326
#[derive(Debug)]
327-
pub struct TypeMismatch {
327+
pub struct TypeMismatch<'db> {
328328
pub expr_or_pat: InFile<ExprOrPatPtr>,
329-
pub expected: Type,
330-
pub actual: Type,
329+
pub expected: Type<'db>,
330+
pub actual: Type<'db>,
331331
}
332332

333333
#[derive(Debug)]
@@ -347,8 +347,8 @@ pub struct UnusedVariable {
347347
}
348348

349349
#[derive(Debug)]
350-
pub struct MovedOutOfRef {
351-
pub ty: Type,
350+
pub struct MovedOutOfRef<'db> {
351+
pub ty: Type<'db>,
352352
pub span: InFile<SyntaxNodePtr>,
353353
}
354354

@@ -398,17 +398,17 @@ pub struct RemoveUnnecessaryElse {
398398
}
399399

400400
#[derive(Debug)]
401-
pub struct CastToUnsized {
401+
pub struct CastToUnsized<'db> {
402402
pub expr: InFile<ExprOrPatPtr>,
403-
pub cast_ty: Type,
403+
pub cast_ty: Type<'db>,
404404
}
405405

406406
#[derive(Debug)]
407-
pub struct InvalidCast {
407+
pub struct InvalidCast<'db> {
408408
pub expr: InFile<ExprOrPatPtr>,
409409
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>,
412412
}
413413

414414
#[derive(Debug)]
@@ -427,12 +427,12 @@ pub struct BadRtn {
427427
pub rtn: InFile<AstPtr<ast::ReturnTypeSyntax>>,
428428
}
429429

430-
impl AnyDiagnostic {
430+
impl<'db> AnyDiagnostic<'db> {
431431
pub(crate) fn body_validation_diagnostic(
432-
db: &dyn HirDatabase,
432+
db: &'db dyn HirDatabase,
433433
diagnostic: BodyValidationDiagnostic,
434434
source_map: &hir_def::expr_store::BodySourceMap,
435-
) -> Option<AnyDiagnostic> {
435+
) -> Option<AnyDiagnostic<'db>> {
436436
match diagnostic {
437437
BodyValidationDiagnostic::RecordMissingFields { record, variant, missed_fields } => {
438438
let variant_data = variant.variant_data(db.upcast());
@@ -563,12 +563,12 @@ impl AnyDiagnostic {
563563
}
564564

565565
pub(crate) fn inference_diagnostic(
566-
db: &dyn HirDatabase,
566+
db: &'db dyn HirDatabase,
567567
def: DefWithBodyId,
568568
d: &InferenceDiagnostic,
569569
outer_types_source_map: &TypesSourceMap,
570570
source_map: &hir_def::expr_store::BodySourceMap,
571-
) -> Option<AnyDiagnostic> {
571+
) -> Option<AnyDiagnostic<'db>> {
572572
let expr_syntax = |expr| {
573573
source_map
574574
.expr_syntax(expr)
@@ -722,7 +722,7 @@ impl AnyDiagnostic {
722722
fn path_diagnostic(
723723
diag: &PathLoweringDiagnostic,
724724
path: InFile<ast::Path>,
725-
) -> Option<AnyDiagnostic> {
725+
) -> Option<AnyDiagnostic<'db>> {
726726
Some(match *diag {
727727
PathLoweringDiagnostic::GenericArgsProhibited { segment, reason } => {
728728
let segment = hir_segment_to_ast_segment(&path.value, segment)?;
@@ -758,8 +758,8 @@ impl AnyDiagnostic {
758758
pub(crate) fn ty_diagnostic(
759759
diag: &TyLoweringDiagnostic,
760760
source_map: &TypesSourceMap,
761-
db: &dyn HirDatabase,
762-
) -> Option<AnyDiagnostic> {
761+
db: &'db dyn HirDatabase,
762+
) -> Option<AnyDiagnostic<'db>> {
763763
let source = match diag.source {
764764
Either::Left(type_ref_id) => {
765765
let Ok(source) = source_map.type_syntax(type_ref_id) else {

crates/hir/src/display.rs

+2-2
Original file line numberDiff line numberDiff line change
@@ -429,7 +429,7 @@ impl HirDisplay for Variant {
429429
}
430430
}
431431

432-
impl HirDisplay for Type {
432+
impl HirDisplay for Type<'_> {
433433
fn hir_fmt(&self, f: &mut HirFormatter<'_>) -> Result<(), HirDisplayError> {
434434
self.ty.hir_fmt(f)
435435
}
@@ -748,7 +748,7 @@ impl HirDisplay for Static {
748748
}
749749
}
750750

751-
impl HirDisplay for TraitRef {
751+
impl HirDisplay for TraitRef<'_> {
752752
fn hir_fmt(&self, f: &mut HirFormatter<'_>) -> Result<(), HirDisplayError> {
753753
self.trait_ref.hir_fmt(f)
754754
}

crates/hir/src/has_source.rs

+1-1
Original file line numberDiff line numberDiff line change
@@ -234,7 +234,7 @@ impl HasSource for LocalSource {
234234
}
235235
}
236236

237-
impl HasSource for Param {
237+
impl HasSource for Param<'_> {
238238
type Ast = Either<ast::SelfParam, ast::Param>;
239239

240240
fn source(self, db: &dyn HirDatabase) -> Option<InFile<Self::Ast>> {

0 commit comments

Comments
 (0)