Don't rely on promotion of PageTableEntry::new inside a const fn#175
Conversation
Hi! Rust compiler team member here. When the `const_fn` feature is enabled, the implementation of `PageTable::new` relies on a compiler bug to work. Specifically, `PageTableEntry::new` should not be eligible for promotion as part of an array initializer. See rust-lang/rust#75502 for more information. This bug may be fixed in the future, which will cause this crate to stop compiling.
|
Thanks a lot for the early warning and for taking the time to fix this for us! I'm wondering if the following would work too: pub const fn new() -> Self {
const EMPTY: PageTableEntry = PageTableEntry::new();
PageTable {
entries: [EMPTY; ENTRY_COUNT],
}
}Here we initialize the array with a The advantage of this implementation would be that it doesn't need access to the private |
|
That works too! The problems that can result from promoting calls to |
|
Thanks a lot for the explanation! |
|
Published as v0.11.5. |
Hi! Rust compiler team member here. When the
const_fnfeature is enabled, the implementation ofPageTable::newrelies on a compiler bug to work. Specifically,PageTableEntry::newshould not be eligible for promotion as part of an array initializer. See rust-lang/rust#75502 for more information. This bug may be fixed in the future, which would cause this crate to stop compiling.