Skip to content

Commit 4ecf3f6

Browse files
authored
Unrolled build for rust-lang#115815
Rollup merge of rust-lang#115815 - bvanjoi:fix-115809, r=oli-obk fix: return early when has tainted in mir pass Fixes rust-lang#115809 As in rust-lang#115643, `run_pass` is skipped if the body has tainted errors. r? `@oli-obk`
2 parents 5adddad + 7c53e87 commit 4ecf3f6

File tree

3 files changed

+37
-0
lines changed

3 files changed

+37
-0
lines changed

compiler/rustc_mir_transform/src/lib.rs

+5
Original file line numberDiff line numberDiff line change
@@ -606,6 +606,11 @@ fn inner_optimized_mir(tcx: TyCtxt<'_>, did: LocalDefId) -> Body<'_> {
606606
let body = tcx.mir_drops_elaborated_and_const_checked(did).steal();
607607
let mut body = remap_mir_for_const_eval_select(tcx, body, hir::Constness::NotConst);
608608
debug!("body: {:#?}", body);
609+
610+
if body.tainted_by_errors.is_some() {
611+
return body;
612+
}
613+
609614
run_optimization_passes(tcx, &mut body);
610615

611616
body

tests/ui/unsized/issue-115809.rs

+13
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,13 @@
1+
// compile-flags: --emit=link -Zmir-opt-level=2 -Zpolymorphize=on
2+
3+
fn foo<T>() {
4+
let a: [i32; 0] = [];
5+
match [a[..]] {
6+
//~^ ERROR cannot move a value of type `[i32]
7+
//~| ERROR cannot move out of type `[i32]`, a non-copy slice
8+
[[x]] => {}
9+
_ => (),
10+
}
11+
}
12+
13+
fn main() {}

tests/ui/unsized/issue-115809.stderr

+19
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,19 @@
1+
error[E0161]: cannot move a value of type `[i32]`
2+
--> $DIR/issue-115809.rs:5:12
3+
|
4+
LL | match [a[..]] {
5+
| ^^^^^ the size of `[i32]` cannot be statically determined
6+
7+
error[E0508]: cannot move out of type `[i32]`, a non-copy slice
8+
--> $DIR/issue-115809.rs:5:12
9+
|
10+
LL | match [a[..]] {
11+
| ^^^^^
12+
| |
13+
| cannot move out of here
14+
| move occurs because value has type `[i32]`, which does not implement the `Copy` trait
15+
16+
error: aborting due to 2 previous errors
17+
18+
Some errors have detailed explanations: E0161, E0508.
19+
For more information about an error, try `rustc --explain E0161`.

0 commit comments

Comments
 (0)