|
54 | 54 | )]
|
55 | 55 | #![allow(missing_docs)]
|
56 | 56 |
|
57 |
| -use crate::marker::DiscriminantKind; |
58 |
| -use crate::marker::Tuple; |
| 57 | +#[cfg(not(bootstrap))] |
| 58 | +use crate::marker::PointerLike; |
| 59 | +use crate::marker::{DiscriminantKind, Tuple}; |
59 | 60 | use crate::mem;
|
60 | 61 |
|
61 | 62 | pub mod mir;
|
@@ -1429,7 +1430,7 @@ extern "rust-intrinsic" {
|
1429 | 1430 | #[must_use = "returns a new pointer rather than modifying its argument"]
|
1430 | 1431 | #[rustc_const_stable(feature = "const_ptr_offset", since = "1.61.0")]
|
1431 | 1432 | #[rustc_nounwind]
|
1432 |
| - pub fn offset<Ptr, Delta>(dst: Ptr, offset: Delta) -> Ptr; |
| 1433 | + pub fn offset<Ptr: PointerLike, Delta>(dst: Ptr, offset: Delta) -> Ptr; |
1433 | 1434 |
|
1434 | 1435 | /// The bootstrap version of this is more restricted.
|
1435 | 1436 | #[cfg(bootstrap)]
|
@@ -2257,9 +2258,21 @@ extern "rust-intrinsic" {
|
2257 | 2258 | /// This is an implementation detail of [`crate::ptr::read`] and should
|
2258 | 2259 | /// not be used anywhere else. See its comments for why this exists.
|
2259 | 2260 | ///
|
2260 |
| - /// This intrinsic can *only* be called where the pointer is a local without |
| 2261 | + /// `Ptr` must be some kind of pointer to `T`. |
| 2262 | + /// |
| 2263 | + /// This intrinsic can *only* be called where the `ptr` is a local without |
2261 | 2264 | /// projections (`read_via_copy(ptr)`, not `read_via_copy(*ptr)`) so that it
|
2262 | 2265 | /// trivially obeys runtime-MIR rules about derefs in operands.
|
| 2266 | + /// |
| 2267 | + /// Not meeting the above requirements may arbitrarily misbehave, and |
| 2268 | + /// per MCP#620 that's *not* a compiler bug. |
| 2269 | + #[cfg(not(bootstrap))] |
| 2270 | + #[rustc_const_unstable(feature = "const_ptr_read", issue = "80377")] |
| 2271 | + #[rustc_nounwind] |
| 2272 | + pub fn read_via_copy<Ptr: PointerLike, T>(ptr: Ptr) -> T; |
| 2273 | + |
| 2274 | + /// The bootstrap version of this intrinsic is more limited. |
| 2275 | + #[cfg(bootstrap)] |
2263 | 2276 | #[rustc_const_unstable(feature = "const_ptr_read", issue = "80377")]
|
2264 | 2277 | #[rustc_nounwind]
|
2265 | 2278 | pub fn read_via_copy<T>(ptr: *const T) -> T;
|
|
0 commit comments