-
Notifications
You must be signed in to change notification settings - Fork 13k
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
ICE: No move_errors
should be allowed in MIR borrowck
#70934
Comments
Important detail: Only happens on the |
(bisecting) |
It happens with master branch as well if I do |
Ah, I see |
regression in nightly-2019-08-17 |
@jonas-schievink great :). Unsure if you're bisecting this further, anyway pinging cleanup crew in case you are not doing it further and also to see if someone is able to get an mcve. @rustbot ping cleanup |
Hey Cleanup Crew ICE-breakers! This bug has been identified as a good cc @AminArria @chrissimpkins @contrun @DutchGhost @elshize @ethanboxx @h-michael @HallerPatrick @hdhoang @hellow554 @imtsuki @jakevossen5 @kanru @KarlK90 @LeSeulArtichaut @MAdrianMattocks @matheus-consoli @mental32 @nmccarty @Noah-Kennedy @pard68 @PeytonT @pierreN @Redblueflame @RobbieClarken @RobertoSnap @robjtede @SarthakSingh31 @senden9 @shekohex @sinato @spastorino @turboladen @woshilapin @yerke |
There don't seem to be any prebuilt artifacts for that commit range, so I've stopped there. |
Assigning |
pub fn f() -> () {
const C: [S2; 1] = [S2];
let _ = S1(C[0]).clone();
}
#[derive(Clone)]
pub struct S1(S2);
#[derive(Clone)]
pub struct S2; Errors:
@rustbot modify labels to -E-needs-mcve |
The reduced example regresses at nightly-2019-09-29 (084beb8..488381c). Edit2: For me, evolvim (develop branch) regresses on that nightly, too.
|
Even smaller: struct S;
fn main() {
&([S][0],);
} Errors:
|
This comment has been minimized.
This comment has been minimized.
1 similar comment
This comment has been minimized.
This comment has been minimized.
This comment has been minimized.
This comment has been minimized.
This comment has been minimized.
This comment has been minimized.
This comment has been minimized.
This comment has been minimized.
This comment has been minimized.
This comment has been minimized.
Looks like this compiles but it shouldn't: struct S;
fn foo() {
&([S][0],);
} Dumping the MIR for this you get: fn foo() -> () {
let mut _0: (); // return place in scope 0 at src/lib.rs:3:10: 3:10
let _1: &(S,); // in scope 0 at src/lib.rs:4:5: 4:15
let mut _2: &(S,); // in scope 0 at src/lib.rs:4:5: 4:15
bb0: {
StorageLive(_1); // bb0[0]: scope 0 at src/lib.rs:4:5: 4:15
_2 = const foo::promoted[0]; // bb0[1]: scope 0 at src/lib.rs:4:5: 4:15
// ty::Const
// + ty: &(S,)
// + val: Unevaluated(DefId(0:5 ~ playground[4e22]::foo[0]), [], Some(promoted[0]))
// mir::Constant
// + span: src/lib.rs:4:5: 4:15
// + literal: Const { ty: &(S,), val: Unevaluated(DefId(0:5 ~ playground[4e22]::foo[0]), [], Some(promoted[0])) }
_1 = _2; // bb0[2]: scope 0 at src/lib.rs:4:5: 4:15
StorageDead(_1); // bb0[3]: scope 0 at src/lib.rs:4:15: 4:16
return; // bb0[4]: scope 0 at src/lib.rs:5:2: 5:2
}
}
promoted[0] in foo: &(S,) = {
let mut _0: &(S,); // return place in scope 0 at src/lib.rs:4:5: 4:15
let mut _1: (S,); // in scope 0 at src/lib.rs:4:6: 4:15
let mut _2: S; // in scope 0 at src/lib.rs:4:7: 4:13
let mut _3: [S; 1]; // in scope 0 at src/lib.rs:4:7: 4:10
let mut _4: S; // in scope 0 at src/lib.rs:4:8: 4:9
let mut _5: usize; // in scope 0 at src/lib.rs:4:11: 4:12
bb0: {
_3 = [move _4]; // bb0[0]: scope 0 at src/lib.rs:4:7: 4:10
_5 = const 0usize; // bb0[1]: scope 0 at src/lib.rs:4:11: 4:12
// ty::Const
// + ty: usize
// + val: Value(Scalar(0x0000000000000000))
// mir::Constant
// + span: src/lib.rs:4:11: 4:12
// + literal: Const { ty: usize, val: Value(Scalar(0x0000000000000000)) }
_2 = move _3[_5]; // bb0[2]: scope 0 at src/lib.rs:4:7: 4:13
(_1.0: S) = move _2; // bb0[3]: scope 0 at src/lib.rs:4:6: 4:15
_0 = &_1; // bb0[4]: scope 0 at src/lib.rs:4:5: 4:15
return; // bb0[5]: scope 0 at src/lib.rs:4:5: 4:15
}
} Presumably, what should happen here is:
The impl<'tcx> MirPass<'tcx> for ElaborateDrops {
fn run_pass(&self, tcx: TyCtxt<'tcx>, src: MirSource<'tcx>, body: &mut BodyAndCache<'tcx>) {
debug!("elaborate_drops({:?} @ {:?})", src, body.span);
let def_id = src.def_id();
let param_env = tcx.param_env(src.def_id()).with_reveal_all();
let move_data = match MoveData::gather_moves(body, tcx, param_env) {
Ok(move_data) => move_data,
Err((move_data, _)) => {
tcx.sess.delay_span_bug(
body.span,
"No `move_errors` should be allowed in MIR borrowck",
);
move_data
}
}; |
This issue is already prioritized as |
I guess we need to track down where We can't avoid that code from getting promoted without getting into an unfun game of whack-a-mole in the promotion code. |
The error is constructed here: rust/src/librustc_mir/util/borrowck_errors.rs Lines 281 to 305 in ba72b15
which is called here:
and here:
|
hmmm... not sure what borrowck does to promoteds. I mean we basically declared all lifetimes to be static, but the same is true for the body of constants which we do run borrowck on. So... let's try to just run borrowck on promoteds and see how it goes. |
alternatively we just run the |
… r=nikomatsakis Report cannot move errors in promoted MIR Closes rust-lang#70934
I get an ICE when I try to build evolvim:
I tried stable, beta and nightly. All ended with an ICE.
The text was updated successfully, but these errors were encountered: