Remove or allow unused features in library doc and tests

This commit is contained in:
mu001999 2026-02-12 11:43:22 +08:00
parent a318a207f0
commit 73c42c1800
20 changed files with 24 additions and 32 deletions

View file

@ -16,7 +16,6 @@
// tidy-alphabetical-start
#![feature(allocator_api)]
#![feature(array_into_iter_constructors)]
#![feature(box_vec_non_null)]
#![feature(char_internals)]
#![feature(const_alloc_error)]
#![feature(const_cmp)]
@ -55,16 +54,12 @@
//
// Language features:
// tidy-alphabetical-start
#![feature(cfg_sanitize)]
#![feature(const_trait_impl)]
#![feature(dropck_eyepatch)]
#![feature(lang_items)]
#![feature(min_specialization)]
#![feature(negative_impls)]
#![feature(never_type)]
#![feature(optimize_attribute)]
#![feature(prelude_import)]
#![feature(rustc_allow_const_fn_unstable)]
#![feature(rustc_attrs)]
#![feature(staged_api)]
#![feature(test)]

View file

@ -3,7 +3,6 @@
#![feature(const_heap)]
#![feature(deque_extend_front)]
#![feature(iter_array_chunks)]
#![feature(wtf8_internals)]
#![feature(cow_is_borrowed)]
#![feature(core_intrinsics)]
#![feature(downcast_unchecked)]
@ -30,8 +29,6 @@
#![feature(string_remove_matches)]
#![feature(const_btree_len)]
#![feature(const_trait_impl)]
#![feature(panic_update_hook)]
#![feature(pointer_is_aligned_to)]
#![feature(test)]
#![feature(thin_box)]
#![feature(drain_keep_rest)]

View file

@ -878,7 +878,7 @@ impl AsciiChar {
/// # Examples
///
/// ```
/// #![feature(ascii_char, ascii_char_variants, is_ascii_octdigit)]
/// #![feature(ascii_char, ascii_char_variants)]
///
/// use std::ascii;
///

View file

@ -774,7 +774,6 @@ impl<T, const N: usize> Cell<[T; N]> {
/// following is unsound:
///
/// ```rust
/// #![feature(cell_get_cloned)]
/// # use std::cell::Cell;
///
/// #[derive(Copy, Debug)]

View file

@ -219,6 +219,7 @@ impl_float_from_bool!(
f16;
doctest_prefix:
// rustdoc doesn't remove the conventional space after the `///`
///# #![allow(unused_features)]
///#![feature(f16)]
///# #[cfg(all(target_arch = "x86_64", target_os = "linux"))] {
///
@ -230,6 +231,7 @@ impl_float_from_bool!(f64);
impl_float_from_bool!(
f128;
doctest_prefix:
///# #![allow(unused_features)]
///#![feature(f128)]
///# #[cfg(all(target_arch = "x86_64", target_os = "linux"))] {
///

View file

@ -148,7 +148,10 @@ pub mod consts {
pub const LN_10: f128 = 2.30258509299404568401799145468436420760110148862877297603333_f128;
}
#[doc(test(attr(feature(cfg_target_has_reliable_f16_f128), allow(internal_features))))]
#[doc(test(attr(
feature(cfg_target_has_reliable_f16_f128),
allow(internal_features, unused_features)
)))]
impl f128 {
/// The radix or base of the internal representation of `f128`.
#[unstable(feature = "f128", issue = "116909")]
@ -1470,7 +1473,11 @@ impl f128 {
// Functions in this module fall into `core_float_math`
// #[unstable(feature = "core_float_math", issue = "137578")]
#[cfg(not(test))]
#[doc(test(attr(feature(cfg_target_has_reliable_f16_f128), expect(internal_features))))]
#[doc(test(attr(
feature(cfg_target_has_reliable_f16_f128),
expect(internal_features),
allow(unused_features)
)))]
impl f128 {
/// Returns the largest integer less than or equal to `self`.
///

View file

@ -142,7 +142,10 @@ pub mod consts {
pub const LN_10: f16 = 2.30258509299404568401799145468436421_f16;
}
#[doc(test(attr(feature(cfg_target_has_reliable_f16_f128), allow(internal_features))))]
#[doc(test(attr(
feature(cfg_target_has_reliable_f16_f128),
allow(internal_features, unused_features)
)))]
impl f16 {
/// The radix or base of the internal representation of `f16`.
#[unstable(feature = "f16", issue = "116909")]

View file

@ -1821,6 +1821,7 @@ pub mod math {
/// # Examples
///
/// ```
/// # #![allow(unused_features)]
/// #![feature(core_float_math)]
///
/// # // FIXME(#140515): mingw has an incorrect fma

View file

@ -1819,6 +1819,7 @@ pub mod math {
/// # Examples
///
/// ```
/// # #![allow(unused_features)]
/// #![feature(core_float_math)]
///
/// # // FIXME(#140515): mingw has an incorrect fma

View file

@ -3072,7 +3072,6 @@ macro_rules! uint_impl {
/// implementing it for wider-than-native types.
///
/// ```
/// #![feature(const_unsigned_bigint_helpers)]
/// fn scalar_mul_eq(little_endian_digits: &mut Vec<u16>, multiplicand: u16) {
/// let mut carry = 0;
/// for d in little_endian_digits.iter_mut() {
@ -3097,6 +3096,7 @@ macro_rules! uint_impl {
/// except that it gives the value of the overflow instead of just whether one happened:
///
/// ```
/// # #![allow(unused_features)]
/// #![feature(const_unsigned_bigint_helpers)]
/// let r = u8::carrying_mul(7, 13, 0);
/// assert_eq!((r.0, r.1 != 0), u8::overflowing_mul(7, 13));
@ -3109,6 +3109,7 @@ macro_rules! uint_impl {
/// [`wrapping_add`](Self::wrapping_add) methods:
///
/// ```
/// # #![allow(unused_features)]
/// #![feature(const_unsigned_bigint_helpers)]
/// assert_eq!(
/// 789_u16.carrying_mul(456, 123).0,

View file

@ -112,7 +112,6 @@ impl Alignment {
///
/// ```
/// #![feature(ptr_alignment_type)]
/// #![feature(layout_for_ptr)]
/// use std::ptr::Alignment;
///
/// assert_eq!(unsafe { Alignment::of_val_raw(&5i32) }.as_usize(), 4);

View file

@ -1800,7 +1800,6 @@ impl<T> *mut [T] {
///
/// ```
/// #![feature(raw_slice_split)]
/// #![feature(slice_ptr_get)]
///
/// let mut v = [1, 0, 3, 0, 5, 6];
/// let ptr = &mut v as *mut [_];

View file

@ -690,7 +690,6 @@ impl Duration {
/// # Examples
///
/// ```
/// #![feature(duration_constants)]
/// use std::time::Duration;
///
/// assert_eq!(Duration::new(0, 0).saturating_add(Duration::new(0, 1)), Duration::new(0, 1));
@ -801,7 +800,6 @@ impl Duration {
/// # Examples
///
/// ```
/// #![feature(duration_constants)]
/// use std::time::Duration;
///
/// assert_eq!(Duration::new(0, 500_000_001).saturating_mul(2), Duration::new(1, 2));

View file

@ -13,7 +13,6 @@
#![feature(cfg_target_has_reliable_f16_f128)]
#![feature(char_internals)]
#![feature(char_max_len)]
#![feature(clamp_magnitude)]
#![feature(clone_to_uninit)]
#![feature(const_array)]
#![feature(const_bool)]
@ -35,7 +34,6 @@
#![feature(const_trait_impl)]
#![feature(const_unsigned_bigint_helpers)]
#![feature(control_flow_ok)]
#![feature(core_float_math)]
#![feature(core_intrinsics)]
#![feature(core_intrinsics_fallbacks)]
#![feature(core_io_borrowed_buf)]
@ -47,7 +45,6 @@
#![feature(drop_guard)]
#![feature(duration_constants)]
#![feature(duration_constructors)]
#![feature(error_generic_member_access)]
#![feature(exact_div)]
#![feature(exact_size_is_empty)]
#![feature(extend_one)]
@ -55,7 +52,6 @@
#![feature(f16)]
#![feature(f128)]
#![feature(float_algebraic)]
#![feature(float_gamma)]
#![feature(float_minimum_maximum)]
#![feature(flt2dec)]
#![feature(fmt_internals)]
@ -94,7 +90,6 @@
#![feature(nonzero_from_str_radix)]
#![feature(numfmt)]
#![feature(one_sided_range)]
#![feature(option_reduce)]
#![feature(pattern)]
#![feature(pointer_is_aligned_to)]
#![feature(portable_simd)]
@ -114,7 +109,6 @@
#![feature(step_trait)]
#![feature(str_internals)]
#![feature(strict_provenance_lints)]
#![feature(test)]
#![feature(trusted_len)]
#![feature(trusted_random_access)]
#![feature(try_blocks)]

View file

@ -16,6 +16,7 @@ use crate::intrinsics;
use crate::sys::cmath;
#[cfg(not(test))]
#[doc(test(attr(allow(unused_features))))]
impl f128 {
/// Raises a number to a floating point power.
///

View file

@ -916,7 +916,6 @@ impl f16 {
///
/// ```
/// #![feature(f16)]
/// #![feature(float_gamma)]
/// # #[cfg(not(miri))]
/// # #[cfg(target_has_reliable_f16_math)] {
///
@ -952,7 +951,6 @@ impl f16 {
///
/// ```
/// #![feature(f16)]
/// #![feature(float_gamma)]
/// # #[cfg(not(miri))]
/// # #[cfg(target_has_reliable_f16_math)] {
///
@ -988,7 +986,6 @@ impl f16 {
///
/// ```
/// #![feature(f16)]
/// #![feature(float_erf)]
/// # #[cfg(not(miri))]
/// # #[cfg(target_has_reliable_f16_math)] {
/// /// The error function relates what percent of a normal distribution lies
@ -1028,7 +1025,6 @@ impl f16 {
///
/// ```
/// #![feature(f16)]
/// #![feature(float_erf)]
/// # #[cfg(not(miri))]
/// # #[cfg(target_has_reliable_f16_math)] {
/// let x: f16 = 0.123;

View file

@ -1,4 +1,4 @@
#![feature(f16, f128, float_gamma, float_minimum_maximum, cfg_target_has_reliable_f16_f128)]
#![feature(f16, f128, float_gamma, cfg_target_has_reliable_f16_f128)]
#![expect(internal_features)] // for reliable_f16_f128
use std::fmt;

View file

@ -1,5 +1,4 @@
#![allow(stable_features)]
#![feature(volatile)]
use std::ptr::{read_volatile, write_volatile};

View file

@ -1,4 +1,4 @@
#![allow(internal_features)]
#![allow(internal_features, unused_features)]
#![feature(stdarch_internal)]
#![cfg_attr(target_arch = "arm", feature(stdarch_arm_feature_detection))]
#![cfg_attr(

View file

@ -1,4 +1,4 @@
#![allow(internal_features)]
#![allow(internal_features, unused_features)]
#![cfg_attr(
any(
target_arch = "arm",