Description
The const_mut_refs
feature gate allows the following in const context:
&mut
arguments- mutable (re)borrows and raw pointers (
&mut
andaddr_of_mut!
expressions) - dereferencing mutable references and raw pointers (
*
expressions)
Remaining work
- Anonymous allocations in statics get duplicated for multiple codegen units #79738
static mut FOO: &'static mut i32 = &mut 42;
is problematic, because LLVM currently duplicates the inner mutable reference when you dostatic mut BAR: &'static mut i32 = FOO;
. It would probably suffice to give all nested allocations in a static names relative to their original static item. Named allocations are neither deduplicated nor duplicated.Currently the interning of the final result of theconst
relies on types more than it should, given thattransmute
is available in consts. Fixed in const-eval interning: get rid of type-driven traversal #119044.
Open questions
- can we stabilize this without figuring out the const heap story? -> yes, no reason this has to wait for const_heapcan we stabilize this without cranelift and codegen_gcc support? ICE: hir:
index out of bounds: the len is 5 but the index is 5
#122399, ICE: hir: index out of bounds: the len is 5 but the index is 5 rustc_codegen_gcc#473
Activity
[-]Mutation in const fn[/-][+]Tracking issue for `&mut T` in const fn[/+]Centril commentedon Jan 5, 2019
alercah commentedon Jan 9, 2019
const fn
#57563eddyb commentedon Feb 13, 2019
Make ilog64 const
216 remaining items