8000 Rollup of 8 pull requests by Centril · Pull Request #65534 · rust-lang/rust · GitHub
[go: up one dir, main page]

Skip to content

Rollup of 8 pull requests #65534

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Closed
wants to merge 26 commits into from
Closed
Show file tree
Hide file tree
Changes from 1 commit
Commits
Show all changes
26 commits
Select commit Hold shift + click to select a range
f04ea6c
Document JSON message output.
ehuss Sep 30, 2019
3b0fd82
Disable Go and OCaml bindings when building LLVM
tmiasko Oct 8, 2019
bcff266
[const-prop] Handle MIR Rvalue::Repeat
wesleywiser Sep 14, 2019
714d00d
[const-prop] Handle MIR Rvalue::Aggregates
wesleywiser Sep 14, 2019
81fa591
[const-prop] Handle MIR Rvalue::Discriminant
wesleywiser Sep 15, 2019
79c5858
[const-prop] Handle MIR Rvalue::Box
wesleywiser Sep 15, 2019
f2afa98
Cleanup const_prop() some
wesleywiser Sep 15, 2019
77f0aaf
Add more coherence tests
weiznich Oct 12, 2019
b6f6dc4
Don't ICE when evaluating writes to uninhabited enum variants
wesleywiser Oct 9, 2019
10236f1
Add long error explanation for E0577
GuillaumeGomez Oct 15, 2019
3d88f2c
Update ui tests
GuillaumeGomez Oct 15, 2019
9123907
Improve comments and structure of `ConstProp::const_prop()`
wesleywiser Oct 13, 2019
83e97c6
properly document panics in div_euclid and rem_euclid
tspiteri Oct 17, 2019
e417180
Update error_codes.rs
Dylan-DPC Oct 17, 2019
a4d9492
add option to ping llvm ice-breakers to triagebot
nikomatsakis Oct 17, 2019
4e6efe4
reorder fmt docs for more clarity
RalfJung Oct 17, 2019
5487994
Update triagebot.toml
nikomatsakis Oct 17, 2019
c0b7e76
example for padding any format
RalfJung Oct 17, 2019
0270858
Rollup merge of #64890 - wesleywiser:const_prop_rvalue, r=oli-obk
Centril Oct 18, 2019
2997a58
Rollup merge of #64925 - ehuss:document-json, r=Mark-Simulacrum
Centril Oct 18, 2019
d80e2e1
Rollup merge of #65201 - tmiasko:no-bindings, r=rkruppe
Centril Oct 18, 2019
001f69d
Rollup merge of #65417 - weiznich:more_coherence_tests, r=nikomatsakis
Centril Oct 18, 2019
030ed01
Rollup merge of #65434 - GuillaumeGomez:long-err-explanation-E0577, r…
Centril Oct 18, 2019
be9a8a9
Rollup merge of #65496 - tspiteri:euc-div-panic, r=KodrAus
Centril Oct 18, 2019
9890b1a
Rollup merge of #65508 - rust-lang:llvm-icebreakers-ping-1, r=simulacrum
Centril Oct 18, 2019
575ee19
Rollup merge of #65513 - RalfJung:fmt, r=Mark-Simulacrum
Centril Oct 18, 2019
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
8000
Prev Previous commit
Next Next commit
[const-prop] Handle MIR Rvalue::Aggregates
  • Loading branch information
wesleywiser committed Oct 11, 2019
commit 714d00d8d848327dfca7aab8bc3bd3b32ea18ebe
8 changes: 7 additions & 1 deletion src/librustc_mir/transform/const_prop.rs
Original file line number Diff line number Diff line change
Expand Up @@ -436,13 +436,13 @@ impl<'mir, 'tcx> ConstPropagator<'mir, 'tcx> {

// if this isn't a supported operation, then return None
match rvalue {
Rvalue::Aggregate(..) |
Rvalue::NullaryOp(NullOp::Box, _) |
Rvalue::Discriminant(..) => return None,

Rvalue::Use(_) |
Rvalue::Len(_) |
Rvalue::Repeat(..) |
Rvalue::Aggregate(..) |
Rvalue::Cast(..) |
Rvalue::NullaryOp(..) |
Rvalue::CheckedBinaryOp(..) |
Expand Down Expand Up @@ -535,6 +535,12 @@ impl<'mir, 'tcx> ConstPropagator<'mir, 'tcx> {
return None;
}
}
} else if let Rvalue::Aggregate(_, operands) = rvalue {
// FIXME(wesleywiser): const eval will turn this into a `const Scalar(<ZST>)` that
// `SimplifyLocals` doesn't know it can remove.
if operands.len() == 0 {
return None;
}
}

self.use_ecx(source_info, |this| {
Expand Down
1 change: 1 addition & 0 deletions src/test/compile-fail/consts/const-err3.rs
Original file line number Diff line number Diff line change
Expand Up @@ -14,6 +14,7 @@ fn main() {
//~^ ERROR const_err
let _e = [5u8][1];
//~^ ERROR const_err
//~| ERROR this expression will panic at runtime
black_box(b);
black_box(c);
black_box(d);
Expand Down
25 changes: 25 additions & 0 deletions src/test/mir-opt/const_prop/aggregate.rs
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
1 change: 1 addition & 0 deletions src/test/run-fail/overflowing-rsh-5.rs
Original file line number Diff line number Diff line change
Expand Up @@ -2,6 +2,7 @@
// compile-flags: -C debug-assertions

#![warn(exceeding_bitshifts)]
#![warn(const_err)]

fn main() {
let _n = 1i64 >> [64][0];
Expand Down
1 change: 1 addition & 0 deletions src/test/run-fail/overflowing-rsh-6.rs
Original file line number Diff line number Diff line change
Expand Up @@ -2,6 +2,7 @@
// compile-flags: -C debug-assertions

#![warn(exceeding_bitshifts)]
#![warn(const_err)]
#![feature(const_indexing)]

fn main() {
Expand Down
1 change: 1 addition & 0 deletions src/test/ui/consts/const-err2.rs
Original file line number Diff line number Diff line change
Expand Up @@ -23,6 +23,7 @@ fn main() {
//~^ ERROR const_err
let _e = [5u8][1];
//~^ ERROR index out of bounds
//~| ERROR this expression will panic at runtime
black_box(a);
black_box(b);
black_box(c);
Expand Down
8 changes: 7 additions & 1 deletion src/test/ui/consts/const-err2.stderr
Original file line number Diff line number Diff line change
Expand Up @@ -34,5 +34,11 @@ error: index out of bounds: the len is 1 but the index is 1
LL | let _e = [5u8][1];
| ^^^^^^^^

error: aborting due to 5 previous errors
error: this expression will panic at runtime
--> $DIR/const-err2.rs:24:14
|
LL | let _e = [5u8][1];
| ^^^^^^^^ index out of bounds: the len is 1 but the index is 1

error: aborting due to 6 previous errors

1 change: 1 addition & 0 deletions src/test/ui/consts/const-err3.rs
Original file line number Diff line number Diff line change
Expand Up @@ -23,6 +23,7 @@ fn main() {
//~^ ERROR const_err
let _e = [5u8][1];
//~^ ERROR const_err
//~| ERROR this expression will panic at runtime
black_box(a);
black_box(b);
black_box(c);
Expand Down
8 changes: 7 additions & 1 deletion src/test/ui/consts/const-err3.stderr
Original file line number Diff line number Diff line change
Expand Up @@ -34,5 +34,11 @@ error: index out of bounds: the len is 1 but the index is 1
LL | let _e = [5u8][1];
| ^^^^^^^^

error: aborting due to 5 previous errors
error: this expression will panic at runtime
--> $DIR/const-err3.rs:24:14
|
LL | let _e = [5u8][1];
| ^^^^^^^^ index out of bounds: the len is 1 but the index is 1

error: aborting due to 6 previous errors

2 changes: 2 additions & 0 deletions src/test/ui/issues/issue-54348.rs
Original file line number Diff line number Diff line change
@@ -1,5 +1,7 @@
fn main() {
[1][0u64 as usize];
[1][1.5 as usize]; //~ ERROR index out of bounds
//~| ERROR this expression will panic at runtime
[1][1u64 as usize]; //~ ERROR index out of bounds
//~| ERROR this expression will panic at runtime
}
16 changes: 14 additions & 2 deletions src/test/ui/issues/issue-54348.stderr
Original file line number Diff line number Diff line change
Expand Up @@ -6,11 +6,23 @@ LL | [1][1.5 as usize];
|
= note: `#[deny(const_err)]` on by default

error: this expression will panic at runtime
--> $DIR/issue-54348.rs:3:5
|
LL | [1][1.5 as usize];
| ^^^^^^^^^^^^^^^^^ index out of bounds: the len is 1 but the index is 1

error: index out of bounds: the len is 1 but the index is 1
--> $DIR/issue-54348.rs:4:5
--> $DIR/issue-54348.rs:5:5
|
LL | [1][1u64 as usize];
| ^^^^^^^^^^^^^^^^^^

error: aborting due to 2 previous errors
error: this expression will panic at runtime
--> $DIR/issue-54348.rs:5:5
|
LL | [1][1u64 as usize];
| ^^^^^^^^^^^^^^^^^^ index out of bounds: the len is 1 but the index is 1

error: aborting due to 4 previous errors

2 changes: 1 addition & 1 deletion src/test/ui/lint/lint-exceeding-bitshifts2.rs
Original file line number Diff line number Diff line change
Expand Up @@ -8,7 +8,7 @@ fn main() {
let n = 1u8 << (4+3);
let n = 1u8 << (4+4); //~ ERROR: attempt to shift left with overflow
let n = 1i64 >> [63][0];
let n = 1i64 >> [64][0]; // should be linting, needs to wait for const propagation
let n = 1i64 >> [64][0]; //~ ERROR: attempt to shift right with overflow

#[cfg(target_pointer_width = "32")]
const BITS: usize = 32;
Expand Down
8 changes: 7 additions & 1 deletion src/test/ui/lint/lint-exceeding-bitshifts2.stderr
Original file line number Diff line number Diff line change
Expand Up @@ -10,6 +10,12 @@ note: lint level defined here
LL | #![deny(exceeding_bitshifts, const_err)]
| ^^^^^^^^^^^^^^^^^^^

error: attempt to shift right with overflow
--> $DIR/lint-exceeding-bitshifts2.rs:11:15
|
LL | let n = 1i64 >> [64][0];
| ^^^^^^^^^^^^^^^

error: attempt to shift left with overflow
--> $DIR/lint-exceeding-bitshifts2.rs:17:15
|
Expand All @@ -22,5 +28,5 @@ error: attempt to shift left with overflow
LL | let n = 1_usize << BITS;
| ^^^^^^^^^^^^^^^

error: aborting due to 3 previous errors
error: aborting due to 4 previous errors

0