-
Notifications
You must be signed in to change notification settings - Fork 36
Open
Description
As of rust-lang/rust#114447, it appears that the common pattern of
static mut EP_MEMORY: [u32; 1024] = [0; 1024];
let usb_bus = UsbBus::new(usb, unsafe { &mut EP_MEMORY });is no longer encouraged, and will stop working in the 2024 edition.
warning: creating a mutable reference to mutable static is discouraged
|
231 | let usb_bus = UsbBus::new(usb, unsafe { &mut EP_MEMORY });
| ^^^^^^^^^^^^^^ mutable reference to mutable static
|
= note: for more information, see issue #114447 <https://github.com/rust-lang/rust/issues/114447>
= note: this will be a hard error in the 2024 edition
= note: this mutable reference has lifetime `'static`, but if the static gets accessed (read or written) by any other means, or any other reference is created, then any further use of this mutable reference is Undefined Behavior
help: use `addr_of_mut!` instead to create a raw pointer
|
231 | unsafe { USB_ALLOCATOR = Some(UsbBus::new(usb, addr_of_mut!(EP_MEMORY))) };
| ~~~~~~~~~~~~~~~~~~~~~~~
The examples still use this outdated pattern.
My understanding is that the "preferred" solution is to make UsbBus::new take a pointer rather than a reference, although I'm not 100% sure.
Disasm
Metadata
Metadata
Assignees
Labels
No labels