Skip to content
This repository was archived by the owner on May 28, 2025. It is now read-only.

Commit f5d1857

Browse files
committedNov 24, 2024·
Auto merge of rust-lang#133415 - matthiaskrgr:rollup-n1ivyd5, r=matthiaskrgr
Rollup of 6 pull requests Successful merges: - rust-lang#133300 (inject_panic_runtime(): Avoid double negation for 'any non rlib') - rust-lang#133301 (Add code example for `wrapping_neg` method for signed integers) - rust-lang#133371 (remove is_trivially_const_drop) - rust-lang#133389 (Stabilize `const_float_methods`) - rust-lang#133398 (rustdoc: do not call to_string, it's already impl Display) - rust-lang#133405 (tidy: Distinguish between two different meanings of "style file") r? `@ghost` `@rustbot` modify labels: rollup
2 parents ab3cf26 + 3ccacef commit f5d1857

File tree

15 files changed

+90
-111
lines changed

15 files changed

+90
-111
lines changed
 

‎compiler/rustc_const_eval/src/check_consts/qualifs.rs

Lines changed: 0 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -170,11 +170,6 @@ impl Qualif for NeedsNonConstDrop {
170170

171171
#[instrument(level = "trace", skip(cx), ret)]
172172
fn in_any_value_of_ty<'tcx>(cx: &ConstCx<'_, 'tcx>, ty: Ty<'tcx>) -> bool {
173-
// Avoid selecting for simple cases, such as builtin types.
174-
if ty::util::is_trivially_const_drop(ty) {
175-
return false;
176-
}
177-
178173
// If this doesn't need drop at all, then don't select `~const Destruct`.
179174
if !ty.needs_drop(cx.tcx, cx.typing_env) {
180175
return false;

‎compiler/rustc_metadata/src/creader.rs

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -724,8 +724,8 @@ impl<'a, 'tcx> CrateLoader<'a, 'tcx> {
724724
fn inject_panic_runtime(&mut self, krate: &ast::Crate) {
725725
// If we're only compiling an rlib, then there's no need to select a
726726
// panic runtime, so we just skip this section entirely.
727-
let any_non_rlib = self.tcx.crate_types().iter().any(|ct| *ct != CrateType::Rlib);
728-
if !any_non_rlib {
727+
let only_rlib = self.tcx.crate_types().iter().all(|ct| *ct == CrateType::Rlib);
728+
if only_rlib {
729729
info!("panic runtime injection skipped, only generating rlib");
730730
return;
731731
}

‎compiler/rustc_middle/src/ty/util.rs

Lines changed: 0 additions & 39 deletions
Original file line numberDiff line numberDiff line change
@@ -1672,45 +1672,6 @@ pub fn needs_drop_components_with_async<'tcx>(
16721672
}
16731673
}
16741674

1675-
pub fn is_trivially_const_drop(ty: Ty<'_>) -> bool {
1676-
match *ty.kind() {
1677-
ty::Bool
1678-
| ty::Char
1679-
| ty::Int(_)
1680-
| ty::Uint(_)
1681-
| ty::Float(_)
1682-
| ty::Infer(ty::IntVar(_))
1683-
| ty::Infer(ty::FloatVar(_))
1684-
| ty::Str
1685-
| ty::RawPtr(_, _)
1686-
| ty::Ref(..)
1687-
| ty::FnDef(..)
1688-
| ty::FnPtr(..)
1689-
| ty::Never
1690-
| ty::Foreign(_) => true,
1691-
1692-
ty::Alias(..)
1693-
| ty::Dynamic(..)
1694-
| ty::Error(_)
1695-
| ty::Bound(..)
1696-
| ty::Param(_)
1697-
| ty::Placeholder(_)
1698-
| ty::Infer(_) => false,
1699-
1700-
// Not trivial because they have components, and instead of looking inside,
1701-
// we'll just perform trait selection.
1702-
ty::Closure(..)
1703-
| ty::CoroutineClosure(..)
1704-
| ty::Coroutine(..)
1705-
| ty::CoroutineWitness(..)
1706-
| ty::Adt(..) => false,
1707-
1708-
ty::Array(ty, _) | ty::Slice(ty) | ty::Pat(ty, _) => is_trivially_const_drop(ty),
1709-
1710-
ty::Tuple(tys) => tys.iter().all(|ty| is_trivially_const_drop(ty)),
1711-
}
1712-
}
1713-
17141675
/// Does the equivalent of
17151676
/// ```ignore (illustrative)
17161677
/// let v = self.iter().map(|p| p.fold_with(folder)).collect::<SmallVec<[_; 8]>>();

‎library/core/src/intrinsics/mod.rs

Lines changed: 40 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -4267,7 +4267,11 @@ pub const fn minnumf16(_x: f16, _y: f16) -> f16 {
42674267
/// The stabilized version of this intrinsic is
42684268
/// [`f32::min`]
42694269
#[rustc_nounwind]
4270-
#[cfg_attr(bootstrap, rustc_const_unstable(feature = "const_float_methods", issue = "130843"))]
4270+
#[cfg_attr(
4271+
bootstrap,
4272+
rustc_const_stable(feature = "const_float_methods", since = "CURRENT_RUSTC_VERSION")
4273+
)]
4274+
#[cfg_attr(not(bootstrap), rustc_intrinsic_const_stable_indirect)]
42714275
#[rustc_intrinsic]
42724276
#[rustc_intrinsic_must_be_overridden]
42734277
pub const fn minnumf32(_x: f32, _y: f32) -> f32 {
@@ -4284,7 +4288,11 @@ pub const fn minnumf32(_x: f32, _y: f32) -> f32 {
42844288
/// The stabilized version of this intrinsic is
42854289
/// [`f64::min`]
42864290
#[rustc_nounwind]
4287-
#[cfg_attr(bootstrap, rustc_const_unstable(feature = "const_float_methods", issue = "130843"))]
4291+
#[cfg_attr(
4292+
bootstrap,
4293+
rustc_const_stable(feature = "const_float_methods", since = "CURRENT_RUSTC_VERSION")
4294+
)]
4295+
#[cfg_attr(not(bootstrap), rustc_intrinsic_const_stable_indirect)]
42884296
#[rustc_intrinsic]
42894297
#[rustc_intrinsic_must_be_overridden]
42904298
pub const fn minnumf64(_x: f64, _y: f64) -> f64 {
@@ -4335,7 +4343,11 @@ pub const fn maxnumf16(_x: f16, _y: f16) -> f16 {
43354343
/// The stabilized version of this intrinsic is
43364344
/// [`f32::max`]
43374345
#[rustc_nounwind]
4338-
#[cfg_attr(bootstrap, rustc_const_unstable(feature = "const_float_methods", issue = "130843"))]
4346+
#[cfg_attr(
4347+
bootstrap,
4348+
rustc_const_stable(feature = "const_float_methods", since = "CURRENT_RUSTC_VERSION")
4349+
)]
4350+
#[cfg_attr(not(bootstrap), rustc_intrinsic_const_stable_indirect)]
43394351
#[rustc_intrinsic]
43404352
#[rustc_intrinsic_must_be_overridden]
43414353
pub const fn maxnumf32(_x: f32, _y: f32) -> f32 {
@@ -4352,7 +4364,11 @@ pub const fn maxnumf32(_x: f32, _y: f32) -> f32 {
43524364
/// The stabilized version of this intrinsic is
43534365
/// [`f64::max`]
43544366
#[rustc_nounwind]
4355-
#[cfg_attr(bootstrap, rustc_const_unstable(feature = "const_float_methods", issue = "130843"))]
4367+
#[cfg_attr(
4368+
bootstrap,
4369+
rustc_const_stable(feature = "const_float_methods", since = "CURRENT_RUSTC_VERSION")
4370+
)]
4371+
#[cfg_attr(not(bootstrap), rustc_intrinsic_const_stable_indirect)]
43564372
#[rustc_intrinsic]
43574373
#[rustc_intrinsic_must_be_overridden]
43584374
pub const fn maxnumf64(_x: f64, _y: f64) -> f64 {
@@ -4393,7 +4409,11 @@ pub const unsafe fn fabsf16(_x: f16) -> f16 {
43934409
/// The stabilized version of this intrinsic is
43944410
/// [`f32::abs`](../../std/primitive.f32.html#method.abs)
43954411
#[rustc_nounwind]
4396-
#[cfg_attr(bootstrap, rustc_const_unstable(feature = "const_float_methods", issue = "130843"))]
4412+
#[cfg_attr(
4413+
bootstrap,
4414+
rustc_const_stable(feature = "const_float_methods", since = "CURRENT_RUSTC_VERSION")
4415+
)]
4416+
#[cfg_attr(not(bootstrap), rustc_intrinsic_const_stable_indirect)]
43974417
#[rustc_intrinsic]
43984418
#[rustc_intrinsic_must_be_overridden]
43994419
pub const unsafe fn fabsf32(_x: f32) -> f32 {
@@ -4405,7 +4425,11 @@ pub const unsafe fn fabsf32(_x: f32) -> f32 {
44054425
/// The stabilized version of this intrinsic is
44064426
/// [`f64::abs`](../../std/primitive.f64.html#method.abs)
44074427
#[rustc_nounwind]
4408-
#[cfg_attr(bootstrap, rustc_const_unstable(feature = "const_float_methods", issue = "130843"))]
4428+
#[cfg_attr(
4429+
bootstrap,
4430+
rustc_const_stable(feature = "const_float_methods", since = "CURRENT_RUSTC_VERSION")
4431+
)]
4432+
#[cfg_attr(not(bootstrap), rustc_intrinsic_const_stable_indirect)]
44094433
#[rustc_intrinsic]
44104434
#[rustc_intrinsic_must_be_overridden]
44114435
pub const unsafe fn fabsf64(_x: f64) -> f64 {
@@ -4441,7 +4465,11 @@ pub const unsafe fn copysignf16(_x: f16, _y: f16) -> f16 {
44414465
/// The stabilized version of this intrinsic is
44424466
/// [`f32::copysign`](../../std/primitive.f32.html#method.copysign)
44434467
#[rustc_nounwind]
4444-
#[cfg_attr(bootstrap, rustc_const_unstable(feature = "const_float_methods", issue = "130843"))]
4468+
#[cfg_attr(
4469+
bootstrap,
4470+
rustc_const_stable(feature = "const_float_methods", since = "CURRENT_RUSTC_VERSION")
4471+
)]
4472+
#[cfg_attr(not(bootstrap), rustc_intrinsic_const_stable_indirect)]
44454473
#[rustc_intrinsic]
44464474
#[rustc_intrinsic_must_be_overridden]
44474475
pub const unsafe fn copysignf32(_x: f32, _y: f32) -> f32 {
@@ -4452,7 +4480,11 @@ pub const unsafe fn copysignf32(_x: f32, _y: f32) -> f32 {
44524480
/// The stabilized version of this intrinsic is
44534481
/// [`f64::copysign`](../../std/primitive.f64.html#method.copysign)
44544482
#[rustc_nounwind]
4455-
#[cfg_attr(bootstrap, rustc_const_unstable(feature = "const_float_methods", issue = "130843"))]
4483+
#[cfg_attr(
4484+
bootstrap,
4485+
rustc_const_stable(feature = "const_float_methods", since = "CURRENT_RUSTC_VERSION")
4486+
)]
4487+
#[cfg_attr(not(bootstrap), rustc_intrinsic_const_stable_indirect)]
44564488
#[rustc_intrinsic]
44574489
#[rustc_intrinsic_must_be_overridden]
44584490
pub const unsafe fn copysignf64(_x: f64, _y: f64) -> f64 {

‎library/core/src/lib.rs

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -118,7 +118,6 @@
118118
#![feature(const_black_box)]
119119
#![feature(const_eq_ignore_ascii_case)]
120120
#![feature(const_eval_select)]
121-
#![feature(const_float_methods)]
122121
#![feature(const_heap)]
123122
#![feature(const_nonnull_new)]
124123
#![feature(const_ptr_sub_ptr)]

‎library/core/src/num/f128.rs

Lines changed: 6 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -334,7 +334,7 @@ impl f128 {
334334
#[inline]
335335
#[must_use]
336336
#[unstable(feature = "f128", issue = "116909")]
337-
#[rustc_allow_const_fn_unstable(const_float_methods)] // for `abs`
337+
#[rustc_const_unstable(feature = "f128", issue = "116909")]
338338
pub const fn is_finite(self) -> bool {
339339
// There's no need to handle NaN separately: if self is NaN,
340340
// the comparison is not true, exactly as desired.
@@ -612,7 +612,6 @@ impl f128 {
612612
/// ```
613613
#[inline]
614614
#[unstable(feature = "f128", issue = "116909")]
615-
#[rustc_const_unstable(feature = "const_float_methods", issue = "130843")]
616615
#[must_use = "this returns the result of the operation, without modifying the original"]
617616
pub const fn recip(self) -> Self {
618617
1.0 / self
@@ -633,7 +632,6 @@ impl f128 {
633632
/// ```
634633
#[inline]
635634
#[unstable(feature = "f128", issue = "116909")]
636-
#[rustc_const_unstable(feature = "const_float_methods", issue = "130843")]
637635
#[must_use = "this returns the result of the operation, without modifying the original"]
638636
pub const fn to_degrees(self) -> Self {
639637
// Use a literal for better precision.
@@ -657,7 +655,6 @@ impl f128 {
657655
/// ```
658656
#[inline]
659657
#[unstable(feature = "f128", issue = "116909")]
660-
#[rustc_const_unstable(feature = "const_float_methods", issue = "130843")]
661658
#[must_use = "this returns the result of the operation, without modifying the original"]
662659
pub const fn to_radians(self) -> f128 {
663660
// Use a literal for better precision.
@@ -686,7 +683,7 @@ impl f128 {
686683
/// ```
687684
#[inline]
688685
#[unstable(feature = "f128", issue = "116909")]
689-
#[rustc_const_unstable(feature = "const_float_methods", issue = "130843")]
686+
#[rustc_const_unstable(feature = "f128", issue = "116909")]
690687
#[must_use = "this returns the result of the comparison, without modifying either input"]
691688
pub const fn max(self, other: f128) -> f128 {
692689
intrinsics::maxnumf128(self, other)
@@ -712,7 +709,7 @@ impl f128 {
712709
/// ```
713710
#[inline]
714711
#[unstable(feature = "f128", issue = "116909")]
715-
#[rustc_const_unstable(feature = "const_float_methods", issue = "130843")]
712+
#[rustc_const_unstable(feature = "f128", issue = "116909")]
716713
#[must_use = "this returns the result of the comparison, without modifying either input"]
717714
pub const fn min(self, other: f128) -> f128 {
718715
intrinsics::minnumf128(self, other)
@@ -1251,7 +1248,6 @@ impl f128 {
12511248
/// ```
12521249
#[inline]
12531250
#[unstable(feature = "f128", issue = "116909")]
1254-
#[rustc_const_unstable(feature = "const_float_methods", issue = "130843")]
12551251
#[must_use = "method returns a new number and does not mutate the original value"]
12561252
pub const fn clamp(mut self, min: f128, max: f128) -> f128 {
12571253
const_assert!(
@@ -1292,7 +1288,7 @@ impl f128 {
12921288
/// ```
12931289
#[inline]
12941290
#[unstable(feature = "f128", issue = "116909")]
1295-
#[rustc_const_unstable(feature = "const_float_methods", issue = "130843")]
1291+
#[rustc_const_unstable(feature = "f128", issue = "116909")]
12961292
#[must_use = "method returns a new number and does not mutate the original value"]
12971293
pub const fn abs(self) -> Self {
12981294
// FIXME(f16_f128): replace with `intrinsics::fabsf128` when available
@@ -1322,7 +1318,7 @@ impl f128 {
13221318
/// ```
13231319
#[inline]
13241320
#[unstable(feature = "f128", issue = "116909")]
1325-
#[rustc_const_unstable(feature = "const_float_methods", issue = "130843")]
1321+
#[rustc_const_unstable(feature = "f128", issue = "116909")]
13261322
#[must_use = "method returns a new number and does not mutate the original value"]
13271323
pub const fn signum(self) -> f128 {
13281324
if self.is_nan() { Self::NAN } else { 1.0_f128.copysign(self) }
@@ -1360,7 +1356,7 @@ impl f128 {
13601356
/// ```
13611357
#[inline]
13621358
#[unstable(feature = "f128", issue = "116909")]
1363-
#[rustc_const_unstable(feature = "const_float_methods", issue = "130843")]
1359+
#[rustc_const_unstable(feature = "f128", issue = "116909")]
13641360
#[must_use = "method returns a new number and does not mutate the original value"]
13651361
pub const fn copysign(self, sign: f128) -> f128 {
13661362
// SAFETY: this is actually a safe intrinsic

‎library/core/src/num/f16.rs

Lines changed: 6 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -326,7 +326,7 @@ impl f16 {
326326
#[inline]
327327
#[must_use]
328328
#[unstable(feature = "f16", issue = "116909")]
329-
#[rustc_allow_const_fn_unstable(const_float_methods)] // for `abs`
329+
#[rustc_const_unstable(feature = "f16", issue = "116909")]
330330
pub const fn is_finite(self) -> bool {
331331
// There's no need to handle NaN separately: if self is NaN,
332332
// the comparison is not true, exactly as desired.
@@ -605,7 +605,6 @@ impl f16 {
605605
/// ```
606606
#[inline]
607607
#[unstable(feature = "f16", issue = "116909")]
608-
#[rustc_const_unstable(feature = "const_float_methods", issue = "130843")]
609608
#[must_use = "this returns the result of the operation, without modifying the original"]
610609
pub const fn recip(self) -> Self {
611610
1.0 / self
@@ -626,7 +625,6 @@ impl f16 {
626625
/// ```
627626
#[inline]
628627
#[unstable(feature = "f16", issue = "116909")]
629-
#[rustc_const_unstable(feature = "const_float_methods", issue = "130843")]
630628
#[must_use = "this returns the result of the operation, without modifying the original"]
631629
pub const fn to_degrees(self) -> Self {
632630
// Use a literal for better precision.
@@ -650,7 +648,6 @@ impl f16 {
650648
/// ```
651649
#[inline]
652650
#[unstable(feature = "f16", issue = "116909")]
653-
#[rustc_const_unstable(feature = "const_float_methods", issue = "130843")]
654651
#[must_use = "this returns the result of the operation, without modifying the original"]
655652
pub const fn to_radians(self) -> f16 {
656653
// Use a literal for better precision.
@@ -677,7 +674,7 @@ impl f16 {
677674
/// ```
678675
#[inline]
679676
#[unstable(feature = "f16", issue = "116909")]
680-
#[rustc_const_unstable(feature = "const_float_methods", issue = "130843")]
677+
#[rustc_const_unstable(feature = "f16", issue = "116909")]
681678
#[must_use = "this returns the result of the comparison, without modifying either input"]
682679
pub const fn max(self, other: f16) -> f16 {
683680
intrinsics::maxnumf16(self, other)
@@ -702,7 +699,7 @@ impl f16 {
702699
/// ```
703700
#[inline]
704701
#[unstable(feature = "f16", issue = "116909")]
705-
#[rustc_const_unstable(feature = "const_float_methods", issue = "130843")]
702+
#[rustc_const_unstable(feature = "f16", issue = "116909")]
706703
#[must_use = "this returns the result of the comparison, without modifying either input"]
707704
pub const fn min(self, other: f16) -> f16 {
708705
intrinsics::minnumf16(self, other)
@@ -1228,7 +1225,6 @@ impl f16 {
12281225
/// ```
12291226
#[inline]
12301227
#[unstable(feature = "f16", issue = "116909")]
1231-
#[rustc_const_unstable(feature = "const_float_methods", issue = "130843")]
12321228
#[must_use = "method returns a new number and does not mutate the original value"]
12331229
pub const fn clamp(mut self, min: f16, max: f16) -> f16 {
12341230
const_assert!(
@@ -1269,7 +1265,7 @@ impl f16 {
12691265
/// ```
12701266
#[inline]
12711267
#[unstable(feature = "f16", issue = "116909")]
1272-
#[rustc_const_unstable(feature = "const_float_methods", issue = "130843")]
1268+
#[rustc_const_unstable(feature = "f16", issue = "116909")]
12731269
#[must_use = "method returns a new number and does not mutate the original value"]
12741270
pub const fn abs(self) -> Self {
12751271
// FIXME(f16_f128): replace with `intrinsics::fabsf16` when available
@@ -1298,7 +1294,7 @@ impl f16 {
12981294
/// ```
12991295
#[inline]
13001296
#[unstable(feature = "f16", issue = "116909")]
1301-
#[rustc_const_unstable(feature = "const_float_methods", issue = "130843")]
1297+
#[rustc_const_unstable(feature = "f16", issue = "116909")]
13021298
#[must_use = "method returns a new number and does not mutate the original value"]
13031299
pub const fn signum(self) -> f16 {
13041300
if self.is_nan() { Self::NAN } else { 1.0_f16.copysign(self) }
@@ -1336,7 +1332,7 @@ impl f16 {
13361332
/// ```
13371333
#[inline]
13381334
#[unstable(feature = "f16", issue = "116909")]
1339-
#[rustc_const_unstable(feature = "const_float_methods", issue = "130843")]
1335+
#[rustc_const_unstable(feature = "f16", issue = "116909")]
13401336
#[must_use = "method returns a new number and does not mutate the original value"]
13411337
pub const fn copysign(self, sign: f16) -> f16 {
13421338
// SAFETY: this is actually a safe intrinsic

‎library/core/src/num/f32.rs

Lines changed: 9 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -569,7 +569,6 @@ impl f32 {
569569
#[stable(feature = "rust1", since = "1.0.0")]
570570
#[rustc_const_stable(feature = "const_float_classify", since = "1.83.0")]
571571
#[inline]
572-
#[rustc_allow_const_fn_unstable(const_float_methods)] // for `abs`
573572
pub const fn is_finite(self) -> bool {
574573
// There's no need to handle NaN separately: if self is NaN,
575574
// the comparison is not true, exactly as desired.
@@ -819,7 +818,7 @@ impl f32 {
819818
/// ```
820819
#[must_use = "this returns the result of the operation, without modifying the original"]
821820
#[stable(feature = "rust1", since = "1.0.0")]
822-
#[rustc_const_unstable(feature = "const_float_methods", issue = "130843")]
821+
#[rustc_const_stable(feature = "const_float_methods", since = "CURRENT_RUSTC_VERSION")]
823822
#[inline]
824823
pub const fn recip(self) -> f32 {
825824
1.0 / self
@@ -837,7 +836,7 @@ impl f32 {
837836
#[must_use = "this returns the result of the operation, \
838837
without modifying the original"]
839838
#[stable(feature = "f32_deg_rad_conversions", since = "1.7.0")]
840-
#[rustc_const_unstable(feature = "const_float_methods", issue = "130843")]
839+
#[rustc_const_stable(feature = "const_float_methods", since = "CURRENT_RUSTC_VERSION")]
841840
#[inline]
842841
pub const fn to_degrees(self) -> f32 {
843842
// Use a constant for better precision.
@@ -857,7 +856,7 @@ impl f32 {
857856
#[must_use = "this returns the result of the operation, \
858857
without modifying the original"]
859858
#[stable(feature = "f32_deg_rad_conversions", since = "1.7.0")]
860-
#[rustc_const_unstable(feature = "const_float_methods", issue = "130843")]
859+
#[rustc_const_stable(feature = "const_float_methods", since = "CURRENT_RUSTC_VERSION")]
861860
#[inline]
862861
pub const fn to_radians(self) -> f32 {
863862
const RADS_PER_DEG: f32 = consts::PI / 180.0;
@@ -879,7 +878,7 @@ impl f32 {
879878
/// ```
880879
#[must_use = "this returns the result of the comparison, without modifying either input"]
881880
#[stable(feature = "rust1", since = "1.0.0")]
882-
#[rustc_const_unstable(feature = "const_float_methods", issue = "130843")]
881+
#[rustc_const_stable(feature = "const_float_methods", since = "CURRENT_RUSTC_VERSION")]
883882
#[inline]
884883
pub const fn max(self, other: f32) -> f32 {
885884
intrinsics::maxnumf32(self, other)
@@ -900,7 +899,7 @@ impl f32 {
900899
/// ```
901900
#[must_use = "this returns the result of the comparison, without modifying either input"]
902901
#[stable(feature = "rust1", since = "1.0.0")]
903-
#[rustc_const_unstable(feature = "const_float_methods", issue = "130843")]
902+
#[rustc_const_stable(feature = "const_float_methods", since = "CURRENT_RUSTC_VERSION")]
904903
#[inline]
905904
pub const fn min(self, other: f32) -> f32 {
906905
intrinsics::minnumf32(self, other)
@@ -1397,7 +1396,7 @@ impl f32 {
13971396
/// ```
13981397
#[must_use = "method returns a new number and does not mutate the original value"]
13991398
#[stable(feature = "clamp", since = "1.50.0")]
1400-
#[rustc_const_unstable(feature = "const_float_methods", issue = "130843")]
1399+
#[rustc_const_stable(feature = "const_float_methods", since = "CURRENT_RUSTC_VERSION")]
14011400
#[inline]
14021401
pub const fn clamp(mut self, min: f32, max: f32) -> f32 {
14031402
const_assert!(
@@ -1434,7 +1433,7 @@ impl f32 {
14341433
/// ```
14351434
#[must_use = "method returns a new number and does not mutate the original value"]
14361435
#[stable(feature = "rust1", since = "1.0.0")]
1437-
#[rustc_const_unstable(feature = "const_float_methods", issue = "130843")]
1436+
#[rustc_const_stable(feature = "const_float_methods", since = "CURRENT_RUSTC_VERSION")]
14381437
#[inline]
14391438
pub const fn abs(self) -> f32 {
14401439
// SAFETY: this is actually a safe intrinsic
@@ -1459,7 +1458,7 @@ impl f32 {
14591458
/// ```
14601459
#[must_use = "method returns a new number and does not mutate the original value"]
14611460
#[stable(feature = "rust1", since = "1.0.0")]
1462-
#[rustc_const_unstable(feature = "const_float_methods", issue = "130843")]
1461+
#[rustc_const_stable(feature = "const_float_methods", since = "CURRENT_RUSTC_VERSION")]
14631462
#[inline]
14641463
pub const fn signum(self) -> f32 {
14651464
if self.is_nan() { Self::NAN } else { 1.0_f32.copysign(self) }
@@ -1494,7 +1493,7 @@ impl f32 {
14941493
#[must_use = "method returns a new number and does not mutate the original value"]
14951494
#[inline]
14961495
#[stable(feature = "copysign", since = "1.35.0")]
1497-
#[rustc_const_unstable(feature = "const_float_methods", issue = "130843")]
1496+
#[rustc_const_stable(feature = "const_float_methods", since = "CURRENT_RUSTC_VERSION")]
14981497
pub const fn copysign(self, sign: f32) -> f32 {
14991498
// SAFETY: this is actually a safe intrinsic
15001499
unsafe { intrinsics::copysignf32(self, sign) }

‎library/core/src/num/f64.rs

Lines changed: 9 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -568,7 +568,6 @@ impl f64 {
568568
#[stable(feature = "rust1", since = "1.0.0")]
569569
#[rustc_const_stable(feature = "const_float_classify", since = "1.83.0")]
570570
#[inline]
571-
#[rustc_allow_const_fn_unstable(const_float_methods)] // for `abs`
572571
pub const fn is_finite(self) -> bool {
573572
// There's no need to handle NaN separately: if self is NaN,
574573
// the comparison is not true, exactly as desired.
@@ -836,7 +835,7 @@ impl f64 {
836835
/// ```
837836
#[must_use = "this returns the result of the operation, without modifying the original"]
838837
#[stable(feature = "rust1", since = "1.0.0")]
839-
#[rustc_const_unstable(feature = "const_float_methods", issue = "130843")]
838+
#[rustc_const_stable(feature = "const_float_methods", since = "CURRENT_RUSTC_VERSION")]
840839
#[inline]
841840
pub const fn recip(self) -> f64 {
842841
1.0 / self
@@ -854,7 +853,7 @@ impl f64 {
854853
#[must_use = "this returns the result of the operation, \
855854
without modifying the original"]
856855
#[stable(feature = "rust1", since = "1.0.0")]
857-
#[rustc_const_unstable(feature = "const_float_methods", issue = "130843")]
856+
#[rustc_const_stable(feature = "const_float_methods", since = "CURRENT_RUSTC_VERSION")]
858857
#[inline]
859858
pub const fn to_degrees(self) -> f64 {
860859
// The division here is correctly rounded with respect to the true
@@ -875,7 +874,7 @@ impl f64 {
875874
#[must_use = "this returns the result of the operation, \
876875
without modifying the original"]
877876
#[stable(feature = "rust1", since = "1.0.0")]
878-
#[rustc_const_unstable(feature = "const_float_methods", issue = "130843")]
877+
#[rustc_const_stable(feature = "const_float_methods", since = "CURRENT_RUSTC_VERSION")]
879878
#[inline]
880879
pub const fn to_radians(self) -> f64 {
881880
const RADS_PER_DEG: f64 = consts::PI / 180.0;
@@ -897,7 +896,7 @@ impl f64 {
897896
/// ```
898897
#[must_use = "this returns the result of the comparison, without modifying either input"]
899898
#[stable(feature = "rust1", since = "1.0.0")]
900-
#[rustc_const_unstable(feature = "const_float_methods", issue = "130843")]
899+
#[rustc_const_stable(feature = "const_float_methods", since = "CURRENT_RUSTC_VERSION")]
901900
#[inline]
902901
pub const fn max(self, other: f64) -> f64 {
903902
intrinsics::maxnumf64(self, other)
@@ -918,7 +917,7 @@ impl f64 {
918917
/// ```
919918
#[must_use = "this returns the result of the comparison, without modifying either input"]
920919
#[stable(feature = "rust1", since = "1.0.0")]
921-
#[rustc_const_unstable(feature = "const_float_methods", issue = "130843")]
920+
#[rustc_const_stable(feature = "const_float_methods", since = "CURRENT_RUSTC_VERSION")]
922921
#[inline]
923922
pub const fn min(self, other: f64) -> f64 {
924923
intrinsics::minnumf64(self, other)
@@ -1397,7 +1396,7 @@ impl f64 {
13971396
/// ```
13981397
#[must_use = "method returns a new number and does not mutate the original value"]
13991398
#[stable(feature = "clamp", since = "1.50.0")]
1400-
#[rustc_const_unstable(feature = "const_float_methods", issue = "130843")]
1399+
#[rustc_const_stable(feature = "const_float_methods", since = "CURRENT_RUSTC_VERSION")]
14011400
#[inline]
14021401
pub const fn clamp(mut self, min: f64, max: f64) -> f64 {
14031402
const_assert!(
@@ -1434,7 +1433,7 @@ impl f64 {
14341433
/// ```
14351434
#[must_use = "method returns a new number and does not mutate the original value"]
14361435
#[stable(feature = "rust1", since = "1.0.0")]
1437-
#[rustc_const_unstable(feature = "const_float_methods", issue = "130843")]
1436+
#[rustc_const_stable(feature = "const_float_methods", since = "CURRENT_RUSTC_VERSION")]
14381437
#[inline]
14391438
pub const fn abs(self) -> f64 {
14401439
// SAFETY: this is actually a safe intrinsic
@@ -1459,7 +1458,7 @@ impl f64 {
14591458
/// ```
14601459
#[must_use = "method returns a new number and does not mutate the original value"]
14611460
#[stable(feature = "rust1", since = "1.0.0")]
1462-
#[rustc_const_unstable(feature = "const_float_methods", issue = "130843")]
1461+
#[rustc_const_stable(feature = "const_float_methods", since = "CURRENT_RUSTC_VERSION")]
14631462
#[inline]
14641463
pub const fn signum(self) -> f64 {
14651464
if self.is_nan() { Self::NAN } else { 1.0_f64.copysign(self) }
@@ -1493,7 +1492,7 @@ impl f64 {
14931492
/// ```
14941493
#[must_use = "method returns a new number and does not mutate the original value"]
14951494
#[stable(feature = "copysign", since = "1.35.0")]
1496-
#[rustc_const_unstable(feature = "const_float_methods", issue = "130843")]
1495+
#[rustc_const_stable(feature = "const_float_methods", since = "CURRENT_RUSTC_VERSION")]
14971496
#[inline]
14981497
pub const fn copysign(self, sign: f64) -> f64 {
14991498
// SAFETY: this is actually a safe intrinsic

‎library/core/src/num/int_macros.rs

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -2101,6 +2101,7 @@ macro_rules! int_impl {
21012101
///
21022102
/// ```
21032103
#[doc = concat!("assert_eq!(100", stringify!($SelfT), ".wrapping_neg(), -100);")]
2104+
#[doc = concat!("assert_eq!((-100", stringify!($SelfT), ").wrapping_neg(), 100);")]
21042105
#[doc = concat!("assert_eq!(", stringify!($SelfT), "::MIN.wrapping_neg(), ", stringify!($SelfT), "::MIN);")]
21052106
/// ```
21062107
#[stable(feature = "num_wrapping", since = "1.2.0")]

‎library/std/src/lib.rs

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -288,7 +288,6 @@
288288
#![feature(cfg_target_thread_local)]
289289
#![feature(cfi_encoding)]
290290
#![feature(concat_idents)]
291-
#![feature(const_float_methods)]
292291
#![feature(decl_macro)]
293292
#![feature(deprecated_suggestion)]
294293
#![feature(doc_cfg)]

‎src/librustdoc/html/format.rs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1296,7 +1296,7 @@ impl clean::Impl {
12961296
self.print_type(inner_type, f, use_absolute, cx)?;
12971297
write!(f, ">")?;
12981298
} else {
1299-
write!(f, "{}&lt;", anchor(ty.def_id(), last, cx).to_string())?;
1299+
write!(f, "{}&lt;", anchor(ty.def_id(), last, cx))?;
13001300
self.print_type(inner_type, f, use_absolute, cx)?;
13011301
write!(f, "&gt;")?;
13021302
}

‎src/tools/clippy/clippy_utils/src/qualify_min_const_fn.rs

Lines changed: 3 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -404,12 +404,11 @@ fn is_ty_const_destruct<'tcx>(tcx: TyCtxt<'tcx>, ty: Ty<'tcx>, body: &Body<'tcx>
404404
// FIXME(const_trait_impl, fee1-dead) revert to const destruct once it works again
405405
#[expect(unused)]
406406
fn is_ty_const_destruct_unused<'tcx>(tcx: TyCtxt<'tcx>, ty: Ty<'tcx>, body: &Body<'tcx>) -> bool {
407-
// Avoid selecting for simple cases, such as builtin types.
408-
if ty::util::is_trivially_const_drop(ty) {
409-
return true;
407+
// If this doesn't need drop at all, then don't select `~const Destruct`.
408+
if !ty.needs_drop(tcx, body.typing_env(tcx)) {
409+
return false;
410410
}
411411

412-
413412
let (infcx, param_env) =
414413
tcx.infer_ctxt().build_with_typing_env(body.typing_env(tcx));
415414
// FIXME(const_trait_impl) constness

‎src/tools/tidy/src/style.rs

Lines changed: 13 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -337,12 +337,16 @@ pub fn check(path: &Path, bad: &mut bool) {
337337
.case_insensitive(true)
338338
.build()
339339
.unwrap();
340-
let style_file = Path::new(file!());
340+
341+
// In some cases, a style check would be triggered by its own implementation
342+
// or comments. A simple workaround is to just allowlist this file.
343+
let this_file = Path::new(file!());
344+
341345
walk(path, skip, &mut |entry, contents| {
342346
let file = entry.path();
343347
let filename = file.file_name().unwrap().to_string_lossy();
344348

345-
let is_style_file = filename.ends_with(".css");
349+
let is_css_file = filename.ends_with(".css");
346350
let under_rustfmt = filename.ends_with(".rs") &&
347351
// This list should ideally be sourced from rustfmt.toml but we don't want to add a toml
348352
// parser to tidy.
@@ -405,13 +409,13 @@ pub fn check(path: &Path, bad: &mut bool) {
405409
let mut comment_block: Option<(usize, usize)> = None;
406410
let is_test = file.components().any(|c| c.as_os_str() == "tests")
407411
|| file.file_stem().unwrap() == "tests";
408-
let is_style = file.ends_with(style_file) || style_file.ends_with(file);
409-
let is_style_test =
410-
is_test && file.parent().unwrap().ends_with(style_file.with_extension(""));
412+
let is_this_file = file.ends_with(this_file) || this_file.ends_with(file);
413+
let is_test_for_this_file =
414+
is_test && file.parent().unwrap().ends_with(this_file.with_extension(""));
411415
// scanning the whole file for multiple needles at once is more efficient than
412416
// executing lines times needles separate searches.
413417
let any_problematic_line =
414-
!is_style && !is_style_test && problematic_regex.is_match(contents);
418+
!is_this_file && !is_test_for_this_file && problematic_regex.is_match(contents);
415419
for (i, line) in contents.split('\n').enumerate() {
416420
if line.is_empty() {
417421
if i == 0 {
@@ -458,19 +462,19 @@ pub fn check(path: &Path, bad: &mut bool) {
458462
"line longer than {max_columns} chars"
459463
);
460464
}
461-
if !is_style_file && line.contains('\t') {
465+
if !is_css_file && line.contains('\t') {
462466
suppressible_tidy_err!(err, skip_tab, "tab character");
463467
}
464468
if line.ends_with(' ') || line.ends_with('\t') {
465469
suppressible_tidy_err!(err, skip_end_whitespace, "trailing whitespace");
466470
}
467-
if is_style_file && line.starts_with(' ') {
471+
if is_css_file && line.starts_with(' ') {
468472
err("CSS files use tabs for indent");
469473
}
470474
if line.contains('\r') {
471475
suppressible_tidy_err!(err, skip_cr, "CR character");
472476
}
473-
if !is_style {
477+
if !is_this_file {
474478
// Allow using TODO in diagnostic suggestions by marking the
475479
// relevant line with `// ignore-tidy-todo`.
476480
if trimmed.contains("TODO") && !trimmed.contains("ignore-tidy-todo") {

‎tests/ui/consts/const-eval/float_methods.rs

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,6 @@
11
//@ run-pass
22
//! Tests the float intrinsics: min, max, abs, copysign
33
4-
#![feature(const_float_methods)]
54
#![feature(f16, f128)]
65

76
const F16_MIN: f16 = 1.0_f16.min(0.5_f16);

0 commit comments

Comments
 (0)
This repository has been archived.