Skip to content
Open
Show file tree
Hide file tree
Changes from 1 commit
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
11 changes: 9 additions & 2 deletions src/changelog.rst
Original file line number Diff line number Diff line change
Expand Up @@ -331,8 +331,15 @@ Language changes in Rust 1.83.0

* `Stabilize \`&mut\`, \`*mut\`, \`&Cell\`, and \`*const Cell\` in const. <https://github.com/rust-lang/rust/pull/129195>`_

* Changed paragraphs: :p:`fls_to4e7imq2c0w`, :p:`fls_6g7c1kjrmfnr`, :p:`fls_hkbwa8xx2fwx`
* Removed paragraph: :p:`fls_ox6sgl9n43g2`
* Changed paragraphs:

- :p:`fls_to4e7imq2c0w`

- :p:`fls_6g7c1kjrmfnr`

- :p:`fls_hkbwa8xx2fwx`

- :p:`fls_ox6sgl9n43g2`

* `Allow creating references to statics in \`const\` initializers. <https://github.com/rust-lang/rust/pull/129759>`_

Expand Down
3 changes: 3 additions & 0 deletions src/values.rst
Original file line number Diff line number Diff line change
Expand Up @@ -95,6 +95,9 @@ The :t:`type specification` of a :t:`constant` shall have ``'static``
The :t:`type` of a :t:`constant` shall implement the :std:`core::marker::Sized`
:t:`trait`.

:dp:`fls_ox6sgl9n43g2`
The type of a :t:`constant` cannot be a :t:`mutable reference type`.
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

This doesn't cover it.

struct W<T>(T);
const _: W<&mut ()> = W(&mut ()); //~ ERROR
const _: W<&AtomicU8> = W(&AtomicU8::new(0)); //~ ERROR

Copy link
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

to be clear, are those additional rules

Copy link
Contributor

@traviscross traviscross Oct 18, 2025

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

What I'm getting at here specifically is that the final value can't contain any mutable references, not just that it can't be a mutable reference type.

struct W<T>(T);
static mut S: u8 = 0;
const _: W<&mut u8> = W(unsafe { &mut S }); //~ ERROR
//       ^^^^^^^^^^ Not a mutable reference type.

And then, yes, there are additional rules that prohibit mutable borrows of lifetime-extended temporaries even when that doesn't result in a mutable reference being contained in the final value.

struct W<T>(T);
const _: W<&u8> = W(&mut 0); //~ ERROR

Copy link
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

at attempt 00c1bfd


:dp:`fls_ndmfqxjpvsqy`
A :t:`constant initializer` is a :t:`construct` that provides the :t:`value` of
its related :t:`constant`.
Expand Down