Skip to content

Commit 374cc90

Browse files
committed
Auto merge of rust-lang#143721 - tgross35:rollup-sjdfp6r, r=tgross35
Rollup of 9 pull requests Successful merges: - rust-lang#141996 (Fix `proc_macro::Ident`'s handling of `$crate`) - rust-lang#142950 (mbe: Rework diagnostics for metavariable expressions) - rust-lang#143011 (Make lint `ambiguous_glob_imports` deny-by-default and report-in-deps) - rust-lang#143265 (Mention as_chunks in the docs for chunks) - rust-lang#143270 (tests/codegen/enum/enum-match.rs: accept negative range attribute) - rust-lang#143298 (`tests/ui`: A New Order [23/N]) - rust-lang#143396 (Move NaN tests to floats/mod.rs) - rust-lang#143398 (tidy: add support for `--extra-checks=auto:` feature) - rust-lang#143644 (Add triagebot stdarch mention ping) r? `@ghost` `@rustbot` modify labels: rollup
2 parents afb3b9d + 0514523 commit 374cc90

File tree

7 files changed

+57
-58
lines changed

7 files changed

+57
-58
lines changed

core/src/slice/mod.rs

Lines changed: 32 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1120,6 +1120,9 @@ impl<T> [T] {
11201120
/// `chunk_size` elements, and [`rchunks`] for the same iterator but starting at the end of the
11211121
/// slice.
11221122
///
1123+
/// If your `chunk_size` is a constant, consider using [`as_chunks`] instead, which will
1124+
/// give references to arrays of exactly that length, rather than slices.
1125+
///
11231126
/// # Panics
11241127
///
11251128
/// Panics if `chunk_size` is zero.
@@ -1137,6 +1140,7 @@ impl<T> [T] {
11371140
///
11381141
/// [`chunks_exact`]: slice::chunks_exact
11391142
/// [`rchunks`]: slice::rchunks
1143+
/// [`as_chunks`]: slice::as_chunks
11401144
#[stable(feature = "rust1", since = "1.0.0")]
11411145
#[rustc_const_unstable(feature = "const_slice_make_iter", issue = "137737")]
11421146
#[inline]
@@ -1156,6 +1160,9 @@ impl<T> [T] {
11561160
/// exactly `chunk_size` elements, and [`rchunks_mut`] for the same iterator but starting at
11571161
/// the end of the slice.
11581162
///
1163+
/// If your `chunk_size` is a constant, consider using [`as_chunks_mut`] instead, which will
1164+
/// give references to arrays of exactly that length, rather than slices.
1165+
///
11591166
/// # Panics
11601167
///
11611168
/// Panics if `chunk_size` is zero.
@@ -1177,6 +1184,7 @@ impl<T> [T] {
11771184
///
11781185
/// [`chunks_exact_mut`]: slice::chunks_exact_mut
11791186
/// [`rchunks_mut`]: slice::rchunks_mut
1187+
/// [`as_chunks_mut`]: slice::as_chunks_mut
11801188
#[stable(feature = "rust1", since = "1.0.0")]
11811189
#[rustc_const_unstable(feature = "const_slice_make_iter", issue = "137737")]
11821190
#[inline]
@@ -1199,6 +1207,9 @@ impl<T> [T] {
11991207
/// See [`chunks`] for a variant of this iterator that also returns the remainder as a smaller
12001208
/// chunk, and [`rchunks_exact`] for the same iterator but starting at the end of the slice.
12011209
///
1210+
/// If your `chunk_size` is a constant, consider using [`as_chunks`] instead, which will
1211+
/// give references to arrays of exactly that length, rather than slices.
1212+
///
12021213
/// # Panics
12031214
///
12041215
/// Panics if `chunk_size` is zero.
@@ -1216,6 +1227,7 @@ impl<T> [T] {
12161227
///
12171228
/// [`chunks`]: slice::chunks
12181229
/// [`rchunks_exact`]: slice::rchunks_exact
1230+
/// [`as_chunks`]: slice::chunks
12191231
#[stable(feature = "chunks_exact", since = "1.31.0")]
12201232
#[rustc_const_unstable(feature = "const_slice_make_iter", issue = "137737")]
12211233
#[inline]
@@ -1239,6 +1251,9 @@ impl<T> [T] {
12391251
/// smaller chunk, and [`rchunks_exact_mut`] for the same iterator but starting at the end of
12401252
/// the slice.
12411253
///
1254+
/// If your `chunk_size` is a constant, consider using [`as_chunks_mut`] instead, which will
1255+
/// give references to arrays of exactly that length, rather than slices.
1256+
///
12421257
/// # Panics
12431258
///
12441259
/// Panics if `chunk_size` is zero.
@@ -1260,6 +1275,7 @@ impl<T> [T] {
12601275
///
12611276
/// [`chunks_mut`]: slice::chunks_mut
12621277
/// [`rchunks_exact_mut`]: slice::rchunks_exact_mut
1278+
/// [`as_chunks_mut`]: slice::as_chunks_mut
12631279
#[stable(feature = "chunks_exact", since = "1.31.0")]
12641280
#[rustc_const_unstable(feature = "const_slice_make_iter", issue = "137737")]
12651281
#[inline]
@@ -1707,6 +1723,9 @@ impl<T> [T] {
17071723
/// `chunk_size` elements, and [`chunks`] for the same iterator but starting at the beginning
17081724
/// of the slice.
17091725
///
1726+
/// If your `chunk_size` is a constant, consider using [`as_rchunks`] instead, which will
1727+
/// give references to arrays of exactly that length, rather than slices.
1728+
///
17101729
/// # Panics
17111730
///
17121731
/// Panics if `chunk_size` is zero.
@@ -1724,6 +1743,7 @@ impl<T> [T] {
17241743
///
17251744
/// [`rchunks_exact`]: slice::rchunks_exact
17261745
/// [`chunks`]: slice::chunks
1746+
/// [`as_rchunks`]: slice::as_rchunks
17271747
#[stable(feature = "rchunks", since = "1.31.0")]
17281748
#[rustc_const_unstable(feature = "const_slice_make_iter", issue = "137737")]
17291749
#[inline]
@@ -1743,6 +1763,9 @@ impl<T> [T] {
17431763
/// exactly `chunk_size` elements, and [`chunks_mut`] for the same iterator but starting at the
17441764
/// beginning of the slice.
17451765
///
1766+
/// If your `chunk_size` is a constant, consider using [`as_rchunks_mut`] instead, which will
1767+
/// give references to arrays of exactly that length, rather than slices.
1768+
///
17461769
/// # Panics
17471770
///
17481771
/// Panics if `chunk_size` is zero.
@@ -1764,6 +1787,7 @@ impl<T> [T] {
17641787
///
17651788
/// [`rchunks_exact_mut`]: slice::rchunks_exact_mut
17661789
/// [`chunks_mut`]: slice::chunks_mut
1790+
/// [`as_rchunks_mut`]: slice::as_rchunks_mut
17671791
#[stable(feature = "rchunks", since = "1.31.0")]
17681792
#[rustc_const_unstable(feature = "const_slice_make_iter", issue = "137737")]
17691793
#[inline]
@@ -1787,6 +1811,9 @@ impl<T> [T] {
17871811
/// chunk, and [`chunks_exact`] for the same iterator but starting at the beginning of the
17881812
/// slice.
17891813
///
1814+
/// If your `chunk_size` is a constant, consider using [`as_rchunks`] instead, which will
1815+
/// give references to arrays of exactly that length, rather than slices.
1816+
///
17901817
/// # Panics
17911818
///
17921819
/// Panics if `chunk_size` is zero.
@@ -1805,6 +1832,7 @@ impl<T> [T] {
18051832
/// [`chunks`]: slice::chunks
18061833
/// [`rchunks`]: slice::rchunks
18071834
/// [`chunks_exact`]: slice::chunks_exact
1835+
/// [`as_rchunks`]: slice::as_rchunks
18081836
#[stable(feature = "rchunks", since = "1.31.0")]
18091837
#[rustc_const_unstable(feature = "const_slice_make_iter", issue = "137737")]
18101838
#[inline]
@@ -1828,6 +1856,9 @@ impl<T> [T] {
18281856
/// smaller chunk, and [`chunks_exact_mut`] for the same iterator but starting at the beginning
18291857
/// of the slice.
18301858
///
1859+
/// If your `chunk_size` is a constant, consider using [`as_rchunks_mut`] instead, which will
1860+
/// give references to arrays of exactly that length, rather than slices.
1861+
///
18311862
/// # Panics
18321863
///
18331864
/// Panics if `chunk_size` is zero.
@@ -1850,6 +1881,7 @@ impl<T> [T] {
18501881
/// [`chunks_mut`]: slice::chunks_mut
18511882
/// [`rchunks_mut`]: slice::rchunks_mut
18521883
/// [`chunks_exact_mut`]: slice::chunks_exact_mut
1884+
/// [`as_rchunks_mut`]: slice::as_rchunks_mut
18531885
#[stable(feature = "rchunks", since = "1.31.0")]
18541886
#[rustc_const_unstable(feature = "const_slice_make_iter", issue = "137737")]
18551887
#[inline]

coretests/tests/floats/f128.rs

Lines changed: 0 additions & 14 deletions
Original file line numberDiff line numberDiff line change
@@ -55,20 +55,6 @@ fn test_num_f128() {
5555
// FIXME(f16_f128,miri): many of these have to be disabled since miri does not yet support
5656
// the intrinsics.
5757

58-
#[test]
59-
fn test_nan() {
60-
let nan: f128 = f128::NAN;
61-
assert!(nan.is_nan());
62-
assert!(!nan.is_infinite());
63-
assert!(!nan.is_finite());
64-
assert!(nan.is_sign_positive());
65-
assert!(!nan.is_sign_negative());
66-
assert!(!nan.is_normal());
67-
assert_eq!(Fp::Nan, nan.classify());
68-
// Ensure the quiet bit is set.
69-
assert!(nan.to_bits() & (1 << (f128::MANTISSA_DIGITS - 2)) != 0);
70-
}
71-
7258
#[test]
7359
fn test_infinity() {
7460
let inf: f128 = f128::INFINITY;

coretests/tests/floats/f16.rs

Lines changed: 0 additions & 14 deletions
Original file line numberDiff line numberDiff line change
@@ -51,20 +51,6 @@ fn test_num_f16() {
5151
// FIXME(f16_f128,miri): many of these have to be disabled since miri does not yet support
5252
// the intrinsics.
5353

54-
#[test]
55-
fn test_nan() {
56-
let nan: f16 = f16::NAN;
57-
assert!(nan.is_nan());
58-
assert!(!nan.is_infinite());
59-
assert!(!nan.is_finite());
60-
assert!(nan.is_sign_positive());
61-
assert!(!nan.is_sign_negative());
62-
assert!(!nan.is_normal());
63-
assert_eq!(Fp::Nan, nan.classify());
64-
// Ensure the quiet bit is set.
65-
assert!(nan.to_bits() & (1 << (f16::MANTISSA_DIGITS - 2)) != 0);
66-
}
67-
6854
#[test]
6955
fn test_infinity() {
7056
let inf: f16 = f16::INFINITY;

coretests/tests/floats/f32.rs

Lines changed: 0 additions & 14 deletions
Original file line numberDiff line numberDiff line change
@@ -35,20 +35,6 @@ fn test_num_f32() {
3535
super::test_num(10f32, 2f32);
3636
}
3737

38-
#[test]
39-
fn test_nan() {
40-
let nan: f32 = f32::NAN;
41-
assert!(nan.is_nan());
42-
assert!(!nan.is_infinite());
43-
assert!(!nan.is_finite());
44-
assert!(!nan.is_normal());
45-
assert!(nan.is_sign_positive());
46-
assert!(!nan.is_sign_negative());
47-
assert_eq!(Fp::Nan, nan.classify());
48-
// Ensure the quiet bit is set.
49-
assert!(nan.to_bits() & (1 << (f32::MANTISSA_DIGITS - 2)) != 0);
50-
}
51-
5238
#[test]
5339
fn test_infinity() {
5440
let inf: f32 = f32::INFINITY;

coretests/tests/floats/f64.rs

Lines changed: 0 additions & 14 deletions
Original file line numberDiff line numberDiff line change
@@ -30,20 +30,6 @@ fn test_num_f64() {
3030
super::test_num(10f64, 2f64);
3131
}
3232

33-
#[test]
34-
fn test_nan() {
35-
let nan: f64 = f64::NAN;
36-
assert!(nan.is_nan());
37-
assert!(!nan.is_infinite());
38-
assert!(!nan.is_finite());
39-
assert!(!nan.is_normal());
40-
assert!(nan.is_sign_positive());
41-
assert!(!nan.is_sign_negative());
42-
assert_eq!(Fp::Nan, nan.classify());
43-
// Ensure the quiet bit is set.
44-
assert!(nan.to_bits() & (1 << (f64::MANTISSA_DIGITS - 2)) != 0);
45-
}
46-
4733
#[test]
4834
fn test_infinity() {
4935
let inf: f64 = f64::INFINITY;

coretests/tests/floats/mod.rs

Lines changed: 23 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,5 @@
11
use std::fmt;
2+
use std::num::FpCategory as Fp;
23
use std::ops::{Add, Div, Mul, Rem, Sub};
34

45
/// Set the default tolerance for float comparison based on the type.
@@ -187,6 +188,8 @@ macro_rules! float_test {
187188
mod const_ {
188189
#[allow(unused)]
189190
use super::Approx;
191+
#[allow(unused)]
192+
use std::num::FpCategory as Fp;
190193
// Shadow the runtime versions of the macro with const-compatible versions.
191194
#[allow(unused)]
192195
use $crate::floats::{
@@ -250,6 +253,26 @@ mod f16;
250253
mod f32;
251254
mod f64;
252255

256+
float_test! {
257+
name: nan,
258+
attrs: {
259+
f16: #[cfg(any(miri, target_has_reliable_f16))],
260+
f128: #[cfg(any(miri, target_has_reliable_f128))],
261+
},
262+
test<Float> {
263+
let nan: Float = Float::NAN;
264+
assert!(nan.is_nan());
265+
assert!(!nan.is_infinite());
266+
assert!(!nan.is_finite());
267+
assert!(!nan.is_normal());
268+
assert!(nan.is_sign_positive());
269+
assert!(!nan.is_sign_negative());
270+
assert!(matches!(nan.classify(), Fp::Nan));
271+
// Ensure the quiet bit is set.
272+
assert!(nan.to_bits() & (1 << (Float::MANTISSA_DIGITS - 2)) != 0);
273+
}
274+
}
275+
253276
float_test! {
254277
name: min,
255278
attrs: {

proc_macro/src/bridge/symbol.rs

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -33,7 +33,7 @@ impl Symbol {
3333
/// Validates and normalizes before converting it to a symbol.
3434
pub(crate) fn new_ident(string: &str, is_raw: bool) -> Self {
3535
// Fast-path: check if this is a valid ASCII identifier
36-
if Self::is_valid_ascii_ident(string.as_bytes()) {
36+
if Self::is_valid_ascii_ident(string.as_bytes()) || string == "$crate" {
3737
if is_raw && !Self::can_be_raw(string) {
3838
panic!("`{}` cannot be a raw identifier", string);
3939
}
@@ -79,7 +79,7 @@ impl Symbol {
7979
// Mimics the behavior of `Symbol::can_be_raw` from `rustc_span`
8080
fn can_be_raw(string: &str) -> bool {
8181
match string {
82-
"_" | "super" | "self" | "Self" | "crate" => false,
82+
"_" | "super" | "self" | "Self" | "crate" | "$crate" => false,
8383
_ => true,
8484
}
8585
}

0 commit comments

Comments
 (0)