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#64890 - wesleywiser:const_prop_rvalue, r=ol…
…i-obk [const-prop] Handle remaining MIR Rvalue cases r? @oli-obk
- Loading branch information
Showing
18 changed files
with
297 additions
and
93 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 |
---|---|---|
@@ -0,0 +1,25 @@ | ||
// compile-flags: -O | ||
|
||
fn main() { | ||
let x = (0, 1, 2).1 + 0; | ||
} | ||
|
||
// END RUST SOURCE | ||
// START rustc.main.ConstProp.before.mir | ||
// bb0: { | ||
// ... | ||
// _3 = (const 0i32, const 1i32, const 2i32); | ||
// _2 = (_3.1: i32); | ||
// _1 = Add(move _2, const 0i32); | ||
// ... | ||
// } | ||
// END rustc.main.ConstProp.before.mir | ||
// START rustc.main.ConstProp.after.mir | ||
// bb0: { | ||
// ... | ||
// _3 = (const 0i32, const 1i32, const 2i32); | ||
// _2 = const 1i32; | ||
// _1 = Add(move _2, const 0i32); | ||
// ... | ||
// } | ||
// END rustc.main.ConstProp.after.mir |
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 |
---|---|---|
@@ -0,0 +1,53 @@ | ||
// compile-flags: -O | ||
|
||
#![feature(box_syntax)] | ||
|
||
// Note: this test verifies that we, in fact, do not const prop `box` | ||
|
||
fn main() { | ||
let x = *(box 42) + 0; | ||
} | ||
|
||
// END RUST SOURCE | ||
// START rustc.main.ConstProp.before.mir | ||
// bb0: { | ||
// ... | ||
// _4 = Box(i32); | ||
// (*_4) = const 42i32; | ||
// _3 = move _4; | ||
// ... | ||
// _2 = (*_3); | ||
// _1 = Add(move _2, const 0i32); | ||
// ... | ||
// drop(_3) -> [return: bb2, unwind: bb1]; | ||
// } | ||
// bb1 (cleanup): { | ||
// resume; | ||
// } | ||
// bb2: { | ||
// ... | ||
// _0 = (); | ||
// ... | ||
// } | ||
// END rustc.main.ConstProp.before.mir | ||
// START rustc.main.ConstProp.after.mir | ||
// bb0: { | ||
// ... | ||
// _4 = Box(i32); | ||
// (*_4) = const 42i32; | ||
// _3 = move _4; | ||
// ... | ||
// _2 = (*_3); | ||
// _1 = Add(move _2, const 0i32); | ||
// ... | ||
// drop(_3) -> [return: bb2, unwind: bb1]; | ||
// } | ||
// bb1 (cleanup): { | ||
// resume; | ||
// } | ||
// bb2: { | ||
// ... | ||
// _0 = (); | ||
// ... | ||
// } | ||
// END rustc.main.ConstProp.after.mir |
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 |
---|---|---|
@@ -0,0 +1,53 @@ | ||
// compile-flags: -O | ||
|
||
fn main() { | ||
let x = (if let Some(true) = Some(true) { 42 } else { 10 }) + 0; | ||
} | ||
|
||
// END RUST SOURCE | ||
// START rustc.main.ConstProp.before.mir | ||
// bb0: { | ||
// ... | ||
// _3 = std::option::Option::<bool>::Some(const true,); | ||
// _4 = discriminant(_3); | ||
// switchInt(move _4) -> [1isize: bb3, otherwise: bb2]; | ||
// } | ||
// bb1: { | ||
// _2 = const 42i32; | ||
// goto -> bb4; | ||
// } | ||
// bb2: { | ||
// _2 = const 10i32; | ||
// goto -> bb4; | ||
// } | ||
// bb3: { | ||
// switchInt(((_3 as Some).0: bool)) -> [false: bb2, otherwise: bb1]; | ||
// } | ||
// bb4: { | ||
// _1 = Add(move _2, const 0i32); | ||
// ... | ||
// } | ||
// END rustc.main.ConstProp.before.mir | ||
// START rustc.main.ConstProp.after.mir | ||
// bb0: { | ||
// ... | ||
// _3 = const Scalar(0x01) : std::option::Option<bool>; | ||
// _4 = const 1isize; | ||
// switchInt(const 1isize) -> [1isize: bb3, otherwise: bb2]; | ||
// } | ||
// bb1: { | ||
// _2 = const 42i32; | ||
// goto -> bb4; | ||
// } | ||
// bb2: { | ||
// _2 = const 10i32; | ||
// goto -> bb4; | ||
// } | ||
// bb3: { | ||
// switchInt(const true) -> [false: bb2, otherwise: bb1]; | ||
// } | ||
// bb4: { | ||
// _1 = Add(move _2, const 0i32); | ||
// ... | ||
// } | ||
// END rustc.main.ConstProp.after.mir |
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 |
---|---|---|
@@ -0,0 +1,37 @@ | ||
// compile-flags: -O | ||
|
||
fn main() { | ||
let x: u32 = [42; 8][2] + 0; | ||
} | ||
|
||
// END RUST SOURCE | ||
// START rustc.main.ConstProp.before.mir | ||
// bb0: { | ||
// ... | ||
// _3 = [const 42u32; 8]; | ||
// ... | ||
// _4 = const 2usize; | ||
// _5 = const 8usize; | ||
// _6 = Lt(_4, _5); | ||
// assert(move _6, "index out of bounds: the len is move _5 but the index is _4") -> bb1; | ||
// } | ||
// bb1: { | ||
// _2 = _3[_4]; | ||
// _1 = Add(move _2, const 0u32); | ||
// ... | ||
// return; | ||
// } | ||
// END rustc.main.ConstProp.before.mir | ||
// START rustc.main.ConstProp.after.mir | ||
// bb0: { | ||
// ... | ||
// _6 = const true; | ||
// assert(const true, "index out of bounds: the len is move _5 but the index is _4") -> bb1; | ||
// } | ||
// bb1: { | ||
// _2 = const 42u32; | ||
// _1 = Add(move _2, const 0u32); | ||
// ... | ||
// return; | ||
// } | ||
// END rustc.main.ConstProp.after.mir |
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
Oops, something went wrong.