Skip to content

Commit e29a153

Browse files
committedFeb 19, 2024
Auto merge of #121295 - matthiaskrgr:rollup-j2vffew, r=matthiaskrgr
Rollup of 6 pull requests Successful merges: - #119808 (Store core::str::CharSearcher::utf8_size as u8) - #121032 (Continue reporting remaining errors instead of silently dropping them) - #121041 (Add `Future` and `IntoFuture` to the 2024 prelude) - #121230 (Extend Level API) - #121272 (Add diagnostic items for legacy numeric constants) - #121275 (add test for panicking attribute macros) r? `@ghost` `@rustbot` modify labels: rollup
·
1.88.01.78.0
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

Lines changed: 3 additions & 2 deletions
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

Lines changed: 17 additions & 13 deletions
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

Lines changed: 14 additions & 0 deletions
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

Lines changed: 14 additions & 0 deletions
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

Lines changed: 2 additions & 0 deletions
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

Lines changed: 2 additions & 0 deletions
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

Lines changed: 6 additions & 2 deletions
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
}

‎library/core/src/str/pattern.rs

Lines changed: 23 additions & 11 deletions
Original file line numberDiff line numberDiff line change
@@ -40,6 +40,7 @@
4040

4141
use crate::cmp;
4242
use crate::cmp::Ordering;
43+
use crate::convert::TryInto as _;
4344
use crate::fmt;
4445
use crate::slice::memchr;
4546

@@ -370,11 +371,17 @@ pub struct CharSearcher<'a> {
370371

371372
// safety invariant: `utf8_size` must be less than 5
372373
/// The number of bytes `needle` takes up when encoded in utf8.
373-
utf8_size: usize,
374+
utf8_size: u8,
374375
/// A utf8 encoded copy of the `needle`
375376
utf8_encoded: [u8; 4],
376377
}
377378

379+
impl CharSearcher<'_> {
380+
fn utf8_size(&self) -> usize {
381+
self.utf8_size.into()
382+
}
383+
}
384+
378385
unsafe impl<'a> Searcher<'a> for CharSearcher<'a> {
379386
#[inline]
380387
fn haystack(&self) -> &'a str {
@@ -414,7 +421,7 @@ unsafe impl<'a> Searcher<'a> for CharSearcher<'a> {
414421
let bytes = self.haystack.as_bytes().get(self.finger..self.finger_back)?;
415422
// the last byte of the utf8 encoded needle
416423
// SAFETY: we have an invariant that `utf8_size < 5`
417-
let last_byte = unsafe { *self.utf8_encoded.get_unchecked(self.utf8_size - 1) };
424+
let last_byte = unsafe { *self.utf8_encoded.get_unchecked(self.utf8_size() - 1) };
418425
if let Some(index) = memchr::memchr(last_byte, bytes) {
419426
// The new finger is the index of the byte we found,
420427
// plus one, since we memchr'd for the last byte of the character.
@@ -434,10 +441,10 @@ unsafe impl<'a> Searcher<'a> for CharSearcher<'a> {
434441
// find something. When we find something the `finger` will be set
435442
// to a UTF8 boundary.
436443
self.finger += index + 1;
437-
if self.finger >= self.utf8_size {
438-
let found_char = self.finger - self.utf8_size;
444+
if self.finger >= self.utf8_size() {
445+
let found_char = self.finger - self.utf8_size();
439446
if let Some(slice) = self.haystack.as_bytes().get(found_char..self.finger) {
440-
if slice == &self.utf8_encoded[0..self.utf8_size] {
447+
if slice == &self.utf8_encoded[0..self.utf8_size()] {
441448
return Some((found_char, self.finger));
442449
}
443450
}
@@ -482,7 +489,7 @@ unsafe impl<'a> ReverseSearcher<'a> for CharSearcher<'a> {
482489
let bytes = haystack.get(self.finger..self.finger_back)?;
483490
// the last byte of the utf8 encoded needle
484491
// SAFETY: we have an invariant that `utf8_size < 5`
485-
let last_byte = unsafe { *self.utf8_encoded.get_unchecked(self.utf8_size - 1) };
492+
let last_byte = unsafe { *self.utf8_encoded.get_unchecked(self.utf8_size() - 1) };
486493
if let Some(index) = memchr::memrchr(last_byte, bytes) {
487494
// we searched a slice that was offset by self.finger,
488495
// add self.finger to recoup the original index
@@ -493,14 +500,14 @@ unsafe impl<'a> ReverseSearcher<'a> for CharSearcher<'a> {
493500
// char in the paradigm of reverse iteration). For
494501
// multibyte chars we need to skip down by the number of more
495502
// bytes they have than ASCII
496-
let shift = self.utf8_size - 1;
503+
let shift = self.utf8_size() - 1;
497504
if index >= shift {
498505
let found_char = index - shift;
499-
if let Some(slice) = haystack.get(found_char..(found_char + self.utf8_size)) {
500-
if slice == &self.utf8_encoded[0..self.utf8_size] {
506+
if let Some(slice) = haystack.get(found_char..(found_char + self.utf8_size())) {
507+
if slice == &self.utf8_encoded[0..self.utf8_size()] {
501508
// move finger to before the character found (i.e., at its start index)
502509
self.finger_back = found_char;
503-
return Some((self.finger_back, self.finger_back + self.utf8_size));
510+
return Some((self.finger_back, self.finger_back + self.utf8_size()));
504511
}
505512
}
506513
}
@@ -542,7 +549,12 @@ impl<'a> Pattern<'a> for char {
542549
#[inline]
543550
fn into_searcher(self, haystack: &'a str) -> Self::Searcher {
544551
let mut utf8_encoded = [0; 4];
545-
let utf8_size = self.encode_utf8(&mut utf8_encoded).len();
552+
let utf8_size = self
553+
.encode_utf8(&mut utf8_encoded)
554+
.len()
555+
.try_into()
556+
.expect("char len should be less than 255");
557+
546558
CharSearcher {
547559
haystack,
548560
finger: 0,

‎library/std/src/prelude/mod.rs

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -132,13 +132,13 @@ pub mod rust_2021 {
132132
/// The 2024 version of the prelude of The Rust Standard Library.
133133
///
134134
/// See the [module-level documentation](self) for more.
135-
#[unstable(feature = "prelude_2024", issue = "none")]
135+
#[unstable(feature = "prelude_2024", issue = "121042")]
136136
pub mod rust_2024 {
137-
#[unstable(feature = "prelude_2024", issue = "none")]
137+
#[unstable(feature = "prelude_2024", issue = "121042")]
138138
#[doc(no_inline)]
139139
pub use super::v1::*;
140140

141-
#[unstable(feature = "prelude_2024", issue = "none")]
141+
#[unstable(feature = "prelude_2024", issue = "121042")]
142142
#[doc(no_inline)]
143143
pub use core::prelude::rust_2024::*;
144144
}

‎src/tools/tidy/src/ui_tests.rs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -16,7 +16,7 @@ const ENTRY_LIMIT: usize = 900;
1616
// FIXME: The following limits should be reduced eventually.
1717

1818
const ISSUES_ENTRY_LIMIT: usize = 1781;
19-
const ROOT_ENTRY_LIMIT: usize = 871;
19+
const ROOT_ENTRY_LIMIT: usize = 872;
2020

2121
const EXPECTED_TEST_FILE_EXTENSIONS: &[&str] = &[
2222
"rs", // test source files

‎tests/ui/async-await/for-await-passthrough.rs

Lines changed: 0 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -4,8 +4,6 @@
44
#![feature(async_iterator, async_iter_from_iter, const_waker, async_for_loop, noop_waker,
55
gen_blocks)]
66

7-
use std::future::Future;
8-
97
async gen fn async_iter() -> i32 {
108
let iter = core::async_iter::from_iter(0..3);
119
for await i in iter {

‎tests/ui/coroutine/async_gen_fn_iter.rs

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -46,7 +46,6 @@ async fn async_main() {
4646
use std::pin::{Pin, pin};
4747
use std::task::*;
4848
use std::async_iter::AsyncIterator;
49-
use std::future::Future;
5049

5150
trait AsyncIterExt {
5251
fn next(&mut self) -> Next<'_, Self>;
Lines changed: 8 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,8 @@
1+
//@ aux-build: test-macros.rs
2+
3+
extern crate test_macros;
4+
5+
#[test_macros::panic_attr] //~ ERROR custom attribute panicked
6+
fn foo() {}
7+
8+
fn main() {}
Lines changed: 10 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,10 @@
1+
error: custom attribute panicked
2+
--> $DIR/custom-attr-panic.rs:5:1
3+
|
4+
LL | #[test_macros::panic_attr]
5+
| ^^^^^^^^^^^^^^^^^^^^^^^^^^
6+
|
7+
= help: message: panic-attr
8+
9+
error: aborting due to 1 previous error
10+

‎tests/ui/rust-2024/prelude2024.rs

Lines changed: 9 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,9 @@
1+
//@ check-pass
2+
//@ compile-flags: -Zunstable-options
3+
//@ edition:2024
4+
5+
fn main() {
6+
fut(async {}.into_future(), async {});
7+
}
8+
9+
fn fut(_: impl Future, _: impl IntoFuture) {}

‎tests/ui/typeck/cyclic_type_ice.rs

Lines changed: 7 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,7 @@
1+
fn thing() {
2+
let f = |_, _| ();
3+
f(f); //~ ERROR: closure/coroutine type that references itself
4+
//~^ ERROR: this function takes 2 arguments but 1 argument was supplied
5+
}
6+
7+
fn main() {}
Lines changed: 31 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,31 @@
1+
error[E0644]: closure/coroutine type that references itself
2+
--> $DIR/cyclic_type_ice.rs:3:7
3+
|
4+
LL | f(f);
5+
| ^ cyclic type of infinite size
6+
|
7+
= note: closures cannot capture themselves or take themselves as argument;
8+
this error may be the result of a recent compiler bug-fix,
9+
see issue #46062 <https://github.com/rust-lang/rust/issues/46062>
10+
for more information
11+
12+
error[E0057]: this function takes 2 arguments but 1 argument was supplied
13+
--> $DIR/cyclic_type_ice.rs:3:5
14+
|
15+
LL | f(f);
16+
| ^--- an argument is missing
17+
|
18+
note: closure defined here
19+
--> $DIR/cyclic_type_ice.rs:2:13
20+
|
21+
LL | let f = |_, _| ();
22+
| ^^^^^^
23+
help: provide the argument
24+
|
25+
LL | f(/* */, /* */);
26+
| ~~~~~~~~~~~~~~~~
27+
28+
error: aborting due to 2 previous errors
29+
30+
Some errors have detailed explanations: E0057, E0644.
31+
For more information about an error, try `rustc --explain E0057`.

0 commit comments

Comments
 (0)
Please sign in to comment.