Skip to content

Commit e29a153

Browse files
committed
Auto merge of rust-lang#121295 - matthiaskrgr:rollup-j2vffew, r=matthiaskrgr
Rollup of 6 pull requests Successful merges: - rust-lang#119808 (Store core::str::CharSearcher::utf8_size as u8) - rust-lang#121032 (Continue reporting remaining errors instead of silently dropping them) - rust-lang#121041 (Add `Future` and `IntoFuture` to the 2024 prelude) - rust-lang#121230 (Extend Level API) - rust-lang#121272 (Add diagnostic items for legacy numeric constants) - rust-lang#121275 (add test for panicking attribute macros) r? `@ghost` `@rustbot` modify labels: rollup
2 parents 43d3470 + 3fe809b commit e29a153

File tree

17 files changed

+150
-35
lines changed

17 files changed

+150
-35
lines changed

compiler/rustc_hir_typeck/src/fn_ctxt/checks.rs

+3-2
Original file line numberDiff line numberDiff line change
@@ -740,8 +740,9 @@ impl<'a, 'tcx> FnCtxt<'a, 'tcx> {
740740
});
741741

742742
// We're done if we found errors, but we already emitted them.
743-
if let Some(reported) = reported {
744-
assert!(errors.is_empty());
743+
if let Some(reported) = reported
744+
&& errors.is_empty()
745+
{
745746
return reported;
746747
}
747748
assert!(!errors.is_empty());

compiler/rustc_lint_defs/src/lib.rs

+17-13
Original file line numberDiff line numberDiff line change
@@ -227,8 +227,8 @@ impl Level {
227227
}
228228

229229
/// Converts a lower-case string to a level. This will never construct the expect
230-
/// level as that would require a [`LintExpectationId`]
231-
pub fn from_str(x: &str) -> Option<Level> {
230+
/// level as that would require a [`LintExpectationId`].
231+
pub fn from_str(x: &str) -> Option<Self> {
232232
match x {
233233
"allow" => Some(Level::Allow),
234234
"warn" => Some(Level::Warn),
@@ -238,17 +238,21 @@ impl Level {
238238
}
239239
}
240240

241-
/// Converts a symbol to a level.
242-
pub fn from_attr(attr: &Attribute) -> Option<Level> {
243-
match attr.name_or_empty() {
244-
sym::allow => Some(Level::Allow),
245-
sym::expect => Some(Level::Expect(LintExpectationId::Unstable {
246-
attr_id: attr.id,
247-
lint_index: None,
248-
})),
249-
sym::warn => Some(Level::Warn),
250-
sym::deny => Some(Level::Deny),
251-
sym::forbid => Some(Level::Forbid),
241+
/// Converts an `Attribute` to a level.
242+
pub fn from_attr(attr: &Attribute) -> Option<Self> {
243+
Self::from_symbol(attr.name_or_empty(), Some(attr.id))
244+
}
245+
246+
/// Converts a `Symbol` to a level.
247+
pub fn from_symbol(s: Symbol, id: Option<AttrId>) -> Option<Self> {
248+
match (s, id) {
249+
(sym::allow, _) => Some(Level::Allow),
250+
(sym::expect, Some(attr_id)) => {
251+
Some(Level::Expect(LintExpectationId::Unstable { attr_id, lint_index: None }))
252+
}
253+
(sym::warn, _) => Some(Level::Warn),
254+
(sym::deny, _) => Some(Level::Deny),
255+
(sym::forbid, _) => Some(Level::Forbid),
252256
_ => None,
253257
}
254258
}

library/core/src/num/f32.rs

+14
Original file line numberDiff line numberDiff line change
@@ -32,6 +32,7 @@ use crate::num::FpCategory;
3232
/// ```
3333
#[stable(feature = "rust1", since = "1.0.0")]
3434
#[deprecated(since = "TBD", note = "replaced by the `RADIX` associated constant on `f32`")]
35+
#[rustc_diagnostic_item = "f32_legacy_const_radix"]
3536
pub const RADIX: u32 = f32::RADIX;
3637

3738
/// Number of significant digits in base 2.
@@ -52,6 +53,7 @@ pub const RADIX: u32 = f32::RADIX;
5253
since = "TBD",
5354
note = "replaced by the `MANTISSA_DIGITS` associated constant on `f32`"
5455
)]
56+
#[rustc_diagnostic_item = "f32_legacy_const_mantissa_dig"]
5557
pub const MANTISSA_DIGITS: u32 = f32::MANTISSA_DIGITS;
5658

5759
/// Approximate number of significant digits in base 10.
@@ -69,6 +71,7 @@ pub const MANTISSA_DIGITS: u32 = f32::MANTISSA_DIGITS;
6971
/// ```
7072
#[stable(feature = "rust1", since = "1.0.0")]
7173
#[deprecated(since = "TBD", note = "replaced by the `DIGITS` associated constant on `f32`")]
74+
#[rustc_diagnostic_item = "f32_legacy_const_digits"]
7275
pub const DIGITS: u32 = f32::DIGITS;
7376

7477
/// [Machine epsilon] value for `f32`.
@@ -90,6 +93,7 @@ pub const DIGITS: u32 = f32::DIGITS;
9093
/// ```
9194
#[stable(feature = "rust1", since = "1.0.0")]
9295
#[deprecated(since = "TBD", note = "replaced by the `EPSILON` associated constant on `f32`")]
96+
#[rustc_diagnostic_item = "f32_legacy_const_epsilon"]
9397
pub const EPSILON: f32 = f32::EPSILON;
9498

9599
/// Smallest finite `f32` value.
@@ -107,6 +111,7 @@ pub const EPSILON: f32 = f32::EPSILON;
107111
/// ```
108112
#[stable(feature = "rust1", since = "1.0.0")]
109113
#[deprecated(since = "TBD", note = "replaced by the `MIN` associated constant on `f32`")]
114+
#[rustc_diagnostic_item = "f32_legacy_const_min"]
110115
pub const MIN: f32 = f32::MIN;
111116

112117
/// Smallest positive normal `f32` value.
@@ -124,6 +129,7 @@ pub const MIN: f32 = f32::MIN;
124129
/// ```
125130
#[stable(feature = "rust1", since = "1.0.0")]
126131
#[deprecated(since = "TBD", note = "replaced by the `MIN_POSITIVE` associated constant on `f32`")]
132+
#[rustc_diagnostic_item = "f32_legacy_const_min_positive"]
127133
pub const MIN_POSITIVE: f32 = f32::MIN_POSITIVE;
128134

129135
/// Largest finite `f32` value.
@@ -141,6 +147,7 @@ pub const MIN_POSITIVE: f32 = f32::MIN_POSITIVE;
141147
/// ```
142148
#[stable(feature = "rust1", since = "1.0.0")]
143149
#[deprecated(since = "TBD", note = "replaced by the `MAX` associated constant on `f32`")]
150+
#[rustc_diagnostic_item = "f32_legacy_const_max"]
144151
pub const MAX: f32 = f32::MAX;
145152

146153
/// One greater than the minimum possible normal power of 2 exponent.
@@ -158,6 +165,7 @@ pub const MAX: f32 = f32::MAX;
158165
/// ```
159166
#[stable(feature = "rust1", since = "1.0.0")]
160167
#[deprecated(since = "TBD", note = "replaced by the `MIN_EXP` associated constant on `f32`")]
168+
#[rustc_diagnostic_item = "f32_legacy_const_min_exp"]
161169
pub const MIN_EXP: i32 = f32::MIN_EXP;
162170

163171
/// Maximum possible power of 2 exponent.
@@ -175,6 +183,7 @@ pub const MIN_EXP: i32 = f32::MIN_EXP;
175183
/// ```
176184
#[stable(feature = "rust1", since = "1.0.0")]
177185
#[deprecated(since = "TBD", note = "replaced by the `MAX_EXP` associated constant on `f32`")]
186+
#[rustc_diagnostic_item = "f32_legacy_const_max_exp"]
178187
pub const MAX_EXP: i32 = f32::MAX_EXP;
179188

180189
/// Minimum possible normal power of 10 exponent.
@@ -192,6 +201,7 @@ pub const MAX_EXP: i32 = f32::MAX_EXP;
192201
/// ```
193202
#[stable(feature = "rust1", since = "1.0.0")]
194203
#[deprecated(since = "TBD", note = "replaced by the `MIN_10_EXP` associated constant on `f32`")]
204+
#[rustc_diagnostic_item = "f32_legacy_const_min_10_exp"]
195205
pub const MIN_10_EXP: i32 = f32::MIN_10_EXP;
196206

197207
/// Maximum possible power of 10 exponent.
@@ -209,6 +219,7 @@ pub const MIN_10_EXP: i32 = f32::MIN_10_EXP;
209219
/// ```
210220
#[stable(feature = "rust1", since = "1.0.0")]
211221
#[deprecated(since = "TBD", note = "replaced by the `MAX_10_EXP` associated constant on `f32`")]
222+
#[rustc_diagnostic_item = "f32_legacy_const_max_10_exp"]
212223
pub const MAX_10_EXP: i32 = f32::MAX_10_EXP;
213224

214225
/// Not a Number (NaN).
@@ -226,6 +237,7 @@ pub const MAX_10_EXP: i32 = f32::MAX_10_EXP;
226237
/// ```
227238
#[stable(feature = "rust1", since = "1.0.0")]
228239
#[deprecated(since = "TBD", note = "replaced by the `NAN` associated constant on `f32`")]
240+
#[rustc_diagnostic_item = "f32_legacy_const_nan"]
229241
pub const NAN: f32 = f32::NAN;
230242

231243
/// Infinity (∞).
@@ -243,6 +255,7 @@ pub const NAN: f32 = f32::NAN;
243255
/// ```
244256
#[stable(feature = "rust1", since = "1.0.0")]
245257
#[deprecated(since = "TBD", note = "replaced by the `INFINITY` associated constant on `f32`")]
258+
#[rustc_diagnostic_item = "f32_legacy_const_infinity"]
246259
pub const INFINITY: f32 = f32::INFINITY;
247260

248261
/// Negative infinity (−∞).
@@ -260,6 +273,7 @@ pub const INFINITY: f32 = f32::INFINITY;
260273
/// ```
261274
#[stable(feature = "rust1", since = "1.0.0")]
262275
#[deprecated(since = "TBD", note = "replaced by the `NEG_INFINITY` associated constant on `f32`")]
276+
#[rustc_diagnostic_item = "f32_legacy_const_neg_infinity"]
263277
pub const NEG_INFINITY: f32 = f32::NEG_INFINITY;
264278

265279
/// Basic mathematical constants.

library/core/src/num/f64.rs

+14
Original file line numberDiff line numberDiff line change
@@ -32,6 +32,7 @@ use crate::num::FpCategory;
3232
/// ```
3333
#[stable(feature = "rust1", since = "1.0.0")]
3434
#[deprecated(since = "TBD", note = "replaced by the `RADIX` associated constant on `f64`")]
35+
#[rustc_diagnostic_item = "f64_legacy_const_radix"]
3536
pub const RADIX: u32 = f64::RADIX;
3637

3738
/// Number of significant digits in base 2.
@@ -52,6 +53,7 @@ pub const RADIX: u32 = f64::RADIX;
5253
since = "TBD",
5354
note = "replaced by the `MANTISSA_DIGITS` associated constant on `f64`"
5455
)]
56+
#[rustc_diagnostic_item = "f64_legacy_const_mantissa_dig"]
5557
pub const MANTISSA_DIGITS: u32 = f64::MANTISSA_DIGITS;
5658

5759
/// Approximate number of significant digits in base 10.
@@ -69,6 +71,7 @@ pub const MANTISSA_DIGITS: u32 = f64::MANTISSA_DIGITS;
6971
/// ```
7072
#[stable(feature = "rust1", since = "1.0.0")]
7173
#[deprecated(since = "TBD", note = "replaced by the `DIGITS` associated constant on `f64`")]
74+
#[rustc_diagnostic_item = "f64_legacy_const_digits"]
7275
pub const DIGITS: u32 = f64::DIGITS;
7376

7477
/// [Machine epsilon] value for `f64`.
@@ -90,6 +93,7 @@ pub const DIGITS: u32 = f64::DIGITS;
9093
/// ```
9194
#[stable(feature = "rust1", since = "1.0.0")]
9295
#[deprecated(since = "TBD", note = "replaced by the `EPSILON` associated constant on `f64`")]
96+
#[rustc_diagnostic_item = "f64_legacy_const_epsilon"]
9397
pub const EPSILON: f64 = f64::EPSILON;
9498

9599
/// Smallest finite `f64` value.
@@ -107,6 +111,7 @@ pub const EPSILON: f64 = f64::EPSILON;
107111
/// ```
108112
#[stable(feature = "rust1", since = "1.0.0")]
109113
#[deprecated(since = "TBD", note = "replaced by the `MIN` associated constant on `f64`")]
114+
#[rustc_diagnostic_item = "f64_legacy_const_min"]
110115
pub const MIN: f64 = f64::MIN;
111116

112117
/// Smallest positive normal `f64` value.
@@ -124,6 +129,7 @@ pub const MIN: f64 = f64::MIN;
124129
/// ```
125130
#[stable(feature = "rust1", since = "1.0.0")]
126131
#[deprecated(since = "TBD", note = "replaced by the `MIN_POSITIVE` associated constant on `f64`")]
132+
#[rustc_diagnostic_item = "f64_legacy_const_min_positive"]
127133
pub const MIN_POSITIVE: f64 = f64::MIN_POSITIVE;
128134

129135
/// Largest finite `f64` value.
@@ -141,6 +147,7 @@ pub const MIN_POSITIVE: f64 = f64::MIN_POSITIVE;
141147
/// ```
142148
#[stable(feature = "rust1", since = "1.0.0")]
143149
#[deprecated(since = "TBD", note = "replaced by the `MAX` associated constant on `f64`")]
150+
#[rustc_diagnostic_item = "f64_legacy_const_max"]
144151
pub const MAX: f64 = f64::MAX;
145152

146153
/// One greater than the minimum possible normal power of 2 exponent.
@@ -158,6 +165,7 @@ pub const MAX: f64 = f64::MAX;
158165
/// ```
159166
#[stable(feature = "rust1", since = "1.0.0")]
160167
#[deprecated(since = "TBD", note = "replaced by the `MIN_EXP` associated constant on `f64`")]
168+
#[rustc_diagnostic_item = "f64_legacy_const_min_exp"]
161169
pub const MIN_EXP: i32 = f64::MIN_EXP;
162170

163171
/// Maximum possible power of 2 exponent.
@@ -175,6 +183,7 @@ pub const MIN_EXP: i32 = f64::MIN_EXP;
175183
/// ```
176184
#[stable(feature = "rust1", since = "1.0.0")]
177185
#[deprecated(since = "TBD", note = "replaced by the `MAX_EXP` associated constant on `f64`")]
186+
#[rustc_diagnostic_item = "f64_legacy_const_max_exp"]
178187
pub const MAX_EXP: i32 = f64::MAX_EXP;
179188

180189
/// Minimum possible normal power of 10 exponent.
@@ -192,6 +201,7 @@ pub const MAX_EXP: i32 = f64::MAX_EXP;
192201
/// ```
193202
#[stable(feature = "rust1", since = "1.0.0")]
194203
#[deprecated(since = "TBD", note = "replaced by the `MIN_10_EXP` associated constant on `f64`")]
204+
#[rustc_diagnostic_item = "f64_legacy_const_min_10_exp"]
195205
pub const MIN_10_EXP: i32 = f64::MIN_10_EXP;
196206

197207
/// Maximum possible power of 10 exponent.
@@ -209,6 +219,7 @@ pub const MIN_10_EXP: i32 = f64::MIN_10_EXP;
209219
/// ```
210220
#[stable(feature = "rust1", since = "1.0.0")]
211221
#[deprecated(since = "TBD", note = "replaced by the `MAX_10_EXP` associated constant on `f64`")]
222+
#[rustc_diagnostic_item = "f64_legacy_const_max_10_exp"]
212223
pub const MAX_10_EXP: i32 = f64::MAX_10_EXP;
213224

214225
/// Not a Number (NaN).
@@ -226,6 +237,7 @@ pub const MAX_10_EXP: i32 = f64::MAX_10_EXP;
226237
/// ```
227238
#[stable(feature = "rust1", since = "1.0.0")]
228239
#[deprecated(since = "TBD", note = "replaced by the `NAN` associated constant on `f64`")]
240+
#[rustc_diagnostic_item = "f64_legacy_const_nan"]
229241
pub const NAN: f64 = f64::NAN;
230242

231243
/// Infinity (∞).
@@ -243,6 +255,7 @@ pub const NAN: f64 = f64::NAN;
243255
/// ```
244256
#[stable(feature = "rust1", since = "1.0.0")]
245257
#[deprecated(since = "TBD", note = "replaced by the `INFINITY` associated constant on `f64`")]
258+
#[rustc_diagnostic_item = "f64_legacy_const_infinity"]
246259
pub const INFINITY: f64 = f64::INFINITY;
247260

248261
/// Negative infinity (−∞).
@@ -260,6 +273,7 @@ pub const INFINITY: f64 = f64::INFINITY;
260273
/// ```
261274
#[stable(feature = "rust1", since = "1.0.0")]
262275
#[deprecated(since = "TBD", note = "replaced by the `NEG_INFINITY` associated constant on `f64`")]
276+
#[rustc_diagnostic_item = "f64_legacy_const_neg_infinity"]
263277
pub const NEG_INFINITY: f64 = f64::NEG_INFINITY;
264278

265279
/// Basic mathematical constants.

library/core/src/num/int_macros.rs

+2
Original file line numberDiff line numberDiff line change
@@ -3507,6 +3507,7 @@ macro_rules! int_impl {
35073507
#[rustc_promotable]
35083508
#[rustc_const_stable(feature = "const_min_value", since = "1.32.0")]
35093509
#[deprecated(since = "TBD", note = "replaced by the `MIN` associated constant on this type")]
3510+
#[rustc_diagnostic_item = concat!(stringify!($SelfT), "_legacy_fn_min_value")]
35103511
pub const fn min_value() -> Self {
35113512
Self::MIN
35123513
}
@@ -3520,6 +3521,7 @@ macro_rules! int_impl {
35203521
#[rustc_promotable]
35213522
#[rustc_const_stable(feature = "const_max_value", since = "1.32.0")]
35223523
#[deprecated(since = "TBD", note = "replaced by the `MAX` associated constant on this type")]
3524+
#[rustc_diagnostic_item = concat!(stringify!($SelfT), "_legacy_fn_max_value")]
35233525
pub const fn max_value() -> Self {
35243526
Self::MAX
35253527
}

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

+2
Original file line numberDiff line numberDiff line change
@@ -20,6 +20,7 @@ macro_rules! int_module {
2020
///
2121
#[$attr]
2222
#[deprecated(since = "TBD", note = "replaced by the `MIN` associated constant on this type")]
23+
#[rustc_diagnostic_item = concat!(stringify!($T), "_legacy_const_min")]
2324
pub const MIN: $T = $T::MIN;
2425

2526
#[doc = concat!(
@@ -39,6 +40,7 @@ macro_rules! int_module {
3940
///
4041
#[$attr]
4142
#[deprecated(since = "TBD", note = "replaced by the `MAX` associated constant on this type")]
43+
#[rustc_diagnostic_item = concat!(stringify!($T), "_legacy_const_max")]
4244
pub const MAX: $T = $T::MAX;
4345
)
4446
}

library/core/src/prelude/mod.rs

+6-2
Original file line numberDiff line numberDiff line change
@@ -49,9 +49,13 @@ pub mod rust_2021 {
4949
/// The 2024 edition of the core prelude.
5050
///
5151
/// See the [module-level documentation](self) for more.
52-
#[unstable(feature = "prelude_2024", issue = "none")]
52+
#[unstable(feature = "prelude_2024", issue = "121042")]
5353
pub mod rust_2024 {
54-
#[unstable(feature = "prelude_2024", issue = "none")]
54+
#[unstable(feature = "prelude_2024", issue = "121042")]
5555
#[doc(no_inline)]
5656
pub use super::rust_2021::*;
57+
58+
#[unstable(feature = "prelude_2024", issue = "121042")]
59+
#[doc(no_inline)]
60+
pub use crate::future::{Future, IntoFuture};
5761
}

0 commit comments

Comments
 (0)