Skip to content

Commit cebeda3

Browse files
matthewjasperMark-Simulacrum
authored andcommitted
Revert change to evaluation order
This change breaks some code and doesn't appear to enable any new code.
1 parent b0dc3c6 commit cebeda3

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

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -335,7 +335,7 @@ impl<'cx, 'tcx> SelectionContext<'cx, 'tcx> {
335335
fn vtable_impl(
336336
&mut self,
337337
impl_def_id: DefId,
338-
mut substs: Normalized<'tcx, SubstsRef<'tcx>>,
338+
substs: Normalized<'tcx, SubstsRef<'tcx>>,
339339
cause: ObligationCause<'tcx>,
340340
recursion_depth: usize,
341341
param_env: ty::ParamEnv<'tcx>,
@@ -357,9 +357,9 @@ impl<'cx, 'tcx> SelectionContext<'cx, 'tcx> {
357357
// relying on projections in the impl-trait-ref.
358358
//
359359
// e.g., `impl<U: Tr, V: Iterator<Item=U>> Foo<<U as Tr>::T> for V`
360-
substs.obligations.append(&mut impl_obligations);
360+
impl_obligations.extend(substs.obligations);
361361

362-
ImplSourceUserDefinedData { impl_def_id, substs: substs.value, nested: substs.obligations }
362+
ImplSourceUserDefinedData { impl_def_id, substs: substs.value, nested: impl_obligations }
363363
}
364364

365365
fn confirm_object_candidate(
Lines changed: 39 additions & 0 deletions
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)