Skip to content

Commit 3e31ffd

Browse files
committed
Revert change to evaluation order
This change breaks some code and doesn't appear to enable any new code.
1 parent d23e084 commit 3e31ffd

File tree

2 files changed

+42
-3
lines changed

2 files changed

+42
-3
lines changed

compiler/rustc_trait_selection/src/traits/select/confirmation.rs

+3-3
Original file line numberDiff line numberDiff line change
@@ -336,7 +336,7 @@ impl<'cx, 'tcx> SelectionContext<'cx, 'tcx> {
336336
fn vtable_impl(
337337
&mut self,
338338
impl_def_id: DefId,
339-
mut substs: Normalized<'tcx, SubstsRef<'tcx>>,
339+
substs: Normalized<'tcx, SubstsRef<'tcx>>,
340340
cause: ObligationCause<'tcx>,
341341
recursion_depth: usize,
342342
param_env: ty::ParamEnv<'tcx>,
@@ -358,9 +358,9 @@ impl<'cx, 'tcx> SelectionContext<'cx, 'tcx> {
358358
// relying on projections in the impl-trait-ref.
359359
//
360360
// e.g., `impl<U: Tr, V: Iterator<Item=U>> Foo<<U as Tr>::T> for V`
361-
substs.obligations.append(&mut impl_obligations);
361+
impl_obligations.extend(substs.obligations);
362362

363-
ImplSourceUserDefinedData { impl_def_id, substs: substs.value, nested: substs.obligations }
363+
ImplSourceUserDefinedData { impl_def_id, substs: substs.value, nested: impl_obligations }
364364
}
365365

366366
fn confirm_object_candidate(
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,39 @@
1+
// Regression test for #79902
2+
3+
// Check that evaluation (which is used to determine whether to copy a type in
4+
// MIR building) evaluates bounds from normalizing an impl after evaluating
5+
// any bounds on the impl.
6+
7+
// check-pass
8+
9+
trait A {
10+
type B;
11+
}
12+
trait M {}
13+
14+
struct G<T, U>(*const T, *const U);
15+
16+
impl<T, U> Clone for G<T, U> {
17+
fn clone(&self) -> Self {
18+
G { ..*self }
19+
}
20+
}
21+
22+
impl<T, U> Copy for G<T, U::B>
23+
where
24+
T: A<B = U>,
25+
U: A,
26+
{
27+
}
28+
29+
impl A for () {
30+
type B = ();
31+
}
32+
33+
fn is_m<T: M>(_: T) {}
34+
35+
fn main() {
36+
let x = G(&(), &());
37+
drop(x);
38+
drop(x);
39+
}

0 commit comments

Comments
 (0)