From be0084a0bc903544835d5c87df9eb9ce29a191d1 Mon Sep 17 00:00:00 2001 From: Florian Diebold Date: Wed, 7 Apr 2021 20:48:58 +0200 Subject: [PATCH] InEnvironment::new takes a reference --- crates/hir/src/lib.rs | 4 ++-- crates/hir_ty/src/infer.rs | 2 +- crates/hir_ty/src/infer/coerce.rs | 2 +- crates/hir_ty/src/method_resolution.rs | 2 +- crates/hir_ty/src/types.rs | 4 ++-- 5 files changed, 7 insertions(+), 7 deletions(-) diff --git a/crates/hir/src/lib.rs b/crates/hir/src/lib.rs index 7ac9118faf3..0afc069061b 100644 --- a/crates/hir/src/lib.rs +++ b/crates/hir/src/lib.rs @@ -1791,7 +1791,7 @@ pub fn impls_trait(&self, db: &dyn HirDatabase, trait_: Trait, args: &[Type]) -> .build(); let goal = Canonical { - value: hir_ty::InEnvironment::new(self.env.env.clone(), trait_ref.cast(&Interner)), + value: hir_ty::InEnvironment::new(&self.env.env, trait_ref.cast(&Interner)), binders: CanonicalVarKinds::empty(&Interner), }; @@ -1810,7 +1810,7 @@ pub fn normalize_trait_assoc_type( .build(); let goal = hir_ty::make_canonical( InEnvironment::new( - self.env.env.clone(), + &self.env.env, AliasEq { alias: AliasTy::Projection(projection), ty: TyKind::BoundVar(BoundVar::new(DebruijnIndex::INNERMOST, 0)) diff --git a/crates/hir_ty/src/infer.rs b/crates/hir_ty/src/infer.rs index 6af0c59b8d1..531159e5427 100644 --- a/crates/hir_ty/src/infer.rs +++ b/crates/hir_ty/src/infer.rs @@ -336,7 +336,7 @@ fn resolve_obligations_as_possible(&mut self) { self.last_obligations_check = Some(self.table.revision); let obligations = mem::replace(&mut self.obligations, Vec::new()); for obligation in obligations { - let in_env = InEnvironment::new(self.trait_env.env.clone(), obligation.clone()); + let in_env = InEnvironment::new(&self.trait_env.env, obligation.clone()); let canonicalized = self.canonicalizer().canonicalize_obligation(in_env); let solution = self.db.trait_solve(self.resolver.krate().unwrap(), canonicalized.value.clone()); diff --git a/crates/hir_ty/src/infer/coerce.rs b/crates/hir_ty/src/infer/coerce.rs index f1af2a0bdcb..fd679f44464 100644 --- a/crates/hir_ty/src/infer/coerce.rs +++ b/crates/hir_ty/src/infer/coerce.rs @@ -139,7 +139,7 @@ fn try_coerce_unsized(&mut self, from_ty: &Ty, to_ty: &Ty) -> Option { b.push(from_ty.clone()).push(to_ty.clone()).build() }; - let goal = InEnvironment::new(self.trait_env.env.clone(), trait_ref.cast(&Interner)); + let goal = InEnvironment::new(&self.trait_env.env, trait_ref.cast(&Interner)); let canonicalizer = self.canonicalizer(); let canonicalized = canonicalizer.canonicalize_obligation(goal); diff --git a/crates/hir_ty/src/method_resolution.rs b/crates/hir_ty/src/method_resolution.rs index 7380b8613a4..7e09a1539d4 100644 --- a/crates/hir_ty/src/method_resolution.rs +++ b/crates/hir_ty/src/method_resolution.rs @@ -845,7 +845,7 @@ fn generic_implements_goal( let obligation = trait_ref.cast(&Interner); Canonical { binders: CanonicalVarKinds::from_iter(&Interner, kinds), - value: InEnvironment::new(env.env.clone(), obligation), + value: InEnvironment::new(&env.env, obligation), } } diff --git a/crates/hir_ty/src/types.rs b/crates/hir_ty/src/types.rs index 72be7e04f46..e1a28f5f7e0 100644 --- a/crates/hir_ty/src/types.rs +++ b/crates/hir_ty/src/types.rs @@ -470,8 +470,8 @@ pub struct InEnvironment { } impl InEnvironment { - pub fn new(environment: chalk_ir::Environment, value: T) -> InEnvironment { - InEnvironment { environment, goal: value } + pub fn new(environment: &chalk_ir::Environment, value: T) -> InEnvironment { + InEnvironment { environment: environment.clone(), goal: value } } }