-
-
Notifications
You must be signed in to change notification settings - Fork 14.7k
Closed
Labels
C-bugCategory: This is a bug.Category: This is a bug.
Description
This code worked fine a couple of months ago:
#[derive(Copy, Clone, Debug)]
enum Fruit {
Apple,
_Banana,
}
fn foo() -> Fruit {
unsafe {
let mut r = mem::uninitialized();
ptr::write(&mut r as *mut Fruit, Fruit::Apple);
r
}
}
Now (1.44.1), this code crashes with:
thread 'main' panicked at 'attempted to leave type `Fruit` uninitialized, which is invalid', ...
This code looks perfectly valid to me: we create a slot for a variable, write to that slot exactly once, and return the value.
Reactions are currently unavailable
Metadata
Metadata
Assignees
Labels
C-bugCategory: This is a bug.Category: This is a bug.
Type
Fields
Give feedbackNo fields configured for issues without a type.