mirror of
https://github.com/rust-lang/rust.git
synced 2024-11-25 16:24:46 +00:00
rustfmt tests/mir-opt
.
The only non-obvious changes: - `building/storage_live_dead_in_statics.rs` has a `#[rustfmt::skip]` attribute to avoid reformating a table of data. - Two `.mir` files have slight changes involving line numbers. - In `unusual_item_types.rs` an `EMIT_MIR` annotation is moved to outside a function, which is the usual spot, because `tidy` complains if such a comment is indented. The commit also tweaks the comments in `rustfmt.toml`.
This commit is contained in:
parent
ac24299636
commit
c9c80d2c5f
14
rustfmt.toml
14
rustfmt.toml
@ -10,17 +10,13 @@ ignore = [
|
||||
"/build-*/",
|
||||
"/vendor/",
|
||||
|
||||
# Some tests are not formatted, for multiple reasons:
|
||||
# - some contain syntax errors that cause rustfmt to give an error
|
||||
# - some UI tests are broken by different formatting
|
||||
# - some require special comments in a particular position (e.g. `EMIT_MIR` comments)
|
||||
# Some tests are not formatted, for various reasons.
|
||||
"/tests/codegen/simd-intrinsic/", # Many types like `u8x64` are better hand-formatted.
|
||||
"/tests/crashes/", # Many tests contain syntax errors.
|
||||
"/tests/debuginfo/", # Tests are somewhat sensitive to source code layout.
|
||||
"/tests/incremental/", # Tests are somewhat sensitive to source code layout.
|
||||
"/tests/mir-opt/",
|
||||
"/tests/crashes/", # Many of these tests contain syntax errors.
|
||||
"/tests/debuginfo/", # These tests are somewhat sensitive to source code layout.
|
||||
"/tests/incremental/", # These tests are somewhat sensitive to source code layout.
|
||||
"/tests/pretty/",
|
||||
"/tests/run-make/translation/test.rs", # Contains syntax errors.
|
||||
"/tests/run-make/translation/test.rs", # This test contains syntax errors.
|
||||
"/tests/run-make-fulldeps/",
|
||||
"/tests/run-pass-valgrind/",
|
||||
"/tests/rustdoc/",
|
||||
|
@ -9,7 +9,6 @@ unsafe fn foo(z: *mut usize) -> u32 {
|
||||
99
|
||||
}
|
||||
|
||||
|
||||
// EMIT_MIR array_index_is_temporary.main.SimplifyCfg-pre-optimizations.after.mir
|
||||
fn main() {
|
||||
// CHECK-LABEL: fn main(
|
||||
|
@ -27,7 +27,9 @@ fn numbered(i: (u32, i32)) {
|
||||
}
|
||||
}
|
||||
|
||||
struct S { x: f32 }
|
||||
struct S {
|
||||
x: f32,
|
||||
}
|
||||
|
||||
// EMIT_MIR debuginfo.structured.built.after.mir
|
||||
#[custom_mir(dialect = "analysis", phase = "post-cleanup")]
|
||||
|
@ -5,21 +5,24 @@
|
||||
// EMIT_MIR enum_cast.far.built.after.mir
|
||||
|
||||
enum Foo {
|
||||
A
|
||||
A,
|
||||
}
|
||||
|
||||
enum Bar {
|
||||
A, B
|
||||
A,
|
||||
B,
|
||||
}
|
||||
|
||||
#[repr(u8)]
|
||||
enum Boo {
|
||||
A, B
|
||||
A,
|
||||
B,
|
||||
}
|
||||
|
||||
#[repr(i16)]
|
||||
enum Far {
|
||||
A, B
|
||||
A,
|
||||
B,
|
||||
}
|
||||
|
||||
fn foo(foo: Foo) -> usize {
|
||||
@ -40,7 +43,9 @@ fn far(far: Far) -> isize {
|
||||
|
||||
// EMIT_MIR enum_cast.droppy.built.after.mir
|
||||
enum Droppy {
|
||||
A, B, C
|
||||
A,
|
||||
B,
|
||||
C,
|
||||
}
|
||||
|
||||
impl Drop for Droppy {
|
||||
@ -82,12 +87,15 @@ fn unsigny(x: UnsignedAroundZero) -> u16 {
|
||||
x as u16
|
||||
}
|
||||
|
||||
enum NotStartingAtZero { A = 4, B = 6, C = 8 }
|
||||
enum NotStartingAtZero {
|
||||
A = 4,
|
||||
B = 6,
|
||||
C = 8,
|
||||
}
|
||||
|
||||
// EMIT_MIR enum_cast.offsetty.built.after.mir
|
||||
fn offsetty(x: NotStartingAtZero) -> u32 {
|
||||
x as u32
|
||||
}
|
||||
|
||||
fn main() {
|
||||
}
|
||||
fn main() {}
|
||||
|
@ -30,9 +30,13 @@ fn test_or() {
|
||||
|
||||
// EMIT_MIR logical_or_in_conditional.test_complex.built.after.mir
|
||||
fn test_complex() {
|
||||
if let E::A(_) = E::f() && ((always_true() && Droppy(0).0 > 0) || Droppy(1).0 > 1) {}
|
||||
if let E::A(_) = E::f()
|
||||
&& ((always_true() && Droppy(0).0 > 0) || Droppy(1).0 > 1)
|
||||
{}
|
||||
|
||||
if !always_true() && let E::B = E::f() {}
|
||||
if !always_true()
|
||||
&& let E::B = E::f()
|
||||
{}
|
||||
}
|
||||
|
||||
fn main() {
|
||||
|
@ -1,7 +1,6 @@
|
||||
// skip-filecheck
|
||||
// Test that we don't generate unnecessarily large MIR for very simple matches
|
||||
|
||||
|
||||
// EMIT_MIR simple_match.match_bool.built.after.mir
|
||||
fn match_bool(x: bool) -> usize {
|
||||
match x {
|
||||
|
@ -3,19 +3,12 @@
|
||||
|
||||
// EMIT_MIR shifts.shift_signed.built.after.mir
|
||||
fn shift_signed(small: i8, big: u128, a: i8, b: i32, c: i128) -> ([i8; 3], [u128; 3]) {
|
||||
(
|
||||
[small >> a, small >> b, small >> c],
|
||||
[big << a, big << b, big << c],
|
||||
)
|
||||
([small >> a, small >> b, small >> c], [big << a, big << b, big << c])
|
||||
}
|
||||
|
||||
// EMIT_MIR shifts.shift_unsigned.built.after.mir
|
||||
fn shift_unsigned(small: u8, big: i128, a: u8, b: u32, c: u128) -> ([u8; 3], [i128; 3]) {
|
||||
(
|
||||
[small >> a, small >> b, small >> c],
|
||||
[big << a, big << b, big << c],
|
||||
)
|
||||
([small >> a, small >> b, small >> c], [big << a, big << b, big << c])
|
||||
}
|
||||
|
||||
fn main() {
|
||||
}
|
||||
fn main() {}
|
||||
|
@ -3,6 +3,7 @@
|
||||
// generate `StorageStart` or `StorageEnd` statements.
|
||||
|
||||
// EMIT_MIR storage_live_dead_in_statics.XXX.built.after.mir
|
||||
#[rustfmt::skip]
|
||||
static XXX: &'static Foo = &Foo {
|
||||
tup: "hi",
|
||||
data: &[
|
||||
@ -20,13 +21,13 @@ static XXX: &'static Foo = &Foo {
|
||||
(0, 1), (0, 2), (0, 3),
|
||||
(0, 1), (0, 2), (0, 3),
|
||||
(0, 1), (0, 2), (0, 3),
|
||||
]
|
||||
],
|
||||
};
|
||||
|
||||
#[derive(Debug)]
|
||||
struct Foo {
|
||||
tup: &'static str,
|
||||
data: &'static [(u32, u32)]
|
||||
data: &'static [(u32, u32)],
|
||||
}
|
||||
|
||||
fn main() {
|
||||
|
@ -8,7 +8,11 @@
|
||||
|
||||
#[derive(Copy, Clone)]
|
||||
#[repr(u32)]
|
||||
enum E { A, B, C }
|
||||
enum E {
|
||||
A,
|
||||
B,
|
||||
C,
|
||||
}
|
||||
|
||||
#[derive(Copy, Clone)]
|
||||
enum Empty {}
|
||||
@ -39,7 +43,5 @@ fn main() {
|
||||
|
||||
// A non-UTF-8 string slice. Regression test for #75763 and #78520.
|
||||
struct Str<const S: &'static str>;
|
||||
let _non_utf8_str: Str::<{
|
||||
unsafe { std::mem::transmute::<&[u8], &str>(&[0xC0, 0xC1, 0xF5]) }
|
||||
}>;
|
||||
let _non_utf8_str: Str<{ unsafe { std::mem::transmute::<&[u8], &str>(&[0xC0, 0xC1, 0xF5]) } }>;
|
||||
}
|
||||
|
@ -31,7 +31,7 @@ struct Delta<T> {
|
||||
enum Epsilon {
|
||||
A(u8, u16),
|
||||
B,
|
||||
C { c: u32 }
|
||||
C { c: u32 },
|
||||
}
|
||||
|
||||
enum Zeta<T> {
|
||||
|
@ -45,7 +45,10 @@ pub unsafe fn undef_union_as_integer() -> u32 {
|
||||
// CHECK-LABEL: fn undef_union_as_integer(
|
||||
// CHECK: _1 = Union32 {
|
||||
// CHECK: _0 = move _1 as u32 (Transmute);
|
||||
union Union32 { value: u32, unit: () }
|
||||
union Union32 {
|
||||
value: u32,
|
||||
unit: (),
|
||||
}
|
||||
unsafe { transmute(Union32 { unit: () }) }
|
||||
}
|
||||
|
||||
|
@ -4,10 +4,12 @@
|
||||
#![feature(custom_mir, core_intrinsics, freeze)]
|
||||
#![allow(unused_assignments)]
|
||||
extern crate core;
|
||||
use core::marker::Freeze;
|
||||
use core::intrinsics::mir::*;
|
||||
use core::marker::Freeze;
|
||||
|
||||
fn opaque(_: impl Sized) -> bool { true }
|
||||
fn opaque(_: impl Sized) -> bool {
|
||||
true
|
||||
}
|
||||
|
||||
fn cmp_ref(a: &u8, b: &u8) -> bool {
|
||||
std::ptr::eq(a as *const u8, b as *const u8)
|
||||
|
@ -7,7 +7,9 @@
|
||||
extern crate core;
|
||||
use core::intrinsics::mir::*;
|
||||
|
||||
fn opaque(_: impl Sized) -> bool { true }
|
||||
fn opaque(_: impl Sized) -> bool {
|
||||
true
|
||||
}
|
||||
|
||||
struct Foo(u8);
|
||||
|
||||
|
@ -8,7 +8,7 @@ use std::intrinsics::mir::*;
|
||||
#[derive(Copy, Clone)]
|
||||
enum E {
|
||||
V1(i32),
|
||||
V2(i32)
|
||||
V2(i32),
|
||||
}
|
||||
|
||||
// EMIT_MIR enum.simple.DataflowConstProp.diff
|
||||
@ -23,7 +23,10 @@ fn simple() {
|
||||
// CHECK: switchInt(const 0_isize) -> [0: [[target_bb:bb.*]], 1: bb2, otherwise: bb1];
|
||||
// CHECK: [[target_bb]]: {
|
||||
// CHECK: [[x]] = const 0_i32;
|
||||
let x = match e { E::V1(x1) => x1, E::V2(x2) => x2 };
|
||||
let x = match e {
|
||||
E::V1(x1) => x1,
|
||||
E::V2(x2) => x2,
|
||||
};
|
||||
}
|
||||
|
||||
// EMIT_MIR enum.constant.DataflowConstProp.diff
|
||||
@ -39,7 +42,10 @@ fn constant() {
|
||||
// CHECK: switchInt(const 0_isize) -> [0: [[target_bb:bb.*]], 1: bb2, otherwise: bb1];
|
||||
// CHECK: [[target_bb]]: {
|
||||
// CHECK: [[x]] = const 0_i32;
|
||||
let x = match e { E::V1(x1) => x1, E::V2(x2) => x2 };
|
||||
let x = match e {
|
||||
E::V1(x1) => x1,
|
||||
E::V2(x2) => x2,
|
||||
};
|
||||
}
|
||||
|
||||
// EMIT_MIR enum.statics.DataflowConstProp.diff
|
||||
@ -58,7 +64,10 @@ fn statics() {
|
||||
// CHECK: switchInt(const 0_isize) -> [0: [[target_bb:bb.*]], 1: bb2, otherwise: bb1];
|
||||
// CHECK: [[target_bb]]: {
|
||||
// CHECK: [[x1]] = const 0_i32;
|
||||
let x1 = match e1 { E::V1(x11) => x11, E::V2(x12) => x12 };
|
||||
let x1 = match e1 {
|
||||
E::V1(x11) => x11,
|
||||
E::V2(x12) => x12,
|
||||
};
|
||||
|
||||
static RC: &E = &E::V2(4);
|
||||
|
||||
@ -72,7 +81,10 @@ fn statics() {
|
||||
// One is `_9 = &(*_12) and another is `_9 = _11`. It is different from what we can
|
||||
// get by printing MIR directly. It is better to check if there are any bugs in the
|
||||
// MIR passes around this stage.
|
||||
let x2 = match e2 { E::V1(x21) => x21, E::V2(x22) => x22 };
|
||||
let x2 = match e2 {
|
||||
E::V1(x21) => x21,
|
||||
E::V2(x22) => x22,
|
||||
};
|
||||
}
|
||||
|
||||
#[rustc_layout_scalar_valid_range_start(1)]
|
||||
@ -132,7 +144,10 @@ fn multiple(x: bool, i: u8) {
|
||||
// CHECK: [[x2]] = const 0_u8;
|
||||
// CHECK: [[some:_.*]] = (({{_.*}} as Some).0: u8)
|
||||
// CHECK: [[x2]] = [[some]];
|
||||
let x2 = match e { Some(i) => i, None => 0 };
|
||||
let x2 = match e {
|
||||
Some(i) => i,
|
||||
None => 0,
|
||||
};
|
||||
|
||||
// Therefore, `x2` should be `Top` here, and no replacement shall happen.
|
||||
|
||||
|
@ -45,7 +45,10 @@ pub unsafe fn undef_union_as_integer() -> u32 {
|
||||
// CHECK-LABEL: fn undef_union_as_integer(
|
||||
// CHECK: _1 = Union32 {
|
||||
// CHECK: _0 = move _1 as u32 (Transmute);
|
||||
union Union32 { value: u32, unit: () }
|
||||
union Union32 {
|
||||
value: u32,
|
||||
unit: (),
|
||||
}
|
||||
unsafe { transmute(Union32 { unit: () }) }
|
||||
}
|
||||
|
||||
|
@ -4,5 +4,7 @@
|
||||
// EMIT_MIR_FOR_EACH_PANIC_STRATEGY
|
||||
|
||||
fn main() {
|
||||
for &foo in &[42, 43] { drop(foo) }
|
||||
for &foo in &[42, 43] {
|
||||
drop(foo)
|
||||
}
|
||||
}
|
||||
|
@ -7,7 +7,9 @@ fn main() {
|
||||
let b = foo();
|
||||
let d = foo();
|
||||
match ****(&&&&b) {
|
||||
true => {let x = 5;},
|
||||
true => {
|
||||
let x = 5;
|
||||
}
|
||||
false => {}
|
||||
}
|
||||
let y = 42;
|
||||
|
@ -32,7 +32,6 @@ impl<T: Call> Call for A<T> {
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
impl<T: Call> Call for B<T> {
|
||||
#[inline]
|
||||
fn call() {
|
||||
|
@ -26,7 +26,6 @@ impl Call for A {
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
impl<T: Call> Call for B<T> {
|
||||
#[inline]
|
||||
fn call() {
|
||||
|
@ -16,8 +16,16 @@ fn main() {
|
||||
|
||||
// Cost is approximately 3 * 25 + 5 = 80.
|
||||
#[inline]
|
||||
pub fn not_inlined() { g(); g(); g(); }
|
||||
pub fn inlined<T>() { g(); g(); g(); }
|
||||
pub fn not_inlined() {
|
||||
g();
|
||||
g();
|
||||
g();
|
||||
}
|
||||
pub fn inlined<T>() {
|
||||
g();
|
||||
g();
|
||||
g();
|
||||
}
|
||||
|
||||
#[inline(never)]
|
||||
fn g() {}
|
||||
|
@ -5,7 +5,7 @@
|
||||
fn main() {
|
||||
// CHECK-LABEL: fn main(
|
||||
// CHECK: (inlined <Vec<()> as Foo>::bar)
|
||||
let x = <Vec::<()> as Foo>::bar();
|
||||
let x = <Vec<()> as Foo>::bar();
|
||||
}
|
||||
|
||||
trait Foo {
|
||||
@ -14,5 +14,7 @@ trait Foo {
|
||||
|
||||
impl<T> Foo for Vec<T> {
|
||||
#[inline(always)]
|
||||
default fn bar() -> u32 { 123 }
|
||||
default fn bar() -> u32 {
|
||||
123
|
||||
}
|
||||
}
|
||||
|
@ -19,11 +19,7 @@ fn inner() -> usize {
|
||||
// CHECK: = {{.*}}[_0];
|
||||
let buffer = &[true];
|
||||
let index = index();
|
||||
if buffer[index] {
|
||||
index
|
||||
} else {
|
||||
0
|
||||
}
|
||||
if buffer[index] { index } else { 0 }
|
||||
}
|
||||
|
||||
fn main() {
|
||||
|
@ -13,6 +13,9 @@ fn main() {
|
||||
// CHECK-NEXT: }
|
||||
// CHECK-NEXT: }
|
||||
// CHECK-NEXT: }
|
||||
let f = |x| { let y = x; y };
|
||||
let f = |x| {
|
||||
let y = x;
|
||||
y
|
||||
};
|
||||
f(())
|
||||
}
|
||||
|
@ -5,7 +5,7 @@
|
||||
#![feature(custom_mir)]
|
||||
|
||||
use std::intrinsics::mir::*;
|
||||
use std::mem::{MaybeUninit, ManuallyDrop, transmute};
|
||||
use std::mem::{transmute, ManuallyDrop, MaybeUninit};
|
||||
|
||||
// EMIT_MIR combine_transmutes.identity_transmutes.InstSimplify.diff
|
||||
pub unsafe fn identity_transmutes() {
|
||||
@ -61,4 +61,7 @@ pub unsafe fn adt_transmutes() {
|
||||
let _a: ManuallyDrop<String> = transmute(MaybeUninit::<String>::uninit());
|
||||
}
|
||||
|
||||
pub union Union32 { u32: u32, i32: i32 }
|
||||
pub union Union32 {
|
||||
u32: u32,
|
||||
i32: i32,
|
||||
}
|
||||
|
@ -5,9 +5,7 @@
|
||||
|
||||
// EMIT_MIR issue_104451_unwindable_intrinsics.main.AbortUnwindingCalls.after.mir
|
||||
fn main() {
|
||||
unsafe {
|
||||
core::intrinsics::const_eval_select((), ow_ct, ow_ct)
|
||||
}
|
||||
unsafe { core::intrinsics::const_eval_select((), ow_ct, ow_ct) }
|
||||
}
|
||||
|
||||
const fn ow_ct() -> ! {
|
||||
|
@ -3,7 +3,6 @@
|
||||
|
||||
// check that we don't emit multiple drop flags when they are not needed.
|
||||
|
||||
|
||||
// EMIT_MIR issue_41110.main.ElaborateDrops.diff
|
||||
fn main() {
|
||||
let x = S.other(S.id());
|
||||
@ -21,11 +20,12 @@ pub fn test() {
|
||||
|
||||
struct S;
|
||||
impl Drop for S {
|
||||
fn drop(&mut self) {
|
||||
}
|
||||
fn drop(&mut self) {}
|
||||
}
|
||||
|
||||
impl S {
|
||||
fn id(self) -> Self { self }
|
||||
fn id(self) -> Self {
|
||||
self
|
||||
}
|
||||
fn other(self, s: Self) {}
|
||||
}
|
||||
|
@ -14,7 +14,6 @@ trait Foo {
|
||||
fn get(&self) -> [u8; 2];
|
||||
}
|
||||
|
||||
|
||||
// EMIT_MIR issue_41697.{impl#0}-{constant#0}.SimplifyCfg-promote-consts.after.mir
|
||||
impl Foo for [u8; 1 + 1] {
|
||||
fn get(&self) -> [u8; 2] {
|
||||
|
@ -1,6 +1,6 @@
|
||||
// MIR for `<impl at $DIR/issue_41697.rs:19:1: 19:23>::{constant#0}` after SimplifyCfg-promote-consts
|
||||
// MIR for `<impl at $DIR/issue_41697.rs:18:1: 18:25>::{constant#0}` after SimplifyCfg-promote-consts
|
||||
|
||||
<impl at $DIR/issue_41697.rs:19:1: 19:23>::{constant#0}: usize = {
|
||||
<impl at $DIR/issue_41697.rs:18:1: 18:25>::{constant#0}: usize = {
|
||||
let mut _0: usize;
|
||||
let mut _1: (usize, bool);
|
||||
|
||||
|
@ -15,11 +15,13 @@ fn main() {
|
||||
}
|
||||
}
|
||||
|
||||
fn cond() -> bool { false }
|
||||
fn cond() -> bool {
|
||||
false
|
||||
}
|
||||
|
||||
struct K;
|
||||
|
||||
enum E {
|
||||
F(K),
|
||||
G(Box<E>)
|
||||
G(Box<E>),
|
||||
}
|
||||
|
@ -9,16 +9,18 @@ enum Never {}
|
||||
|
||||
union Foo {
|
||||
a: u64,
|
||||
b: Never
|
||||
b: Never,
|
||||
}
|
||||
|
||||
|
||||
// EMIT_MIR issue_72181.foo.built.after.mir
|
||||
fn foo(xs: [(Never, u32); 1]) -> u32 { xs[0].1 }
|
||||
fn foo(xs: [(Never, u32); 1]) -> u32 {
|
||||
xs[0].1
|
||||
}
|
||||
|
||||
// EMIT_MIR issue_72181.bar.built.after.mir
|
||||
fn bar([(_, x)]: [(Never, u32); 1]) -> u32 { x }
|
||||
|
||||
fn bar([(_, x)]: [(Never, u32); 1]) -> u32 {
|
||||
x
|
||||
}
|
||||
|
||||
// EMIT_MIR issue_72181.main.built.after.mir
|
||||
fn main() {
|
||||
|
@ -14,9 +14,7 @@ fn f(v: Void) -> ! {
|
||||
|
||||
// EMIT_MIR issue_72181_1.main.built.after.mir
|
||||
fn main() {
|
||||
let v: Void = unsafe {
|
||||
std::mem::transmute::<(), Void>(())
|
||||
};
|
||||
let v: Void = unsafe { std::mem::transmute::<(), Void>(()) };
|
||||
|
||||
f(v);
|
||||
}
|
||||
|
@ -17,15 +17,13 @@ fn bar<T> (it: Box<[T]>)
|
||||
}
|
||||
|
||||
// EMIT_MIR issue_91633.fun.built.after.mir
|
||||
fn fun<T> (it: &[T]) -> &T
|
||||
{
|
||||
fn fun<T>(it: &[T]) -> &T {
|
||||
let f = &it[0];
|
||||
f
|
||||
}
|
||||
|
||||
// EMIT_MIR issue_91633.foo.built.after.mir
|
||||
fn foo<T: Clone> (it: Box<[T]>) -> T
|
||||
{
|
||||
fn foo<T: Clone>(it: Box<[T]>) -> T {
|
||||
let f = it[0].clone();
|
||||
f
|
||||
}
|
||||
|
@ -8,11 +8,7 @@ pub fn foo(bytes: [u8; 16]) -> Option<[u8; 4]> {
|
||||
// big endian `u32`s
|
||||
let dwords: [u32; 4] = unsafe { transmute(bytes) };
|
||||
const FF: u32 = 0x0000_ffff_u32.to_be();
|
||||
if let [0, 0, 0 | FF, ip] = dwords {
|
||||
Some(unsafe { transmute(ip) })
|
||||
} else {
|
||||
None
|
||||
}
|
||||
if let [0, 0, 0 | FF, ip] = dwords { Some(unsafe { transmute(ip) }) } else { None }
|
||||
}
|
||||
|
||||
fn main() {
|
||||
|
@ -330,11 +330,7 @@ fn mutable_ref() -> bool {
|
||||
let a = std::ptr::addr_of_mut!(x);
|
||||
x = 7;
|
||||
unsafe { *a = 8 };
|
||||
if x == 7 {
|
||||
true
|
||||
} else {
|
||||
false
|
||||
}
|
||||
if x == 7 { true } else { false }
|
||||
}
|
||||
|
||||
/// This function has 2 TOs: 1-3-4 and 0-1-3-4-6.
|
||||
@ -461,11 +457,7 @@ fn aggregate(x: u8) -> u8 {
|
||||
const FOO: (u8, u8) = (5, 13);
|
||||
|
||||
let (a, b) = FOO;
|
||||
if a == 7 {
|
||||
b
|
||||
} else {
|
||||
a
|
||||
}
|
||||
if a == 7 { b } else { a }
|
||||
}
|
||||
|
||||
/// Verify that we can leverage the existence of an `Assume` terminator.
|
||||
|
@ -7,11 +7,7 @@ pub fn array_bound<const N: usize>(index: usize, slice: &[u8; N]) -> u8 {
|
||||
// CHECK-LABEL: fn array_bound(
|
||||
// CHECK: [[len:_.*]] = const N;
|
||||
// CHECK: Lt(move {{_.*}}, move [[len]]);
|
||||
if index < slice.len() {
|
||||
slice[index]
|
||||
} else {
|
||||
42
|
||||
}
|
||||
if index < slice.len() { slice[index] } else { 42 }
|
||||
}
|
||||
|
||||
// EMIT_MIR lower_array_len.array_bound_mut.NormalizeArrayLen.diff
|
||||
|
@ -5,11 +5,7 @@
|
||||
pub fn bound(index: usize, slice: &[u8]) -> u8 {
|
||||
// CHECK-LABEL: fn bound(
|
||||
// CHECK-NOT: ::len(
|
||||
if index < slice.len() {
|
||||
slice[index]
|
||||
} else {
|
||||
42
|
||||
}
|
||||
if index < slice.len() { slice[index] } else { 42 }
|
||||
}
|
||||
|
||||
fn main() {
|
||||
|
@ -1,7 +1,6 @@
|
||||
// skip-filecheck
|
||||
//@ test-mir-pass: MatchBranchSimplification
|
||||
|
||||
|
||||
// EMIT_MIR matches_u8.exhaustive_match.MatchBranchSimplification.diff
|
||||
// EMIT_MIR matches_u8.exhaustive_match_i8.MatchBranchSimplification.diff
|
||||
|
||||
|
@ -10,7 +10,8 @@
|
||||
#![allow(warnings)]
|
||||
|
||||
// EMIT_MIR named_lifetimes_basic.use_x.nll.0.mir
|
||||
fn use_x<'a, 'b: 'a, 'c>(w: &'a mut i32, x: &'b u32, y: &'a u32, z: &'c u32) -> bool { true }
|
||||
|
||||
fn main() {
|
||||
fn use_x<'a, 'b: 'a, 'c>(w: &'a mut i32, x: &'b u32, y: &'a u32, z: &'c u32) -> bool {
|
||||
true
|
||||
}
|
||||
|
||||
fn main() {}
|
||||
|
@ -10,5 +10,7 @@ fn nrvo(init: fn(&mut [u8; 1024])) -> [u8; 1024] {
|
||||
}
|
||||
|
||||
fn main() {
|
||||
let _ = nrvo(|buf| { buf[4] = 4; });
|
||||
let _ = nrvo(|buf| {
|
||||
buf[4] = 4;
|
||||
});
|
||||
}
|
||||
|
@ -1,7 +1,6 @@
|
||||
// skip-filecheck
|
||||
// EMIT_MIR_FOR_EACH_PANIC_STRATEGY
|
||||
|
||||
|
||||
// EMIT_MIR packed_struct_drop_aligned.main.SimplifyCfg-pre-optimizations.after.mir
|
||||
fn main() {
|
||||
let mut x = Packed(Aligned(Droppy(0)));
|
||||
|
@ -12,7 +12,6 @@ pub fn f_unit() {
|
||||
f_dispatch(());
|
||||
}
|
||||
|
||||
|
||||
// EMIT_MIR intrinsics.f_u64.PreCodegen.after.mir
|
||||
pub fn f_u64() {
|
||||
f_dispatch(0u64);
|
||||
@ -28,8 +27,7 @@ pub fn f_dispatch<T>(t: T) {
|
||||
}
|
||||
|
||||
#[inline(never)]
|
||||
pub fn f_zst<T>(_t: T) {
|
||||
}
|
||||
pub fn f_zst<T>(_t: T) {}
|
||||
|
||||
#[inline(never)]
|
||||
pub fn f_non_zst<T>(_t: T) {}
|
||||
|
@ -17,18 +17,16 @@ fn new<T, E>(x: Result<T, E>) -> Result<T, E> {
|
||||
} {
|
||||
ControlFlow::Continue(v) => v,
|
||||
ControlFlow::Break(e) => return Err(e),
|
||||
}
|
||||
},
|
||||
)
|
||||
}
|
||||
|
||||
// EMIT_MIR try_identity.old.PreCodegen.after.mir
|
||||
fn old<T, E>(x: Result<T, E>) -> Result<T, E> {
|
||||
Ok(
|
||||
match x {
|
||||
Ok(match x {
|
||||
Ok(v) => v,
|
||||
Err(e) => return Err(e),
|
||||
}
|
||||
)
|
||||
})
|
||||
}
|
||||
|
||||
fn main() {
|
||||
|
@ -787,7 +787,9 @@ fn mut_raw_then_mut_shr() -> (i32, i32) {
|
||||
let xshr = &*xref;
|
||||
// Verify that we completely replace with `x` in both cases.
|
||||
let a = *xshr;
|
||||
unsafe { *xraw = 4; }
|
||||
unsafe {
|
||||
*xraw = 4;
|
||||
}
|
||||
(a, x)
|
||||
}
|
||||
|
||||
@ -842,8 +844,7 @@ fn debuginfo() {
|
||||
|
||||
// `constant_index_from_end` and `subslice` should not be promoted, as their value depends
|
||||
// on the slice length.
|
||||
if let [_, ref constant_index, subslice @ .., ref constant_index_from_end] = &[6; 10][..] {
|
||||
}
|
||||
if let [_, ref constant_index, subslice @ .., ref constant_index_from_end] = &[6; 10][..] {}
|
||||
|
||||
let multiple_borrow = &&&mut T(6).0;
|
||||
}
|
||||
|
@ -59,7 +59,9 @@ pub fn main() {
|
||||
fn array_casts() {
|
||||
let mut x: [usize; 2] = [0, 0];
|
||||
let p = &mut x as *mut usize;
|
||||
unsafe { *p.add(1) = 1; }
|
||||
unsafe {
|
||||
*p.add(1) = 1;
|
||||
}
|
||||
|
||||
let x: [usize; 2] = [0, 1];
|
||||
let p = &x as *const usize;
|
||||
|
@ -1,7 +1,6 @@
|
||||
// skip-filecheck
|
||||
//@ test-mir-pass: SimplifyLocals-before-const-prop
|
||||
|
||||
|
||||
#![feature(thread_local)]
|
||||
|
||||
#[derive(Copy, Clone)]
|
||||
@ -37,7 +36,8 @@ fn r() {
|
||||
let _ = &mut a;
|
||||
}
|
||||
|
||||
#[thread_local] static mut X: u32 = 0;
|
||||
#[thread_local]
|
||||
static mut X: u32 = 0;
|
||||
|
||||
// EMIT_MIR simplify_locals.t1.SimplifyLocals-before-const-prop.diff
|
||||
fn t1() {
|
||||
|
@ -4,9 +4,7 @@
|
||||
|
||||
fn foo<T>() {
|
||||
if let (Some(a), None) = (Option::<u8>::None, Option::<T>::None) {
|
||||
if a > 42u8 {
|
||||
|
||||
}
|
||||
if a > 42u8 {}
|
||||
}
|
||||
}
|
||||
|
||||
|
@ -5,8 +5,11 @@ fn noop() {}
|
||||
|
||||
// EMIT_MIR simplify_match.main.GVN.diff
|
||||
fn main() {
|
||||
match { let x = false; x } {
|
||||
match {
|
||||
let x = false;
|
||||
x
|
||||
} {
|
||||
true => noop(),
|
||||
false => {},
|
||||
false => {}
|
||||
}
|
||||
}
|
||||
|
@ -19,10 +19,7 @@ fn foo<T: Err>() {
|
||||
|
||||
// CHECK-NOT: [foo:_.*]: Foo
|
||||
// CHECK-NOT: Box<dyn std::fmt::Display + 'static>
|
||||
let foo: Foo<T> = Foo {
|
||||
x: Ok(Box::new(5_u32)),
|
||||
y: 7_u32,
|
||||
};
|
||||
let foo: Foo<T> = Foo { x: Ok(Box::new(5_u32)), y: 7_u32 };
|
||||
|
||||
let x = foo.x;
|
||||
let y = foo.y;
|
||||
|
@ -17,7 +17,7 @@ struct Foo {
|
||||
_: struct {
|
||||
d: [u8; 1],
|
||||
}
|
||||
}
|
||||
},
|
||||
}
|
||||
|
||||
#[repr(C)]
|
||||
@ -31,9 +31,8 @@ union Bar {
|
||||
_: union {
|
||||
d: [u8; 1],
|
||||
}
|
||||
},
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
fn access<T>(_: T) {}
|
||||
|
||||
@ -71,5 +70,4 @@ fn bar(bar: Bar) {
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
fn main() {}
|
||||
|
@ -56,7 +56,7 @@ fn as_match() {
|
||||
// CHECK: return;
|
||||
match empty() {
|
||||
None => {}
|
||||
Some(_x) => match _x {}
|
||||
Some(_x) => match _x {},
|
||||
}
|
||||
}
|
||||
|
||||
|
@ -3,7 +3,6 @@
|
||||
// that we don't create filenames containing `<` and `>`
|
||||
//@ compile-flags: -Zmir-opt-level=0
|
||||
|
||||
|
||||
struct A;
|
||||
|
||||
// EMIT_MIR unusual_item_types.{impl#0}-ASSOCIATED_CONSTANT.built.after.mir
|
||||
@ -23,8 +22,8 @@ enum E {
|
||||
V = 5,
|
||||
}
|
||||
|
||||
// EMIT_MIR core.ptr-drop_in_place.Vec_i32_.AddMovesForPackedDrops.before.mir
|
||||
pub fn main() {
|
||||
let f = Test::X as fn(usize) -> Test;
|
||||
// EMIT_MIR core.ptr-drop_in_place.Vec_i32_.AddMovesForPackedDrops.before.mir
|
||||
let v = Vec::<i32>::new();
|
||||
}
|
||||
|
@ -1,6 +1,6 @@
|
||||
// MIR for `<impl at $DIR/unusual_item_types.rs:10:1: 10:7>::ASSOCIATED_CONSTANT` after built
|
||||
// MIR for `<impl at $DIR/unusual_item_types.rs:9:1: 9:7>::ASSOCIATED_CONSTANT` after built
|
||||
|
||||
const <impl at $DIR/unusual_item_types.rs:10:1: 10:7>::ASSOCIATED_CONSTANT: i32 = {
|
||||
const <impl at $DIR/unusual_item_types.rs:9:1: 9:7>::ASSOCIATED_CONSTANT: i32 = {
|
||||
let mut _0: i32;
|
||||
|
||||
bb0: {
|
||||
|
Loading…
Reference in New Issue
Block a user