Skip to content

Commit

Permalink
Normalize type parameters in create_mono_items_for_default_impls.
Browse files Browse the repository at this point in the history
  • Loading branch information
alessandrod committed Jul 15, 2019
1 parent 83e4eed commit a907b7c
Show file tree
Hide file tree
Showing 2 changed files with 29 additions and 1 deletion.
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,
);
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> {
}

0 comments on commit a907b7c

Please sign in to comment.