Skip to content

Commit 4fce9c2

Browse files
committed
Delay bug to prevent ICE in MIR borrowck
1 parent ed6468d commit 4fce9c2

File tree

3 files changed

+30
-1
lines changed

3 files changed

+30
-1
lines changed

src/librustc_mir/transform/elaborate_drops.rs

+7-1
Original file line numberDiff line numberDiff line change
@@ -28,7 +28,13 @@ impl<'tcx> MirPass<'tcx> for ElaborateDrops {
2828
let param_env = tcx.param_env(src.def_id()).with_reveal_all();
2929
let move_data = match MoveData::gather_moves(body, tcx, param_env) {
3030
Ok(move_data) => move_data,
31-
Err(_) => bug!("No `move_errors` should be allowed in MIR borrowck"),
31+
Err((move_data, _)) => {
32+
tcx.sess.delay_span_bug(
33+
body.span,
34+
"No `move_errors` should be allowed in MIR borrowck",
35+
);
36+
move_data
37+
}
3238
};
3339
let elaborate_patch = {
3440
let body = &*body;

src/test/ui/mir/issue-67947.rs

+7
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,7 @@
1+
struct Bug {
2+
A: [(); { *"" }.len()],
3+
//~^ ERROR: cannot move a value of type str
4+
//~| ERROR: cannot move out of a shared reference
5+
}
6+
7+
fn main() {}

src/test/ui/mir/issue-67947.stderr

+16
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,16 @@
1+
error[E0161]: cannot move a value of type str: the size of str cannot be statically determined
2+
--> $DIR/issue-67947.rs:2:13
3+
|
4+
LL | A: [(); { *"" }.len()],
5+
| ^^^^^^^
6+
7+
error[E0507]: cannot move out of a shared reference
8+
--> $DIR/issue-67947.rs:2:15
9+
|
10+
LL | A: [(); { *"" }.len()],
11+
| ^^^ move occurs because value has type `str`, which does not implement the `Copy` trait
12+
13+
error: aborting due to 2 previous errors
14+
15+
Some errors have detailed explanations: E0161, E0507.
16+
For more information about an error, try `rustc --explain E0161`.

0 commit comments

Comments
 (0)