Add missing const stability attributes
This commit is contained in:
parent
41f84c258a
commit
1911eb8b61
@ -512,6 +512,7 @@ impl<T, const N: usize> [T; N] {
|
||||
|
||||
/// Returns a slice containing the entire array. Equivalent to `&s[..]`.
|
||||
#[stable(feature = "array_as_slice", since = "1.57.0")]
|
||||
#[rustc_const_stable(feature = "array_as_slice", since = "1.57.0")]
|
||||
pub const fn as_slice(&self) -> &[T] {
|
||||
self
|
||||
}
|
||||
|
@ -1959,6 +1959,7 @@ impl<T: ?Sized> UnsafeCell<T> {
|
||||
/// ```
|
||||
#[inline(always)]
|
||||
#[stable(feature = "unsafe_cell_raw_get", since = "1.56.0")]
|
||||
#[rustc_const_stable(feature = "unsafe_cell_raw_get", since = "1.56.0")]
|
||||
pub const fn raw_get(this: *const Self) -> *mut T {
|
||||
// We can just cast the pointer from `UnsafeCell<T>` to `T` because of
|
||||
// #[repr(transparent)]. This exploits libstd's special status, there is
|
||||
|
@ -1064,6 +1064,7 @@ macro_rules! int_impl {
|
||||
///
|
||||
/// ```
|
||||
#[stable(feature = "saturating_div", since = "1.58.0")]
|
||||
#[rustc_const_stable(feature = "saturating_div", since = "1.58.0")]
|
||||
#[must_use = "this returns the result of the operation, \
|
||||
without modifying the original"]
|
||||
#[inline]
|
||||
|
@ -972,6 +972,7 @@ macro_rules! nonzero_unsigned_is_power_of_two {
|
||||
/// ```
|
||||
#[must_use]
|
||||
#[stable(feature = "nonzero_is_power_of_two", since = "1.59.0")]
|
||||
#[rustc_const_stable(feature = "nonzero_is_power_of_two", since = "1.59.0")]
|
||||
#[inline]
|
||||
pub const fn is_power_of_two(self) -> bool {
|
||||
// LLVM 11 normalizes `unchecked_sub(x, 1) & x == 0` to the implementation seen here.
|
||||
|
@ -1132,6 +1132,7 @@ macro_rules! uint_impl {
|
||||
///
|
||||
/// ```
|
||||
#[stable(feature = "saturating_div", since = "1.58.0")]
|
||||
#[rustc_const_stable(feature = "saturating_div", since = "1.58.0")]
|
||||
#[must_use = "this returns the result of the operation, \
|
||||
without modifying the original"]
|
||||
#[inline]
|
||||
|
@ -1,11 +1,12 @@
|
||||
#![feature(staged_api)]
|
||||
#![feature(const_trait_impl)]
|
||||
#![stable(feature = "stable", since = "1.0.0")]
|
||||
|
||||
#[stable(feature = "stable", since = "1.0.0")]
|
||||
pub const fn foo() {} //~ ERROR function has missing const stability attribute
|
||||
|
||||
#[unstable(feature = "unstable", issue = "none")]
|
||||
pub const fn bar() {} // ok for now
|
||||
pub const fn bar() {} // ok because function is unstable
|
||||
|
||||
#[stable(feature = "stable", since = "1.0.0")]
|
||||
pub struct Foo;
|
||||
@ -14,11 +15,12 @@ impl Foo {
|
||||
pub const fn foo() {} //~ ERROR associated function has missing const stability attribute
|
||||
|
||||
#[unstable(feature = "unstable", issue = "none")]
|
||||
pub const fn bar() {} // ok for now
|
||||
pub const fn bar() {} // ok because function is unstable
|
||||
}
|
||||
|
||||
// FIXME When #![feature(const_trait_impl)] is stabilized, add tests for const
|
||||
// trait impls. Right now, a "trait methods cannot be stable const fn" error is
|
||||
// emitted, but that's not in the scope of this test.
|
||||
// FIXME Once #![feature(const_trait_impl)] is allowed to be stable, add a test
|
||||
// for const trait impls. Right now, a "trait methods cannot be stable const fn"
|
||||
// error is emitted. This occurs prior to the lint being tested here, such that
|
||||
// the lint cannot currently be tested on this use case.
|
||||
|
||||
fn main() {}
|
||||
|
@ -1,11 +1,11 @@
|
||||
error: function has missing const stability attribute
|
||||
--> $DIR/missing-const-stability.rs:5:1
|
||||
--> $DIR/missing-const-stability.rs:6:1
|
||||
|
|
||||
LL | pub const fn foo() {}
|
||||
| ^^^^^^^^^^^^^^^^^^^^^
|
||||
|
||||
error: associated function has missing const stability attribute
|
||||
--> $DIR/missing-const-stability.rs:14:5
|
||||
--> $DIR/missing-const-stability.rs:15:5
|
||||
|
|
||||
LL | pub const fn foo() {}
|
||||
| ^^^^^^^^^^^^^^^^^^^^^
|
||||
|
Loading…
x
Reference in New Issue
Block a user