Skip to content

Commit 32dae91

Browse files
Remap RPITIT substs properly
1 parent a2037e3 commit 32dae91

File tree

2 files changed

+31
-0
lines changed

2 files changed

+31
-0
lines changed

compiler/rustc_trait_selection/src/traits/project.rs

+7
Original file line numberDiff line numberDiff line change
@@ -2260,6 +2260,13 @@ fn confirm_impl_trait_in_trait_candidate<'tcx>(
22602260
// since `data.substs` are the impl substs.
22612261
let impl_fn_substs =
22622262
obligation.predicate.substs.rebase_onto(tcx, tcx.parent(trait_fn_def_id), data.substs);
2263+
let impl_fn_substs = translate_substs(
2264+
selcx.infcx(),
2265+
obligation.param_env,
2266+
data.impl_def_id,
2267+
impl_fn_substs,
2268+
leaf_def.defining_node,
2269+
);
22632270

22642271
if !check_substs_compatible(tcx, &leaf_def.item, impl_fn_substs) {
22652272
let err = tcx.ty_error_with_message(
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,24 @@
1+
// check-pass
2+
3+
#![feature(specialization)]
4+
#![feature(return_position_impl_trait_in_trait)]
5+
#![allow(incomplete_features)]
6+
7+
trait Foo {
8+
fn bar(&self) -> impl Sized;
9+
}
10+
11+
impl<U> Foo for U
12+
where
13+
U: Copy,
14+
{
15+
fn bar(&self) -> U {
16+
*self
17+
}
18+
}
19+
20+
impl Foo for i32 {}
21+
22+
fn main() {
23+
let _: i32 = 1i32.bar();
24+
}

0 commit comments

Comments
 (0)