This repository was archived by the owner on May 28, 2025. It is now read-only.
Commit 256b6fb
committed
Auto merge of rust-lang#117905 - RalfJung:no-const-mut, r=lcnr
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
7 files changed
+18
-13
lines changed- library/core
- src
- ptr
- tests
- tests/ui/consts/const-eval
7 files changed
+18
-13
lines changed| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
2749 | 2749 | | |
2750 | 2750 | | |
2751 | 2751 | | |
2752 | | - | |
| 2752 | + | |
2753 | 2753 | | |
2754 | 2754 | | |
2755 | 2755 | | |
2756 | 2756 | | |
2757 | 2757 | | |
2758 | | - | |
| 2758 | + | |
2759 | 2759 | | |
2760 | 2760 | | |
2761 | 2761 | | |
| |||
2845 | 2845 | | |
2846 | 2846 | | |
2847 | 2847 | | |
2848 | | - | |
| 2848 | + | |
2849 | 2849 | | |
2850 | 2850 | | |
2851 | 2851 | | |
2852 | 2852 | | |
2853 | 2853 | | |
2854 | | - | |
| 2854 | + | |
2855 | 2855 | | |
2856 | 2856 | | |
2857 | 2857 | | |
| |||
| 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 | |
|---|---|---|---|
| |||
1284 | 1284 | | |
1285 | 1285 | | |
1286 | 1286 | | |
1287 | | - | |
| 1287 | + | |
1288 | 1288 | | |
1289 | 1289 | | |
1290 | 1290 | | |
| |||
1304 | 1304 | | |
1305 | 1305 | | |
1306 | 1306 | | |
1307 | | - | |
| 1307 | + | |
1308 | 1308 | | |
1309 | 1309 | | |
1310 | 1310 | | |
| |||
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
1176 | 1176 | | |
1177 | 1177 | | |
1178 | 1178 | | |
1179 | | - | |
1180 | 1179 | | |
1181 | 1180 | | |
1182 | 1181 | | |
| |||
1294 | 1293 | | |
1295 | 1294 | | |
1296 | 1295 | | |
1297 | | - | |
| 1296 | + | |
| 1297 | + | |
| 1298 | + | |
| 1299 | + | |
| 1300 | + | |
1298 | 1301 | | |
1299 | 1302 | | |
1300 | 1303 | | |
| |||
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
1385 | 1385 | | |
1386 | 1386 | | |
1387 | 1387 | | |
1388 | | - | |
| 1388 | + | |
1389 | 1389 | | |
1390 | 1390 | | |
1391 | 1391 | | |
| |||
1405 | 1405 | | |
1406 | 1406 | | |
1407 | 1407 | | |
1408 | | - | |
| 1408 | + | |
1409 | 1409 | | |
1410 | 1410 | | |
1411 | 1411 | | |
| |||
1425 | 1425 | | |
1426 | 1426 | | |
1427 | 1427 | | |
1428 | | - | |
| 1428 | + | |
1429 | 1429 | | |
1430 | 1430 | | |
1431 | 1431 | | |
| |||
1445 | 1445 | | |
1446 | 1446 | | |
1447 | 1447 | | |
1448 | | - | |
| 1448 | + | |
1449 | 1449 | | |
1450 | 1450 | | |
1451 | 1451 | | |
| |||
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
14 | 14 | | |
15 | 15 | | |
16 | 16 | | |
| 17 | + | |
17 | 18 | | |
18 | 19 | | |
19 | 20 | | |
| |||
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
1 | | - | |
| 1 | + | |
2 | 2 | | |
3 | 3 | | |
4 | 4 | | |
| |||
0 commit comments