Skip to content

Commit fb4b0c7

Browse files
BoxyUwURalfJung
andauthored
Wording nits for const section
Co-authored-by: Ralf Jung <[email protected]>
1 parent 3c8b478 commit fb4b0c7

File tree

1 file changed

+4
-2
lines changed

1 file changed

+4
-2
lines changed

posts/2024-11-28-Rust-1.83.0.md

Lines changed: 4 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -24,7 +24,7 @@ If you'd like to help us out by testing future releases, you might consider upda
2424
This release includes several large extensions to what code running in const contexts can do. This refers to all code that the compiler has to evaluate at compile-time: the initial value of `const` and `static` items, array lengths, enum discriminant values, const generic arguments, and functions callable from such contexts (`const fn`).
2525

2626
**References to statics.**
27-
So far, `const` items and `const fn` were forbidden from referencing `static items`.
27+
So far, const contexts except for the initializer expression of a `static` item were forbidden from referencing `static` items.
2828
This limitation has now been lifted:
2929
```rust
3030
static S: i32 = 25;
@@ -40,7 +40,9 @@ const C1: i32 = unsafe { S };
4040
const C2: &i32 = unsafe { &S };
4141
// error: encountered reference to mutable memory in `const`
4242
```
43-
These limitations ensure that constants are still "constant": the value they evaluate to, and their meaning as a pattern (which can involve dereferencing references), will be the same throughout the entire program execution. However, a constant is permitted to evaluate to a raw pointer that points to a mutable or interior mutable static:
43+
These limitations ensure that constants are still "constant": the value they evaluate to, and their meaning as a pattern (which can involve dereferencing references), will be the same throughout the entire program execution.
44+
45+
That said, a constant is permitted to evaluate to a raw pointer that points to a mutable or interior mutable static:
4446
```rust
4547
static mut S: i32 = 64;
4648
const C: *mut i32 = &raw mut S;

0 commit comments

Comments
 (0)