diff options
| author | Alessandro Decina <alessandro.d@gmail.com> | 2019-07-08 18:13:30 +1000 |
|---|---|---|
| committer | Alessandro Decina <alessandro.d@gmail.com> | 2019-07-15 10:28:17 +1000 |
| commit | a907b7c51929eccd5af8774c60ac412772f2cacd (patch) | |
| tree | b2b64a499a9f7b3508fcb1edab05f500bee4c091 | |
| parent | 83e4eed16ef7adb54a802e3b684427e0e912c2b7 (diff) | |
| download | rust-a907b7c51929eccd5af8774c60ac412772f2cacd.tar.gz rust-a907b7c51929eccd5af8774c60ac412772f2cacd.zip | |
Normalize type parameters in create_mono_items_for_default_impls.
Fixes http://github.com/rust-lang/rust/issues/58375
| -rw-r--r-- | src/librustc_mir/monomorphize/collector.rs | 7 | ||||
| -rw-r--r-- | src/test/run-pass/issue-58375-monomorphize-default-impls.rs | 23 |
2 files changed, 29 insertions, 1 deletions
diff --git a/src/librustc_mir/monomorphize/collector.rs b/src/librustc_mir/monomorphize/collector.rs index 6e9390f7750..acf438dc66b 100644 --- a/src/librustc_mir/monomorphize/collector.rs +++ b/src/librustc_mir/monomorphize/collector.rs @@ -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(); diff --git a/src/test/run-pass/issue-58375-monomorphize-default-impls.rs b/src/test/run-pass/issue-58375-monomorphize-default-impls.rs new file mode 100644 index 00000000000..e4ae72927a4 --- /dev/null +++ b/src/test/run-pass/issue-58375-monomorphize-default-impls.rs @@ -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> { +} \ No newline at end of file |
