forked from rust-lang/rust
-
Notifications
You must be signed in to change notification settings - Fork 1
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Rollup merge of rust-lang#94093 - tmiasko:pp-no-variants, r=oli-obk
Fix pretty printing of enums without variants 92d20c4 removed no-variants special case from `try_destructure_const` with expectation that this case would be handled gracefully when `read_discriminant` returns an error. Alas in that case `read_discriminant` succeeds while returning a non-existing variant, so the special case is still necessary. Fixes rust-lang#94073. r? ``@oli-obk``
- Loading branch information
Showing
3 changed files
with
75 additions
and
65 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,23 +1,34 @@ | ||
// Verify that we can pretty print invalid constant introduced | ||
// by constant propagation. Regression test for issue #93688. | ||
// | ||
// compile-flags: -Copt-level=0 -Zinline-mir | ||
// Verify that we can pretty print invalid constants. | ||
|
||
#![feature(inline_const)] | ||
#[inline(always)] | ||
pub fn f(x: Option<Option<()>>) -> Option<()> { | ||
match x { | ||
None => None, | ||
Some(y) => y, | ||
} | ||
} | ||
|
||
#[derive(Copy, Clone)] | ||
#[repr(u32)] | ||
enum E { A, B, C } | ||
|
||
#[derive(Copy, Clone)] | ||
enum Empty {} | ||
|
||
// EMIT_MIR invalid_constant.main.ConstProp.diff | ||
fn main() { | ||
f(None); | ||
|
||
union Union { | ||
// An invalid char. | ||
union InvalidChar { | ||
int: u32, | ||
chr: char, | ||
} | ||
let _invalid_char = const { Union { int: 0x110001 } }; | ||
let _invalid_char = const { InvalidChar { int: 0x110001 } }; | ||
|
||
// An enum with an invalid tag. Regression test for #93688. | ||
union InvalidTag { | ||
int: u32, | ||
e: E, | ||
} | ||
let _invalid_tag = [InvalidTag { int: 4 }]; | ||
|
||
// An enum without variants. Regression test for #94073. | ||
union NoVariants { | ||
int: u32, | ||
empty: Empty, | ||
} | ||
let _enum_without_variants = [NoVariants { int: 0 }]; | ||
} |