5353use crate :: marker:: { ConstParamTy , DiscriminantKind , Tuple } ;
5454use crate :: ptr;
5555
56+ mod bounds;
5657pub mod fallback;
5758pub mod mir;
5859pub mod simd;
@@ -1730,7 +1731,7 @@ pub const fn needs_drop<T: ?Sized>() -> bool;
17301731#[ rustc_intrinsic_const_stable_indirect]
17311732#[ rustc_nounwind]
17321733#[ 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 ;
17341735
17351736/// Calculates the offset from a pointer, potentially wrapping.
17361737///
@@ -1751,6 +1752,33 @@ pub const unsafe fn offset<Ptr, Delta>(dst: Ptr, offset: Delta) -> Ptr;
17511752#[ rustc_intrinsic]
17521753pub const unsafe fn arith_offset < T > ( dst : * const T , offset : isize ) -> * const T ;
17531754
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+
17541782/// Masks out bits of the pointer according to a mask.
17551783///
17561784/// 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;
22122240/// [`f16::floor`](../../std/primitive.f16.html#method.floor)
22132241#[ rustc_intrinsic]
22142242#[ rustc_nounwind]
2215- pub unsafe fn floorf16 ( x : f16 ) -> f16 ;
2243+ pub const unsafe fn floorf16 ( x : f16 ) -> f16 ;
22162244/// Returns the largest integer less than or equal to an `f32`.
22172245///
22182246/// The stabilized version of this intrinsic is
22192247/// [`f32::floor`](../../std/primitive.f32.html#method.floor)
22202248#[ rustc_intrinsic]
22212249#[ rustc_nounwind]
2222- pub unsafe fn floorf32 ( x : f32 ) -> f32 ;
2250+ pub const unsafe fn floorf32 ( x : f32 ) -> f32 ;
22232251/// Returns the largest integer less than or equal to an `f64`.
22242252///
22252253/// The stabilized version of this intrinsic is
22262254/// [`f64::floor`](../../std/primitive.f64.html#method.floor)
22272255#[ rustc_intrinsic]
22282256#[ rustc_nounwind]
2229- pub unsafe fn floorf64 ( x : f64 ) -> f64 ;
2257+ pub const unsafe fn floorf64 ( x : f64 ) -> f64 ;
22302258/// Returns the largest integer less than or equal to an `f128`.
22312259///
22322260/// The stabilized version of this intrinsic is
22332261/// [`f128::floor`](../../std/primitive.f128.html#method.floor)
22342262#[ rustc_intrinsic]
22352263#[ rustc_nounwind]
2236- pub unsafe fn floorf128 ( x : f128 ) -> f128 ;
2264+ pub const unsafe fn floorf128 ( x : f128 ) -> f128 ;
22372265
22382266/// Returns the smallest integer greater than or equal to an `f16`.
22392267///
22402268/// The stabilized version of this intrinsic is
22412269/// [`f16::ceil`](../../std/primitive.f16.html#method.ceil)
22422270#[ rustc_intrinsic]
22432271#[ rustc_nounwind]
2244- pub unsafe fn ceilf16 ( x : f16 ) -> f16 ;
2272+ pub const unsafe fn ceilf16 ( x : f16 ) -> f16 ;
22452273/// Returns the smallest integer greater than or equal to an `f32`.
22462274///
22472275/// The stabilized version of this intrinsic is
22482276/// [`f32::ceil`](../../std/primitive.f32.html#method.ceil)
22492277#[ rustc_intrinsic]
22502278#[ rustc_nounwind]
2251- pub unsafe fn ceilf32 ( x : f32 ) -> f32 ;
2279+ pub const unsafe fn ceilf32 ( x : f32 ) -> f32 ;
22522280/// Returns the smallest integer greater than or equal to an `f64`.
22532281///
22542282/// The stabilized version of this intrinsic is
22552283/// [`f64::ceil`](../../std/primitive.f64.html#method.ceil)
22562284#[ rustc_intrinsic]
22572285#[ rustc_nounwind]
2258- pub unsafe fn ceilf64 ( x : f64 ) -> f64 ;
2286+ pub const unsafe fn ceilf64 ( x : f64 ) -> f64 ;
22592287/// Returns the smallest integer greater than or equal to an `f128`.
22602288///
22612289/// The stabilized version of this intrinsic is
22622290/// [`f128::ceil`](../../std/primitive.f128.html#method.ceil)
22632291#[ rustc_intrinsic]
22642292#[ rustc_nounwind]
2265- pub unsafe fn ceilf128 ( x : f128 ) -> f128 ;
2293+ pub const unsafe fn ceilf128 ( x : f128 ) -> f128 ;
22662294
22672295/// Returns the integer part of an `f16`.
22682296///
22692297/// The stabilized version of this intrinsic is
22702298/// [`f16::trunc`](../../std/primitive.f16.html#method.trunc)
22712299#[ rustc_intrinsic]
22722300#[ rustc_nounwind]
2273- pub unsafe fn truncf16 ( x : f16 ) -> f16 ;
2301+ pub const unsafe fn truncf16 ( x : f16 ) -> f16 ;
22742302/// Returns the integer part of an `f32`.
22752303///
22762304/// The stabilized version of this intrinsic is
22772305/// [`f32::trunc`](../../std/primitive.f32.html#method.trunc)
22782306#[ rustc_intrinsic]
22792307#[ rustc_nounwind]
2280- pub unsafe fn truncf32 ( x : f32 ) -> f32 ;
2308+ pub const unsafe fn truncf32 ( x : f32 ) -> f32 ;
22812309/// Returns the integer part of an `f64`.
22822310///
22832311/// The stabilized version of this intrinsic is
22842312/// [`f64::trunc`](../../std/primitive.f64.html#method.trunc)
22852313#[ rustc_intrinsic]
22862314#[ rustc_nounwind]
2287- pub unsafe fn truncf64 ( x : f64 ) -> f64 ;
2315+ pub const unsafe fn truncf64 ( x : f64 ) -> f64 ;
22882316/// Returns the integer part of an `f128`.
22892317///
22902318/// The stabilized version of this intrinsic is
22912319/// [`f128::trunc`](../../std/primitive.f128.html#method.trunc)
22922320#[ rustc_intrinsic]
22932321#[ rustc_nounwind]
2294- pub unsafe fn truncf128 ( x : f128 ) -> f128 ;
2322+ pub const unsafe fn truncf128 ( x : f128 ) -> f128 ;
22952323
22962324/// Returns the nearest integer to an `f16`. Rounds half-way cases to the number with an even
22972325/// least significant digit.
@@ -2300,7 +2328,7 @@ pub unsafe fn truncf128(x: f128) -> f128;
23002328/// [`f16::round_ties_even`](../../std/primitive.f16.html#method.round_ties_even)
23012329#[ rustc_intrinsic]
23022330#[ rustc_nounwind]
2303- pub fn round_ties_even_f16 ( x : f16 ) -> f16 ;
2331+ pub const fn round_ties_even_f16 ( x : f16 ) -> f16 ;
23042332
23052333/// Returns the nearest integer to an `f32`. Rounds half-way cases to the number with an even
23062334/// least significant digit.
@@ -2309,7 +2337,7 @@ pub fn round_ties_even_f16(x: f16) -> f16;
23092337/// [`f32::round_ties_even`](../../std/primitive.f32.html#method.round_ties_even)
23102338#[ rustc_intrinsic]
23112339#[ rustc_nounwind]
2312- pub fn round_ties_even_f32 ( x : f32 ) -> f32 ;
2340+ pub const fn round_ties_even_f32 ( x : f32 ) -> f32 ;
23132341
23142342/// Returns the nearest integer to an `f64`. Rounds half-way cases to the number with an even
23152343/// least significant digit.
@@ -2318,7 +2346,7 @@ pub fn round_ties_even_f32(x: f32) -> f32;
23182346/// [`f64::round_ties_even`](../../std/primitive.f64.html#method.round_ties_even)
23192347#[ rustc_intrinsic]
23202348#[ rustc_nounwind]
2321- pub fn round_ties_even_f64 ( x : f64 ) -> f64 ;
2349+ pub const fn round_ties_even_f64 ( x : f64 ) -> f64 ;
23222350
23232351/// Returns the nearest integer to an `f128`. Rounds half-way cases to the number with an even
23242352/// least significant digit.
@@ -2327,36 +2355,36 @@ pub fn round_ties_even_f64(x: f64) -> f64;
23272355/// [`f128::round_ties_even`](../../std/primitive.f128.html#method.round_ties_even)
23282356#[ rustc_intrinsic]
23292357#[ rustc_nounwind]
2330- pub fn round_ties_even_f128 ( x : f128 ) -> f128 ;
2358+ pub const fn round_ties_even_f128 ( x : f128 ) -> f128 ;
23312359
23322360/// Returns the nearest integer to an `f16`. Rounds half-way cases away from zero.
23332361///
23342362/// The stabilized version of this intrinsic is
23352363/// [`f16::round`](../../std/primitive.f16.html#method.round)
23362364#[ rustc_intrinsic]
23372365#[ rustc_nounwind]
2338- pub unsafe fn roundf16 ( x : f16 ) -> f16 ;
2366+ pub const unsafe fn roundf16 ( x : f16 ) -> f16 ;
23392367/// Returns the nearest integer to an `f32`. Rounds half-way cases away from zero.
23402368///
23412369/// The stabilized version of this intrinsic is
23422370/// [`f32::round`](../../std/primitive.f32.html#method.round)
23432371#[ rustc_intrinsic]
23442372#[ rustc_nounwind]
2345- pub unsafe fn roundf32 ( x : f32 ) -> f32 ;
2373+ pub const unsafe fn roundf32 ( x : f32 ) -> f32 ;
23462374/// Returns the nearest integer to an `f64`. Rounds half-way cases away from zero.
23472375///
23482376/// The stabilized version of this intrinsic is
23492377/// [`f64::round`](../../std/primitive.f64.html#method.round)
23502378#[ rustc_intrinsic]
23512379#[ rustc_nounwind]
2352- pub unsafe fn roundf64 ( x : f64 ) -> f64 ;
2380+ pub const unsafe fn roundf64 ( x : f64 ) -> f64 ;
23532381/// Returns the nearest integer to an `f128`. Rounds half-way cases away from zero.
23542382///
23552383/// The stabilized version of this intrinsic is
23562384/// [`f128::round`](../../std/primitive.f128.html#method.round)
23572385#[ rustc_intrinsic]
23582386#[ rustc_nounwind]
2359- pub unsafe fn roundf128 ( x : f128 ) -> f128 ;
2387+ pub const unsafe fn roundf128 ( x : f128 ) -> f128 ;
23602388
23612389/// Float addition that allows optimizations based on algebraic rules.
23622390/// May assume inputs are finite.
@@ -3575,18 +3603,9 @@ pub const fn type_id<T: ?Sized + 'static>() -> u128;
35753603#[ unstable( feature = "core_intrinsics" , issue = "none" ) ]
35763604#[ rustc_intrinsic_const_stable_indirect]
35773605#[ 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 > ;
35903609
35913610/// Lowers in MIR to `Rvalue::UnaryOp` with `UnOp::PtrMetadata`.
35923611///
0 commit comments