-
Notifications
You must be signed in to change notification settings - Fork 13.6k
Closed
rust-lang/reference
#1590Closed
Copy link
Labels
A-const-evalArea: Constant evaluation, covers all const contexts (static, const fn, ...)Area: Constant evaluation, covers all const contexts (static, const fn, ...)B-unstableBlocker: Implemented in the nightly compiler and unstable.Blocker: Implemented in the nightly compiler and unstable.C-tracking-issueCategory: An issue tracking the progress of sth. like the implementation of an RFCCategory: An issue tracking the progress of sth. like the implementation of an RFCF-const_mut_refs`#![feature(const_mut_refs)]``#![feature(const_mut_refs)]`T-langRelevant to the language teamRelevant to the language team
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 the
const
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. - Mutable reference protected by a mutex in static context is considered UB #120450
- Figure out what to do with regression: encountered mutable pointer in final value when "outer scope" rule applies in const/static with interior mutability #121610: that's happening in const-eval interning: accept interior mutable pointers in final value #128543
- Adjust documentation: const_eval: update for const_mut_refs and const_refs_to_cell stabilization reference#1590
- Stabilization PR: Stabilize
&mut
(and*mut
) as well as&Cell
(and*const Cell
) in const #129195
Open questions
- can we stabilize this without figuring out the const heap story? -> yes, no reason this has to wait for const_heap
- can 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
elichai, Lokathor, stanislav-tkach, ldm0, sffc and 44 moreCentril, SplittyDev, Etherian, elichai, GrayJack and 23 morejaudigerryoqun, benluelo, Rudxain and JSorngard
Metadata
Metadata
Assignees
Labels
A-const-evalArea: Constant evaluation, covers all const contexts (static, const fn, ...)Area: Constant evaluation, covers all const contexts (static, const fn, ...)B-unstableBlocker: Implemented in the nightly compiler and unstable.Blocker: Implemented in the nightly compiler and unstable.C-tracking-issueCategory: An issue tracking the progress of sth. like the implementation of an RFCCategory: An issue tracking the progress of sth. like the implementation of an RFCF-const_mut_refs`#![feature(const_mut_refs)]``#![feature(const_mut_refs)]`T-langRelevant to the language teamRelevant to the language team