This repository was archived by the owner on May 28, 2025. It is now read-only.
Commit 1930f26
committed
Auto merge of rust-lang#117905 - RalfJung:no-const-mut, r=<try>
revert stabilization of const_intrinsic_copy
`@rust-lang/wg-const-eval` I don't know what we were thinking when we approved rust-lang#97276... const-eval isn't supposed to be able to mutate anything yet! It's also near impossible to actually call `copy` in const on stable since `&mut` expressions are generally unstable. However, there's one exception...
```rust
static mut INT: i32 = unsafe {
let val = &mut [1]; // `&mut` on arrays is allowed in `static mut`
(val as *mut [i32; 1]).copy_from(&[42], 1);
val[0]
};
fn main() { unsafe {
dbg!(INT);
} }
```
Inside `static mut`, we accept some `&mut` since ~forever, to make `static mut FOO: &mut [T] = &mut [...];` work. We reject any attempt to actually write to that mutable reference though... except for the `copy` functions.
I think we should revert stabilizing these functions that take `*mut`, and then re-stabilize them together with `ptr.write` once mutable references are stable.
(This will likely fail on PowerPC until rust-lang/stdarch#1497 lands. But we'll need a crater run first anyway.)File tree
6 files changed
+17
-12
lines changed- library/core
- src
- ptr
- tests
6 files changed
+17
-12
lines changed| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
2665 | 2665 | | |
2666 | 2666 | | |
2667 | 2667 | | |
2668 | | - | |
| 2668 | + | |
2669 | 2669 | | |
2670 | 2670 | | |
2671 | 2671 | | |
2672 | 2672 | | |
2673 | 2673 | | |
2674 | | - | |
| 2674 | + | |
2675 | 2675 | | |
2676 | 2676 | | |
2677 | 2677 | | |
| |||
2761 | 2761 | | |
2762 | 2762 | | |
2763 | 2763 | | |
2764 | | - | |
| 2764 | + | |
2765 | 2765 | | |
2766 | 2766 | | |
2767 | 2767 | | |
2768 | 2768 | | |
2769 | 2769 | | |
2770 | | - | |
| 2770 | + | |
2771 | 2771 | | |
2772 | 2772 | | |
2773 | 2773 | | |
| |||
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
135 | 135 | | |
136 | 136 | | |
137 | 137 | | |
| 138 | + | |
138 | 139 | | |
139 | 140 | | |
140 | 141 | | |
| |||
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
1283 | 1283 | | |
1284 | 1284 | | |
1285 | 1285 | | |
1286 | | - | |
| 1286 | + | |
1287 | 1287 | | |
1288 | 1288 | | |
1289 | 1289 | | |
| |||
1303 | 1303 | | |
1304 | 1304 | | |
1305 | 1305 | | |
1306 | | - | |
| 1306 | + | |
1307 | 1307 | | |
1308 | 1308 | | |
1309 | 1309 | | |
| |||
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
1161 | 1161 | | |
1162 | 1162 | | |
1163 | 1163 | | |
1164 | | - | |
1165 | 1164 | | |
1166 | 1165 | | |
1167 | 1166 | | |
| |||
1279 | 1278 | | |
1280 | 1279 | | |
1281 | 1280 | | |
1282 | | - | |
| 1281 | + | |
| 1282 | + | |
| 1283 | + | |
| 1284 | + | |
| 1285 | + | |
1283 | 1286 | | |
1284 | 1287 | | |
1285 | 1288 | | |
| |||
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
1384 | 1384 | | |
1385 | 1385 | | |
1386 | 1386 | | |
1387 | | - | |
| 1387 | + | |
1388 | 1388 | | |
1389 | 1389 | | |
1390 | 1390 | | |
| |||
1404 | 1404 | | |
1405 | 1405 | | |
1406 | 1406 | | |
1407 | | - | |
| 1407 | + | |
1408 | 1408 | | |
1409 | 1409 | | |
1410 | 1410 | | |
| |||
1424 | 1424 | | |
1425 | 1425 | | |
1426 | 1426 | | |
1427 | | - | |
| 1427 | + | |
1428 | 1428 | | |
1429 | 1429 | | |
1430 | 1430 | | |
| |||
1444 | 1444 | | |
1445 | 1445 | | |
1446 | 1446 | | |
1447 | | - | |
| 1447 | + | |
1448 | 1448 | | |
1449 | 1449 | | |
1450 | 1450 | | |
| |||
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
14 | 14 | | |
15 | 15 | | |
16 | 16 | | |
| 17 | + | |
17 | 18 | | |
18 | 19 | | |
19 | 20 | | |
| |||
0 commit comments