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();
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))

View File

@ -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());

View File

@ -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);

View File

@ -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),
}
}

View File

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