53
53
use crate :: marker:: { ConstParamTy , DiscriminantKind , Tuple } ;
54
54
use crate :: ptr;
55
55
56
+ mod bounds;
56
57
pub mod fallback;
57
58
pub mod mir;
58
59
pub mod simd;
@@ -1730,7 +1731,7 @@ pub const fn needs_drop<T: ?Sized>() -> bool;
1730
1731
#[ rustc_intrinsic_const_stable_indirect]
1731
1732
#[ rustc_nounwind]
1732
1733
#[ rustc_intrinsic]
1733
- pub const unsafe fn offset < Ptr , Delta > ( dst : Ptr , offset : Delta ) -> Ptr ;
1734
+ pub const unsafe fn offset < Ptr : bounds :: BuiltinDeref , Delta > ( dst : Ptr , offset : Delta ) -> Ptr ;
1734
1735
1735
1736
/// Calculates the offset from a pointer, potentially wrapping.
1736
1737
///
@@ -1751,6 +1752,33 @@ pub const unsafe fn offset<Ptr, Delta>(dst: Ptr, offset: Delta) -> Ptr;
1751
1752
#[ rustc_intrinsic]
1752
1753
pub const unsafe fn arith_offset < T > ( dst : * const T , offset : isize ) -> * const T ;
1753
1754
1755
+ /// Projects to the `index`-th element of `slice_ptr`, as the same kind of pointer
1756
+ /// as the slice was provided -- so `&mut [T] → &mut T`, `&[T] → &T`,
1757
+ /// `*mut [T] → *mut T`, or `*const [T] → *const T` -- without a bounds check.
1758
+ ///
1759
+ /// This is exposed via `<usize as SliceIndex>::get(_unchecked)(_mut)`,
1760
+ /// and isn't intended to be used elsewhere.
1761
+ ///
1762
+ /// Expands in MIR to `{&, &mut, &raw const, &raw mut} (*slice_ptr)[index]`,
1763
+ /// depending on the types involved, so no backend support is needed.
1764
+ ///
1765
+ /// # Safety
1766
+ ///
1767
+ /// - `index < PtrMetadata(slice_ptr)`, so the indexing is in-bounds for the slice
1768
+ /// - the resulting offsetting is in-bounds of the allocated object, which is
1769
+ /// always the case for references, but needs to be upheld manually for pointers
1770
+ #[ cfg( not( bootstrap) ) ]
1771
+ #[ rustc_nounwind]
1772
+ #[ rustc_intrinsic]
1773
+ pub const unsafe fn slice_get_unchecked <
1774
+ ItemPtr : bounds:: ChangePointee < [ T ] , Pointee = T , Output = SlicePtr > ,
1775
+ SlicePtr ,
1776
+ T ,
1777
+ > (
1778
+ slice_ptr : SlicePtr ,
1779
+ index : usize ,
1780
+ ) -> ItemPtr ;
1781
+
1754
1782
/// Masks out bits of the pointer according to a mask.
1755
1783
///
1756
1784
/// Note that, unlike most intrinsics, this is safe to call;
@@ -2212,86 +2240,86 @@ pub unsafe fn fmuladdf128(a: f128, b: f128, c: f128) -> f128;
2212
2240
/// [`f16::floor`](../../std/primitive.f16.html#method.floor)
2213
2241
#[ rustc_intrinsic]
2214
2242
#[ rustc_nounwind]
2215
- pub unsafe fn floorf16 ( x : f16 ) -> f16 ;
2243
+ pub const unsafe fn floorf16 ( x : f16 ) -> f16 ;
2216
2244
/// Returns the largest integer less than or equal to an `f32`.
2217
2245
///
2218
2246
/// The stabilized version of this intrinsic is
2219
2247
/// [`f32::floor`](../../std/primitive.f32.html#method.floor)
2220
2248
#[ rustc_intrinsic]
2221
2249
#[ rustc_nounwind]
2222
- pub unsafe fn floorf32 ( x : f32 ) -> f32 ;
2250
+ pub const unsafe fn floorf32 ( x : f32 ) -> f32 ;
2223
2251
/// Returns the largest integer less than or equal to an `f64`.
2224
2252
///
2225
2253
/// The stabilized version of this intrinsic is
2226
2254
/// [`f64::floor`](../../std/primitive.f64.html#method.floor)
2227
2255
#[ rustc_intrinsic]
2228
2256
#[ rustc_nounwind]
2229
- pub unsafe fn floorf64 ( x : f64 ) -> f64 ;
2257
+ pub const unsafe fn floorf64 ( x : f64 ) -> f64 ;
2230
2258
/// Returns the largest integer less than or equal to an `f128`.
2231
2259
///
2232
2260
/// The stabilized version of this intrinsic is
2233
2261
/// [`f128::floor`](../../std/primitive.f128.html#method.floor)
2234
2262
#[ rustc_intrinsic]
2235
2263
#[ rustc_nounwind]
2236
- pub unsafe fn floorf128 ( x : f128 ) -> f128 ;
2264
+ pub const unsafe fn floorf128 ( x : f128 ) -> f128 ;
2237
2265
2238
2266
/// Returns the smallest integer greater than or equal to an `f16`.
2239
2267
///
2240
2268
/// The stabilized version of this intrinsic is
2241
2269
/// [`f16::ceil`](../../std/primitive.f16.html#method.ceil)
2242
2270
#[ rustc_intrinsic]
2243
2271
#[ rustc_nounwind]
2244
- pub unsafe fn ceilf16 ( x : f16 ) -> f16 ;
2272
+ pub const unsafe fn ceilf16 ( x : f16 ) -> f16 ;
2245
2273
/// Returns the smallest integer greater than or equal to an `f32`.
2246
2274
///
2247
2275
/// The stabilized version of this intrinsic is
2248
2276
/// [`f32::ceil`](../../std/primitive.f32.html#method.ceil)
2249
2277
#[ rustc_intrinsic]
2250
2278
#[ rustc_nounwind]
2251
- pub unsafe fn ceilf32 ( x : f32 ) -> f32 ;
2279
+ pub const unsafe fn ceilf32 ( x : f32 ) -> f32 ;
2252
2280
/// Returns the smallest integer greater than or equal to an `f64`.
2253
2281
///
2254
2282
/// The stabilized version of this intrinsic is
2255
2283
/// [`f64::ceil`](../../std/primitive.f64.html#method.ceil)
2256
2284
#[ rustc_intrinsic]
2257
2285
#[ rustc_nounwind]
2258
- pub unsafe fn ceilf64 ( x : f64 ) -> f64 ;
2286
+ pub const unsafe fn ceilf64 ( x : f64 ) -> f64 ;
2259
2287
/// Returns the smallest integer greater than or equal to an `f128`.
2260
2288
///
2261
2289
/// The stabilized version of this intrinsic is
2262
2290
/// [`f128::ceil`](../../std/primitive.f128.html#method.ceil)
2263
2291
#[ rustc_intrinsic]
2264
2292
#[ rustc_nounwind]
2265
- pub unsafe fn ceilf128 ( x : f128 ) -> f128 ;
2293
+ pub const unsafe fn ceilf128 ( x : f128 ) -> f128 ;
2266
2294
2267
2295
/// Returns the integer part of an `f16`.
2268
2296
///
2269
2297
/// The stabilized version of this intrinsic is
2270
2298
/// [`f16::trunc`](../../std/primitive.f16.html#method.trunc)
2271
2299
#[ rustc_intrinsic]
2272
2300
#[ rustc_nounwind]
2273
- pub unsafe fn truncf16 ( x : f16 ) -> f16 ;
2301
+ pub const unsafe fn truncf16 ( x : f16 ) -> f16 ;
2274
2302
/// Returns the integer part of an `f32`.
2275
2303
///
2276
2304
/// The stabilized version of this intrinsic is
2277
2305
/// [`f32::trunc`](../../std/primitive.f32.html#method.trunc)
2278
2306
#[ rustc_intrinsic]
2279
2307
#[ rustc_nounwind]
2280
- pub unsafe fn truncf32 ( x : f32 ) -> f32 ;
2308
+ pub const unsafe fn truncf32 ( x : f32 ) -> f32 ;
2281
2309
/// Returns the integer part of an `f64`.
2282
2310
///
2283
2311
/// The stabilized version of this intrinsic is
2284
2312
/// [`f64::trunc`](../../std/primitive.f64.html#method.trunc)
2285
2313
#[ rustc_intrinsic]
2286
2314
#[ rustc_nounwind]
2287
- pub unsafe fn truncf64 ( x : f64 ) -> f64 ;
2315
+ pub const unsafe fn truncf64 ( x : f64 ) -> f64 ;
2288
2316
/// Returns the integer part of an `f128`.
2289
2317
///
2290
2318
/// The stabilized version of this intrinsic is
2291
2319
/// [`f128::trunc`](../../std/primitive.f128.html#method.trunc)
2292
2320
#[ rustc_intrinsic]
2293
2321
#[ rustc_nounwind]
2294
- pub unsafe fn truncf128 ( x : f128 ) -> f128 ;
2322
+ pub const unsafe fn truncf128 ( x : f128 ) -> f128 ;
2295
2323
2296
2324
/// Returns the nearest integer to an `f16`. Rounds half-way cases to the number with an even
2297
2325
/// least significant digit.
@@ -2300,7 +2328,7 @@ pub unsafe fn truncf128(x: f128) -> f128;
2300
2328
/// [`f16::round_ties_even`](../../std/primitive.f16.html#method.round_ties_even)
2301
2329
#[ rustc_intrinsic]
2302
2330
#[ rustc_nounwind]
2303
- pub fn round_ties_even_f16 ( x : f16 ) -> f16 ;
2331
+ pub const fn round_ties_even_f16 ( x : f16 ) -> f16 ;
2304
2332
2305
2333
/// Returns the nearest integer to an `f32`. Rounds half-way cases to the number with an even
2306
2334
/// least significant digit.
@@ -2309,7 +2337,7 @@ pub fn round_ties_even_f16(x: f16) -> f16;
2309
2337
/// [`f32::round_ties_even`](../../std/primitive.f32.html#method.round_ties_even)
2310
2338
#[ rustc_intrinsic]
2311
2339
#[ rustc_nounwind]
2312
- pub fn round_ties_even_f32 ( x : f32 ) -> f32 ;
2340
+ pub const fn round_ties_even_f32 ( x : f32 ) -> f32 ;
2313
2341
2314
2342
/// Returns the nearest integer to an `f64`. Rounds half-way cases to the number with an even
2315
2343
/// least significant digit.
@@ -2318,7 +2346,7 @@ pub fn round_ties_even_f32(x: f32) -> f32;
2318
2346
/// [`f64::round_ties_even`](../../std/primitive.f64.html#method.round_ties_even)
2319
2347
#[ rustc_intrinsic]
2320
2348
#[ rustc_nounwind]
2321
- pub fn round_ties_even_f64 ( x : f64 ) -> f64 ;
2349
+ pub const fn round_ties_even_f64 ( x : f64 ) -> f64 ;
2322
2350
2323
2351
/// Returns the nearest integer to an `f128`. Rounds half-way cases to the number with an even
2324
2352
/// least significant digit.
@@ -2327,36 +2355,36 @@ pub fn round_ties_even_f64(x: f64) -> f64;
2327
2355
/// [`f128::round_ties_even`](../../std/primitive.f128.html#method.round_ties_even)
2328
2356
#[ rustc_intrinsic]
2329
2357
#[ rustc_nounwind]
2330
- pub fn round_ties_even_f128 ( x : f128 ) -> f128 ;
2358
+ pub const fn round_ties_even_f128 ( x : f128 ) -> f128 ;
2331
2359
2332
2360
/// Returns the nearest integer to an `f16`. Rounds half-way cases away from zero.
2333
2361
///
2334
2362
/// The stabilized version of this intrinsic is
2335
2363
/// [`f16::round`](../../std/primitive.f16.html#method.round)
2336
2364
#[ rustc_intrinsic]
2337
2365
#[ rustc_nounwind]
2338
- pub unsafe fn roundf16 ( x : f16 ) -> f16 ;
2366
+ pub const unsafe fn roundf16 ( x : f16 ) -> f16 ;
2339
2367
/// Returns the nearest integer to an `f32`. Rounds half-way cases away from zero.
2340
2368
///
2341
2369
/// The stabilized version of this intrinsic is
2342
2370
/// [`f32::round`](../../std/primitive.f32.html#method.round)
2343
2371
#[ rustc_intrinsic]
2344
2372
#[ rustc_nounwind]
2345
- pub unsafe fn roundf32 ( x : f32 ) -> f32 ;
2373
+ pub const unsafe fn roundf32 ( x : f32 ) -> f32 ;
2346
2374
/// Returns the nearest integer to an `f64`. Rounds half-way cases away from zero.
2347
2375
///
2348
2376
/// The stabilized version of this intrinsic is
2349
2377
/// [`f64::round`](../../std/primitive.f64.html#method.round)
2350
2378
#[ rustc_intrinsic]
2351
2379
#[ rustc_nounwind]
2352
- pub unsafe fn roundf64 ( x : f64 ) -> f64 ;
2380
+ pub const unsafe fn roundf64 ( x : f64 ) -> f64 ;
2353
2381
/// Returns the nearest integer to an `f128`. Rounds half-way cases away from zero.
2354
2382
///
2355
2383
/// The stabilized version of this intrinsic is
2356
2384
/// [`f128::round`](../../std/primitive.f128.html#method.round)
2357
2385
#[ rustc_intrinsic]
2358
2386
#[ rustc_nounwind]
2359
- pub unsafe fn roundf128 ( x : f128 ) -> f128 ;
2387
+ pub const unsafe fn roundf128 ( x : f128 ) -> f128 ;
2360
2388
2361
2389
/// Float addition that allows optimizations based on algebraic rules.
2362
2390
/// May assume inputs are finite.
@@ -3575,18 +3603,9 @@ pub const fn type_id<T: ?Sized + 'static>() -> u128;
3575
3603
#[ unstable( feature = "core_intrinsics" , issue = "none" ) ]
3576
3604
#[ rustc_intrinsic_const_stable_indirect]
3577
3605
#[ rustc_intrinsic]
3578
- pub const fn aggregate_raw_ptr < P : AggregateRawPtr < D , Metadata = M > , D , M > ( data : D , meta : M ) -> P ;
3579
-
3580
- #[ unstable( feature = "core_intrinsics" , issue = "none" ) ]
3581
- pub trait AggregateRawPtr < D > {
3582
- type Metadata : Copy ;
3583
- }
3584
- impl < P : ?Sized , T : ptr:: Thin > AggregateRawPtr < * const T > for * const P {
3585
- type Metadata = <P as ptr:: Pointee >:: Metadata ;
3586
- }
3587
- impl < P : ?Sized , T : ptr:: Thin > AggregateRawPtr < * mut T > for * mut P {
3588
- type Metadata = <P as ptr:: Pointee >:: Metadata ;
3589
- }
3606
+ pub const fn aggregate_raw_ptr < P : bounds:: BuiltinDeref , D , M > ( data : D , meta : M ) -> P
3607
+ where
3608
+ <P as bounds:: BuiltinDeref >:: Pointee : ptr:: Pointee < Metadata = M > ;
3590
3609
3591
3610
/// Lowers in MIR to `Rvalue::UnaryOp` with `UnOp::PtrMetadata`.
3592
3611
///
0 commit comments