Skip to content

Commit 1b6b06a

Browse files
committed
Auto merge of #80132 - matthewjasper:revert-eval-order, r=nikomatsakis
Revert change to trait evaluation order This change breaks some code and doesn't appear to enable any new code. closes #79902 r? `@nikomatsakis`
2 parents bd2f1cb + 3e31ffd commit 1b6b06a

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
@@ -334,7 +334,7 @@ impl<'cx, 'tcx> SelectionContext<'cx, 'tcx> {
334334
fn vtable_impl(
335335
&mut self,
336336
impl_def_id: DefId,
337-
mut substs: Normalized<'tcx, SubstsRef<'tcx>>,
337+
substs: Normalized<'tcx, SubstsRef<'tcx>>,
338338
cause: ObligationCause<'tcx>,
339339
recursion_depth: usize,
340340
param_env: ty::ParamEnv<'tcx>,
@@ -356,9 +356,9 @@ impl<'cx, 'tcx> SelectionContext<'cx, 'tcx> {
356356
// relying on projections in the impl-trait-ref.
357357
//
358358
// e.g., `impl<U: Tr, V: Iterator<Item=U>> Foo<<U as Tr>::T> for V`
359-
substs.obligations.append(&mut impl_obligations);
359+
impl_obligations.extend(substs.obligations);
360360

361-
ImplSourceUserDefinedData { impl_def_id, substs: substs.value, nested: substs.obligations }
361+
ImplSourceUserDefinedData { impl_def_id, substs: substs.value, nested: impl_obligations }
362362
}
363363

364364
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)