Skip to content

Commit c6b74f7

Browse files
authored
Merge pull request #19495 from Veykril/push-woywmrxrtqqy
chore: Start infesting ide crates with 'db lifetime
2 parents a31e10a + 03f1003 commit c6b74f7

Some content is hidden

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

79 files changed

+1214
-815
lines changed

crates/hir/src/attrs.rs

Lines changed: 6 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -242,9 +242,9 @@ fn resolve_assoc_or_field(
242242
resolve_field(db, variant_def, name, ns)
243243
}
244244

245-
fn resolve_assoc_item(
246-
db: &dyn HirDatabase,
247-
ty: &Type,
245+
fn resolve_assoc_item<'db>(
246+
db: &'db dyn HirDatabase,
247+
ty: &Type<'db>,
248248
name: &Name,
249249
ns: Option<Namespace>,
250250
) -> Option<DocLinkDef> {
@@ -256,10 +256,10 @@ fn resolve_assoc_item(
256256
})
257257
}
258258

259-
fn resolve_impl_trait_item(
260-
db: &dyn HirDatabase,
259+
fn resolve_impl_trait_item<'db>(
260+
db: &'db dyn HirDatabase,
261261
resolver: Resolver<'_>,
262-
ty: &Type,
262+
ty: &Type<'db>,
263263
name: &Name,
264264
ns: Option<Namespace>,
265265
) -> Option<DocLinkDef> {

crates/hir/src/diagnostics.rs

Lines changed: 40 additions & 40 deletions
Original file line numberDiff line numberDiff line change
@@ -36,15 +36,15 @@ pub use hir_ty::{
3636
};
3737

3838
macro_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 {
6969
diagnostics![
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;

crates/hir/src/display.rs

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -431,7 +431,7 @@ impl HirDisplay for Variant {
431431
}
432432
}
433433

434-
impl HirDisplay for Type {
434+
impl HirDisplay for Type<'_> {
435435
fn hir_fmt(&self, f: &mut HirFormatter<'_>) -> Result<(), HirDisplayError> {
436436
self.ty.hir_fmt(f)
437437
}
@@ -743,7 +743,7 @@ impl HirDisplay for Static {
743743
}
744744
}
745745

746-
impl HirDisplay for TraitRef {
746+
impl HirDisplay for TraitRef<'_> {
747747
fn hir_fmt(&self, f: &mut HirFormatter<'_>) -> Result<(), HirDisplayError> {
748748
self.trait_ref.hir_fmt(f)
749749
}

crates/hir/src/has_source.rs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -225,7 +225,7 @@ impl HasSource for LocalSource {
225225
}
226226
}
227227

228-
impl HasSource for Param {
228+
impl HasSource for Param<'_> {
229229
type Ast = Either<ast::SelfParam, ast::Param>;
230230

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

0 commit comments

Comments
 (0)