Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Normalize type parameters in create_mono_items_for_default_impls. #62682

Merged
merged 3 commits into from
Jul 18, 2019
Merged
Show file tree
Hide file tree
Changes from 2 commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
7 changes: 6 additions & 1 deletion src/librustc_mir/monomorphize/collector.rs
Original file line number Diff line number Diff line change
Expand Up @@ -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,
);
alessandrod marked this conversation as resolved.
Show resolved Hide resolved
let instance = ty::Instance::resolve(tcx,
ty::ParamEnv::reveal_all(),
param_env,
method.def_id,
substs).unwrap();

Expand Down
23 changes: 23 additions & 0 deletions src/test/run-pass/issue-58375-monomorphize-default-impls.rs
Original file line number Diff line number Diff line change
@@ -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> {
}