Skip to content

Commit a907b7c

Browse files
committed
Normalize type parameters in create_mono_items_for_default_impls.
Fixes http://github.com/rust-lang/rust/issues/58375
1 parent 83e4eed commit a907b7c

File tree

2 files changed

+29
-1
lines changed

2 files changed

+29
-1
lines changed

src/librustc_mir/monomorphize/collector.rs

+6-1
Original file line numberDiff line numberDiff line change
@@ -1166,8 +1166,13 @@ fn create_mono_items_for_default_impls<'tcx>(
11661166
}
11671167
});
11681168

1169+
let param_env = ty::ParamEnv::reveal_all();
1170+
let substs = tcx.normalize_erasing_regions(
1171+
param_env,
1172+
substs,
1173+
);
11691174
let instance = ty::Instance::resolve(tcx,
1170-
ty::ParamEnv::reveal_all(),
1175+
param_env,
11711176
method.def_id,
11721177
substs).unwrap();
11731178

Original file line numberDiff line numberDiff line change
@@ -0,0 +1,23 @@
1+
// Make sure that the mono-item collector does not crash when trying to
2+
// instantiate a default impl for DecodeUtf16<<u8 as A>::Item>
3+
// See https://github.com/rust-lang/rust/issues/58375
4+
// compile-flags:-C link-dead-code
5+
6+
#![crate_type = "rlib"]
7+
8+
pub struct DecodeUtf16<I>(I);
9+
10+
pub trait Arbitrary {
11+
fn arbitrary() {}
12+
}
13+
14+
pub trait A {
15+
type Item;
16+
}
17+
18+
impl A for u8 {
19+
type Item = char;
20+
}
21+
22+
impl Arbitrary for DecodeUtf16<<u8 as A>::Item> {
23+
}

0 commit comments

Comments
 (0)