InEnvironment::new takes a reference

This commit is contained in:
Florian Diebold 2021-04-07 20:48:58 +02:00
parent d1b645d236
commit be0084a0bc
5 changed files with 7 additions and 7 deletions

View file

@ -1791,7 +1791,7 @@ impl Type {
.build(); .build();
let goal = Canonical { 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), binders: CanonicalVarKinds::empty(&Interner),
}; };
@ -1810,7 +1810,7 @@ impl Type {
.build(); .build();
let goal = hir_ty::make_canonical( let goal = hir_ty::make_canonical(
InEnvironment::new( InEnvironment::new(
self.env.env.clone(), &self.env.env,
AliasEq { AliasEq {
alias: AliasTy::Projection(projection), alias: AliasTy::Projection(projection),
ty: TyKind::BoundVar(BoundVar::new(DebruijnIndex::INNERMOST, 0)) ty: TyKind::BoundVar(BoundVar::new(DebruijnIndex::INNERMOST, 0))

View file

@ -336,7 +336,7 @@ impl<'a> InferenceContext<'a> {
self.last_obligations_check = Some(self.table.revision); self.last_obligations_check = Some(self.table.revision);
let obligations = mem::replace(&mut self.obligations, Vec::new()); let obligations = mem::replace(&mut self.obligations, Vec::new());
for obligation in obligations { 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 canonicalized = self.canonicalizer().canonicalize_obligation(in_env);
let solution = let solution =
self.db.trait_solve(self.resolver.krate().unwrap(), canonicalized.value.clone()); self.db.trait_solve(self.resolver.krate().unwrap(), canonicalized.value.clone());

View file

@ -139,7 +139,7 @@ impl<'a> InferenceContext<'a> {
b.push(from_ty.clone()).push(to_ty.clone()).build() 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 canonicalizer = self.canonicalizer();
let canonicalized = canonicalizer.canonicalize_obligation(goal); let canonicalized = canonicalizer.canonicalize_obligation(goal);

View file

@ -845,7 +845,7 @@ fn generic_implements_goal(
let obligation = trait_ref.cast(&Interner); let obligation = trait_ref.cast(&Interner);
Canonical { Canonical {
binders: CanonicalVarKinds::from_iter(&Interner, kinds), binders: CanonicalVarKinds::from_iter(&Interner, kinds),
value: InEnvironment::new(env.env.clone(), obligation), value: InEnvironment::new(&env.env, obligation),
} }
} }

View file

@ -470,8 +470,8 @@ pub struct InEnvironment<T> {
} }
impl<T> InEnvironment<T> { impl<T> InEnvironment<T> {
pub fn new(environment: chalk_ir::Environment<Interner>, value: T) -> InEnvironment<T> { pub fn new(environment: &chalk_ir::Environment<Interner>, value: T) -> InEnvironment<T> {
InEnvironment { environment, goal: value } InEnvironment { environment: environment.clone(), goal: value }
} }
} }