Commit 56fe773
committed
Remove restriction on dereferencing pointers in const
We had said that the dereference operator could not be used with raw
pointers in a constant expression. However, that restriction has been
lifted. First, in Rust 1.58, we stabilized `const_raw_ptr_deref`.
rust-lang/rust#89551
This allowed for dereferencing immutable raw pointers in a constant
expression. Then, in Rust 1.83, we stabilized `const_mut_refs` and
`const_refs_to_cell`.
rust-lang/rust#129195
That allowed for:
- Mentioning `&mut` types.
- Creating `&mut` and `*mut` values.
- Creating `&T` and `*const T` values where `T` contains interior
mutability.
- Dereferencing `&mut` and `*mut` values (both for reads and writes).
Let's remove the stated restriction on dereferencing raw pointers in a
constant expression and add examples.1 parent 9753ddb commit 56fe773
1 file changed
+17
-1
lines changed| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
203 | 203 | | |
204 | 204 | | |
205 | 205 | | |
206 | | - | |
| 206 | + | |
| 207 | + | |
| 208 | + | |
| 209 | + | |
| 210 | + | |
| 211 | + | |
| 212 | + | |
| 213 | + | |
| 214 | + | |
| 215 | + | |
| 216 | + | |
| 217 | + | |
| 218 | + | |
| 219 | + | |
| 220 | + | |
| 221 | + | |
| 222 | + | |
207 | 223 | | |
208 | 224 | | |
209 | 225 | | |
| |||
0 commit comments