Normalize type parameters in create_mono_items_for_default_impls.

Fixes http://github.com/rust-lang/rust/issues/58375
This commit is contained in:
Alessandro Decina 2019-07-08 18:13:30 +10:00
parent 83e4eed16e
commit a907b7c519
2 changed files with 29 additions and 1 deletions

View file

@ -1166,8 +1166,13 @@ fn create_mono_items_for_default_impls<'tcx>(
}
});
let param_env = ty::ParamEnv::reveal_all();
let substs = tcx.normalize_erasing_regions(
param_env,
substs,
);
let instance = ty::Instance::resolve(tcx,
ty::ParamEnv::reveal_all(),
param_env,
method.def_id,
substs).unwrap();

View file

@ -0,0 +1,23 @@
// Make sure that the mono-item collector does not crash when trying to
// instantiate a default impl for DecodeUtf16<<u8 as A>::Item>
// See https://github.com/rust-lang/rust/issues/58375
// compile-flags:-C link-dead-code
#![crate_type = "rlib"]
pub struct DecodeUtf16<I>(I);
pub trait Arbitrary {
fn arbitrary() {}
}
pub trait A {
type Item;
}
impl A for u8 {
type Item = char;
}
impl Arbitrary for DecodeUtf16<<u8 as A>::Item> {
}