-
Notifications
You must be signed in to change notification settings - Fork 13.5k
Closed
Labels
A-borrow-checkerArea: The borrow checkerArea: The borrow checkerI-needs-decisionIssue: In need of a decision.Issue: In need of a decision.I-unsoundIssue: A soundness hole (worst kind of bug), see: https://en.wikipedia.org/wiki/SoundnessIssue: A soundness hole (worst kind of bug), see: https://en.wikipedia.org/wiki/SoundnessT-langRelevant to the language teamRelevant to the language team
Description
#![feature(untagged_unions)]
#![allow(unused)]
#[allow(unions_with_drop_fields)]
union U {
x: (Vec<u8>, Vec<u8>),
y: Vec<u8>,
}
fn main() { unsafe {
let u = U { x: (Vec::new(), Vec::new()) };
let a = u.x.0;
let a = u.y; // This is incorrectly accepted despite u.y being "collaterally moved"
}}
When implementing move checking for unions I incorrectly assumed that moves automatically "propagate" to parent "loan paths", like in borrow checker, e.g.
let a = &mut u.x.0;
let a = &u.y; // This currently gives correct error due to u.y being "collaterally borrowed"
, this turns out to not be the case.
This case was missed in tests, so the error went unnoticed.
I have some quick fix, will submit tomorrow.
Metadata
Metadata
Assignees
Labels
A-borrow-checkerArea: The borrow checkerArea: The borrow checkerI-needs-decisionIssue: In need of a decision.Issue: In need of a decision.I-unsoundIssue: A soundness hole (worst kind of bug), see: https://en.wikipedia.org/wiki/SoundnessIssue: A soundness hole (worst kind of bug), see: https://en.wikipedia.org/wiki/SoundnessT-langRelevant to the language teamRelevant to the language team