Rollup merge of #136176 - oli-obk:pattern-type-mir-opts, r=compiler-errors
Render pattern types nicely in mir dumps avoid falling through to the fallback rendering that just does a hex dump r? ``@scottmcm`` best reviewed commit by commit
This commit is contained in:
commit
f49ad60fee
3 changed files with 31 additions and 0 deletions
|
@ -1740,6 +1740,10 @@ pub trait PrettyPrinter<'tcx>: Printer<'tcx> + fmt::Write {
|
||||||
" as ",
|
" as ",
|
||||||
)?;
|
)?;
|
||||||
}
|
}
|
||||||
|
ty::Pat(base_ty, pat) => {
|
||||||
|
self.pretty_print_const_scalar_int(int, *base_ty, print_ty)?;
|
||||||
|
p!(write(" is {pat:?}"));
|
||||||
|
}
|
||||||
// Nontrivial types with scalar bit representation
|
// Nontrivial types with scalar bit representation
|
||||||
_ => {
|
_ => {
|
||||||
let print = |this: &mut Self| {
|
let print = |this: &mut Self| {
|
||||||
|
|
15
tests/mir-opt/pattern_types.main.PreCodegen.after.mir
Normal file
15
tests/mir-opt/pattern_types.main.PreCodegen.after.mir
Normal file
|
@ -0,0 +1,15 @@
|
||||||
|
// MIR for `main` after PreCodegen
|
||||||
|
|
||||||
|
fn main() -> () {
|
||||||
|
let mut _0: ();
|
||||||
|
scope 1 {
|
||||||
|
debug x => const 2_u32 is 1..=;
|
||||||
|
scope 2 {
|
||||||
|
debug y => const 0_u32 is 1..=;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
bb0: {
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
}
|
12
tests/mir-opt/pattern_types.rs
Normal file
12
tests/mir-opt/pattern_types.rs
Normal file
|
@ -0,0 +1,12 @@
|
||||||
|
#![feature(pattern_types)]
|
||||||
|
#![feature(pattern_type_macro)]
|
||||||
|
|
||||||
|
use std::pat::pattern_type;
|
||||||
|
|
||||||
|
// EMIT_MIR pattern_types.main.PreCodegen.after.mir
|
||||||
|
fn main() {
|
||||||
|
// CHECK: debug x => const 2_u32 is 1..=
|
||||||
|
let x: pattern_type!(u32 is 1..) = unsafe { std::mem::transmute(2) };
|
||||||
|
// CHECK: debug y => const 0_u32 is 1..=
|
||||||
|
let y: pattern_type!(u32 is 1..) = unsafe { std::mem::transmute(0) };
|
||||||
|
}
|
Loading…
Add table
Add a link
Reference in a new issue