Unnamed repository; edit this file 'description' to name the repository.
add lifetime to `InternedOpaqueTyId`
| -rw-r--r-- | crates/hir-ty/src/db.rs | 2 | ||||
| -rw-r--r-- | crates/hir-ty/src/dyn_compatibility.rs | 4 | ||||
| -rw-r--r-- | crates/hir-ty/src/infer.rs | 2 | ||||
| -rw-r--r-- | crates/hir-ty/src/lower.rs | 8 | ||||
| -rw-r--r-- | crates/hir-ty/src/next_solver/def_id.rs | 6 | ||||
| -rw-r--r-- | crates/hir-ty/src/next_solver/infer/select.rs | 2 | ||||
| -rw-r--r-- | crates/hir-ty/src/next_solver/interner.rs | 6 | ||||
| -rw-r--r-- | crates/hir-ty/src/next_solver/solver.rs | 2 | ||||
| -rw-r--r-- | crates/hir-ty/src/next_solver/ty.rs | 2 | ||||
| -rw-r--r-- | crates/hir-ty/src/opaques.rs | 12 |
10 files changed, 25 insertions, 21 deletions
diff --git a/crates/hir-ty/src/db.rs b/crates/hir-ty/src/db.rs index 9944079cd3..2954af0b52 100644 --- a/crates/hir-ty/src/db.rs +++ b/crates/hir-ty/src/db.rs @@ -346,7 +346,7 @@ fn hir_database_is_dyn_compatible() { fn _assert_dyn_compatible(_: &dyn HirDatabase) {} } -#[salsa_macros::interned(no_lifetime, debug, revisions = usize::MAX)] +#[salsa_macros::interned(debug, revisions = usize::MAX)] #[derive(PartialOrd, Ord)] pub struct InternedOpaqueTyId { pub loc: ImplTraitId, diff --git a/crates/hir-ty/src/dyn_compatibility.rs b/crates/hir-ty/src/dyn_compatibility.rs index 3920a84639..751e1424ab 100644 --- a/crates/hir-ty/src/dyn_compatibility.rs +++ b/crates/hir-ty/src/dyn_compatibility.rs @@ -498,9 +498,9 @@ fn contains_illegal_impl_trait_in_trait<'db>( db: &'db dyn HirDatabase, sig: &EarlyBinder<'db, Binder<'db, rustc_type_ir::FnSig<DbInterner<'db>>>>, ) -> Option<MethodViolationCode> { - struct OpaqueTypeCollector(FxHashSet<InternedOpaqueTyId>); + struct OpaqueTypeCollector<'db>(FxHashSet<InternedOpaqueTyId<'db>>); - impl<'db> rustc_type_ir::TypeVisitor<DbInterner<'db>> for OpaqueTypeCollector { + impl<'db> rustc_type_ir::TypeVisitor<DbInterner<'db>> for OpaqueTypeCollector<'db> { type Result = ControlFlow<()>; fn visit_ty( diff --git a/crates/hir-ty/src/infer.rs b/crates/hir-ty/src/infer.rs index 462f81a304..5db5be0fd1 100644 --- a/crates/hir-ty/src/infer.rs +++ b/crates/hir-ty/src/infer.rs @@ -767,7 +767,7 @@ pub struct InferenceResult<'db> { pub(crate) type_of_pat: ArenaMap<PatId, StoredTy>, pub(crate) type_of_binding: ArenaMap<BindingId, StoredTy>, pub(crate) type_of_type_placeholder: FxHashMap<TypeRefId, StoredTy>, - pub(crate) type_of_opaque: FxHashMap<InternedOpaqueTyId, StoredTy>, + pub(crate) type_of_opaque: FxHashMap<InternedOpaqueTyId<'db>, StoredTy>, /// Whether there are any type-mismatching errors in the result. // FIXME: This isn't as useful as initially thought due to us falling back placeholders to diff --git a/crates/hir-ty/src/lower.rs b/crates/hir-ty/src/lower.rs index f68358af94..edc92b1e09 100644 --- a/crates/hir-ty/src/lower.rs +++ b/crates/hir-ty/src/lower.rs @@ -1267,7 +1267,11 @@ impl<'db, 'a> TyLoweringContext<'db, 'a> { } } - fn lower_impl_trait(&mut self, def_id: InternedOpaqueTyId, bounds: &[TypeBound]) -> ImplTrait { + fn lower_impl_trait( + &mut self, + def_id: InternedOpaqueTyId<'db>, + bounds: &[TypeBound], + ) -> ImplTrait { let interner = self.interner; cov_mark::hit!(lower_rpit); let args = GenericArgs::identity_for_item(interner, def_id.into()); @@ -1526,7 +1530,7 @@ impl ImplTraitId { } } -impl InternedOpaqueTyId { +impl InternedOpaqueTyId<'_> { #[inline] pub fn predicates<'db>(self, db: &'db dyn HirDatabase) -> EarlyBinder<'db, &'db [Clause<'db>]> { self.loc(db).predicates(db) diff --git a/crates/hir-ty/src/next_solver/def_id.rs b/crates/hir-ty/src/next_solver/def_id.rs index dd6b19a84b..b122a8cddc 100644 --- a/crates/hir-ty/src/next_solver/def_id.rs +++ b/crates/hir-ty/src/next_solver/def_id.rs @@ -43,7 +43,7 @@ pub enum SolverDefId<'db> { InternedClosureId(InternedClosureId<'db>), InternedCoroutineId(InternedCoroutineId<'db>), InternedCoroutineClosureId(InternedCoroutineClosureId<'db>), - InternedOpaqueTyId(InternedOpaqueTyId), + InternedOpaqueTyId(InternedOpaqueTyId<'db>), EnumVariantId(EnumVariantId), Ctor(Ctor), } @@ -136,7 +136,7 @@ impl_from!( InternedClosureId<'db>, InternedCoroutineId<'db>, InternedCoroutineClosureId<'db>, - InternedOpaqueTyId, + InternedOpaqueTyId<'db>, EnumVariantId, Ctor for SolverDefId<'db> @@ -457,7 +457,7 @@ declare_id_wrapper_with_lt!(ClosureIdWrapper, InternedClosureId); declare_id_wrapper_with_lt!(CoroutineIdWrapper, InternedCoroutineId); declare_id_wrapper_with_lt!(CoroutineClosureIdWrapper, InternedCoroutineClosureId); declare_id_wrapper!(AdtIdWrapper, AdtId); -declare_id_wrapper!(OpaqueTyIdWrapper, InternedOpaqueTyId, OpaqueTyIdWrapper); +declare_id_wrapper_with_lt!(OpaqueTyIdWrapper, InternedOpaqueTyId, OpaqueTyIdWrapper<'db>); macro_rules! declare_ty_const_pair { ( $ty_id_name:ident, $const_id_name:ident, $term_id_name:ident ) => { diff --git a/crates/hir-ty/src/next_solver/infer/select.rs b/crates/hir-ty/src/next_solver/infer/select.rs index d6f0379c11..1462f29205 100644 --- a/crates/hir-ty/src/next_solver/infer/select.rs +++ b/crates/hir-ty/src/next_solver/infer/select.rs @@ -40,7 +40,7 @@ pub enum SelectionError<'db> { /// Computing an opaque type's hidden type caused an error (e.g. a cycle error). /// We can thus not know whether the hidden type implements an auto trait, so /// we should not presume anything about it. - OpaqueTypeAutoTraitLeakageUnknown(InternedOpaqueTyId), + OpaqueTypeAutoTraitLeakageUnknown(InternedOpaqueTyId<'db>), /// Error for a `ConstArgHasType` goal ConstArgHasWrongType { ct: Const<'db>, ct_ty: Ty<'db>, expected_ty: Ty<'db> }, } diff --git a/crates/hir-ty/src/next_solver/interner.rs b/crates/hir-ty/src/next_solver/interner.rs index ab6ce31256..a7216a034c 100644 --- a/crates/hir-ty/src/next_solver/interner.rs +++ b/crates/hir-ty/src/next_solver/interner.rs @@ -894,8 +894,8 @@ impl<'db> Interner for DbInterner<'db> { type TraitAssocTyId = TraitAssocTyId; type TraitAssocConstId = TraitAssocConstId; type TraitAssocTermId = TraitAssocTermId; - type OpaqueTyId = OpaqueTyIdWrapper; - type LocalOpaqueTyId = OpaqueTyIdWrapper; + type OpaqueTyId = OpaqueTyIdWrapper<'db>; + type LocalOpaqueTyId = OpaqueTyIdWrapper<'db>; type FreeTyAliasId = FreeTyAliasId; type FreeConstAliasId = FreeConstAliasId; type FreeTermAliasId = FreeTermAliasId; @@ -2345,7 +2345,7 @@ TrivialTypeTraversalImpls! { InherentAssocTyId, InherentAssocConstId, InherentAssocTermId, - OpaqueTyIdWrapper, + OpaqueTyIdWrapper<'_>, AnyImplId, GeneralConstIdWrapper<'_>, Safety, diff --git a/crates/hir-ty/src/next_solver/solver.rs b/crates/hir-ty/src/next_solver/solver.rs index b1b3a0e0dc..5486a56581 100644 --- a/crates/hir-ty/src/next_solver/solver.rs +++ b/crates/hir-ty/src/next_solver/solver.rs @@ -130,7 +130,7 @@ impl<'db> SolverDelegate for SolverContext<'db> { fn add_item_bounds_for_hidden_type( &self, - opaque_id: OpaqueTyIdWrapper, + opaque_id: OpaqueTyIdWrapper<'_>, args: GenericArgs<'db>, param_env: ParamEnv<'db>, hidden_ty: Ty<'db>, diff --git a/crates/hir-ty/src/next_solver/ty.rs b/crates/hir-ty/src/next_solver/ty.rs index 397db9375b..05f559c034 100644 --- a/crates/hir-ty/src/next_solver/ty.rs +++ b/crates/hir-ty/src/next_solver/ty.rs @@ -176,7 +176,7 @@ impl<'db> Ty<'db> { pub fn new_opaque( interner: DbInterner<'db>, - def_id: InternedOpaqueTyId, + def_id: InternedOpaqueTyId<'db>, args: GenericArgs<'db>, ) -> Self { Ty::new_alias( diff --git a/crates/hir-ty/src/opaques.rs b/crates/hir-ty/src/opaques.rs index 1d7cd1b05d..9cb0022ca6 100644 --- a/crates/hir-ty/src/opaques.rs +++ b/crates/hir-ty/src/opaques.rs @@ -20,10 +20,10 @@ use crate::{ }, }; -pub(crate) fn opaque_types_defined_by( - db: &dyn HirDatabase, +pub(crate) fn opaque_types_defined_by<'db>( + db: &'db dyn HirDatabase, def_id: InferBodyId<'_>, - result: &mut Vec<SolverDefId<'_>>, + result: &mut Vec<SolverDefId<'db>>, ) { if let Some(func) = def_id.as_function() { // A function may define its own RPITs. @@ -79,11 +79,11 @@ pub(crate) fn opaque_types_defined_by( // FIXME: Collect opaques from `#[define_opaque]`. - fn extend_with_opaques( - db: &dyn HirDatabase, + fn extend_with_opaques<'db>( + db: &'db dyn HirDatabase, opaques: &Option<Box<StoredEarlyBinder<ImplTraits>>>, mut make_impl_trait: impl FnMut(ImplTraitIdx) -> ImplTraitId, - result: &mut Vec<SolverDefId<'_>>, + result: &mut Vec<SolverDefId<'db>>, ) { if let Some(opaques) = opaques { for (opaque_idx, _) in (**opaques).as_ref().skip_binder().impl_traits.iter() { |