Skip to content

chore: Start infesting ide crates with 'db lifetime #19495

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Draft
wants to merge 1 commit into
base: master
Choose a base branch
from
Draft
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
12 changes: 6 additions & 6 deletions crates/hir/src/attrs.rs
Original file line number Diff line number Diff line change
Expand Up @@ -226,9 +226,9 @@ fn resolve_assoc_or_field(
resolve_field(db, variant_def, name, ns)
}

fn resolve_assoc_item(
db: &dyn HirDatabase,
ty: &Type,
fn resolve_assoc_item<'db>(
db: &'db dyn HirDatabase,
ty: &Type<'db>,
name: &Name,
ns: Option<Namespace>,
) -> Option<DocLinkDef> {
Expand All @@ -240,10 +240,10 @@ fn resolve_assoc_item(
})
}

fn resolve_impl_trait_item(
db: &dyn HirDatabase,
fn resolve_impl_trait_item<'db>(
db: &'db dyn HirDatabase,
resolver: Resolver,
ty: &Type,
ty: &Type<'db>,
name: &Name,
ns: Option<Namespace>,
) -> Option<DocLinkDef> {
Expand Down
80 changes: 40 additions & 40 deletions crates/hir/src/diagnostics.rs
Original file line number Diff line number Diff line change
Expand Up @@ -35,15 +35,15 @@ pub use hir_ty::{
};

macro_rules! diagnostics {
($($diag:ident,)*) => {
($($diag:ident $(<$lt:lifetime>)?,)*) => {
#[derive(Debug)]
pub enum AnyDiagnostic {$(
$diag(Box<$diag>),
pub enum AnyDiagnostic<'db> {$(
$diag(Box<$diag $(<$lt>)?>),
)*}

$(
impl From<$diag> for AnyDiagnostic {
fn from(d: $diag) -> AnyDiagnostic {
impl<'db> From<$diag $(<$lt>)?> for AnyDiagnostic<'db> {
fn from(d: $diag $(<$lt>)?) -> AnyDiagnostic<'db> {
AnyDiagnostic::$diag(Box::new(d))
}
}
Expand All @@ -68,12 +68,12 @@ macro_rules! diagnostics {
diagnostics![
AwaitOutsideOfAsync,
BreakOutsideOfLoop,
CastToUnsized,
ExpectedFunction,
CastToUnsized<'db>,
ExpectedFunction<'db>,
InactiveCode,
IncoherentImpl,
IncorrectCase,
InvalidCast,
InvalidCast<'db>,
InvalidDeriveTarget,
MacroDefError,
MacroError,
Expand All @@ -84,7 +84,7 @@ diagnostics![
MissingFields,
MissingMatchArms,
MissingUnsafe,
MovedOutOfRef,
MovedOutOfRef<'db>,
NeedMut,
NonExhaustiveLet,
NoSuchField,
Expand All @@ -97,17 +97,17 @@ diagnostics![
TraitImplMissingAssocItems,
TraitImplOrphan,
TraitImplRedundantAssocItems,
TypedHole,
TypeMismatch,
TypedHole<'db>,
TypeMismatch<'db>,
UndeclaredLabel,
UnimplementedBuiltinMacro,
UnreachableLabel,
UnresolvedAssocItem,
UnresolvedExternCrate,
UnresolvedField,
UnresolvedField<'db>,
UnresolvedImport,
UnresolvedMacroCall,
UnresolvedMethodCall,
UnresolvedMethodCall<'db>,
UnresolvedModule,
UnresolvedIdent,
UnusedMut,
Expand All @@ -125,9 +125,9 @@ pub struct BreakOutsideOfLoop {
}

#[derive(Debug)]
pub struct TypedHole {
pub struct TypedHole<'db> {
pub expr: InFile<ExprOrPatPtr>,
pub expected: Type,
pub expected: Type<'db>,
}

#[derive(Debug)]
Expand Down Expand Up @@ -237,25 +237,25 @@ pub struct MismatchedTupleStructPatArgCount {
}

#[derive(Debug)]
pub struct ExpectedFunction {
pub struct ExpectedFunction<'db> {
pub call: InFile<ExprOrPatPtr>,
pub found: Type,
pub found: Type<'db>,
}

#[derive(Debug)]
pub struct UnresolvedField {
pub struct UnresolvedField<'db> {
pub expr: InFile<ExprOrPatPtr>,
pub receiver: Type,
pub receiver: Type<'db>,
pub name: Name,
pub method_with_same_name_exists: bool,
}

#[derive(Debug)]
pub struct UnresolvedMethodCall {
pub struct UnresolvedMethodCall<'db> {
pub expr: InFile<ExprOrPatPtr>,
pub receiver: Type,
pub receiver: Type<'db>,
pub name: Name,
pub field_with_same_name: Option<Type>,
pub field_with_same_name: Option<Type<'db>>,
pub assoc_func_with_same_name: Option<Function>,
}

Expand Down Expand Up @@ -324,10 +324,10 @@ pub struct NonExhaustiveLet {
}

#[derive(Debug)]
pub struct TypeMismatch {
pub struct TypeMismatch<'db> {
pub expr_or_pat: InFile<ExprOrPatPtr>,
pub expected: Type,
pub actual: Type,
pub expected: Type<'db>,
pub actual: Type<'db>,
}

#[derive(Debug)]
Expand All @@ -347,8 +347,8 @@ pub struct UnusedVariable {
}

#[derive(Debug)]
pub struct MovedOutOfRef {
pub ty: Type,
pub struct MovedOutOfRef<'db> {
pub ty: Type<'db>,
pub span: InFile<SyntaxNodePtr>,
}

Expand Down Expand Up @@ -398,17 +398,17 @@ pub struct RemoveUnnecessaryElse {
}

#[derive(Debug)]
pub struct CastToUnsized {
pub struct CastToUnsized<'db> {
pub expr: InFile<ExprOrPatPtr>,
pub cast_ty: Type,
pub cast_ty: Type<'db>,
}

#[derive(Debug)]
pub struct InvalidCast {
pub struct InvalidCast<'db> {
pub expr: InFile<ExprOrPatPtr>,
pub error: CastError,
pub expr_ty: Type,
pub cast_ty: Type,
pub expr_ty: Type<'db>,
pub cast_ty: Type<'db>,
}

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

impl AnyDiagnostic {
impl<'db> AnyDiagnostic<'db> {
pub(crate) fn body_validation_diagnostic(
db: &dyn HirDatabase,
db: &'db dyn HirDatabase,
diagnostic: BodyValidationDiagnostic,
source_map: &hir_def::expr_store::BodySourceMap,
) -> Option<AnyDiagnostic> {
) -> Option<AnyDiagnostic<'db>> {
match diagnostic {
BodyValidationDiagnostic::RecordMissingFields { record, variant, missed_fields } => {
let variant_data = variant.variant_data(db.upcast());
Expand Down Expand Up @@ -563,12 +563,12 @@ impl AnyDiagnostic {
}

pub(crate) fn inference_diagnostic(
db: &dyn HirDatabase,
db: &'db dyn HirDatabase,
def: DefWithBodyId,
d: &InferenceDiagnostic,
outer_types_source_map: &TypesSourceMap,
source_map: &hir_def::expr_store::BodySourceMap,
) -> Option<AnyDiagnostic> {
) -> Option<AnyDiagnostic<'db>> {
let expr_syntax = |expr| {
source_map
.expr_syntax(expr)
Expand Down Expand Up @@ -722,7 +722,7 @@ impl AnyDiagnostic {
fn path_diagnostic(
diag: &PathLoweringDiagnostic,
path: InFile<ast::Path>,
) -> Option<AnyDiagnostic> {
) -> Option<AnyDiagnostic<'db>> {
Some(match *diag {
PathLoweringDiagnostic::GenericArgsProhibited { segment, reason } => {
let segment = hir_segment_to_ast_segment(&path.value, segment)?;
Expand Down Expand Up @@ -758,8 +758,8 @@ impl AnyDiagnostic {
pub(crate) fn ty_diagnostic(
diag: &TyLoweringDiagnostic,
source_map: &TypesSourceMap,
db: &dyn HirDatabase,
) -> Option<AnyDiagnostic> {
db: &'db dyn HirDatabase,
) -> Option<AnyDiagnostic<'db>> {
let source = match diag.source {
Either::Left(type_ref_id) => {
let Ok(source) = source_map.type_syntax(type_ref_id) else {
Expand Down
4 changes: 2 additions & 2 deletions crates/hir/src/display.rs
Original file line number Diff line number Diff line change
Expand Up @@ -429,7 +429,7 @@ impl HirDisplay for Variant {
}
}

impl HirDisplay for Type {
impl HirDisplay for Type<'_> {
fn hir_fmt(&self, f: &mut HirFormatter<'_>) -> Result<(), HirDisplayError> {
self.ty.hir_fmt(f)
}
Expand Down Expand Up @@ -748,7 +748,7 @@ impl HirDisplay for Static {
}
}

impl HirDisplay for TraitRef {
impl HirDisplay for TraitRef<'_> {
fn hir_fmt(&self, f: &mut HirFormatter<'_>) -> Result<(), HirDisplayError> {
self.trait_ref.hir_fmt(f)
}
Expand Down
2 changes: 1 addition & 1 deletion crates/hir/src/has_source.rs
Original file line number Diff line number Diff line change
Expand Up @@ -234,7 +234,7 @@ impl HasSource for LocalSource {
}
}

impl HasSource for Param {
impl HasSource for Param<'_> {
type Ast = Either<ast::SelfParam, ast::Param>;

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