Unnamed repository; edit this file 'description' to name the repository.
Diffstat (limited to 'crates/hir-ty/src/infer.rs')
-rw-r--r--crates/hir-ty/src/infer.rs14
1 files changed, 11 insertions, 3 deletions
diff --git a/crates/hir-ty/src/infer.rs b/crates/hir-ty/src/infer.rs
index b399a7e0ed..0b16da722e 100644
--- a/crates/hir-ty/src/infer.rs
+++ b/crates/hir-ty/src/infer.rs
@@ -61,7 +61,7 @@ use rustc_ast_ir::Mutability;
use rustc_hash::{FxHashMap, FxHashSet};
use rustc_type_ir::{
AliasTyKind, TypeFoldable, TypeVisitableExt,
- inherent::{IntoKind, Ty as _},
+ inherent::{GenericArgs as _, IntoKind, Ty as _},
};
use smallvec::SmallVec;
use span::Edition;
@@ -1189,6 +1189,7 @@ pub(crate) struct InferenceContext<'body, 'db> {
pub(crate) edition: Edition,
allow_using_generic_params: bool,
generics: OnceCell<Generics<'db>>,
+ identity_args: OnceCell<GenericArgs<'db>>,
pub(crate) table: unify::InferenceTable<'db>,
pub(crate) lang_items: &'db LangItems,
pub(crate) features: &'db UnstableFeatures,
@@ -1302,6 +1303,7 @@ impl<'body, 'db> InferenceContext<'body, 'db> {
generic_def,
allow_using_generic_params,
generics: OnceCell::new(),
+ identity_args: OnceCell::new(),
store,
traits_in_scope: resolver.traits_in_scope(db),
resolver,
@@ -1840,6 +1842,7 @@ impl<'body, 'db> InferenceContext<'body, 'db> {
types_source,
store_owner,
self.generic_def,
+ &self.generics,
lifetime_elision,
self.allow_using_generic_params,
&self.defined_anon_consts,
@@ -1905,8 +1908,12 @@ impl<'body, 'db> InferenceContext<'body, 'db> {
}
fn generics(&self) -> &Generics<'db> {
- self.generics.get_or_init(|| {
- crate::generics::generics(self.db, self.store_owner.generic_def(self.db))
+ self.generics.get_or_init(|| crate::generics::generics(self.db, self.generic_def))
+ }
+
+ fn identity_args(&self) -> GenericArgs<'db> {
+ *self.identity_args.get_or_init(|| {
+ GenericArgs::identity_for_item(self.interner(), self.store_owner.into())
})
}
@@ -2182,6 +2189,7 @@ impl<'body, 'db> InferenceContext<'body, 'db> {
InferenceTyDiagnosticSource::Body,
self.store_owner,
self.generic_def,
+ &self.generics,
LifetimeElisionKind::Infer,
self.allow_using_generic_params,
&self.defined_anon_consts,