-
Notifications
You must be signed in to change notification settings - Fork 13k
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Auto merge of #60888 - Manishearth:rollup-oihtoyq, r=Manishearth
Rollup of 5 pull requests Successful merges: - #60207 (Outdent example, preserving nested fence) - #60278 (Document the `html_root_url` doc attribute value.) - #60597 (Do some simple constant propagation in the ConstProp pass) - #60837 (Update release notes for 1.35.0) - #60887 (Update clippy) Failed merges: r? @ghost
- Loading branch information
Showing
9 changed files
with
312 additions
and
21 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
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,33 @@ | ||
fn main() { | ||
let x: u32 = [0, 1, 2, 3][2]; | ||
} | ||
|
||
// END RUST SOURCE | ||
// START rustc.main.ConstProp.before.mir | ||
// bb0: { | ||
// ... | ||
// _2 = [const 0u32, const 1u32, const 2u32, const 3u32]; | ||
// ... | ||
// _3 = const 2usize; | ||
// _4 = const 4usize; | ||
// _5 = Lt(_3, _4); | ||
// assert(move _5, "index out of bounds: the len is move _4 but the index is _3") -> bb1; | ||
// } | ||
// bb1: { | ||
// _1 = _2[_3]; | ||
// ... | ||
// return; | ||
// } | ||
// END rustc.main.ConstProp.before.mir | ||
// START rustc.main.ConstProp.after.mir | ||
// bb0: { | ||
// ... | ||
// _5 = const true; | ||
// assert(move _5, "index out of bounds: the len is move _4 but the index is _3") -> bb1; | ||
// } | ||
// bb1: { | ||
// _1 = _2[_3]; | ||
// ... | ||
// 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
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,21 @@ | ||
// compile-flags: -C overflow-checks=on | ||
|
||
fn main() { | ||
let x: u32 = 1 + 1; | ||
} | ||
|
||
// END RUST SOURCE | ||
// START rustc.main.ConstProp.before.mir | ||
// bb0: { | ||
// ... | ||
// _2 = CheckedAdd(const 1u32, const 1u32); | ||
// assert(!move (_2.1: bool), "attempt to add with overflow") -> bb1; | ||
// } | ||
// END rustc.main.ConstProp.before.mir | ||
// START rustc.main.ConstProp.after.mir | ||
// bb0: { | ||
// ... | ||
// _2 = (const 2u32, const false); | ||
// assert(!move (_2.1: bool), "attempt to add with overflow") -> bb1; | ||
// } | ||
// END rustc.main.ConstProp.after.mir |
34 changes: 34 additions & 0 deletions
34
src/test/mir-opt/const_prop/const_prop_fails_gracefully.rs
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,34 @@ | ||
#[inline(never)] | ||
fn read(_: usize) { } | ||
|
||
fn main() { | ||
const FOO: &i32 = &1; | ||
let x = FOO as *const i32 as usize; | ||
read(x); | ||
} | ||
|
||
// END RUST SOURCE | ||
// START rustc.main.ConstProp.before.mir | ||
// bb0: { | ||
// ... | ||
// _3 = _4; | ||
// _2 = move _3 as *const i32 (Misc); | ||
// ... | ||
// _1 = move _2 as usize (Misc); | ||
// ... | ||
// _6 = _1; | ||
// _5 = const read(move _6) -> bb1; | ||
// } | ||
// END rustc.main.ConstProp.before.mir | ||
// START rustc.main.ConstProp.after.mir | ||
// bb0: { | ||
// ... | ||
// _3 = _4; | ||
// _2 = move _3 as *const i32 (Misc); | ||
// ... | ||
// _1 = move _2 as usize (Misc); | ||
// ... | ||
// _6 = _1; | ||
// _5 = const read(move _6) -> bb1; | ||
// } | ||
// END rustc.main.ConstProp.after.mir |
Oops, something went wrong.