diff options
| author | Matthias Krüger <matthias.krueger@famsik.de> | 2022-12-09 07:25:47 +0100 |
|---|---|---|
| committer | GitHub <noreply@github.com> | 2022-12-09 07:25:47 +0100 |
| commit | 04dac4285aefc2fb18ad07b1e40f6771e0763aea (patch) | |
| tree | 796b1b354041013db7a9123f620a3f115f5882b3 /src | |
| parent | 6111a7345be5f50b7170aa6ec69a5d823878cb27 (diff) | |
| parent | e73ef59cb6d806d9f5405237383d65bf02095127 (diff) | |
Rollup merge of #105455 - lcnr:correct-reveal-in-validate, r=jackh726
use the correct `Reveal` during validation supersedes #105454. Deals with https://github.com/rust-lang/rust/issues/105009#issuecomment-1342395333, not closing #105009 as the ICE may leak into beta The issue was the following: - we optimize the mir, using `Reveal::All` - some optimization relies on the hidden type of an opaque type - we then validate using `Reveal::UserFacing` again which is not able to observe the hidden type r? `@jackh726`
Diffstat (limited to 'src')
| -rw-r--r-- | src/test/ui/mir/validate/issue-95978-validator-lifetime-comparison.rs (renamed from src/test/ui/mir/issue-95978-validator-lifetime-comparison.rs) | 0 | ||||
| -rw-r--r-- | src/test/ui/mir/validate/needs-reveal-all.rs | 52 |
2 files changed, 52 insertions, 0 deletions
diff --git a/src/test/ui/mir/issue-95978-validator-lifetime-comparison.rs b/src/test/ui/mir/validate/issue-95978-validator-lifetime-comparison.rs index cd6c5bf2719..cd6c5bf2719 100644 --- a/src/test/ui/mir/issue-95978-validator-lifetime-comparison.rs +++ b/src/test/ui/mir/validate/issue-95978-validator-lifetime-comparison.rs diff --git a/src/test/ui/mir/validate/needs-reveal-all.rs b/src/test/ui/mir/validate/needs-reveal-all.rs new file mode 100644 index 00000000000..3852daf245e --- /dev/null +++ b/src/test/ui/mir/validate/needs-reveal-all.rs @@ -0,0 +1,52 @@ +// Regression test for #105009. the issue here was that even after the `RevealAll` pass, +// `validate` still used `Reveal::UserFacing`. This meant that it now ends up comparing +// opaque types with their revealed version, resulting in an ICE. +// +// We're using these flags to run the `RevealAll` pass while making it less likely to +// accidentally removing the assignment from `Foo<fn_ptr>` to `Foo<fn_def>`. + +// compile-flags: -Zinline_mir=yes -Zmir-opt-level=0 -Zvalidate-mir +// run-pass + +use std::hint::black_box; + +trait Func { + type Ret: Id; +} + +trait Id { + type Assoc; +} +impl Id for u32 { + type Assoc = u32; +} +impl Id for i32 { + type Assoc = i32; +} + +impl<F: FnOnce() -> R, R: Id> Func for F { + type Ret = R; +} + +fn bar() -> impl Copy + Id { + 0u32 +} + +struct Foo<T: Func> { + _func: T, + value: Option<<<T as Func>::Ret as Id>::Assoc>, +} + +fn main() { + let mut fn_def = black_box(Foo { + _func: bar, + value: None, + }); + let fn_ptr = black_box(Foo { + _func: bar as fn() -> _, + value: None, + }); + + fn_def.value = fn_ptr.value; + black_box(fn_def); +} |
