From be0084a0bc903544835d5c87df9eb9ce29a191d1 Mon Sep 17 00:00:00 2001 From: Florian Diebold Date: Wed, 7 Apr 2021 20:48:58 +0200 Subject: 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(-) (limited to 'crates') diff --git a/crates/hir/src/lib.rs b/crates/hir/src/lib.rs index 7ac9118fa..0afc06906 100644 --- a/crates/hir/src/lib.rs +++ b/crates/hir/src/lib.rs @@ -1791,7 +1791,7 @@ impl 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 @@ impl 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 6af0c59b8..531159e54 100644 --- a/crates/hir_ty/src/infer.rs +++ b/crates/hir_ty/src/infer.rs @@ -336,7 +336,7 @@ impl<'a> InferenceContext<'a> { 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 f1af2a0bd..fd679f444 100644 --- a/crates/hir_ty/src/infer/coerce.rs +++ b/crates/hir_ty/src/infer/coerce.rs @@ -139,7 +139,7 @@ impl<'a> InferenceContext<'a> { 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 7380b8613..7e09a1539 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 72be7e04f..e1a28f5f7 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 } } } -- cgit v1.2.3