Unnamed repository; edit this file 'description' to name the repository.
-rw-r--r--crates/hir-ty/src/autoderef.rs2
-rw-r--r--crates/hir-ty/src/consteval.rs8
-rw-r--r--crates/hir-ty/src/consteval/tests.rs2
-rw-r--r--crates/hir-ty/src/diagnostics/expr.rs2
-rw-r--r--crates/hir-ty/src/display.rs5
-rw-r--r--crates/hir-ty/src/dyn_compatibility.rs55
-rw-r--r--crates/hir-ty/src/infer.rs2
-rw-r--r--crates/hir-ty/src/infer/closure/analysis.rs2
-rw-r--r--crates/hir-ty/src/infer/coerce.rs2
-rw-r--r--crates/hir-ty/src/infer/unify.rs4
-rw-r--r--crates/hir-ty/src/layout.rs6
-rw-r--r--crates/hir-ty/src/layout/tests.rs2
-rw-r--r--crates/hir-ty/src/lower.rs50
-rw-r--r--crates/hir-ty/src/lower/path.rs2
-rw-r--r--crates/hir-ty/src/method_resolution.rs6
-rw-r--r--crates/hir-ty/src/mir.rs2
-rw-r--r--crates/hir-ty/src/mir/borrowck.rs4
-rw-r--r--crates/hir-ty/src/mir/eval.rs2
-rw-r--r--crates/hir-ty/src/mir/eval/tests.rs2
-rw-r--r--crates/hir-ty/src/mir/lower.rs2
-rw-r--r--crates/hir-ty/src/mir/monomorphization.rs2
-rw-r--r--crates/hir-ty/src/next_solver/interner.rs10
-rw-r--r--crates/hir-ty/src/next_solver/ty.rs2
-rw-r--r--crates/hir-ty/src/opaques.rs2
-rw-r--r--crates/hir-ty/src/specialization.rs2
-rw-r--r--crates/hir-ty/src/traits.rs2
-rw-r--r--crates/hir-ty/src/variance.rs4
-rw-r--r--crates/hir/src/attrs.rs2
-rw-r--r--crates/hir/src/lib.rs76
-rw-r--r--crates/hir/src/semantics.rs2
-rw-r--r--crates/hir/src/source_analyzer.rs24
-rw-r--r--crates/hir/src/term_search/tactics.rs2
-rw-r--r--crates/ide-assists/src/handlers/generate_from_impl_for_enum.rs2
-rw-r--r--crates/ide-assists/src/handlers/generate_single_field_struct_from.rs2
-rw-r--r--crates/rust-analyzer/src/cli/analysis_stats.rs6
35 files changed, 153 insertions, 149 deletions
diff --git a/crates/hir-ty/src/autoderef.rs b/crates/hir-ty/src/autoderef.rs
index d21108fb5a..47d06be893 100644
--- a/crates/hir-ty/src/autoderef.rs
+++ b/crates/hir-ty/src/autoderef.rs
@@ -38,7 +38,7 @@ pub fn autoderef<'db>(
env: Arc<TraitEnvironment<'db>>,
ty: Canonical<'db, Ty<'db>>,
) -> impl Iterator<Item = Ty<'db>> + use<'db> {
- let interner = DbInterner::new_with(db, Some(env.krate), env.block);
+ let interner = DbInterner::new_with(db, env.krate, env.block);
let infcx = interner.infer_ctxt().build(TypingMode::PostAnalysis);
let (ty, _) = infcx.instantiate_canonical(&ty);
let autoderef = Autoderef::new(&infcx, &env, ty);
diff --git a/crates/hir-ty/src/consteval.rs b/crates/hir-ty/src/consteval.rs
index 61f29b4ab7..8430c3a41c 100644
--- a/crates/hir-ty/src/consteval.rs
+++ b/crates/hir-ty/src/consteval.rs
@@ -83,7 +83,7 @@ pub fn intern_const_ref<'a>(
ty: Ty<'a>,
krate: Crate,
) -> Const<'a> {
- let interner = DbInterner::new_with(db, Some(krate), None);
+ let interner = DbInterner::new_no_crate(db);
let layout = db.layout_of_ty(ty, TraitEnvironment::empty(krate));
let kind = match value {
LiteralConstRef::Int(i) => {
@@ -128,7 +128,7 @@ pub fn usize_const<'db>(db: &'db dyn HirDatabase, value: Option<u128>, krate: Cr
intern_const_ref(
db,
&value.map_or(LiteralConstRef::Unknown, LiteralConstRef::UInt),
- Ty::new_uint(DbInterner::new_with(db, Some(krate), None), rustc_type_ir::UintTy::Usize),
+ Ty::new_uint(DbInterner::new_no_crate(db), rustc_type_ir::UintTy::Usize),
krate,
)
}
@@ -183,7 +183,7 @@ pub(crate) fn const_eval_discriminant_variant<'db>(
db: &'db dyn HirDatabase,
variant_id: EnumVariantId,
) -> Result<i128, ConstEvalError<'db>> {
- let interner = DbInterner::new_with(db, None, None);
+ let interner = DbInterner::new_no_crate(db);
let def = variant_id.into();
let body = db.body(def);
let loc = variant_id.lookup(db);
@@ -292,7 +292,7 @@ pub(crate) fn const_eval_static_query<'db>(
db: &'db dyn HirDatabase,
def: StaticId,
) -> Result<Const<'db>, ConstEvalError<'db>> {
- let interner = DbInterner::new_with(db, None, None);
+ let interner = DbInterner::new_no_crate(db);
let body = db.monomorphized_mir_body(
def.into(),
GenericArgs::new_from_iter(interner, []),
diff --git a/crates/hir-ty/src/consteval/tests.rs b/crates/hir-ty/src/consteval/tests.rs
index 6095250713..f25147622f 100644
--- a/crates/hir-ty/src/consteval/tests.rs
+++ b/crates/hir-ty/src/consteval/tests.rs
@@ -123,7 +123,7 @@ fn pretty_print_err(e: ConstEvalError<'_>, db: &TestDB) -> String {
fn eval_goal(db: &TestDB, file_id: EditionedFileId) -> Result<Const<'_>, ConstEvalError<'_>> {
let _tracing = setup_tracing();
- let interner = DbInterner::new_with(db, None, None);
+ let interner = DbInterner::new_no_crate(db);
let module_id = db.module_for_file(file_id.file_id(db));
let def_map = module_id.def_map(db);
let scope = &def_map[module_id.local_id].scope;
diff --git a/crates/hir-ty/src/diagnostics/expr.rs b/crates/hir-ty/src/diagnostics/expr.rs
index 0eca0c09d6..565b91df52 100644
--- a/crates/hir-ty/src/diagnostics/expr.rs
+++ b/crates/hir-ty/src/diagnostics/expr.rs
@@ -79,7 +79,7 @@ impl BodyValidationDiagnostic {
let infer = db.infer(owner);
let body = db.body(owner);
let env = db.trait_environment_for_body(owner);
- let interner = DbInterner::new_with(db, Some(env.krate), env.block);
+ let interner = DbInterner::new_with(db, env.krate, env.block);
let infcx =
interner.infer_ctxt().build(TypingMode::typeck_for_body(interner, owner.into()));
let mut validator = ExprValidator {
diff --git a/crates/hir-ty/src/display.rs b/crates/hir-ty/src/display.rs
index 6767bd05b3..4b4ada45ae 100644
--- a/crates/hir-ty/src/display.rs
+++ b/crates/hir-ty/src/display.rs
@@ -309,8 +309,7 @@ pub trait HirDisplay<'db> {
allow_opaque: bool,
) -> Result<String, DisplaySourceCodeError> {
let mut result = String::new();
- let interner =
- DbInterner::new_with(db, Some(module_id.krate()), module_id.containing_block());
+ let interner = DbInterner::new_with(db, module_id.krate(), module_id.containing_block());
match self.hir_fmt(&mut HirFormatter {
db,
interner,
@@ -544,7 +543,7 @@ impl<'db, T: HirDisplay<'db>> HirDisplayWrapper<'_, 'db, T> {
DisplayKind::SourceCode { target_module_id, .. } => target_module_id.containing_block(),
DisplayKind::Diagnostics | DisplayKind::Test => None,
};
- let interner = DbInterner::new_with(self.db, Some(krate), block);
+ let interner = DbInterner::new_with(self.db, krate, block);
self.t.hir_fmt(&mut HirFormatter {
db: self.db,
interner,
diff --git a/crates/hir-ty/src/dyn_compatibility.rs b/crates/hir-ty/src/dyn_compatibility.rs
index 1bd5981d10..d6de9ca7f4 100644
--- a/crates/hir-ty/src/dyn_compatibility.rs
+++ b/crates/hir-ty/src/dyn_compatibility.rs
@@ -53,7 +53,7 @@ pub fn dyn_compatibility(
db: &dyn HirDatabase,
trait_: TraitId,
) -> Option<DynCompatibilityViolation> {
- let interner = DbInterner::new_with(db, Some(trait_.krate(db)), None);
+ let interner = DbInterner::new_no_crate(db);
for super_trait in elaborate::supertrait_def_ids(interner, trait_.into()) {
if let Some(v) = db.dyn_compatibility_of_trait(super_trait.0) {
return if super_trait.0 == trait_ {
@@ -75,7 +75,7 @@ pub fn dyn_compatibility_with_callback<F>(
where
F: FnMut(DynCompatibilityViolation) -> ControlFlow<()>,
{
- let interner = DbInterner::new_with(db, Some(trait_.krate(db)), None);
+ let interner = DbInterner::new_no_crate(db);
for super_trait in elaborate::supertrait_def_ids(interner, trait_.into()).skip(1) {
if db.dyn_compatibility_of_trait(super_trait.0).is_some() {
cb(DynCompatibilityViolation::HasNonCompatibleSuperTrait(trait_))?;
@@ -135,7 +135,7 @@ pub fn generics_require_sized_self(db: &dyn HirDatabase, def: GenericDefId) -> b
return false;
};
- let interner = DbInterner::new_with(db, Some(krate), None);
+ let interner = DbInterner::new_no_crate(db);
let predicates = GenericPredicates::query_explicit(db, def);
// FIXME: We should use `explicit_predicates_of` here, which hasn't been implemented to
// rust-analyzer yet
@@ -234,34 +234,34 @@ fn contains_illegal_self_type_reference<'db, T: rustc_type_ir::TypeVisitable<DbI
&mut self,
ty: <DbInterner<'db> as rustc_type_ir::Interner>::Ty,
) -> Self::Result {
- let interner = DbInterner::new_with(self.db, None, None);
+ let interner = DbInterner::new_no_crate(self.db);
match ty.kind() {
rustc_type_ir::TyKind::Param(param) if param.index == 0 => ControlFlow::Break(()),
rustc_type_ir::TyKind::Param(_) => ControlFlow::Continue(()),
- rustc_type_ir::TyKind::Alias(AliasTyKind::Projection, proj) => match self
- .allow_self_projection
- {
- AllowSelfProjection::Yes => {
- let trait_ = proj.trait_def_id(DbInterner::new_with(self.db, None, None));
- let trait_ = match trait_ {
- SolverDefId::TraitId(id) => id,
- _ => unreachable!(),
- };
- if self.super_traits.is_none() {
- self.super_traits = Some(
- elaborate::supertrait_def_ids(interner, self.trait_.into())
- .map(|super_trait| super_trait.0)
- .collect(),
- )
- }
- if self.super_traits.as_ref().is_some_and(|s| s.contains(&trait_)) {
- ControlFlow::Continue(())
- } else {
- ty.super_visit_with(self)
+ rustc_type_ir::TyKind::Alias(AliasTyKind::Projection, proj) => {
+ match self.allow_self_projection {
+ AllowSelfProjection::Yes => {
+ let trait_ = proj.trait_def_id(interner);
+ let trait_ = match trait_ {
+ SolverDefId::TraitId(id) => id,
+ _ => unreachable!(),
+ };
+ if self.super_traits.is_none() {
+ self.super_traits = Some(
+ elaborate::supertrait_def_ids(interner, self.trait_.into())
+ .map(|super_trait| super_trait.0)
+ .collect(),
+ )
+ }
+ if self.super_traits.as_ref().is_some_and(|s| s.contains(&trait_)) {
+ ControlFlow::Continue(())
+ } else {
+ ty.super_visit_with(self)
+ }
}
+ AllowSelfProjection::No => ty.super_visit_with(self),
}
- AllowSelfProjection::No => ty.super_visit_with(self),
- },
+ }
_ => ty.super_visit_with(self),
}
}
@@ -401,7 +401,8 @@ fn receiver_is_dispatchable<'db>(
) -> bool {
let sig = sig.instantiate_identity();
- let interner: DbInterner<'_> = DbInterner::new_with(db, Some(trait_.krate(db)), None);
+ let module = trait_.module(db);
+ let interner = DbInterner::new_with(db, module.krate(), module.containing_block());
let self_param_id = TypeParamId::from_unchecked(TypeOrConstParamId {
parent: trait_.into(),
local_id: LocalTypeOrConstParamId::from_raw(la_arena::RawIdx::from_u32(0)),
diff --git a/crates/hir-ty/src/infer.rs b/crates/hir-ty/src/infer.rs
index 15eb355128..17de94b7df 100644
--- a/crates/hir-ty/src/infer.rs
+++ b/crates/hir-ty/src/infer.rs
@@ -167,7 +167,7 @@ pub(crate) fn infer_cycle_result(
) -> Arc<InferenceResult<'_>> {
Arc::new(InferenceResult {
has_errors: true,
- ..InferenceResult::new(Ty::new_error(DbInterner::new_with(db, None, None), ErrorGuaranteed))
+ ..InferenceResult::new(Ty::new_error(DbInterner::new_no_crate(db), ErrorGuaranteed))
})
}
diff --git a/crates/hir-ty/src/infer/closure/analysis.rs b/crates/hir-ty/src/infer/closure/analysis.rs
index 944b3594ba..935c5a5078 100644
--- a/crates/hir-ty/src/infer/closure/analysis.rs
+++ b/crates/hir-ty/src/infer/closure/analysis.rs
@@ -101,7 +101,7 @@ impl<'db> CapturedItem<'db> {
}
pub fn ty(&self, db: &'db dyn HirDatabase, subst: GenericArgs<'db>) -> Ty<'db> {
- let interner = DbInterner::new_with(db, None, None);
+ let interner = DbInterner::new_no_crate(db);
self.ty.instantiate(interner, subst.split_closure_args_untupled().parent_args)
}
diff --git a/crates/hir-ty/src/infer/coerce.rs b/crates/hir-ty/src/infer/coerce.rs
index 4acf964bbc..aeb354368c 100644
--- a/crates/hir-ty/src/infer/coerce.rs
+++ b/crates/hir-ty/src/infer/coerce.rs
@@ -1578,7 +1578,7 @@ fn coerce<'db>(
env: Arc<TraitEnvironment<'db>>,
tys: &Canonical<'db, (Ty<'db>, Ty<'db>)>,
) -> Result<(Vec<Adjustment<'db>>, Ty<'db>), TypeError<DbInterner<'db>>> {
- let interner = DbInterner::new_with(db, Some(env.krate), env.block);
+ let interner = DbInterner::new_with(db, env.krate, env.block);
let infcx = interner.infer_ctxt().build(TypingMode::PostAnalysis);
let ((ty1_with_vars, ty2_with_vars), vars) = infcx.instantiate_canonical(tys);
diff --git a/crates/hir-ty/src/infer/unify.rs b/crates/hir-ty/src/infer/unify.rs
index 0b566497c4..b7187fac68 100644
--- a/crates/hir-ty/src/infer/unify.rs
+++ b/crates/hir-ty/src/infer/unify.rs
@@ -113,7 +113,7 @@ fn could_unify_impl<'db>(
tys: &Canonical<'db, (Ty<'db>, Ty<'db>)>,
select: for<'a> fn(&mut ObligationCtxt<'a, 'db>) -> Vec<NextSolverError<'db>>,
) -> bool {
- let interner = DbInterner::new_with(db, Some(env.krate), env.block);
+ let interner = DbInterner::new_with(db, env.krate, env.block);
let infcx = interner.infer_ctxt().build(TypingMode::PostAnalysis);
let cause = ObligationCause::dummy();
let at = infcx.at(&cause, env.env);
@@ -148,7 +148,7 @@ impl<'db> InferenceTable<'db> {
trait_env: Arc<TraitEnvironment<'db>>,
owner: Option<DefWithBodyId>,
) -> Self {
- let interner = DbInterner::new_with(db, Some(trait_env.krate), trait_env.block);
+ let interner = DbInterner::new_with(db, trait_env.krate, trait_env.block);
let typing_mode = match owner {
Some(owner) => TypingMode::typeck_for_body(interner, owner.into()),
// IDE things wants to reveal opaque types.
diff --git a/crates/hir-ty/src/layout.rs b/crates/hir-ty/src/layout.rs
index fc0b9d30b3..908b4dc5d7 100644
--- a/crates/hir-ty/src/layout.rs
+++ b/crates/hir-ty/src/layout.rs
@@ -143,7 +143,7 @@ fn layout_of_simd_ty<'db>(
let Some(TyKind::Array(e_ty, e_len)) = fields
.next()
.filter(|_| fields.next().is_none())
- .map(|f| (*f.1).instantiate(DbInterner::new_with(db, None, None), args).kind())
+ .map(|f| (*f.1).instantiate(DbInterner::new_no_crate(db), args).kind())
else {
return Err(LayoutError::InvalidSimdType);
};
@@ -161,7 +161,7 @@ pub fn layout_of_ty_query<'db>(
trait_env: Arc<TraitEnvironment<'db>>,
) -> Result<Arc<Layout>, LayoutError> {
let krate = trait_env.krate;
- let interner = DbInterner::new_with(db, Some(krate), trait_env.block);
+ let interner = DbInterner::new_with(db, krate, trait_env.block);
let Ok(target) = db.target_data_layout(krate) else {
return Err(LayoutError::TargetLayoutNotAvailable);
};
@@ -401,7 +401,7 @@ fn field_ty<'a>(
fd: LocalFieldId,
args: &GenericArgs<'a>,
) -> Ty<'a> {
- db.field_types(def)[fd].instantiate(DbInterner::new_with(db, None, None), args)
+ db.field_types(def)[fd].instantiate(DbInterner::new_no_crate(db), args)
}
fn scalar_unit(dl: &TargetDataLayout, value: Primitive) -> Scalar {
diff --git a/crates/hir-ty/src/layout/tests.rs b/crates/hir-ty/src/layout/tests.rs
index f0fed83597..2ce0a67920 100644
--- a/crates/hir-ty/src/layout/tests.rs
+++ b/crates/hir-ty/src/layout/tests.rs
@@ -80,7 +80,7 @@ fn eval_goal(
})
.unwrap();
crate::attach_db(&db, || {
- let interner = DbInterner::new_with(&db, None, None);
+ let interner = DbInterner::new_no_crate(&db);
let goal_ty = match adt_or_type_alias_id {
Either::Left(adt_id) => crate::next_solver::Ty::new_adt(
interner,
diff --git a/crates/hir-ty/src/lower.rs b/crates/hir-ty/src/lower.rs
index 3f187d205d..59e1801483 100644
--- a/crates/hir-ty/src/lower.rs
+++ b/crates/hir-ty/src/lower.rs
@@ -193,7 +193,7 @@ impl<'db, 'a> TyLoweringContext<'db, 'a> {
let in_binders = DebruijnIndex::ZERO;
Self {
db,
- interner: DbInterner::new_with(db, Some(resolver.krate()), None),
+ interner: DbInterner::new_no_crate(db),
resolver,
def,
generics: Default::default(),
@@ -1101,7 +1101,7 @@ impl ValueTyDefId {
/// the constructor function `(usize) -> Foo` which lives in the values
/// namespace.
pub(crate) fn ty_query<'db>(db: &'db dyn HirDatabase, def: TyDefId) -> EarlyBinder<'db, Ty<'db>> {
- let interner = DbInterner::new_with(db, None, None);
+ let interner = DbInterner::new_no_crate(db);
match def {
TyDefId::BuiltinType(it) => EarlyBinder::bind(Ty::from_builtin_type(interner, it)),
TyDefId::AdtId(it) => EarlyBinder::bind(Ty::new_adt(
@@ -1116,7 +1116,7 @@ pub(crate) fn ty_query<'db>(db: &'db dyn HirDatabase, def: TyDefId) -> EarlyBind
/// Build the declared type of a function. This should not need to look at the
/// function body.
fn type_for_fn<'db>(db: &'db dyn HirDatabase, def: FunctionId) -> EarlyBinder<'db, Ty<'db>> {
- let interner = DbInterner::new_with(db, None, None);
+ let interner = DbInterner::new_no_crate(db);
EarlyBinder::bind(Ty::new_fn_def(
interner,
CallableDefId::FunctionId(def).into(),
@@ -1165,7 +1165,7 @@ fn type_for_struct_constructor<'db>(
FieldsShape::Record => None,
FieldsShape::Unit => Some(type_for_adt(db, def.into())),
FieldsShape::Tuple => {
- let interner = DbInterner::new_with(db, None, None);
+ let interner = DbInterner::new_no_crate(db);
Some(EarlyBinder::bind(Ty::new_fn_def(
interner,
CallableDefId::StructId(def).into(),
@@ -1185,7 +1185,7 @@ fn type_for_enum_variant_constructor<'db>(
FieldsShape::Record => None,
FieldsShape::Unit => Some(type_for_adt(db, def.loc(db).parent.into())),
FieldsShape::Tuple => {
- let interner = DbInterner::new_with(db, None, None);
+ let interner = DbInterner::new_no_crate(db);
Some(EarlyBinder::bind(Ty::new_fn_def(
interner,
CallableDefId::EnumVariantId(def).into(),
@@ -1216,7 +1216,7 @@ pub(crate) fn type_for_type_alias_with_diagnostics_query<'db>(
let type_alias_data = db.type_alias_signature(t);
let mut diags = None;
let resolver = t.resolver(db);
- let interner = DbInterner::new_with(db, Some(resolver.krate()), None);
+ let interner = DbInterner::new_no_crate(db);
let inner = if type_alias_data.flags.contains(TypeAliasFlags::IS_EXTERN) {
EarlyBinder::bind(Ty::new_foreign(interner, t.into()))
} else {
@@ -1244,7 +1244,7 @@ pub(crate) fn type_for_type_alias_with_diagnostics_cycle_result<'db>(
db: &'db dyn HirDatabase,
_adt: TypeAliasId,
) -> (EarlyBinder<'db, Ty<'db>>, Diagnostics) {
- (EarlyBinder::bind(Ty::new_error(DbInterner::new_with(db, None, None), ErrorGuaranteed)), None)
+ (EarlyBinder::bind(Ty::new_error(DbInterner::new_no_crate(db), ErrorGuaranteed)), None)
}
pub(crate) fn impl_self_ty_query<'db>(
@@ -1277,7 +1277,7 @@ pub(crate) fn impl_self_ty_with_diagnostics_cycle_result(
db: &dyn HirDatabase,
_impl_id: ImplId,
) -> (EarlyBinder<'_, Ty<'_>>, Diagnostics) {
- (EarlyBinder::bind(Ty::new_error(DbInterner::new_with(db, None, None), ErrorGuaranteed)), None)
+ (EarlyBinder::bind(Ty::new_error(DbInterner::new_no_crate(db), ErrorGuaranteed)), None)
}
pub(crate) fn const_param_ty_query<'db>(db: &'db dyn HirDatabase, def: ConstParamId) -> Ty<'db> {
@@ -1292,7 +1292,7 @@ pub(crate) fn const_param_ty_with_diagnostics_query<'db>(
let (parent_data, store) = db.generic_params_and_store(def.parent());
let data = &parent_data[def.local_id()];
let resolver = def.parent().resolver(db);
- let interner = DbInterner::new_with(db, Some(resolver.krate()), None);
+ let interner = DbInterner::new_no_crate(db);
let mut ctx = TyLoweringContext::new(
db,
&resolver,
@@ -1313,10 +1313,9 @@ pub(crate) fn const_param_ty_with_diagnostics_query<'db>(
pub(crate) fn const_param_ty_with_diagnostics_cycle_result<'db>(
db: &'db dyn HirDatabase,
_: crate::db::HirDatabaseData,
- def: ConstParamId,
+ _def: ConstParamId,
) -> (Ty<'db>, Diagnostics) {
- let resolver = def.parent().resolver(db);
- let interner = DbInterner::new_with(db, Some(resolver.krate()), None);
+ let interner = DbInterner::new_no_crate(db);
(Ty::new_error(interner, ErrorGuaranteed), None)
}
@@ -1374,7 +1373,7 @@ pub(crate) fn generic_predicates_for_param<'db>(
assoc_name: Option<Name>,
) -> EarlyBinder<'db, Box<[Clause<'db>]>> {
let generics = generics(db, def);
- let interner = DbInterner::new_with(db, None, None);
+ let interner = DbInterner::new_no_crate(db);
let resolver = def.resolver(db);
let mut ctx = TyLoweringContext::new(
db,
@@ -1520,8 +1519,7 @@ pub fn type_alias_bounds_with_diagnostics<'db>(
}
if !ctx.unsized_types.contains(&interner_ty) {
- let sized_trait = LangItem::Sized
- .resolve_trait(ctx.db, interner.krate.expect("Must have interner.krate"));
+ let sized_trait = LangItem::Sized.resolve_trait(ctx.db, resolver.krate());
if let Some(sized_trait) = sized_trait {
let trait_ref = TraitRef::new_from_args(
interner,
@@ -1625,7 +1623,7 @@ pub(crate) fn trait_environment_query<'db>(
def: GenericDefId,
) -> Arc<TraitEnvironment<'db>> {
let module = def.module(db);
- let interner = DbInterner::new_with(db, Some(module.krate()), module.containing_block());
+ let interner = DbInterner::new_no_crate(db);
let predicates = GenericPredicates::query_all(db, def);
let traits_in_scope = predicates
.iter_identity_copied()
@@ -1663,7 +1661,7 @@ where
{
let generics = generics(db, def);
let resolver = def.resolver(db);
- let interner = DbInterner::new_with(db, Some(resolver.krate()), None);
+ let interner = DbInterner::new_no_crate(db);
let mut ctx = TyLoweringContext::new(
db,
&resolver,
@@ -1811,7 +1809,7 @@ fn push_const_arg_has_type_predicates<'db>(
predicates: &mut Vec<Clause<'db>>,
generics: &Generics,
) {
- let interner = DbInterner::new_with(db, None, None);
+ let interner = DbInterner::new_no_crate(db);
let const_params_offset = generics.len_parent() + generics.len_lifetimes_self();
for (param_index, (param_idx, param_data)) in generics.iter_self_type_or_consts().enumerate() {
if !matches!(param_data, TypeOrConstParamData::ConstParamData(_)) {
@@ -1844,7 +1842,7 @@ fn implicitly_sized_clauses<'a, 'subst, 'db>(
args: &'subst GenericArgs<'db>,
resolver: &Resolver<'db>,
) -> Option<impl Iterator<Item = Clause<'db>> + Captures<'a> + Captures<'subst>> {
- let interner = DbInterner::new_with(db, Some(resolver.krate()), None);
+ let interner = DbInterner::new_no_crate(db);
let sized_trait = LangItem::Sized.resolve_trait(db, resolver.krate())?;
let trait_self_idx = trait_self_param_idx(db, def);
@@ -1992,7 +1990,7 @@ fn fn_sig_for_fn<'db>(
) -> EarlyBinder<'db, PolyFnSig<'db>> {
let data = db.function_signature(def);
let resolver = def.resolver(db);
- let interner = DbInterner::new_with(db, Some(resolver.krate()), None);
+ let interner = DbInterner::new_no_crate(db);
let mut ctx_params = TyLoweringContext::new(
db,
&resolver,
@@ -2028,7 +2026,7 @@ fn fn_sig_for_fn<'db>(
}
fn type_for_adt<'db>(db: &'db dyn HirDatabase, adt: AdtId) -> EarlyBinder<'db, Ty<'db>> {
- let interner = DbInterner::new_with(db, None, None);
+ let interner = DbInterner::new_no_crate(db);
let args = GenericArgs::identity_for_item(interner, adt.into());
let ty = Ty::new_adt(interner, adt, args);
EarlyBinder::bind(ty)
@@ -2043,7 +2041,7 @@ fn fn_sig_for_struct_constructor<'db>(
let ret = type_for_adt(db, def.into()).skip_binder();
let inputs_and_output =
- Tys::new_from_iter(DbInterner::new_with(db, None, None), params.chain(Some(ret)));
+ Tys::new_from_iter(DbInterner::new_no_crate(db), params.chain(Some(ret)));
EarlyBinder::bind(Binder::dummy(FnSig {
abi: FnAbi::RustCall,
c_variadic: false,
@@ -2062,7 +2060,7 @@ fn fn_sig_for_enum_variant_constructor<'db>(
let ret = type_for_adt(db, parent.into()).skip_binder();
let inputs_and_output =
- Tys::new_from_iter(DbInterner::new_with(db, None, None), params.chain(Some(ret)));
+ Tys::new_from_iter(DbInterner::new_no_crate(db), params.chain(Some(ret)));
EarlyBinder::bind(Binder::dummy(FnSig {
abi: FnAbi::RustCall,
c_variadic: false,
@@ -2078,7 +2076,7 @@ pub(crate) fn associated_ty_item_bounds<'db>(
) -> EarlyBinder<'db, BoundExistentialPredicates<'db>> {
let type_alias_data = db.type_alias_signature(type_alias);
let resolver = hir_def::resolver::HasResolver::resolver(type_alias, db);
- let interner = DbInterner::new_with(db, Some(resolver.krate()), None);
+ let interner = DbInterner::new_no_crate(db);
let mut ctx = TyLoweringContext::new(
db,
&resolver,
@@ -2157,7 +2155,7 @@ pub(crate) fn associated_type_by_name_including_super_traits<'db>(
trait_ref: TraitRef<'db>,
name: &Name,
) -> Option<(TraitRef<'db>, TypeAliasId)> {
- let interner = DbInterner::new_with(db, None, None);
+ let interner = DbInterner::new_no_crate(db);
rustc_type_ir::elaborate::supertraits(interner, Binder::dummy(trait_ref)).find_map(|t| {
let trait_id = t.as_ref().skip_binder().def_id.0;
let assoc_type = trait_id.trait_items(db).associated_type_by_name(name)?;
@@ -2171,7 +2169,7 @@ pub fn associated_type_shorthand_candidates(
res: TypeNs,
mut cb: impl FnMut(&Name, TypeAliasId) -> bool,
) -> Option<TypeAliasId> {
- let interner = DbInterner::new_with(db, None, None);
+ let interner = DbInterner::new_no_crate(db);
named_associated_type_shorthand_candidates(interner, def, res, None, |name, _, id| {
cb(name, id).then_some(id)
})
diff --git a/crates/hir-ty/src/lower/path.rs b/crates/hir-ty/src/lower/path.rs
index 6d3ce74aed..fe96b6832e 100644
--- a/crates/hir-ty/src/lower/path.rs
+++ b/crates/hir-ty/src/lower/path.rs
@@ -1100,7 +1100,7 @@ pub(crate) fn substs_from_args_and_bindings<'db>(
explicit_self_ty: Option<Ty<'db>>,
ctx: &mut impl GenericArgsLowerer<'db>,
) -> GenericArgs<'db> {
- let interner = DbInterner::new_with(db, None, None);
+ let interner = DbInterner::new_no_crate(db);
tracing::debug!(?args_and_bindings);
diff --git a/crates/hir-ty/src/method_resolution.rs b/crates/hir-ty/src/method_resolution.rs
index 59299f2c35..4ec01e61b8 100644
--- a/crates/hir-ty/src/method_resolution.rs
+++ b/crates/hir-ty/src/method_resolution.rs
@@ -418,7 +418,7 @@ pub(crate) fn lookup_impl_method_query<'db>(
func: FunctionId,
fn_subst: GenericArgs<'db>,
) -> (FunctionId, GenericArgs<'db>) {
- let interner = DbInterner::new_with(db, Some(env.krate), env.block);
+ let interner = DbInterner::new_with(db, env.krate, env.block);
let infcx = interner.infer_ctxt().build(TypingMode::PostAnalysis);
let ItemContainerId::TraitId(trait_id) = func.loc(db).container else {
@@ -597,7 +597,7 @@ impl InherentImpls {
continue;
}
- let interner = DbInterner::new_with(db, None, None);
+ let interner = DbInterner::new_no_crate(db);
let self_ty = db.impl_self_ty(impl_id);
let self_ty = self_ty.instantiate_identity();
if let Some(self_ty) =
@@ -723,7 +723,7 @@ impl TraitImpls {
None => continue,
};
let self_ty = trait_ref.self_ty();
- let interner = DbInterner::new_with(db, None, None);
+ let interner = DbInterner::new_no_crate(db);
let entry = map.entry(trait_ref.def_id.0).or_default();
match simplify_type(interner, self_ty, TreatParams::InstantiateWithInfer) {
Some(self_ty) => {
diff --git a/crates/hir-ty/src/mir.rs b/crates/hir-ty/src/mir.rs
index b5b691d466..317578fcd9 100644
--- a/crates/hir-ty/src/mir.rs
+++ b/crates/hir-ty/src/mir.rs
@@ -134,7 +134,7 @@ impl<'db> Operand<'db> {
func_id: hir_def::FunctionId,
generic_args: GenericArgs<'db>,
) -> Operand<'db> {
- let interner = DbInterner::new_with(db, None, None);
+ let interner = DbInterner::new_no_crate(db);
let ty = Ty::new_fn_def(interner, CallableDefId::FunctionId(func_id).into(), generic_args);
Operand::from_bytes(Box::default(), ty)
}
diff --git a/crates/hir-ty/src/mir/borrowck.rs b/crates/hir-ty/src/mir/borrowck.rs
index 01892657bc..acd064598a 100644
--- a/crates/hir-ty/src/mir/borrowck.rs
+++ b/crates/hir-ty/src/mir/borrowck.rs
@@ -97,7 +97,7 @@ pub fn borrowck_query<'db>(
) -> Result<Arc<[BorrowckResult<'db>]>, MirLowerError<'db>> {
let _p = tracing::info_span!("borrowck_query").entered();
let module = def.module(db);
- let interner = DbInterner::new_with(db, Some(module.krate()), module.containing_block());
+ let interner = DbInterner::new_with(db, module.krate(), module.containing_block());
let env = db.trait_environment_for_body(def);
let mut res = vec![];
// This calculates opaques defining scope which is a bit costly therefore is put outside `all_mir_bodies()`.
@@ -124,7 +124,7 @@ fn make_fetch_closure_field<'db>(
let infer = db.infer(def);
let (captures, _) = infer.closure_info(c);
let parent_subst = subst.split_closure_args_untupled().parent_args;
- let interner = DbInterner::new_with(db, None, None);
+ let interner = DbInterner::new_no_crate(db);
captures.get(f).expect("broken closure field").ty.instantiate(interner, parent_subst)
}
}
diff --git a/crates/hir-ty/src/mir/eval.rs b/crates/hir-ty/src/mir/eval.rs
index da15ca695e..ba89b71d9d 100644
--- a/crates/hir-ty/src/mir/eval.rs
+++ b/crates/hir-ty/src/mir/eval.rs
@@ -641,7 +641,7 @@ impl<'db> Evaluator<'db> {
Err(e) => return Err(MirEvalError::TargetDataLayoutNotAvailable(e)),
};
let cached_ptr_size = target_data_layout.pointer_size().bytes_usize();
- let interner = DbInterner::new_with(db, Some(crate_id), module.containing_block());
+ let interner = DbInterner::new_with(db, crate_id, module.containing_block());
let infcx = interner.infer_ctxt().build(TypingMode::PostAnalysis);
Ok(Evaluator {
target_data_layout,
diff --git a/crates/hir-ty/src/mir/eval/tests.rs b/crates/hir-ty/src/mir/eval/tests.rs
index 88acd49065..bb2afb2f00 100644
--- a/crates/hir-ty/src/mir/eval/tests.rs
+++ b/crates/hir-ty/src/mir/eval/tests.rs
@@ -17,7 +17,7 @@ use super::{MirEvalError, interpret_mir};
fn eval_main(db: &TestDB, file_id: EditionedFileId) -> Result<(String, String), MirEvalError<'_>> {
crate::attach_db(db, || {
- let interner = DbInterner::new_with(db, None, None);
+ let interner = DbInterner::new_no_crate(db);
let module_id = db.module_for_file(file_id.file_id(db));
let def_map = module_id.def_map(db);
let scope = &def_map[module_id.local_id].scope;
diff --git a/crates/hir-ty/src/mir/lower.rs b/crates/hir-ty/src/mir/lower.rs
index 7f457ca59a..9037fdf57c 100644
--- a/crates/hir-ty/src/mir/lower.rs
+++ b/crates/hir-ty/src/mir/lower.rs
@@ -302,7 +302,7 @@ impl<'a, 'db> MirLowerCtx<'a, 'db> {
};
let resolver = owner.resolver(db);
let env = db.trait_environment_for_body(owner);
- let interner = DbInterner::new_with(db, Some(env.krate), env.block);
+ let interner = DbInterner::new_with(db, env.krate, env.block);
// FIXME(next-solver): Is `non_body_analysis()` correct here? Don't we want to reveal opaque types defined by this body?
let infcx = interner.infer_ctxt().build(TypingMode::non_body_analysis());
diff --git a/crates/hir-ty/src/mir/monomorphization.rs b/crates/hir-ty/src/mir/monomorphization.rs
index 745f73948d..754d539e20 100644
--- a/crates/hir-ty/src/mir/monomorphization.rs
+++ b/crates/hir-ty/src/mir/monomorphization.rs
@@ -98,7 +98,7 @@ impl<'db> Filler<'db> {
env: Arc<TraitEnvironment<'db>>,
subst: GenericArgs<'db>,
) -> Self {
- let interner = DbInterner::new_with(db, Some(env.krate), env.block);
+ let interner = DbInterner::new_with(db, env.krate, env.block);
let infcx = interner.infer_ctxt().build(TypingMode::PostAnalysis);
Self { infcx, trait_env: env, subst }
}
diff --git a/crates/hir-ty/src/next_solver/interner.rs b/crates/hir-ty/src/next_solver/interner.rs
index a3c984f6c9..a62835d9b0 100644
--- a/crates/hir-ty/src/next_solver/interner.rs
+++ b/crates/hir-ty/src/next_solver/interner.rs
@@ -288,12 +288,18 @@ impl<'db> DbInterner<'db> {
})
}
+ /// Creates a new interner without an active crate. Good only for interning things, not for trait solving etc..
+ /// As a rule of thumb, when you create an `InferCtxt`, you need to provide the crate (and the block).
+ pub fn new_no_crate(db: &'db dyn HirDatabase) -> Self {
+ DbInterner { db, krate: None, block: None }
+ }
+
pub fn new_with(
db: &'db dyn HirDatabase,
- krate: Option<Crate>,
+ krate: Crate,
block: Option<BlockId>,
) -> DbInterner<'db> {
- DbInterner { db, krate, block }
+ DbInterner { db, krate: Some(krate), block }
}
#[inline]
diff --git a/crates/hir-ty/src/next_solver/ty.rs b/crates/hir-ty/src/next_solver/ty.rs
index 58849ce9ca..4f9de5a1a9 100644
--- a/crates/hir-ty/src/next_solver/ty.rs
+++ b/crates/hir-ty/src/next_solver/ty.rs
@@ -620,7 +620,7 @@ impl<'db> Ty<'db> {
// FIXME: Should this be here?
pub fn impl_trait_bounds(self, db: &'db dyn HirDatabase) -> Option<Vec<Clause<'db>>> {
- let interner = DbInterner::new_with(db, None, None);
+ let interner = DbInterner::new_no_crate(db);
match self.kind() {
TyKind::Alias(AliasTyKind::Opaque, opaque_ty) => Some(
diff --git a/crates/hir-ty/src/opaques.rs b/crates/hir-ty/src/opaques.rs
index acf532c5e4..fa99013d5e 100644
--- a/crates/hir-ty/src/opaques.rs
+++ b/crates/hir-ty/src/opaques.rs
@@ -118,7 +118,7 @@ pub(crate) fn tait_hidden_types<'db>(
let loc = type_alias.loc(db);
let module = loc.module(db);
- let interner = DbInterner::new_with(db, Some(module.krate()), module.containing_block());
+ let interner = DbInterner::new_with(db, module.krate(), module.containing_block());
let infcx = interner.infer_ctxt().build(TypingMode::non_body_analysis());
let mut ocx = ObligationCtxt::new(&infcx);
let cause = ObligationCause::dummy();
diff --git a/crates/hir-ty/src/specialization.rs b/crates/hir-ty/src/specialization.rs
index 304679d372..b69b437677 100644
--- a/crates/hir-ty/src/specialization.rs
+++ b/crates/hir-ty/src/specialization.rs
@@ -46,7 +46,7 @@ fn specializes_query(
parent_impl_def_id: ImplId,
) -> bool {
let trait_env = db.trait_environment(specializing_impl_def_id.into());
- let interner = DbInterner::new_with(db, Some(trait_env.krate), trait_env.block);
+ let interner = DbInterner::new_with(db, trait_env.krate, trait_env.block);
let specializing_impl_signature = db.impl_signature(specializing_impl_def_id);
let parent_impl_signature = db.impl_signature(parent_impl_def_id);
diff --git a/crates/hir-ty/src/traits.rs b/crates/hir-ty/src/traits.rs
index 2055c3151c..0f5c70ef57 100644
--- a/crates/hir-ty/src/traits.rs
+++ b/crates/hir-ty/src/traits.rs
@@ -257,7 +257,7 @@ fn implements_trait_unique_impl<'db>(
trait_: TraitId,
create_args: &mut dyn FnMut(&InferCtxt<'db>) -> GenericArgs<'db>,
) -> bool {
- let interner = DbInterner::new_with(db, Some(env.krate), env.block);
+ let interner = DbInterner::new_with(db, env.krate, env.block);
// FIXME(next-solver): I believe this should be `PostAnalysis`.
let infcx = interner.infer_ctxt().build(TypingMode::non_body_analysis());
diff --git a/crates/hir-ty/src/variance.rs b/crates/hir-ty/src/variance.rs
index b57bf03f24..df9d53f3e5 100644
--- a/crates/hir-ty/src/variance.rs
+++ b/crates/hir-ty/src/variance.rs
@@ -32,7 +32,7 @@ use crate::{
pub(crate) fn variances_of(db: &dyn HirDatabase, def: GenericDefId) -> VariancesOf<'_> {
tracing::debug!("variances_of(def={:?})", def);
- let interner = DbInterner::new_with(db, None, None);
+ let interner = DbInterner::new_no_crate(db);
match def {
GenericDefId::FunctionId(_) => (),
GenericDefId::AdtId(adt) => {
@@ -107,7 +107,7 @@ pub(crate) fn variances_of_cycle_initial(
db: &dyn HirDatabase,
def: GenericDefId,
) -> VariancesOf<'_> {
- let interner = DbInterner::new_with(db, None, None);
+ let interner = DbInterner::new_no_crate(db);
let generics = generics(db, def);
let count = generics.len();
diff --git a/crates/hir/src/attrs.rs b/crates/hir/src/attrs.rs
index cfc408038d..f1ca6cc4a9 100644
--- a/crates/hir/src/attrs.rs
+++ b/crates/hir/src/attrs.rs
@@ -271,7 +271,7 @@ fn resolve_impl_trait_item<'db>(
// attributes here. Use path resolution directly instead.
//
// FIXME: resolve type aliases (which are not yielded by iterate_path_candidates)
- let interner = DbInterner::new_with(db, Some(environment.krate), environment.block);
+ let interner = DbInterner::new_with(db, environment.krate, environment.block);
let infcx = interner.infer_ctxt().build(TypingMode::PostAnalysis);
let unstable_features =
MethodResolutionUnstableFeatures::from_def_map(resolver.top_level_def_map());
diff --git a/crates/hir/src/lib.rs b/crates/hir/src/lib.rs
index 2d70a8dca1..f941cbd232 100644
--- a/crates/hir/src/lib.rs
+++ b/crates/hir/src/lib.rs
@@ -765,7 +765,7 @@ impl Module {
}
self.legacy_macros(db).into_iter().for_each(|m| emit_macro_def_diagnostics(db, acc, m));
- let interner = DbInterner::new_with(db, Some(self.id.krate()), self.id.containing_block());
+ let interner = DbInterner::new_with(db, self.id.krate(), self.id.containing_block());
let infcx = interner.infer_ctxt().build(TypingMode::non_body_analysis());
let mut impl_assoc_items_scratch = vec![];
@@ -1282,8 +1282,7 @@ pub struct InstantiatedField<'db> {
impl<'db> InstantiatedField<'db> {
/// Returns the type as in the signature of the struct.
pub fn ty(&self, db: &'db dyn HirDatabase) -> TypeNs<'db> {
- let krate = self.inner.krate(db);
- let interner = DbInterner::new_with(db, Some(krate.base()), None);
+ let interner = DbInterner::new_no_crate(db);
let var_id = self.inner.parent.into();
let field = db.field_types(var_id)[self.inner.id];
@@ -1305,7 +1304,7 @@ impl TupleField {
}
pub fn ty<'db>(&self, db: &'db dyn HirDatabase) -> Type<'db> {
- let interner = DbInterner::new_with(db, None, None);
+ let interner = DbInterner::new_no_crate(db);
let ty = db
.infer(self.owner)
.tuple_field_access_type(self.tuple)
@@ -1381,7 +1380,7 @@ impl Field {
VariantDef::Union(it) => it.id.into(),
VariantDef::Variant(it) => it.parent_enum(db).id.into(),
};
- let interner = DbInterner::new_with(db, None, None);
+ let interner = DbInterner::new_no_crate(db);
let args = generic_args_from_tys(interner, def_id.into(), generics.map(|ty| ty.ty));
let ty = db.field_types(var_id)[self.id].instantiate(interner, args);
Type::new(db, var_id, ty)
@@ -1506,8 +1505,7 @@ impl<'db> InstantiatedStruct<'db> {
}
pub fn ty(self, db: &'db dyn HirDatabase) -> TypeNs<'db> {
- let krate = self.inner.krate(db);
- let interner = DbInterner::new_with(db, Some(krate.base()), None);
+ let interner = DbInterner::new_no_crate(db);
let ty = db.ty(self.inner.id.into());
TypeNs::new(db, self.inner.id, ty.instantiate(interner, self.args))
@@ -1605,7 +1603,7 @@ impl Enum {
/// The type of the enum variant bodies.
pub fn variant_body_ty<'db>(self, db: &'db dyn HirDatabase) -> Type<'db> {
- let interner = DbInterner::new_with(db, None, None);
+ let interner = DbInterner::new_no_crate(db);
Type::new_for_crate(
self.id.lookup(db).container.krate(),
match db.enum_signature(self.id).variant_body_type() {
@@ -1669,8 +1667,7 @@ pub struct InstantiatedEnum<'db> {
impl<'db> InstantiatedEnum<'db> {
pub fn ty(self, db: &'db dyn HirDatabase) -> TypeNs<'db> {
- let krate = self.inner.krate(db);
- let interner = DbInterner::new_with(db, Some(krate.base()), None);
+ let interner = DbInterner::new_no_crate(db);
let ty = db.ty(self.inner.id.into());
TypeNs::new(db, self.inner.id, ty.instantiate(interner, self.args))
@@ -1816,7 +1813,7 @@ impl Adt {
pub fn layout(self, db: &dyn HirDatabase) -> Result<Layout, LayoutError> {
let env = db.trait_environment(self.into());
- let interner = DbInterner::new_with(db, Some(env.krate), env.block);
+ let interner = DbInterner::new_no_crate(db);
let adt_id = AdtId::from(self);
let args = GenericArgs::for_item_with_defaults(interner, adt_id.into(), |_, id, _| {
GenericArg::error_from_id(interner, id)
@@ -1841,7 +1838,7 @@ impl Adt {
args: impl IntoIterator<Item = Type<'db>>,
) -> Type<'db> {
let id = AdtId::from(self);
- let interner = DbInterner::new_with(db, None, None);
+ let interner = DbInterner::new_no_crate(db);
let ty = Ty::new_adt(
interner,
id,
@@ -2277,7 +2274,7 @@ impl Function {
pub fn fn_ptr_type(self, db: &dyn HirDatabase) -> Type<'_> {
let resolver = self.id.resolver(db);
- let interner = DbInterner::new_with(db, None, None);
+ let interner = DbInterner::new_no_crate(db);
// FIXME: This shouldn't be `instantiate_identity()`, we shouldn't leak `TyKind::Param`s.
let callable_sig = db.callable_item_signature(self.id.into()).instantiate_identity();
let ty = Ty::new_fn_ptr(interner, callable_sig);
@@ -2305,10 +2302,10 @@ impl Function {
generics: impl Iterator<Item = Type<'db>>,
) -> Type<'db> {
let resolver = self.id.resolver(db);
- let interner = DbInterner::new_with(db, None, None);
+ let interner = DbInterner::new_no_crate(db);
let args = generic_args_from_tys(interner, self.id.into(), generics.map(|ty| ty.ty));
- let interner = DbInterner::new_with(db, None, None);
+ let interner = DbInterner::new_no_crate(db);
let ty = db
.callable_item_signature(self.id.into())
.instantiate(interner, args)
@@ -2396,7 +2393,7 @@ impl Function {
generics: impl Iterator<Item = Type<'db>>,
) -> Vec<Param<'db>> {
let environment = db.trait_environment(self.id.into());
- let interner = DbInterner::new_with(db, None, None);
+ let interner = DbInterner::new_no_crate(db);
let args = generic_args_from_tys(interner, self.id.into(), generics.map(|ty| ty.ty));
let callable_sig =
db.callable_item_signature(self.id.into()).instantiate(interner, args).skip_binder();
@@ -2547,7 +2544,7 @@ impl Function {
db: &dyn HirDatabase,
span_formatter: impl Fn(FileId, TextRange) -> String,
) -> Result<String, ConstEvalError<'_>> {
- let interner = DbInterner::new_with(db, None, None);
+ let interner = DbInterner::new_no_crate(db);
let body = db.monomorphized_mir_body(
self.id.into(),
GenericArgs::new_from_iter(interner, []),
@@ -2704,7 +2701,7 @@ impl SelfParam {
db: &'db dyn HirDatabase,
generics: impl Iterator<Item = Type<'db>>,
) -> Type<'db> {
- let interner = DbInterner::new_with(db, None, None);
+ let interner = DbInterner::new_no_crate(db);
let args = generic_args_from_tys(interner, self.func.into(), generics.map(|ty| ty.ty));
let callable_sig =
db.callable_item_signature(self.func.into()).instantiate(interner, args).skip_binder();
@@ -2804,7 +2801,7 @@ impl Const {
/// Evaluate the constant.
pub fn eval(self, db: &dyn HirDatabase) -> Result<EvaluatedConst<'_>, ConstEvalError<'_>> {
- let interner = DbInterner::new_with(db, None, None);
+ let interner = DbInterner::new_no_crate(db);
let ty = db.value_ty(self.id.into()).unwrap().instantiate_identity();
db.const_eval(self.id, GenericArgs::new_from_iter(interner, []), None)
.map(|it| EvaluatedConst { const_: it, def: self.id.into(), ty })
@@ -3076,7 +3073,7 @@ impl BuiltinType {
pub fn ty<'db>(self, db: &'db dyn HirDatabase) -> Type<'db> {
let core = Crate::core(db).map(|core| core.id).unwrap_or_else(|| db.all_crates()[0]);
- let interner = DbInterner::new_with(db, None, None);
+ let interner = DbInterner::new_no_crate(db);
Type::new_for_crate(core, Ty::from_builtin_type(interner, self.inner))
}
@@ -4208,7 +4205,7 @@ impl TypeParam {
pub fn ty(self, db: &dyn HirDatabase) -> Type<'_> {
let resolver = self.id.parent().resolver(db);
- let interner = DbInterner::new_with(db, None, None);
+ let interner = DbInterner::new_no_crate(db);
let index = hir_ty::param_idx(db, self.id.into()).unwrap();
let ty = Ty::new_param(interner, self.id, index as u32);
Type::new_with_resolver_inner(db, &resolver, ty)
@@ -4412,9 +4409,12 @@ impl Impl {
/// blanket impls, and only does a shallow type constructor check. In fact, this should've probably been on `Adt`
/// etc., and not on `Type`. If you would want to create a precise list of all impls applying to a type,
/// you would need to include blanket impls, and try to prove to predicates for each candidate.
- pub fn all_for_type<'db>(db: &'db dyn HirDatabase, Type { ty, env }: Type<'db>) -> Vec<Impl> {
+ pub fn all_for_type<'db>(
+ db: &'db dyn HirDatabase,
+ Type { ty, env: _ }: Type<'db>,
+ ) -> Vec<Impl> {
let mut result = Vec::new();
- let interner = DbInterner::new_with(db, Some(env.krate), env.block);
+ let interner = DbInterner::new_no_crate(db);
let Some(simplified_ty) =
fast_reject::simplify_type(interner, ty, fast_reject::TreatParams::AsRigid)
else {
@@ -4591,7 +4591,7 @@ pub struct Closure<'db> {
impl<'db> Closure<'db> {
fn as_ty(&self, db: &'db dyn HirDatabase) -> Ty<'db> {
- let interner = DbInterner::new_with(db, None, None);
+ let interner = DbInterner::new_no_crate(db);
match self.id {
AnyClosureId::ClosureId(id) => Ty::new_closure(interner, id.into(), self.subst),
AnyClosureId::CoroutineClosureId(id) => {
@@ -4821,7 +4821,7 @@ impl<'db> Type<'db> {
}
fn from_def(db: &'db dyn HirDatabase, def: impl Into<TyDefId> + HasResolver) -> Self {
- let interner = DbInterner::new_with(db, None, None);
+ let interner = DbInterner::new_no_crate(db);
let ty = db.ty(def.into());
let def = match def.into() {
TyDefId::AdtId(it) => GenericDefId::AdtId(it),
@@ -4844,7 +4844,7 @@ impl<'db> Type<'db> {
db: &'db dyn HirDatabase,
def: impl Into<ValueTyDefId> + HasResolver,
) -> Self {
- let interner = DbInterner::new_with(db, None, None);
+ let interner = DbInterner::new_no_crate(db);
let Some(ty) = db.value_ty(def.into()) else {
return Type::new(db, def, Ty::new_error(interner, ErrorGuaranteed));
};
@@ -4900,7 +4900,7 @@ impl<'db> Type<'db> {
}
pub fn contains_reference(&self, db: &'db dyn HirDatabase) -> bool {
- let interner = DbInterner::new_with(db, None, None);
+ let interner = DbInterner::new_no_crate(db);
return self.ty.visit_with(&mut Visitor { interner }).is_break();
fn is_phantom_data(db: &dyn HirDatabase, adt_id: AdtId) -> bool {
@@ -5127,7 +5127,7 @@ impl<'db> Type<'db> {
// FIXME: Find better API that also handles const generics
pub fn impls_trait(&self, db: &'db dyn HirDatabase, trait_: Trait, args: &[Type<'db>]) -> bool {
- let interner = DbInterner::new_with(db, None, None);
+ let interner = DbInterner::new_no_crate(db);
let args = generic_args_from_tys(
interner,
trait_.id.into(),
@@ -5142,7 +5142,7 @@ impl<'db> Type<'db> {
args: &[Type<'db>],
alias: TypeAlias,
) -> Option<Type<'db>> {
- let interner = DbInterner::new_with(db, Some(self.env.krate), self.env.block);
+ let interner = DbInterner::new_with(db, self.env.krate, self.env.block);
let args = generic_args_from_tys(
interner,
alias.id.into(),
@@ -5168,7 +5168,7 @@ impl<'db> Type<'db> {
}
pub fn as_callable(&self, db: &'db dyn HirDatabase) -> Option<Callable<'db>> {
- let interner = DbInterner::new_with(db, None, None);
+ let interner = DbInterner::new_no_crate(db);
let callee = match self.ty.kind() {
TyKind::Closure(id, subst) => Callee::Closure(id.0, subst),
TyKind::CoroutineClosure(id, subst) => Callee::CoroutineClosure(id.0, subst),
@@ -5242,7 +5242,7 @@ impl<'db> Type<'db> {
}
pub fn fields(&self, db: &'db dyn HirDatabase) -> Vec<(Field, Self)> {
- let interner = DbInterner::new_with(db, None, None);
+ let interner = DbInterner::new_no_crate(db);
let (variant_id, substs) = match self.ty.kind() {
TyKind::Adt(adt_def, substs) => {
let id = match adt_def.def_id().0 {
@@ -5299,7 +5299,7 @@ impl<'db> Type<'db> {
}
fn autoderef_(&self, db: &'db dyn HirDatabase) -> impl Iterator<Item = Ty<'db>> {
- let interner = DbInterner::new_with(db, None, None);
+ let interner = DbInterner::new_no_crate(db);
// There should be no inference vars in types passed here
let canonical = hir_ty::replace_errors_with_variables(interner, &self.ty);
autoderef(db, self.env.clone(), canonical)
@@ -5335,7 +5335,7 @@ impl<'db> Type<'db> {
}
};
- let interner = DbInterner::new_with(db, None, None);
+ let interner = DbInterner::new_no_crate(db);
let Some(simplified_type) =
fast_reject::simplify_type(interner, self.ty, fast_reject::TreatParams::AsRigid)
else {
@@ -5484,7 +5484,7 @@ impl<'db> Type<'db> {
f: impl FnOnce(&MethodResolutionContext<'_, 'db>) -> R,
) -> R {
let module = resolver.module();
- let interner = DbInterner::new_with(db, Some(module.krate()), module.containing_block());
+ let interner = DbInterner::new_with(db, module.krate(), module.containing_block());
let infcx = interner.infer_ctxt().build(TypingMode::PostAnalysis);
let unstable_features =
MethodResolutionUnstableFeatures::from_def_map(resolver.top_level_def_map());
@@ -5781,7 +5781,7 @@ impl<'db> Type<'db> {
/// Note that we consider placeholder types to unify with everything.
/// For example `Option<T>` and `Option<U>` unify although there is unresolved goal `T = U`.
pub fn could_unify_with(&self, db: &'db dyn HirDatabase, other: &Type<'db>) -> bool {
- let interner = DbInterner::new_with(db, None, None);
+ let interner = DbInterner::new_no_crate(db);
let tys = hir_ty::replace_errors_with_variables(interner, &(self.ty, other.ty));
hir_ty::could_unify(db, self.env.clone(), &tys)
}
@@ -5791,13 +5791,13 @@ impl<'db> Type<'db> {
/// This means that placeholder types are not considered to unify if there are any bounds set on
/// them. For example `Option<T>` and `Option<U>` do not unify as we cannot show that `T = U`
pub fn could_unify_with_deeply(&self, db: &'db dyn HirDatabase, other: &Type<'db>) -> bool {
- let interner = DbInterner::new_with(db, None, None);
+ let interner = DbInterner::new_no_crate(db);
let tys = hir_ty::replace_errors_with_variables(interner, &(self.ty, other.ty));
hir_ty::could_unify_deeply(db, self.env.clone(), &tys)
}
pub fn could_coerce_to(&self, db: &'db dyn HirDatabase, to: &Type<'db>) -> bool {
- let interner = DbInterner::new_with(db, None, None);
+ let interner = DbInterner::new_no_crate(db);
let tys = hir_ty::replace_errors_with_variables(interner, &(self.ty, to.ty));
hir_ty::could_coerce(db, self.env.clone(), &tys)
}
@@ -5823,7 +5823,7 @@ impl<'db> Type<'db> {
}
pub fn drop_glue(&self, db: &'db dyn HirDatabase) -> DropGlue {
- let interner = DbInterner::new_with(db, Some(self.env.krate), self.env.block);
+ let interner = DbInterner::new_with(db, self.env.krate, self.env.block);
let infcx = interner.infer_ctxt().build(TypingMode::PostAnalysis);
hir_ty::drop::has_drop_glue(&infcx, self.ty, self.env.clone())
}
diff --git a/crates/hir/src/semantics.rs b/crates/hir/src/semantics.rs
index 769cfd90b8..b4f85484fd 100644
--- a/crates/hir/src/semantics.rs
+++ b/crates/hir/src/semantics.rs
@@ -1655,7 +1655,7 @@ impl<'db> SemanticsImpl<'db> {
func: Function,
subst: impl IntoIterator<Item = Type<'db>>,
) -> Option<Function> {
- let interner = DbInterner::new_with(self.db, None, None);
+ let interner = DbInterner::new_no_crate(self.db);
let mut subst = subst.into_iter();
let substs =
hir_ty::next_solver::GenericArgs::for_item(interner, trait_.id.into(), |_, id, _| {
diff --git a/crates/hir/src/source_analyzer.rs b/crates/hir/src/source_analyzer.rs
index 858426ceab..b4389797e6 100644
--- a/crates/hir/src/source_analyzer.rs
+++ b/crates/hir/src/source_analyzer.rs
@@ -267,7 +267,7 @@ impl<'db> SourceAnalyzer<'db> {
db: &'db dyn HirDatabase,
ty: &ast::Type,
) -> Option<Type<'db>> {
- let interner = DbInterner::new_with(db, None, None);
+ let interner = DbInterner::new_no_crate(db);
let type_ref = self.type_id(ty)?;
@@ -410,7 +410,7 @@ impl<'db> SourceAnalyzer<'db> {
) -> Option<Callable<'db>> {
let expr_id = self.expr_id(call.clone().into())?.as_expr()?;
let (func, args) = self.infer()?.method_resolution(expr_id)?;
- let interner = DbInterner::new_with(db, None, None);
+ let interner = DbInterner::new_no_crate(db);
let ty = db.value_ty(func.into())?.instantiate(interner, args);
let ty = Type::new_with_resolver(db, &self.resolver, ty);
let mut res = ty.as_callable(db)?;
@@ -592,7 +592,7 @@ impl<'db> SourceAnalyzer<'db> {
let poll_fn = LangItem::FuturePoll.resolve_function(db, self.resolver.krate())?;
// HACK: subst for `poll()` coincides with that for `Future` because `poll()` itself
// doesn't have any generic parameters, so we skip building another subst for `poll()`.
- let interner = DbInterner::new_with(db, None, None);
+ let interner = DbInterner::new_no_crate(db);
let substs = GenericArgs::new_from_iter(interner, [ty.into()]);
Some(self.resolve_impl_method_or_trait_def(db, poll_fn, substs))
}
@@ -632,7 +632,7 @@ impl<'db> SourceAnalyzer<'db> {
let ty = self.ty_of_expr(prefix_expr.expr()?)?;
- let interner = DbInterner::new_with(db, None, None);
+ let interner = DbInterner::new_no_crate(db);
// HACK: subst for all methods coincides with that for their trait because the methods
// don't have any generic parameters, so we skip building another subst for the methods.
let substs = GenericArgs::new_from_iter(interner, [ty.into()]);
@@ -665,7 +665,7 @@ impl<'db> SourceAnalyzer<'db> {
.unwrap_or(index_fn);
// HACK: subst for all methods coincides with that for their trait because the methods
// don't have any generic parameters, so we skip building another subst for the methods.
- let interner = DbInterner::new_with(db, None, None);
+ let interner = DbInterner::new_no_crate(db);
let substs = GenericArgs::new_from_iter(interner, [base_ty.into(), index_ty.into()]);
Some(self.resolve_impl_method_or_trait_def(db, op_fn, substs))
}
@@ -684,7 +684,7 @@ impl<'db> SourceAnalyzer<'db> {
})?;
// HACK: subst for `index()` coincides with that for `Index` because `index()` itself
// doesn't have any generic parameters, so we skip building another subst for `index()`.
- let interner = DbInterner::new_with(db, None, None);
+ let interner = DbInterner::new_no_crate(db);
let substs = GenericArgs::new_from_iter(interner, [lhs.into(), rhs.into()]);
Some(self.resolve_impl_method_or_trait_def(db, op_fn, substs))
@@ -700,7 +700,7 @@ impl<'db> SourceAnalyzer<'db> {
let op_fn = LangItem::TryTraitBranch.resolve_function(db, self.resolver.krate())?;
// HACK: subst for `branch()` coincides with that for `Try` because `branch()` itself
// doesn't have any generic parameters, so we skip building another subst for `branch()`.
- let interner = DbInterner::new_with(db, None, None);
+ let interner = DbInterner::new_no_crate(db);
let substs = GenericArgs::new_from_iter(interner, [ty.into()]);
Some(self.resolve_impl_method_or_trait_def(db, op_fn, substs))
@@ -714,7 +714,7 @@ impl<'db> SourceAnalyzer<'db> {
let record_expr = ast::RecordExpr::cast(field.syntax().parent().and_then(|p| p.parent())?)?;
let expr = ast::Expr::from(record_expr);
let expr_id = self.store_sm()?.node_expr(InFile::new(self.file_id, &expr))?;
- let interner = DbInterner::new_with(db, None, None);
+ let interner = DbInterner::new_no_crate(db);
let ast_name = field.field_name()?;
let local_name = ast_name.as_name();
@@ -755,7 +755,7 @@ impl<'db> SourceAnalyzer<'db> {
db: &'db dyn HirDatabase,
field: &ast::RecordPatField,
) -> Option<(Field, Type<'db>, GenericSubstitution<'db>)> {
- let interner = DbInterner::new_with(db, None, None);
+ let interner = DbInterner::new_no_crate(db);
let field_name = field.field_name()?.as_name();
let record_pat = ast::RecordPat::cast(field.syntax().parent().and_then(|p| p.parent())?)?;
let pat_id = self.pat_id(&record_pat.into())?;
@@ -817,7 +817,7 @@ impl<'db> SourceAnalyzer<'db> {
let trait_env = container.env;
- let interner = DbInterner::new_with(db, Some(trait_env.krate), trait_env.block);
+ let interner = DbInterner::new_with(db, trait_env.krate, trait_env.block);
let infcx = interner.infer_ctxt().build(TypingMode::PostAnalysis);
let mut container = Either::Right(container.ty);
@@ -1273,7 +1273,7 @@ impl<'db> SourceAnalyzer<'db> {
variant: VariantId,
missing_fields: Vec<LocalFieldId>,
) -> Vec<(Field, Type<'db>)> {
- let interner = DbInterner::new_with(db, None, None);
+ let interner = DbInterner::new_no_crate(db);
let field_types = db.field_types(variant);
missing_fields
@@ -1423,7 +1423,7 @@ impl<'db> SourceAnalyzer<'db> {
None => return (const_id, subs),
};
let env = db.trait_environment_for_body(owner);
- let interner = DbInterner::new_with(db, Some(env.krate), env.block);
+ let interner = DbInterner::new_with(db, env.krate, env.block);
let infcx = interner.infer_ctxt().build(TypingMode::PostAnalysis);
method_resolution::lookup_impl_const(&infcx, env, const_id, subs)
}
diff --git a/crates/hir/src/term_search/tactics.rs b/crates/hir/src/term_search/tactics.rs
index dddc03585a..979ec8c49f 100644
--- a/crates/hir/src/term_search/tactics.rs
+++ b/crates/hir/src/term_search/tactics.rs
@@ -597,7 +597,7 @@ pub(super) fn famous_types<'a, 'lt, 'db, DB: HirDatabase>(
) -> impl Iterator<Item = Expr<'db>> + use<'a, 'db, 'lt, DB> {
let db = ctx.sema.db;
let module = ctx.scope.module();
- let interner = DbInterner::new_with(db, None, None);
+ let interner = DbInterner::new_no_crate(db);
let bool_ty = Ty::new_bool(interner);
let unit_ty = Ty::new_unit(interner);
[
diff --git a/crates/ide-assists/src/handlers/generate_from_impl_for_enum.rs b/crates/ide-assists/src/handlers/generate_from_impl_for_enum.rs
index 6a868239cb..fa87a49933 100644
--- a/crates/ide-assists/src/handlers/generate_from_impl_for_enum.rs
+++ b/crates/ide-assists/src/handlers/generate_from_impl_for_enum.rs
@@ -123,7 +123,7 @@ fn existing_from_impl(
let variant = sema.to_def(variant)?;
let krate = variant.module(db).krate();
let from_trait = FamousDefs(sema, krate).core_convert_From()?;
- let interner = DbInterner::new_with(db, Some(krate.base()), None);
+ let interner = DbInterner::new_with(db, krate.base(), None);
use hir::next_solver::infer::DbInternerInferExt;
let infcx = interner.infer_ctxt().build(TypingMode::non_body_analysis());
diff --git a/crates/ide-assists/src/handlers/generate_single_field_struct_from.rs b/crates/ide-assists/src/handlers/generate_single_field_struct_from.rs
index a1ec763365..9e87ec00dc 100644
--- a/crates/ide-assists/src/handlers/generate_single_field_struct_from.rs
+++ b/crates/ide-assists/src/handlers/generate_single_field_struct_from.rs
@@ -220,7 +220,7 @@ fn from_impl_exists(
let strukt = sema.to_def(strukt)?;
let krate = strukt.krate(db);
let from_trait = FamousDefs(sema, krate).core_convert_From()?;
- let interner = DbInterner::new_with(db, Some(krate.base()), None);
+ let interner = DbInterner::new_with(db, krate.base(), None);
use hir::next_solver::infer::DbInternerInferExt;
let infcx = interner.infer_ctxt().build(TypingMode::non_body_analysis());
diff --git a/crates/rust-analyzer/src/cli/analysis_stats.rs b/crates/rust-analyzer/src/cli/analysis_stats.rs
index 59a4de953c..219fc9eb0b 100644
--- a/crates/rust-analyzer/src/cli/analysis_stats.rs
+++ b/crates/rust-analyzer/src/cli/analysis_stats.rs
@@ -10,8 +10,8 @@ use std::{
use cfg::{CfgAtom, CfgDiff};
use hir::{
- Adt, AssocItem, Crate, DefWithBody, FindPathConfig, HasCrate, HasSource, HirDisplay, ModuleDef,
- Name, crate_lang_items,
+ Adt, AssocItem, Crate, DefWithBody, FindPathConfig, HasSource, HirDisplay, ModuleDef, Name,
+ crate_lang_items,
db::{DefDatabase, ExpandDatabase, HirDatabase},
next_solver::{DbInterner, GenericArgs},
};
@@ -374,7 +374,7 @@ impl flags::AnalysisStats {
let mut all = 0;
let mut fail = 0;
for &a in adts {
- let interner = DbInterner::new_with(db, Some(a.krate(db).base()), None);
+ let interner = DbInterner::new_no_crate(db);
let generic_params = db.generic_params(a.into());
if generic_params.iter_type_or_consts().next().is_some()
|| generic_params.iter_lt().next().is_some()