From 9f579968cd4a7544eae0b76859089d78b418f131 Mon Sep 17 00:00:00 2001 From: Yoshua Wuyts Date: Thu, 24 Jun 2021 13:01:17 +0200 Subject: [PATCH 01/19] Add Integer::{log,log2,log10} variants --- library/core/src/num/int_macros.rs | 188 ++++++++++++++++++++++++++++ library/core/src/num/uint_macros.rs | 188 ++++++++++++++++++++++++++++ library/core/tests/lib.rs | 1 + library/core/tests/num/int_log.rs | 99 +++++++++++++++ library/core/tests/num/mod.rs | 1 + library/std/src/lib.rs | 1 + 6 files changed, 478 insertions(+) create mode 100644 library/core/tests/num/int_log.rs diff --git a/library/core/src/num/int_macros.rs b/library/core/src/num/int_macros.rs index 2e466106fe5..a9461649d4a 100644 --- a/library/core/src/num/int_macros.rs +++ b/library/core/src/num/int_macros.rs @@ -1744,6 +1744,194 @@ macro_rules! int_impl { } } + /// Returns the logarithm of the number with respect to an arbitrary base. + /// + /// This method may not be optimized owing to implementation details; + /// `log2` can produce results more efficiently for base 2, and `log10` + /// can produce results more efficiently for base 10. + /// + /// # Panics + /// + /// When the number is zero, or if the base is not at least 2; it + /// panics in debug mode and the return value is wrapped to 0 in release + /// mode (the only situation in which the method can return 0). + /// + /// # Examples + /// + /// ``` + /// #![feature(int_log)] + #[doc = concat!("assert_eq!(5", stringify!($SelfT), ".log(5), 1);")] + /// ``` + #[unstable(feature = "int_log", issue = "70887")] + #[must_use = "this returns the result of the operation, \ + without modifying the original"] + #[inline] + #[track_caller] + #[rustc_inherit_overflow_checks] + #[allow(arithmetic_overflow)] + pub const fn log(self, base: Self) -> Self { + match self.checked_log(base) { + Some(n) => n, + None => { + // In debug builds, trigger a panic on None. + // This should optimize completely out in release builds. + let _ = Self::MAX + 1; + + 0 + }, + } + } + + /// Returns the base 2 logarithm of the number. + /// + /// # Panics + /// + /// When the number is zero it panics in debug mode and the return value + /// is wrapped to 0 in release mode (the only situation in which the + /// method can return 0). + /// + /// # Examples + /// + /// ``` + /// #![feature(int_log)] + #[doc = concat!("assert_eq!(2", stringify!($SelfT), ".log2(), 1);")] + /// ``` + #[unstable(feature = "int_log", issue = "70887")] + #[must_use = "this returns the result of the operation, \ + without modifying the original"] + #[inline] + #[track_caller] + #[rustc_inherit_overflow_checks] + #[allow(arithmetic_overflow)] + pub const fn log2(self) -> Self { + match self.checked_log2() { + Some(n) => n, + None => { + // In debug builds, trigger a panic on None. + // This should optimize completely out in release builds. + let _ = Self::MAX + 1; + + 0 + }, + } + } + + /// Returns the base 10 logarithm of the number. + /// + /// # Panics + /// + /// When the number is zero it panics in debug mode and the return value + /// is wrapped to 0 in release mode (the only situation in which the + /// method can return 0). + /// + /// # Example + /// + /// ``` + /// #![feature(int_log)] + #[doc = concat!("assert_eq!(10", stringify!($SelfT), ".log10(), 1);")] + /// ``` + #[unstable(feature = "int_log", issue = "70887")] + #[must_use = "this returns the result of the operation, \ + without modifying the original"] + #[inline] + #[track_caller] + #[rustc_inherit_overflow_checks] + #[allow(arithmetic_overflow)] + pub const fn log10(self) -> Self { + match self.checked_log10() { + Some(n) => n, + None => { + // In debug builds, trigger a panic on None. + // This should optimize completely out in release builds. + let _ = Self::MAX + 1; + + 0 + }, + } + } + + /// Returns the logarithm of the number with respect to an arbitrary base. + /// + /// Returns `None` if the number is negative or zero, or if the base is not at least 2. + /// + /// This method may not be optimized owing to implementation details; + /// `checked_log2` can produce results more efficiently for base 2, and + /// `checked_log10` can produce results more efficiently for base 10. + /// + /// # Examples + /// + /// ``` + /// #![feature(int_log)] + #[doc = concat!("assert_eq!(5", stringify!($SelfT), ".checked_log(5), Some(1));")] + /// ``` + #[unstable(feature = "int_log", issue = "70887")] + #[must_use = "this returns the result of the operation, \ + without modifying the original"] + #[inline] + pub const fn checked_log(self, base: Self) -> Option { + if self <= 0 || base <= 1 { + None + } else { + let mut n = 0; + let mut r = self; + + // Optimization for 128 bit wide integers. + if Self::BITS == 128 { + let b = Self::log2(self) / (Self::log2(base) + 1); + n += b; + r /= base.pow(b as u32); + } + + while r >= base { + r /= base; + n += 1; + } + Some(n) + } + } + + /// Returns the base 2 logarithm of the number. + /// + /// Returns `None` if the number is negative or zero. + /// + /// # Examples + /// + /// ``` + /// #![feature(int_log)] + #[doc = concat!("assert_eq!(2", stringify!($SelfT), ".checked_log2(), Some(1));")] + /// ``` + #[unstable(feature = "int_log", issue = "70887")] + #[must_use = "this returns the result of the operation, \ + without modifying the original"] + #[inline] + pub const fn checked_log2(self) -> Option { + if self <= 0 { + None + } else { + // SAFETY: We just checked that this number is positive + let log = (Self::BITS - 1) as Self - unsafe { intrinsics::ctlz_nonzero(self) }; + Some(log) + } + } + + /// Returns the base 10 logarithm of the number. + /// + /// Returns `None` if the number is negative or zero. + /// + /// # Example + /// + /// ``` + /// #![feature(int_log)] + #[doc = concat!("assert_eq!(10", stringify!($SelfT), ".checked_log10(), Some(1));")] + /// ``` + #[unstable(feature = "int_log", issue = "70887")] + #[must_use = "this returns the result of the operation, \ + without modifying the original"] + #[inline] + pub const fn checked_log10(self) -> Option { + self.checked_log(10) + } + /// Computes the absolute value of `self`. /// /// # Overflow behavior diff --git a/library/core/src/num/uint_macros.rs b/library/core/src/num/uint_macros.rs index e512d90ef37..bf4d2e7433e 100644 --- a/library/core/src/num/uint_macros.rs +++ b/library/core/src/num/uint_macros.rs @@ -634,6 +634,194 @@ macro_rules! uint_impl { } } + /// Returns the logarithm of the number with respect to an arbitrary base. + /// + /// This method may not be optimized owing to implementation details; + /// `log2` can produce results more efficiently for base 2, and `log10` + /// can produce results more efficiently for base 10. + /// + /// # Panics + /// + /// When the number is negative, zero, or if the base is not at least 2; + /// it panics in debug mode and the return value is wrapped to 0 in + /// release mode (the only situation in which the method can return 0). + /// + /// # Examples + /// + /// ``` + /// #![feature(int_log)] + #[doc = concat!("assert_eq!(5", stringify!($SelfT), ".log(5), 1);")] + /// ``` + #[unstable(feature = "int_log", issue = "70887")] + #[must_use = "this returns the result of the operation, \ + without modifying the original"] + #[inline] + #[track_caller] + #[rustc_inherit_overflow_checks] + #[allow(arithmetic_overflow)] + pub const fn log(self, base: Self) -> Self { + match self.checked_log(base) { + Some(n) => n, + None => { + // In debug builds, trigger a panic on None. + // This should optimize completely out in release builds. + let _ = Self::MAX + 1; + + 0 + }, + } + } + + /// Returns the base 2 logarithm of the number. + /// + /// # Panics + /// + /// When the number is negative or zero it panics in debug mode and + /// the return value is wrapped to 0 in release mode (the only situation in + /// which the method can return 0). + /// + /// # Examples + /// + /// ``` + /// #![feature(int_log)] + #[doc = concat!("assert_eq!(2", stringify!($SelfT), ".log2(), 1);")] + /// ``` + #[unstable(feature = "int_log", issue = "70887")] + #[must_use = "this returns the result of the operation, \ + without modifying the original"] + #[inline] + #[track_caller] + #[rustc_inherit_overflow_checks] + #[allow(arithmetic_overflow)] + pub const fn log2(self) -> Self { + match self.checked_log2() { + Some(n) => n, + None => { + // In debug builds, trigger a panic on None. + // This should optimize completely out in release builds. + let _ = Self::MAX + 1; + + 0 + }, + } + } + + /// Returns the base 10 logarithm of the number. + /// + /// # Panics + /// + /// When the number is negative or zero it panics in debug mode and the + /// return value is wrapped to 0 in release mode (the only situation in + /// which the method can return 0). + /// + /// # Example + /// + /// ``` + /// #![feature(int_log)] + #[doc = concat!("assert_eq!(10", stringify!($SelfT), ".log10(), 1);")] + /// ``` + #[unstable(feature = "int_log", issue = "70887")] + #[must_use = "this returns the result of the operation, \ + without modifying the original"] + #[inline] + #[track_caller] + #[rustc_inherit_overflow_checks] + #[allow(arithmetic_overflow)] + pub const fn log10(self) -> Self { + match self.checked_log10() { + Some(n) => n, + None => { + // In debug builds, trigger a panic on None. + // This should optimize completely out in release builds. + let _ = Self::MAX + 1; + + 0 + }, + } + } + + /// Returns the logarithm of the number with respect to an arbitrary base. + /// + /// Returns `None` if the number is zero, or if the base is not at least 2. + /// + /// This method may not be optimized owing to implementation details; + /// `checked_log2` can produce results more efficiently for base 2, and + /// `checked_log10` can produce results more efficiently for base 10. + /// + /// # Examples + /// + /// ``` + /// #![feature(int_log)] + #[doc = concat!("assert_eq!(5", stringify!($SelfT), ".checked_log(5), Some(1));")] + /// ``` + #[unstable(feature = "int_log", issue = "70887")] + #[must_use = "this returns the result of the operation, \ + without modifying the original"] + #[inline] + pub const fn checked_log(self, base: Self) -> Option { + if self <= 0 || base <= 1 { + None + } else { + let mut n = 0; + let mut r = self; + + // Optimization for 128 bit wide integers. + if Self::BITS == 128 { + let b = Self::log2(self) / (Self::log2(base) + 1); + n += b; + r /= base.pow(b as u32); + } + + while r >= base { + r /= base; + n += 1; + } + Some(n) + } + } + + /// Returns the base 2 logarithm of the number. + /// + /// Returns `None` if the number is zero. + /// + /// # Examples + /// + /// ``` + /// #![feature(int_log)] + #[doc = concat!("assert_eq!(2", stringify!($SelfT), ".checked_log2(), Some(1));")] + /// ``` + #[unstable(feature = "int_log", issue = "70887")] + #[must_use = "this returns the result of the operation, \ + without modifying the original"] + #[inline] + pub const fn checked_log2(self) -> Option { + if self <= 0 { + None + } else { + // SAFETY: We just checked that this number is positive + let log = (Self::BITS - 1) as Self - unsafe { intrinsics::ctlz_nonzero(self) }; + Some(log) + } + } + + /// Returns the base 10 logarithm of the number. + /// + /// Returns `None` if the number is zero. + /// + /// # Examples + /// + /// ``` + /// #![feature(int_log)] + #[doc = concat!("assert_eq!(10", stringify!($SelfT), ".checked_log10(), Some(1));")] + /// ``` + #[unstable(feature = "int_log", issue = "70887")] + #[must_use = "this returns the result of the operation, \ + without modifying the original"] + #[inline] + pub const fn checked_log10(self) -> Option { + self.checked_log(10) + } + /// Checked negation. Computes `-self`, returning `None` unless `self == /// 0`. /// diff --git a/library/core/tests/lib.rs b/library/core/tests/lib.rs index 56af3848584..62491cc4d92 100644 --- a/library/core/tests/lib.rs +++ b/library/core/tests/lib.rs @@ -45,6 +45,7 @@ #![feature(try_trait_v2)] #![feature(slice_internals)] #![feature(slice_partition_dedup)] +#![feature(int_log)] #![feature(iter_advance_by)] #![feature(iter_partition_in_place)] #![feature(iter_intersperse)] diff --git a/library/core/tests/num/int_log.rs b/library/core/tests/num/int_log.rs new file mode 100644 index 00000000000..99a9b17ab11 --- /dev/null +++ b/library/core/tests/num/int_log.rs @@ -0,0 +1,99 @@ +//! This tests the `Integer::{log,log2,log10}` methods. These tests are in a +//! separate file because there's both a large number of them, and not all tests +//! can be run on Android. This is because in Android `log2` uses an imprecise +//! approximation:https://github.com/rust-lang/rust/blob/4825e12fc9c79954aa0fe18f5521efa6c19c7539/src/libstd/sys/unix/android.rs#L27-L53 + +#[test] +fn checked_log() { + assert_eq!(999u32.checked_log(10), Some(2)); + assert_eq!(1000u32.checked_log(10), Some(3)); + assert_eq!(555u32.checked_log(13), Some(2)); + assert_eq!(63u32.checked_log(4), Some(2)); + assert_eq!(64u32.checked_log(4), Some(3)); + assert_eq!(10460353203u64.checked_log(3), Some(21)); + assert_eq!(10460353202u64.checked_log(3), Some(20)); + assert_eq!(147808829414345923316083210206383297601u128.checked_log(3), Some(80)); + assert_eq!(147808829414345923316083210206383297600u128.checked_log(3), Some(79)); + assert_eq!(22528399544939174411840147874772641u128.checked_log(19683), Some(8)); + assert_eq!(22528399544939174411840147874772631i128.checked_log(19683), Some(7)); + + assert_eq!(0u8.checked_log(4), None); + assert_eq!(0u16.checked_log(4), None); + assert_eq!(0i8.checked_log(4), None); + assert_eq!(0i16.checked_log(4), None); + + for i in i16::MIN..=0 { + assert_eq!(i.checked_log(4), None); + } + for i in 1..=i16::MAX { + assert_eq!(i.checked_log(13), Some((i as f32).log(13.0) as i16)); + } + for i in 1..=u16::MAX { + assert_eq!(i.checked_log(13), Some((i as f32).log(13.0) as u16)); + } +} + +#[test] +fn checked_log2() { + assert_eq!(5u32.checked_log2(), Some(2)); + assert_eq!(0u64.checked_log2(), None); + assert_eq!(128i32.checked_log2(), Some(7)); + assert_eq!((-55i16).checked_log2(), None); + + assert_eq!(0u8.checked_log2(), None); + assert_eq!(0u16.checked_log2(), None); + assert_eq!(0i8.checked_log2(), None); + assert_eq!(0i16.checked_log2(), None); + + for i in 1..=u8::MAX { + assert_eq!(i.checked_log2(), Some((i as f32).log2() as u8)); + } + for i in 1..=u16::MAX { + // Guard against Android's imprecise f32::log2 implementation. + if i != 8192 && i != 32768 { + assert_eq!(i.checked_log2(), Some((i as f32).log2() as u16)); + } + } + for i in i8::MIN..=0 { + assert_eq!(i.checked_log2(), None); + } + for i in 1..=i8::MAX { + assert_eq!(i.checked_log2(), Some((i as f32).log2() as i8)); + } + for i in i16::MIN..=0 { + assert_eq!(i.checked_log2(), None); + } + for i in 1..=i16::MAX { + // Guard against Android's imprecise f32::log2 implementation. + if i != 8192 { + assert_eq!(i.checked_log2(), Some((i as f32).log2() as i16)); + } + } +} + +// Validate cases that fail on Android's imprecise float log2 implementation. +#[test] +#[cfg(not(target_os = "android"))] +fn checked_log2_not_android() { + assert_eq!(8192u16.checked_log2(), Some((8192f32).log2() as u16)); + assert_eq!(32768u16.checked_log2(), Some((32768f32).log2() as u16)); + assert_eq!(8192i16.checked_log2(), Some((8192f32).log2() as i16)); +} + +#[test] +fn checked_log10() { + assert_eq!(0u8.checked_log10(), None); + assert_eq!(0u16.checked_log10(), None); + assert_eq!(0i8.checked_log10(), None); + assert_eq!(0i16.checked_log10(), None); + + for i in i16::MIN..=0 { + assert_eq!(i.checked_log10(), None); + } + for i in 1..=i16::MAX { + assert_eq!(i.checked_log10(), Some((i as f32).log10() as i16)); + } + for i in 1..=u16::MAX { + assert_eq!(i.checked_log10(), Some((i as f32).log10() as u16)); + } +} diff --git a/library/core/tests/num/mod.rs b/library/core/tests/num/mod.rs index bbb67667dfc..76e838cf6bf 100644 --- a/library/core/tests/num/mod.rs +++ b/library/core/tests/num/mod.rs @@ -29,6 +29,7 @@ mod u8; mod bignum; mod dec2flt; mod flt2dec; +mod int_log; mod ops; mod wrapping; diff --git a/library/std/src/lib.rs b/library/std/src/lib.rs index 1cfa71e250f..5419262b516 100644 --- a/library/std/src/lib.rs +++ b/library/std/src/lib.rs @@ -279,6 +279,7 @@ #![feature(hashmap_internals)] #![feature(int_error_internals)] #![feature(integer_atomics)] +#![feature(int_log)] #![feature(into_future)] #![feature(intra_doc_pointers)] #![feature(iter_zip)] From 8c2a37a04abd3a921ee315aa5e1b62f3c52570a7 Mon Sep 17 00:00:00 2001 From: Guillaume Gomez Date: Wed, 9 Jun 2021 22:35:41 +0200 Subject: [PATCH 02/19] Clean up rustdoc IDs --- src/librustdoc/html/markdown.rs | 15 +++++++++++---- 1 file changed, 11 insertions(+), 4 deletions(-) diff --git a/src/librustdoc/html/markdown.rs b/src/librustdoc/html/markdown.rs index bafb522f363..9fff508165a 100644 --- a/src/librustdoc/html/markdown.rs +++ b/src/librustdoc/html/markdown.rs @@ -1358,7 +1358,10 @@ pub struct IdMap { fn init_id_map() -> FxHashMap { let mut map = FxHashMap::default(); - // This is the list of IDs used by rustdoc templates. + // This is the list of IDs used in Javascript. + map.insert("help".to_owned(), 1); + // This is the list of IDs used in HTML generated in Rust (including the ones + // used in tera template files). map.insert("mainThemeStyle".to_owned(), 1); map.insert("themeStyle".to_owned(), 1); map.insert("theme-picker".to_owned(), 1); @@ -1375,14 +1378,14 @@ fn init_id_map() -> FxHashMap { map.insert("rustdoc-vars".to_owned(), 1); map.insert("sidebar-vars".to_owned(), 1); map.insert("copy-path".to_owned(), 1); - map.insert("help".to_owned(), 1); map.insert("TOC".to_owned(), 1); - map.insert("render-detail".to_owned(), 1); - // This is the list of IDs used by rustdoc sections. + // This is the list of IDs used by rustdoc sections (but still generated by + // rustdoc). map.insert("fields".to_owned(), 1); map.insert("variants".to_owned(), 1); map.insert("implementors-list".to_owned(), 1); map.insert("synthetic-implementors-list".to_owned(), 1); + map.insert("foreign-impls".to_owned(), 1); map.insert("implementations".to_owned(), 1); map.insert("trait-implementations".to_owned(), 1); map.insert("synthetic-implementations".to_owned(), 1); @@ -1393,6 +1396,10 @@ fn init_id_map() -> FxHashMap { map.insert("provided-methods".to_owned(), 1); map.insert("implementors".to_owned(), 1); map.insert("synthetic-implementors".to_owned(), 1); + map.insert("trait-implementations-list".to_owned(), 1); + map.insert("synthetic-implementations-list".to_owned(), 1); + map.insert("blanket-implementations-list".to_owned(), 1); + map.insert("deref-methods".to_owned(), 1); map } From 3d20b2a14ffcf16687bcf9f93fb941fb36e92872 Mon Sep 17 00:00:00 2001 From: Mara Bos Date: Mon, 5 Jul 2021 11:55:45 +0000 Subject: [PATCH 03/19] Test ManuallyDrop::clone_from. --- library/core/tests/manually_drop.rs | 8 ++++++++ 1 file changed, 8 insertions(+) diff --git a/library/core/tests/manually_drop.rs b/library/core/tests/manually_drop.rs index 77a338daf7d..9eac279733a 100644 --- a/library/core/tests/manually_drop.rs +++ b/library/core/tests/manually_drop.rs @@ -2,6 +2,7 @@ use core::mem::ManuallyDrop; #[test] fn smoke() { + #[derive(Clone)] struct TypeWithDrop; impl Drop for TypeWithDrop { fn drop(&mut self) { @@ -16,4 +17,11 @@ fn smoke() { let x: Box> = Box::new(ManuallyDrop::new([TypeWithDrop, TypeWithDrop])); drop(x); + + // test clone and clone_from implementations + let mut x = ManuallyDrop::new(TypeWithDrop); + let y = x.clone(); + x.clone_from(&y); + drop(x); + drop(y); } From a87fb1802761ee51b2f9f8928e50c27c6b64ab9c Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?J=C3=BAnior=20Bassani?= Date: Tue, 6 Jul 2021 10:50:17 -0300 Subject: [PATCH 04/19] Replace deprecated compare_and_swap by compare_exchange_weak in core::sync::atomic::fence example --- library/core/src/sync/atomic.rs | 6 +++++- 1 file changed, 5 insertions(+), 1 deletion(-) diff --git a/library/core/src/sync/atomic.rs b/library/core/src/sync/atomic.rs index f1a115563fd..3f5c10b02eb 100644 --- a/library/core/src/sync/atomic.rs +++ b/library/core/src/sync/atomic.rs @@ -2648,7 +2648,11 @@ unsafe fn atomic_umin(dst: *mut T, val: T, order: Ordering) -> T { /// /// pub fn lock(&self) { /// // Wait until the old value is `false`. -/// while self.flag.compare_and_swap(false, true, Ordering::Relaxed) != false {} +/// while self +/// .flag +/// .compare_exchange_weak(false, true, Ordering::Relaxed, Ordering::Relaxed) +/// .is_err() +/// {} /// // This fence synchronizes-with store in `unlock`. /// fence(Ordering::Acquire); /// } From 0d61e6e8d68be269c57d1d067f29a8a0e5eb6e29 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?J=C3=BAnior=20Bassani?= Date: Tue, 6 Jul 2021 10:53:14 -0300 Subject: [PATCH 05/19] Fix typo in core::sync::atomic::compiler_fence example --- library/core/src/sync/atomic.rs | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/library/core/src/sync/atomic.rs b/library/core/src/sync/atomic.rs index 3f5c10b02eb..b673b36c102 100644 --- a/library/core/src/sync/atomic.rs +++ b/library/core/src/sync/atomic.rs @@ -2714,7 +2714,7 @@ pub fn fence(order: Ordering) { /// Without `compiler_fence`, the `assert_eq!` in following code /// is *not* guaranteed to succeed, despite everything happening in a single thread. /// To see why, remember that the compiler is free to swap the stores to -/// `IMPORTANT_VARIABLE` and `IS_READ` since they are both +/// `IMPORTANT_VARIABLE` and `IS_READY` since they are both /// `Ordering::Relaxed`. If it does, and the signal handler is invoked right /// after `IS_READY` is updated, then the signal handler will see /// `IS_READY=1`, but `IMPORTANT_VARIABLE=0`. From 0b3653bbdd70ff0c19edc5c59a794f4c4cd86f31 Mon Sep 17 00:00:00 2001 From: Pietro Albini Date: Tue, 6 Jul 2021 15:45:15 +0200 Subject: [PATCH 06/19] migrate cpu-usage-over-time.py to python 3 The only change here is a fix for `sys.platform` on Linux. Python 3.3 changed the API to return "linux" instead of "linux2"/"linux3", so this commit uses `.startswith("python")` to make the code work on Python 3 without breaking Python 2. --- src/ci/cpu-usage-over-time.py | 7 +++++-- src/ci/scripts/collect-cpu-stats.sh | 2 +- 2 files changed, 6 insertions(+), 3 deletions(-) diff --git a/src/ci/cpu-usage-over-time.py b/src/ci/cpu-usage-over-time.py index 78ac0603681..267c3964d0d 100644 --- a/src/ci/cpu-usage-over-time.py +++ b/src/ci/cpu-usage-over-time.py @@ -1,4 +1,4 @@ -#!/usr/bin/env python +#!/usr/bin/env python3 # ignore-tidy-linelength # This is a small script that we use on CI to collect CPU usage statistics of @@ -37,7 +37,10 @@ import datetime import sys import time -if sys.platform == 'linux2': +# Python 3.3 changed the value of `sys.platform` on Linux from "linux2" to just +# "linux". We check here with `.startswith` to keep compatibility with older +# Python versions (especially Python 2.7). +if sys.platform.startswith('linux'): class State: def __init__(self): with open('/proc/stat', 'r') as file: diff --git a/src/ci/scripts/collect-cpu-stats.sh b/src/ci/scripts/collect-cpu-stats.sh index 08065431f98..853b4628fab 100755 --- a/src/ci/scripts/collect-cpu-stats.sh +++ b/src/ci/scripts/collect-cpu-stats.sh @@ -6,4 +6,4 @@ set -euo pipefail IFS=$'\n\t' -python src/ci/cpu-usage-over-time.py &> cpu-usage.csv & +python3 src/ci/cpu-usage-over-time.py &> cpu-usage.csv & From bbfb8579ff4403a2c23e296614d2f5474b124ac9 Mon Sep 17 00:00:00 2001 From: Ryan Levick Date: Tue, 29 Jun 2021 15:35:15 +0200 Subject: [PATCH 07/19] Rename disjoint_capture_migration lint to rust_2021_incompatible_closure_captures --- compiler/rustc_lint_defs/src/builtin.rs | 10 ++--- compiler/rustc_typeck/src/check/upvar.rs | 9 ++-- .../migrations/auto_traits.fixed | 10 ++--- .../migrations/auto_traits.rs | 10 ++--- .../migrations/auto_traits.stderr | 4 +- .../migrations/insignificant_drop.fixed | 44 +++++++++---------- .../migrations/insignificant_drop.rs | 44 +++++++++---------- .../migrations/insignificant_drop.stderr | 4 +- .../insignificant_drop_attr_migrations.fixed | 15 +++---- .../insignificant_drop_attr_migrations.rs | 15 +++---- .../insignificant_drop_attr_migrations.stderr | 8 ++-- .../insignificant_drop_attr_no_migrations.rs | 2 +- .../migrations/issue-78720.rs | 4 +- .../migrations/migrations_rustfix.fixed | 2 +- .../migrations/migrations_rustfix.rs | 2 +- .../migrations/migrations_rustfix.stderr | 4 +- .../migrations/mir_calls_to_shims.fixed | 15 ++++--- .../migrations/mir_calls_to_shims.rs | 15 ++++--- .../migrations/mir_calls_to_shims.stderr | 6 +-- .../migrations/no_migrations.rs | 5 +-- .../migrations/precise.fixed | 13 +++--- .../migrations/precise.rs | 13 +++--- .../migrations/precise.stderr | 6 +-- .../migrations/precise_no_migrations.rs | 5 +-- .../migrations/significant_drop.fixed | 44 +++++++++---------- .../migrations/significant_drop.rs | 44 +++++++++---------- .../migrations/significant_drop.stderr | 4 +- 27 files changed, 180 insertions(+), 177 deletions(-) diff --git a/compiler/rustc_lint_defs/src/builtin.rs b/compiler/rustc_lint_defs/src/builtin.rs index 9dab4053c8e..5c0b7aaf11b 100644 --- a/compiler/rustc_lint_defs/src/builtin.rs +++ b/compiler/rustc_lint_defs/src/builtin.rs @@ -2967,7 +2967,7 @@ declare_lint_pass! { MISSING_ABI, INVALID_DOC_ATTRIBUTES, SEMICOLON_IN_EXPRESSIONS_FROM_MACROS, - DISJOINT_CAPTURE_MIGRATION, + RUST_2021_INCOMPATIBLE_CLOSURE_CAPTURES, LEGACY_DERIVE_HELPERS, PROC_MACRO_BACK_COMPAT, OR_PATTERNS_BACK_COMPAT, @@ -3002,7 +3002,7 @@ declare_lint! { } declare_lint! { - /// The `disjoint_capture_migration` lint detects variables that aren't completely + /// The `rust_2021_incompatible_closure_captures` lint detects variables that aren't completely /// captured in Rust 2021 and affect the Drop order of at least one path starting at this variable. /// It can also detect when a variable implements a trait, but one of its field does not and /// the field is captured by a closure and used with the assumption that said field implements @@ -3011,7 +3011,7 @@ declare_lint! { /// ### Example of drop reorder /// /// ```rust,compile_fail - /// # #![deny(disjoint_capture_migration)] + /// # #![deny(rust_2021_incompatible_closure_captures)] /// # #![allow(unused)] /// struct FancyInteger(i32); /// @@ -3046,7 +3046,7 @@ declare_lint! { /// ### Example of auto-trait /// /// ```rust,compile_fail - /// #![deny(disjoint_capture_migration)] + /// #![deny(rust_2021_incompatible_closure_captures)] /// use std::thread; /// /// struct Pointer(*mut i32); @@ -3068,7 +3068,7 @@ declare_lint! { /// In the above example, only `fptr.0` is captured in Rust 2021. /// The field is of type *mut i32 which doesn't implement Send, making the code invalid as the /// field cannot be sent between thread safely. - pub DISJOINT_CAPTURE_MIGRATION, + pub RUST_2021_INCOMPATIBLE_CLOSURE_CAPTURES, Allow, "detects closures affected by Rust 2021 changes", @future_incompatible = FutureIncompatibleInfo { diff --git a/compiler/rustc_typeck/src/check/upvar.rs b/compiler/rustc_typeck/src/check/upvar.rs index e5f18778f43..da8e6746b22 100644 --- a/compiler/rustc_typeck/src/check/upvar.rs +++ b/compiler/rustc_typeck/src/check/upvar.rs @@ -173,7 +173,7 @@ impl<'a, 'tcx> FnCtxt<'a, 'tcx> { let closure_hir_id = self.tcx.hir().local_def_id_to_hir_id(local_def_id); - if should_do_disjoint_capture_migration_analysis(self.tcx, closure_hir_id) { + if should_do_rust_2021_incompatible_closure_captures_analysis(self.tcx, closure_hir_id) { self.perform_2229_migration_anaysis(closure_def_id, body_id, capture_clause, span); } @@ -505,7 +505,7 @@ impl<'a, 'tcx> FnCtxt<'a, 'tcx> { let local_def_id = closure_def_id.expect_local(); let closure_hir_id = self.tcx.hir().local_def_id_to_hir_id(local_def_id); self.tcx.struct_span_lint_hir( - lint::builtin::DISJOINT_CAPTURE_MIGRATION, + lint::builtin::RUST_2021_INCOMPATIBLE_CLOSURE_CAPTURES, closure_hir_id, span, |lint| { @@ -1829,8 +1829,9 @@ fn var_name(tcx: TyCtxt<'_>, var_hir_id: hir::HirId) -> Symbol { tcx.hir().name(var_hir_id) } -fn should_do_disjoint_capture_migration_analysis(tcx: TyCtxt<'_>, closure_id: hir::HirId) -> bool { - let (level, _) = tcx.lint_level_at_node(lint::builtin::DISJOINT_CAPTURE_MIGRATION, closure_id); +fn should_do_rust_2021_incompatible_closure_captures_analysis(tcx: TyCtxt<'_>, closure_id: hir::HirId) -> bool { + let (level, _) = + tcx.lint_level_at_node(lint::builtin::RUST_2021_INCOMPATIBLE_CLOSURE_CAPTURES, closure_id); !matches!(level, lint::Level::Allow) } diff --git a/src/test/ui/closures/2229_closure_analysis/migrations/auto_traits.fixed b/src/test/ui/closures/2229_closure_analysis/migrations/auto_traits.fixed index ee8dd4b4fc3..134d07c400b 100644 --- a/src/test/ui/closures/2229_closure_analysis/migrations/auto_traits.fixed +++ b/src/test/ui/closures/2229_closure_analysis/migrations/auto_traits.fixed @@ -1,10 +1,10 @@ // run-rustfix -#![deny(disjoint_capture_migration)] +#![deny(rust_2021_incompatible_closure_captures)] use std::thread; /* Test Send Trait Migration */ -struct SendPointer (*mut i32); +struct SendPointer(*mut i32); unsafe impl Send for SendPointer {} fn test_send_trait() { @@ -18,8 +18,8 @@ fn test_send_trait() { } /* Test Sync Trait Migration */ -struct CustomInt (*mut i32); -struct SyncPointer (CustomInt); +struct CustomInt(*mut i32); +struct SyncPointer(CustomInt); unsafe impl Sync for SyncPointer {} unsafe impl Send for CustomInt {} @@ -38,7 +38,7 @@ fn test_sync_trait() { struct S(String); struct T(i32); -struct U(S,T); +struct U(S, T); impl Clone for U { fn clone(&self) -> Self { diff --git a/src/test/ui/closures/2229_closure_analysis/migrations/auto_traits.rs b/src/test/ui/closures/2229_closure_analysis/migrations/auto_traits.rs index 7a6dcc55bbb..b48a724f052 100644 --- a/src/test/ui/closures/2229_closure_analysis/migrations/auto_traits.rs +++ b/src/test/ui/closures/2229_closure_analysis/migrations/auto_traits.rs @@ -1,10 +1,10 @@ // run-rustfix -#![deny(disjoint_capture_migration)] +#![deny(rust_2021_incompatible_closure_captures)] use std::thread; /* Test Send Trait Migration */ -struct SendPointer (*mut i32); +struct SendPointer(*mut i32); unsafe impl Send for SendPointer {} fn test_send_trait() { @@ -18,8 +18,8 @@ fn test_send_trait() { } /* Test Sync Trait Migration */ -struct CustomInt (*mut i32); -struct SyncPointer (CustomInt); +struct CustomInt(*mut i32); +struct SyncPointer(CustomInt); unsafe impl Sync for SyncPointer {} unsafe impl Send for CustomInt {} @@ -38,7 +38,7 @@ fn test_sync_trait() { struct S(String); struct T(i32); -struct U(S,T); +struct U(S, T); impl Clone for U { fn clone(&self) -> Self { diff --git a/src/test/ui/closures/2229_closure_analysis/migrations/auto_traits.stderr b/src/test/ui/closures/2229_closure_analysis/migrations/auto_traits.stderr index d8420f9652e..3d3dde15412 100644 --- a/src/test/ui/closures/2229_closure_analysis/migrations/auto_traits.stderr +++ b/src/test/ui/closures/2229_closure_analysis/migrations/auto_traits.stderr @@ -12,8 +12,8 @@ LL | | }); note: the lint level is defined here --> $DIR/auto_traits.rs:2:9 | -LL | #![deny(disjoint_capture_migration)] - | ^^^^^^^^^^^^^^^^^^^^^^^^^^ +LL | #![deny(rust_2021_incompatible_closure_captures)] + | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ = note: for more information, see help: add a dummy let to cause `fptr` to be fully captured | diff --git a/src/test/ui/closures/2229_closure_analysis/migrations/insignificant_drop.fixed b/src/test/ui/closures/2229_closure_analysis/migrations/insignificant_drop.fixed index 4bc9b19642f..51d9c4881af 100644 --- a/src/test/ui/closures/2229_closure_analysis/migrations/insignificant_drop.fixed +++ b/src/test/ui/closures/2229_closure_analysis/migrations/insignificant_drop.fixed @@ -1,6 +1,6 @@ // run-rustfix -#![deny(disjoint_capture_migration)] +#![deny(rust_2021_incompatible_closure_captures)] //~^ NOTE: the lint level is defined here // Test cases for types that implement a insignificant drop (stlib defined) @@ -13,9 +13,9 @@ fn test1_all_need_migration() { let t2 = (String::new(), String::new()); let c = || { let _ = (&t, &t1, &t2); - //~^ ERROR: drop order - //~| NOTE: for more information, see - //~| HELP: add a dummy let to cause `t`, `t1`, `t2` to be fully captured + //~^ ERROR: drop order + //~| NOTE: for more information, see + //~| HELP: add a dummy let to cause `t`, `t1`, `t2` to be fully captured let _t = t.0; let _t1 = t1.0; @@ -33,9 +33,9 @@ fn test2_only_precise_paths_need_migration() { let t2 = (String::new(), String::new()); let c = || { let _ = (&t, &t1); - //~^ ERROR: drop order - //~| NOTE: for more information, see - //~| HELP: add a dummy let to cause `t`, `t1` to be fully captured + //~^ ERROR: drop order + //~| NOTE: for more information, see + //~| HELP: add a dummy let to cause `t`, `t1` to be fully captured let _t = t.0; let _t1 = t1.0; let _t2 = t2; @@ -50,9 +50,9 @@ fn test3_only_by_value_need_migration() { let t = (String::new(), String::new()); let t1 = (String::new(), String::new()); let c = || { let _ = &t; - //~^ ERROR: drop order - //~| NOTE: for more information, see - //~| HELP: add a dummy let to cause `t` to be fully captured + //~^ ERROR: drop order + //~| NOTE: for more information, see + //~| HELP: add a dummy let to cause `t` to be fully captured let _t = t.0; println!("{}", t1.1); }; @@ -69,9 +69,9 @@ fn test4_only_non_copy_types_need_migration() { let t1 = (0i32, 0i32); let c = || { let _ = &t; - //~^ ERROR: drop order - //~| NOTE: for more information, see - //~| HELP: add a dummy let to cause `t` to be fully captured + //~^ ERROR: drop order + //~| NOTE: for more information, see + //~| HELP: add a dummy let to cause `t` to be fully captured let _t = t.0; let _t1 = t1.0; }; @@ -88,9 +88,9 @@ fn test5_only_drop_types_need_migration() { let s = S(0i32, 0i32); let c = || { let _ = &t; - //~^ ERROR: drop order - //~| NOTE: for more information, see - //~| HELP: add a dummy let to cause `t` to be fully captured + //~^ ERROR: drop order + //~| NOTE: for more information, see + //~| HELP: add a dummy let to cause `t` to be fully captured let _t = t.0; let _s = s.0; }; @@ -104,9 +104,9 @@ fn test6_move_closures_non_copy_types_might_need_migration() { let t = (String::new(), String::new()); let t1 = (String::new(), String::new()); let c = move || { let _ = (&t1, &t); - //~^ ERROR: drop order - //~| NOTE: for more information, see - //~| HELP: add a dummy let to cause `t1`, `t` to be fully captured + //~^ ERROR: drop order + //~| NOTE: for more information, see + //~| HELP: add a dummy let to cause `t1`, `t` to be fully captured println!("{} {}", t1.1, t.1); }; @@ -120,9 +120,9 @@ fn test7_drop_non_drop_aggregate_need_migration() { let t = (String::new(), String::new(), 0i32); let c = || { let _ = &t; - //~^ ERROR: drop order - //~| NOTE: for more information, see - //~| HELP: add a dummy let to cause `t` to be fully captured + //~^ ERROR: drop order + //~| NOTE: for more information, see + //~| HELP: add a dummy let to cause `t` to be fully captured let _t = t.0; }; diff --git a/src/test/ui/closures/2229_closure_analysis/migrations/insignificant_drop.rs b/src/test/ui/closures/2229_closure_analysis/migrations/insignificant_drop.rs index 446ce43a469..c732cbb4fa5 100644 --- a/src/test/ui/closures/2229_closure_analysis/migrations/insignificant_drop.rs +++ b/src/test/ui/closures/2229_closure_analysis/migrations/insignificant_drop.rs @@ -1,6 +1,6 @@ // run-rustfix -#![deny(disjoint_capture_migration)] +#![deny(rust_2021_incompatible_closure_captures)] //~^ NOTE: the lint level is defined here // Test cases for types that implement a insignificant drop (stlib defined) @@ -13,9 +13,9 @@ fn test1_all_need_migration() { let t2 = (String::new(), String::new()); let c = || { - //~^ ERROR: drop order - //~| NOTE: for more information, see - //~| HELP: add a dummy let to cause `t`, `t1`, `t2` to be fully captured + //~^ ERROR: drop order + //~| NOTE: for more information, see + //~| HELP: add a dummy let to cause `t`, `t1`, `t2` to be fully captured let _t = t.0; let _t1 = t1.0; @@ -33,9 +33,9 @@ fn test2_only_precise_paths_need_migration() { let t2 = (String::new(), String::new()); let c = || { - //~^ ERROR: drop order - //~| NOTE: for more information, see - //~| HELP: add a dummy let to cause `t`, `t1` to be fully captured + //~^ ERROR: drop order + //~| NOTE: for more information, see + //~| HELP: add a dummy let to cause `t`, `t1` to be fully captured let _t = t.0; let _t1 = t1.0; let _t2 = t2; @@ -50,9 +50,9 @@ fn test3_only_by_value_need_migration() { let t = (String::new(), String::new()); let t1 = (String::new(), String::new()); let c = || { - //~^ ERROR: drop order - //~| NOTE: for more information, see - //~| HELP: add a dummy let to cause `t` to be fully captured + //~^ ERROR: drop order + //~| NOTE: for more information, see + //~| HELP: add a dummy let to cause `t` to be fully captured let _t = t.0; println!("{}", t1.1); }; @@ -69,9 +69,9 @@ fn test4_only_non_copy_types_need_migration() { let t1 = (0i32, 0i32); let c = || { - //~^ ERROR: drop order - //~| NOTE: for more information, see - //~| HELP: add a dummy let to cause `t` to be fully captured + //~^ ERROR: drop order + //~| NOTE: for more information, see + //~| HELP: add a dummy let to cause `t` to be fully captured let _t = t.0; let _t1 = t1.0; }; @@ -88,9 +88,9 @@ fn test5_only_drop_types_need_migration() { let s = S(0i32, 0i32); let c = || { - //~^ ERROR: drop order - //~| NOTE: for more information, see - //~| HELP: add a dummy let to cause `t` to be fully captured + //~^ ERROR: drop order + //~| NOTE: for more information, see + //~| HELP: add a dummy let to cause `t` to be fully captured let _t = t.0; let _s = s.0; }; @@ -104,9 +104,9 @@ fn test6_move_closures_non_copy_types_might_need_migration() { let t = (String::new(), String::new()); let t1 = (String::new(), String::new()); let c = move || { - //~^ ERROR: drop order - //~| NOTE: for more information, see - //~| HELP: add a dummy let to cause `t1`, `t` to be fully captured + //~^ ERROR: drop order + //~| NOTE: for more information, see + //~| HELP: add a dummy let to cause `t1`, `t` to be fully captured println!("{} {}", t1.1, t.1); }; @@ -120,9 +120,9 @@ fn test7_drop_non_drop_aggregate_need_migration() { let t = (String::new(), String::new(), 0i32); let c = || { - //~^ ERROR: drop order - //~| NOTE: for more information, see - //~| HELP: add a dummy let to cause `t` to be fully captured + //~^ ERROR: drop order + //~| NOTE: for more information, see + //~| HELP: add a dummy let to cause `t` to be fully captured let _t = t.0; }; diff --git a/src/test/ui/closures/2229_closure_analysis/migrations/insignificant_drop.stderr b/src/test/ui/closures/2229_closure_analysis/migrations/insignificant_drop.stderr index 0dfbcddc279..89a2b0eb953 100644 --- a/src/test/ui/closures/2229_closure_analysis/migrations/insignificant_drop.stderr +++ b/src/test/ui/closures/2229_closure_analysis/migrations/insignificant_drop.stderr @@ -14,8 +14,8 @@ LL | | }; note: the lint level is defined here --> $DIR/insignificant_drop.rs:3:9 | -LL | #![deny(disjoint_capture_migration)] - | ^^^^^^^^^^^^^^^^^^^^^^^^^^ +LL | #![deny(rust_2021_incompatible_closure_captures)] + | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ = note: for more information, see help: add a dummy let to cause `t`, `t1`, `t2` to be fully captured | diff --git a/src/test/ui/closures/2229_closure_analysis/migrations/insignificant_drop_attr_migrations.fixed b/src/test/ui/closures/2229_closure_analysis/migrations/insignificant_drop_attr_migrations.fixed index 5a781219a72..8c85cd990d3 100644 --- a/src/test/ui/closures/2229_closure_analysis/migrations/insignificant_drop_attr_migrations.fixed +++ b/src/test/ui/closures/2229_closure_analysis/migrations/insignificant_drop_attr_migrations.fixed @@ -1,8 +1,7 @@ // run-rustfix -#![deny(disjoint_capture_migration)] +#![deny(rust_2021_incompatible_closure_captures)] //~^ NOTE: the lint level is defined here - #![feature(rustc_attrs)] #![allow(unused)] @@ -36,9 +35,9 @@ fn significant_drop_needs_migration() { let t = (SigDrop {}, SigDrop {}); let c = || { let _ = &t; - //~^ ERROR: drop order - //~| NOTE: for more information, see - //~| HELP: add a dummy let to cause `t` to be fully captured + //~^ ERROR: drop order + //~| NOTE: for more information, see + //~| HELP: add a dummy let to cause `t` to be fully captured let _t = t.0; }; @@ -54,9 +53,9 @@ fn generic_struct_with_significant_drop_needs_migration() { // move is used to force i32 to be copied instead of being a ref let c = move || { let _ = &t; - //~^ ERROR: drop order - //~| NOTE: for more information, see - //~| HELP: add a dummy let to cause `t` to be fully captured + //~^ ERROR: drop order + //~| NOTE: for more information, see + //~| HELP: add a dummy let to cause `t` to be fully captured let _t = t.1; }; diff --git a/src/test/ui/closures/2229_closure_analysis/migrations/insignificant_drop_attr_migrations.rs b/src/test/ui/closures/2229_closure_analysis/migrations/insignificant_drop_attr_migrations.rs index d57da326556..17cee28e311 100644 --- a/src/test/ui/closures/2229_closure_analysis/migrations/insignificant_drop_attr_migrations.rs +++ b/src/test/ui/closures/2229_closure_analysis/migrations/insignificant_drop_attr_migrations.rs @@ -1,8 +1,7 @@ // run-rustfix -#![deny(disjoint_capture_migration)] +#![deny(rust_2021_incompatible_closure_captures)] //~^ NOTE: the lint level is defined here - #![feature(rustc_attrs)] #![allow(unused)] @@ -36,9 +35,9 @@ fn significant_drop_needs_migration() { let t = (SigDrop {}, SigDrop {}); let c = || { - //~^ ERROR: drop order - //~| NOTE: for more information, see - //~| HELP: add a dummy let to cause `t` to be fully captured + //~^ ERROR: drop order + //~| NOTE: for more information, see + //~| HELP: add a dummy let to cause `t` to be fully captured let _t = t.0; }; @@ -54,9 +53,9 @@ fn generic_struct_with_significant_drop_needs_migration() { // move is used to force i32 to be copied instead of being a ref let c = move || { - //~^ ERROR: drop order - //~| NOTE: for more information, see - //~| HELP: add a dummy let to cause `t` to be fully captured + //~^ ERROR: drop order + //~| NOTE: for more information, see + //~| HELP: add a dummy let to cause `t` to be fully captured let _t = t.1; }; diff --git a/src/test/ui/closures/2229_closure_analysis/migrations/insignificant_drop_attr_migrations.stderr b/src/test/ui/closures/2229_closure_analysis/migrations/insignificant_drop_attr_migrations.stderr index d25f8f635be..1d3bda03d0e 100644 --- a/src/test/ui/closures/2229_closure_analysis/migrations/insignificant_drop_attr_migrations.stderr +++ b/src/test/ui/closures/2229_closure_analysis/migrations/insignificant_drop_attr_migrations.stderr @@ -1,5 +1,5 @@ error: drop order will change in Rust 2021 - --> $DIR/insignificant_drop_attr_migrations.rs:38:13 + --> $DIR/insignificant_drop_attr_migrations.rs:37:13 | LL | let c = || { | _____________^ @@ -13,8 +13,8 @@ LL | | }; note: the lint level is defined here --> $DIR/insignificant_drop_attr_migrations.rs:3:9 | -LL | #![deny(disjoint_capture_migration)] - | ^^^^^^^^^^^^^^^^^^^^^^^^^^ +LL | #![deny(rust_2021_incompatible_closure_captures)] + | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ = note: for more information, see help: add a dummy let to cause `t` to be fully captured | @@ -27,7 +27,7 @@ LL | }; | error: drop order will change in Rust 2021 - --> $DIR/insignificant_drop_attr_migrations.rs:56:13 + --> $DIR/insignificant_drop_attr_migrations.rs:55:13 | LL | let c = move || { | _____________^ diff --git a/src/test/ui/closures/2229_closure_analysis/migrations/insignificant_drop_attr_no_migrations.rs b/src/test/ui/closures/2229_closure_analysis/migrations/insignificant_drop_attr_no_migrations.rs index a00377456ac..a527bf42e57 100644 --- a/src/test/ui/closures/2229_closure_analysis/migrations/insignificant_drop_attr_no_migrations.rs +++ b/src/test/ui/closures/2229_closure_analysis/migrations/insignificant_drop_attr_no_migrations.rs @@ -1,6 +1,6 @@ // run-pass -#![deny(disjoint_capture_migration)] +#![deny(rust_2021_incompatible_closure_captures)] #![feature(rustc_attrs)] #![allow(unused)] diff --git a/src/test/ui/closures/2229_closure_analysis/migrations/issue-78720.rs b/src/test/ui/closures/2229_closure_analysis/migrations/issue-78720.rs index ee3138ea69e..ff5d284614b 100644 --- a/src/test/ui/closures/2229_closure_analysis/migrations/issue-78720.rs +++ b/src/test/ui/closures/2229_closure_analysis/migrations/issue-78720.rs @@ -1,10 +1,10 @@ // run-pass -#![warn(disjoint_capture_migration)] +#![warn(rust_2021_incompatible_closure_captures)] fn main() { if let a = "" { - //~^ WARNING: irrefutable `if let` pattern + //~^ WARNING: irrefutable `if let` pattern drop(|_: ()| drop(a)); } } diff --git a/src/test/ui/closures/2229_closure_analysis/migrations/migrations_rustfix.fixed b/src/test/ui/closures/2229_closure_analysis/migrations/migrations_rustfix.fixed index 42b6ce54d3c..c974299c153 100644 --- a/src/test/ui/closures/2229_closure_analysis/migrations/migrations_rustfix.fixed +++ b/src/test/ui/closures/2229_closure_analysis/migrations/migrations_rustfix.fixed @@ -1,5 +1,5 @@ // run-rustfix -#![deny(disjoint_capture_migration)] +#![deny(rust_2021_incompatible_closure_captures)] //~^ NOTE: the lint level is defined here // Test the two possible cases for automated migartion using rustfix diff --git a/src/test/ui/closures/2229_closure_analysis/migrations/migrations_rustfix.rs b/src/test/ui/closures/2229_closure_analysis/migrations/migrations_rustfix.rs index ab0ed460fba..dd9556aa567 100644 --- a/src/test/ui/closures/2229_closure_analysis/migrations/migrations_rustfix.rs +++ b/src/test/ui/closures/2229_closure_analysis/migrations/migrations_rustfix.rs @@ -1,5 +1,5 @@ // run-rustfix -#![deny(disjoint_capture_migration)] +#![deny(rust_2021_incompatible_closure_captures)] //~^ NOTE: the lint level is defined here // Test the two possible cases for automated migartion using rustfix diff --git a/src/test/ui/closures/2229_closure_analysis/migrations/migrations_rustfix.stderr b/src/test/ui/closures/2229_closure_analysis/migrations/migrations_rustfix.stderr index 7b654f480a3..2d5e5e5e55c 100644 --- a/src/test/ui/closures/2229_closure_analysis/migrations/migrations_rustfix.stderr +++ b/src/test/ui/closures/2229_closure_analysis/migrations/migrations_rustfix.stderr @@ -13,8 +13,8 @@ LL | | }; note: the lint level is defined here --> $DIR/migrations_rustfix.rs:2:9 | -LL | #![deny(disjoint_capture_migration)] - | ^^^^^^^^^^^^^^^^^^^^^^^^^^ +LL | #![deny(rust_2021_incompatible_closure_captures)] + | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ = note: for more information, see help: add a dummy let to cause `t` to be fully captured | diff --git a/src/test/ui/closures/2229_closure_analysis/migrations/mir_calls_to_shims.fixed b/src/test/ui/closures/2229_closure_analysis/migrations/mir_calls_to_shims.fixed index abff6802e95..7f49b460ef6 100644 --- a/src/test/ui/closures/2229_closure_analysis/migrations/mir_calls_to_shims.fixed +++ b/src/test/ui/closures/2229_closure_analysis/migrations/mir_calls_to_shims.fixed @@ -1,16 +1,20 @@ // run-rustfix -#![deny(disjoint_capture_migration)] +#![deny(rust_2021_incompatible_closure_captures)] // ignore-wasm32-bare compiled with panic=abort by default - #![feature(fn_traits)] #![feature(never_type)] use std::panic; -fn foo_diverges() -> ! { panic!() } +fn foo_diverges() -> ! { + panic!() +} -fn assert_panics(f: F) where F: FnOnce() { +fn assert_panics(f: F) +where + F: FnOnce(), +{ let f = panic::AssertUnwindSafe(f); let result = panic::catch_unwind(move || { let _ = &f; //~^ ERROR: `UnwindSafe`, `RefUnwindSafe` trait implementation @@ -23,7 +27,8 @@ fn assert_panics(f: F) where F: FnOnce() { } fn test_fn_ptr_panic(mut t: T) - where T: Fn() -> ! +where + T: Fn() -> !, { let as_fn = >::call; assert_panics(|| as_fn(&t, ())); diff --git a/src/test/ui/closures/2229_closure_analysis/migrations/mir_calls_to_shims.rs b/src/test/ui/closures/2229_closure_analysis/migrations/mir_calls_to_shims.rs index baa17e85b52..3c654bec526 100644 --- a/src/test/ui/closures/2229_closure_analysis/migrations/mir_calls_to_shims.rs +++ b/src/test/ui/closures/2229_closure_analysis/migrations/mir_calls_to_shims.rs @@ -1,16 +1,20 @@ // run-rustfix -#![deny(disjoint_capture_migration)] +#![deny(rust_2021_incompatible_closure_captures)] // ignore-wasm32-bare compiled with panic=abort by default - #![feature(fn_traits)] #![feature(never_type)] use std::panic; -fn foo_diverges() -> ! { panic!() } +fn foo_diverges() -> ! { + panic!() +} -fn assert_panics(f: F) where F: FnOnce() { +fn assert_panics(f: F) +where + F: FnOnce(), +{ let f = panic::AssertUnwindSafe(f); let result = panic::catch_unwind(move || { //~^ ERROR: `UnwindSafe`, `RefUnwindSafe` trait implementation @@ -23,7 +27,8 @@ fn assert_panics(f: F) where F: FnOnce() { } fn test_fn_ptr_panic(mut t: T) - where T: Fn() -> ! +where + T: Fn() -> !, { let as_fn = >::call; assert_panics(|| as_fn(&t, ())); diff --git a/src/test/ui/closures/2229_closure_analysis/migrations/mir_calls_to_shims.stderr b/src/test/ui/closures/2229_closure_analysis/migrations/mir_calls_to_shims.stderr index 8dca06a836c..dca5c454b83 100644 --- a/src/test/ui/closures/2229_closure_analysis/migrations/mir_calls_to_shims.stderr +++ b/src/test/ui/closures/2229_closure_analysis/migrations/mir_calls_to_shims.stderr @@ -1,5 +1,5 @@ error: `UnwindSafe`, `RefUnwindSafe` trait implementation will change in Rust 2021 - --> $DIR/mir_calls_to_shims.rs:15:38 + --> $DIR/mir_calls_to_shims.rs:19:38 | LL | let result = panic::catch_unwind(move || { | ______________________________________^ @@ -12,8 +12,8 @@ LL | | }); note: the lint level is defined here --> $DIR/mir_calls_to_shims.rs:3:9 | -LL | #![deny(disjoint_capture_migration)] - | ^^^^^^^^^^^^^^^^^^^^^^^^^^ +LL | #![deny(rust_2021_incompatible_closure_captures)] + | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ = note: for more information, see help: add a dummy let to cause `f` to be fully captured | diff --git a/src/test/ui/closures/2229_closure_analysis/migrations/no_migrations.rs b/src/test/ui/closures/2229_closure_analysis/migrations/no_migrations.rs index 420d66fba5e..8b75e226ab5 100644 --- a/src/test/ui/closures/2229_closure_analysis/migrations/no_migrations.rs +++ b/src/test/ui/closures/2229_closure_analysis/migrations/no_migrations.rs @@ -2,8 +2,7 @@ // Set of test cases that don't need migrations -#![deny(disjoint_capture_migration)] - +#![deny(rust_2021_incompatible_closure_captures)] // Copy types as copied by the closure instead of being moved into the closure // Therefore their drop order isn't tied to the closure and won't be requiring any @@ -53,7 +52,6 @@ fn test4_insignificant_drop_non_drop_aggregate() { c(); } - struct Foo(i32); impl Drop for Foo { fn drop(&mut self) { @@ -80,5 +78,4 @@ fn main() { test3_only_copy_types_move_closure(); test4_insignificant_drop_non_drop_aggregate(); test5_significant_drop_non_drop_aggregate(); - } diff --git a/src/test/ui/closures/2229_closure_analysis/migrations/precise.fixed b/src/test/ui/closures/2229_closure_analysis/migrations/precise.fixed index 90ea1ed2883..ba5e5b573f1 100644 --- a/src/test/ui/closures/2229_closure_analysis/migrations/precise.fixed +++ b/src/test/ui/closures/2229_closure_analysis/migrations/precise.fixed @@ -1,6 +1,6 @@ // run-rustfix -#![deny(disjoint_capture_migration)] +#![deny(rust_2021_incompatible_closure_captures)] #[derive(Debug)] struct Foo(i32); @@ -17,8 +17,8 @@ fn test_precise_analysis_drop_paths_not_captured_by_move() { let t = ConstainsDropField(Foo(10), Foo(20)); let c = || { let _ = &t; - //~^ ERROR: drop order - //~| HELP: add a dummy let to cause `t` to be fully captured + //~^ ERROR: drop order + //~| HELP: add a dummy let to cause `t` to be fully captured let _t = t.0; let _t = &t.1; }; @@ -28,8 +28,7 @@ fn test_precise_analysis_drop_paths_not_captured_by_move() { struct S; impl Drop for S { - fn drop(&mut self) { - } + fn drop(&mut self) {} } struct T(S, S); @@ -40,8 +39,8 @@ fn test_precise_analysis_long_path_missing() { let u = U(T(S, S), T(S, S)); let c = || { let _ = &u; - //~^ ERROR: drop order - //~| HELP: add a dummy let to cause `u` to be fully captured + //~^ ERROR: drop order + //~| HELP: add a dummy let to cause `u` to be fully captured let _x = u.0.0; let _x = u.0.1; let _x = u.1.0; diff --git a/src/test/ui/closures/2229_closure_analysis/migrations/precise.rs b/src/test/ui/closures/2229_closure_analysis/migrations/precise.rs index cb432304592..92b6f25c80d 100644 --- a/src/test/ui/closures/2229_closure_analysis/migrations/precise.rs +++ b/src/test/ui/closures/2229_closure_analysis/migrations/precise.rs @@ -1,6 +1,6 @@ // run-rustfix -#![deny(disjoint_capture_migration)] +#![deny(rust_2021_incompatible_closure_captures)] #[derive(Debug)] struct Foo(i32); @@ -17,8 +17,8 @@ fn test_precise_analysis_drop_paths_not_captured_by_move() { let t = ConstainsDropField(Foo(10), Foo(20)); let c = || { - //~^ ERROR: drop order - //~| HELP: add a dummy let to cause `t` to be fully captured + //~^ ERROR: drop order + //~| HELP: add a dummy let to cause `t` to be fully captured let _t = t.0; let _t = &t.1; }; @@ -28,8 +28,7 @@ fn test_precise_analysis_drop_paths_not_captured_by_move() { struct S; impl Drop for S { - fn drop(&mut self) { - } + fn drop(&mut self) {} } struct T(S, S); @@ -40,8 +39,8 @@ fn test_precise_analysis_long_path_missing() { let u = U(T(S, S), T(S, S)); let c = || { - //~^ ERROR: drop order - //~| HELP: add a dummy let to cause `u` to be fully captured + //~^ ERROR: drop order + //~| HELP: add a dummy let to cause `u` to be fully captured let _x = u.0.0; let _x = u.0.1; let _x = u.1.0; diff --git a/src/test/ui/closures/2229_closure_analysis/migrations/precise.stderr b/src/test/ui/closures/2229_closure_analysis/migrations/precise.stderr index f010c51f136..2788207296f 100644 --- a/src/test/ui/closures/2229_closure_analysis/migrations/precise.stderr +++ b/src/test/ui/closures/2229_closure_analysis/migrations/precise.stderr @@ -13,8 +13,8 @@ LL | | }; note: the lint level is defined here --> $DIR/precise.rs:3:9 | -LL | #![deny(disjoint_capture_migration)] - | ^^^^^^^^^^^^^^^^^^^^^^^^^^ +LL | #![deny(rust_2021_incompatible_closure_captures)] + | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ = note: for more information, see help: add a dummy let to cause `t` to be fully captured | @@ -27,7 +27,7 @@ LL | }; | error: drop order will change in Rust 2021 - --> $DIR/precise.rs:42:13 + --> $DIR/precise.rs:41:13 | LL | let c = || { | _____________^ diff --git a/src/test/ui/closures/2229_closure_analysis/migrations/precise_no_migrations.rs b/src/test/ui/closures/2229_closure_analysis/migrations/precise_no_migrations.rs index e3a7220bf09..587d71c40fc 100644 --- a/src/test/ui/closures/2229_closure_analysis/migrations/precise_no_migrations.rs +++ b/src/test/ui/closures/2229_closure_analysis/migrations/precise_no_migrations.rs @@ -1,6 +1,6 @@ // run-pass -#![deny(disjoint_capture_migration)] +#![deny(rust_2021_incompatible_closure_captures)] #[derive(Debug)] struct Foo(i32); @@ -73,8 +73,7 @@ fn test_precise_analysis_parent_captured_2() { struct S; impl Drop for S { - fn drop(&mut self) { - } + fn drop(&mut self) {} } struct T(S, S); diff --git a/src/test/ui/closures/2229_closure_analysis/migrations/significant_drop.fixed b/src/test/ui/closures/2229_closure_analysis/migrations/significant_drop.fixed index 1c970175d18..58ed2de26b3 100644 --- a/src/test/ui/closures/2229_closure_analysis/migrations/significant_drop.fixed +++ b/src/test/ui/closures/2229_closure_analysis/migrations/significant_drop.fixed @@ -1,5 +1,5 @@ // run-rustfix -#![deny(disjoint_capture_migration)] +#![deny(rust_2021_incompatible_closure_captures)] //~^ NOTE: the lint level is defined here // Test cases for types that implement a significant drop (user defined) @@ -23,9 +23,9 @@ fn test1_all_need_migration() { let t2 = (Foo(0), Foo(0)); let c = || { let _ = (&t, &t1, &t2); - //~^ ERROR: drop order - //~| NOTE: for more information, see - //~| HELP: add a dummy let to cause `t`, `t1`, `t2` to be fully captured + //~^ ERROR: drop order + //~| NOTE: for more information, see + //~| HELP: add a dummy let to cause `t`, `t1`, `t2` to be fully captured let _t = t.0; let _t1 = t1.0; let _t2 = t2.0; @@ -42,9 +42,9 @@ fn test2_only_precise_paths_need_migration() { let t2 = (Foo(0), Foo(0)); let c = || { let _ = (&t, &t1); - //~^ ERROR: drop order - //~| NOTE: for more information, see - //~| HELP: add a dummy let to cause `t`, `t1` to be fully captured + //~^ ERROR: drop order + //~| NOTE: for more information, see + //~| HELP: add a dummy let to cause `t`, `t1` to be fully captured let _t = t.0; let _t1 = t1.0; let _t2 = t2; @@ -59,9 +59,9 @@ fn test3_only_by_value_need_migration() { let t = (Foo(0), Foo(0)); let t1 = (Foo(0), Foo(0)); let c = || { let _ = &t; - //~^ ERROR: drop order - //~| NOTE: for more information, see - //~| HELP: add a dummy let to cause `t` to be fully captured + //~^ ERROR: drop order + //~| NOTE: for more information, see + //~| HELP: add a dummy let to cause `t` to be fully captured let _t = t.0; println!("{:?}", t1.1); }; @@ -77,9 +77,9 @@ fn test4_type_contains_drop_need_migration() { let t = ConstainsDropField(Foo(0), Foo(0)); let c = || { let _ = &t; - //~^ ERROR: drop order - //~| NOTE: for more information, see - //~| HELP: add a dummy let to cause `t` to be fully captured + //~^ ERROR: drop order + //~| NOTE: for more information, see + //~| HELP: add a dummy let to cause `t` to be fully captured let _t = t.0; }; @@ -93,9 +93,9 @@ fn test5_drop_non_drop_aggregate_need_migration() { let t = (Foo(0), Foo(0), 0i32); let c = || { let _ = &t; - //~^ ERROR: drop order - //~| NOTE: for more information, see - //~| HELP: add a dummy let to cause `t` to be fully captured + //~^ ERROR: drop order + //~| NOTE: for more information, see + //~| HELP: add a dummy let to cause `t` to be fully captured let _t = t.0; }; @@ -107,9 +107,9 @@ fn test6_significant_insignificant_drop_aggregate_need_migration() { let t = (Foo(0), String::new()); let c = || { let _ = &t; - //~^ ERROR: drop order - //~| NOTE: for more information, see - //~| HELP: add a dummy let to cause `t` to be fully captured + //~^ ERROR: drop order + //~| NOTE: for more information, see + //~| HELP: add a dummy let to cause `t` to be fully captured let _t = t.1; }; @@ -123,9 +123,9 @@ fn test7_move_closures_non_copy_types_might_need_migration() { let t1 = (Foo(0), Foo(0), Foo(0)); let c = move || { let _ = (&t1, &t); - //~^ ERROR: drop order - //~| NOTE: for more information, see - //~| HELP: add a dummy let to cause `t1`, `t` to be fully captured + //~^ ERROR: drop order + //~| NOTE: for more information, see + //~| HELP: add a dummy let to cause `t1`, `t` to be fully captured println!("{:?} {:?}", t1.1, t.1); }; diff --git a/src/test/ui/closures/2229_closure_analysis/migrations/significant_drop.rs b/src/test/ui/closures/2229_closure_analysis/migrations/significant_drop.rs index c479a6a54f0..0890fc1c212 100644 --- a/src/test/ui/closures/2229_closure_analysis/migrations/significant_drop.rs +++ b/src/test/ui/closures/2229_closure_analysis/migrations/significant_drop.rs @@ -1,5 +1,5 @@ // run-rustfix -#![deny(disjoint_capture_migration)] +#![deny(rust_2021_incompatible_closure_captures)] //~^ NOTE: the lint level is defined here // Test cases for types that implement a significant drop (user defined) @@ -23,9 +23,9 @@ fn test1_all_need_migration() { let t2 = (Foo(0), Foo(0)); let c = || { - //~^ ERROR: drop order - //~| NOTE: for more information, see - //~| HELP: add a dummy let to cause `t`, `t1`, `t2` to be fully captured + //~^ ERROR: drop order + //~| NOTE: for more information, see + //~| HELP: add a dummy let to cause `t`, `t1`, `t2` to be fully captured let _t = t.0; let _t1 = t1.0; let _t2 = t2.0; @@ -42,9 +42,9 @@ fn test2_only_precise_paths_need_migration() { let t2 = (Foo(0), Foo(0)); let c = || { - //~^ ERROR: drop order - //~| NOTE: for more information, see - //~| HELP: add a dummy let to cause `t`, `t1` to be fully captured + //~^ ERROR: drop order + //~| NOTE: for more information, see + //~| HELP: add a dummy let to cause `t`, `t1` to be fully captured let _t = t.0; let _t1 = t1.0; let _t2 = t2; @@ -59,9 +59,9 @@ fn test3_only_by_value_need_migration() { let t = (Foo(0), Foo(0)); let t1 = (Foo(0), Foo(0)); let c = || { - //~^ ERROR: drop order - //~| NOTE: for more information, see - //~| HELP: add a dummy let to cause `t` to be fully captured + //~^ ERROR: drop order + //~| NOTE: for more information, see + //~| HELP: add a dummy let to cause `t` to be fully captured let _t = t.0; println!("{:?}", t1.1); }; @@ -77,9 +77,9 @@ fn test4_type_contains_drop_need_migration() { let t = ConstainsDropField(Foo(0), Foo(0)); let c = || { - //~^ ERROR: drop order - //~| NOTE: for more information, see - //~| HELP: add a dummy let to cause `t` to be fully captured + //~^ ERROR: drop order + //~| NOTE: for more information, see + //~| HELP: add a dummy let to cause `t` to be fully captured let _t = t.0; }; @@ -93,9 +93,9 @@ fn test5_drop_non_drop_aggregate_need_migration() { let t = (Foo(0), Foo(0), 0i32); let c = || { - //~^ ERROR: drop order - //~| NOTE: for more information, see - //~| HELP: add a dummy let to cause `t` to be fully captured + //~^ ERROR: drop order + //~| NOTE: for more information, see + //~| HELP: add a dummy let to cause `t` to be fully captured let _t = t.0; }; @@ -107,9 +107,9 @@ fn test6_significant_insignificant_drop_aggregate_need_migration() { let t = (Foo(0), String::new()); let c = || { - //~^ ERROR: drop order - //~| NOTE: for more information, see - //~| HELP: add a dummy let to cause `t` to be fully captured + //~^ ERROR: drop order + //~| NOTE: for more information, see + //~| HELP: add a dummy let to cause `t` to be fully captured let _t = t.1; }; @@ -123,9 +123,9 @@ fn test7_move_closures_non_copy_types_might_need_migration() { let t1 = (Foo(0), Foo(0), Foo(0)); let c = move || { - //~^ ERROR: drop order - //~| NOTE: for more information, see - //~| HELP: add a dummy let to cause `t1`, `t` to be fully captured + //~^ ERROR: drop order + //~| NOTE: for more information, see + //~| HELP: add a dummy let to cause `t1`, `t` to be fully captured println!("{:?} {:?}", t1.1, t.1); }; diff --git a/src/test/ui/closures/2229_closure_analysis/migrations/significant_drop.stderr b/src/test/ui/closures/2229_closure_analysis/migrations/significant_drop.stderr index 873a9100bee..ebf9f169fd4 100644 --- a/src/test/ui/closures/2229_closure_analysis/migrations/significant_drop.stderr +++ b/src/test/ui/closures/2229_closure_analysis/migrations/significant_drop.stderr @@ -14,8 +14,8 @@ LL | | }; note: the lint level is defined here --> $DIR/significant_drop.rs:2:9 | -LL | #![deny(disjoint_capture_migration)] - | ^^^^^^^^^^^^^^^^^^^^^^^^^^ +LL | #![deny(rust_2021_incompatible_closure_captures)] + | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ = note: for more information, see help: add a dummy let to cause `t`, `t1`, `t2` to be fully captured | From df71a99a0ea8d89cb1ec9281a6a24a8710c37c9d Mon Sep 17 00:00:00 2001 From: Ryan Levick Date: Tue, 29 Jun 2021 16:05:32 +0200 Subject: [PATCH 08/19] Rename lint --- compiler/rustc_lint/src/lib.rs | 1 + .../2229_closure_analysis/migrations/old_name.rs | 9 +++++++++ .../2229_closure_analysis/migrations/old_name.stderr | 10 ++++++++++ 3 files changed, 20 insertions(+) create mode 100644 src/test/ui/closures/2229_closure_analysis/migrations/old_name.rs create mode 100644 src/test/ui/closures/2229_closure_analysis/migrations/old_name.stderr diff --git a/compiler/rustc_lint/src/lib.rs b/compiler/rustc_lint/src/lib.rs index 89f9809d643..b3b759a466a 100644 --- a/compiler/rustc_lint/src/lib.rs +++ b/compiler/rustc_lint/src/lib.rs @@ -325,6 +325,7 @@ fn register_builtins(store: &mut LintStore, no_interleave_lints: bool) { store.register_renamed("redundant_semicolon", "redundant_semicolons"); store.register_renamed("overlapping_patterns", "overlapping_range_endpoints"); store.register_renamed("safe_packed_borrows", "unaligned_references"); + store.register_renamed("disjoint_capture_migration", "rust_2021_incompatible_closure_captures"); // These were moved to tool lints, but rustc still sees them when compiling normally, before // tool lints are registered, so `check_tool_name_for_backwards_compat` doesn't work. Use diff --git a/src/test/ui/closures/2229_closure_analysis/migrations/old_name.rs b/src/test/ui/closures/2229_closure_analysis/migrations/old_name.rs new file mode 100644 index 00000000000..16e3cca7b77 --- /dev/null +++ b/src/test/ui/closures/2229_closure_analysis/migrations/old_name.rs @@ -0,0 +1,9 @@ +// check-pass + +// Ensure that the old name for `rust_2021_incompatible_closure_captures` is still +// accepted by the compiler + +#![allow(disjoint_capture_migration)] +//~^ WARN lint `disjoint_capture_migration` has been renamed + +fn main() {} diff --git a/src/test/ui/closures/2229_closure_analysis/migrations/old_name.stderr b/src/test/ui/closures/2229_closure_analysis/migrations/old_name.stderr new file mode 100644 index 00000000000..47cb689fa01 --- /dev/null +++ b/src/test/ui/closures/2229_closure_analysis/migrations/old_name.stderr @@ -0,0 +1,10 @@ +warning: lint `disjoint_capture_migration` has been renamed to `rust_2021_incompatible_closure_captures` + --> $DIR/old_name.rs:6:10 + | +LL | #![allow(disjoint_capture_migration)] + | ^^^^^^^^^^^^^^^^^^^^^^^^^^ help: use the new name: `rust_2021_incompatible_closure_captures` + | + = note: `#[warn(renamed_and_removed_lints)]` on by default + +warning: 1 warning emitted + From 1d49658f5c7adc403311b815c9ec8d23e4551de2 Mon Sep 17 00:00:00 2001 From: Ryan Levick Date: Tue, 29 Jun 2021 16:39:19 +0200 Subject: [PATCH 09/19] Change or_patterns_back_compat lint to rust_2021_incompatible_or_patterns --- compiler/rustc_expand/src/mbe/macro_rules.rs | 6 ++++-- compiler/rustc_lint/src/lib.rs | 1 + compiler/rustc_lint_defs/src/builtin.rs | 8 ++++---- library/core/src/lib.rs | 1 + src/test/ui/macros/macro-or-patterns-back-compat.fixed | 2 +- src/test/ui/macros/macro-or-patterns-back-compat.rs | 2 +- src/test/ui/macros/macro-or-patterns-back-compat.stderr | 4 ++-- 7 files changed, 14 insertions(+), 10 deletions(-) diff --git a/compiler/rustc_expand/src/mbe/macro_rules.rs b/compiler/rustc_expand/src/mbe/macro_rules.rs index a255b4f83ac..8b68c94e61a 100644 --- a/compiler/rustc_expand/src/mbe/macro_rules.rs +++ b/compiler/rustc_expand/src/mbe/macro_rules.rs @@ -18,7 +18,9 @@ use rustc_data_structures::fx::FxHashMap; use rustc_data_structures::sync::Lrc; use rustc_errors::{Applicability, DiagnosticBuilder}; use rustc_feature::Features; -use rustc_lint_defs::builtin::{OR_PATTERNS_BACK_COMPAT, SEMICOLON_IN_EXPRESSIONS_FROM_MACROS}; +use rustc_lint_defs::builtin::{ + RUST_2021_INCOMPATIBLE_OR_PATTERNS, SEMICOLON_IN_EXPRESSIONS_FROM_MACROS, +}; use rustc_lint_defs::BuiltinLintDiagnostics; use rustc_parse::parser::Parser; use rustc_session::parse::ParseSess; @@ -975,7 +977,7 @@ fn check_matcher_core( Some(NonterminalKind::PatParam { inferred: false }), )); sess.buffer_lint_with_diagnostic( - &OR_PATTERNS_BACK_COMPAT, + &RUST_2021_INCOMPATIBLE_OR_PATTERNS, span, ast::CRATE_NODE_ID, "the meaning of the `pat` fragment specifier is changing in Rust 2021, which may affect this macro", diff --git a/compiler/rustc_lint/src/lib.rs b/compiler/rustc_lint/src/lib.rs index b3b759a466a..2e5ef8daf14 100644 --- a/compiler/rustc_lint/src/lib.rs +++ b/compiler/rustc_lint/src/lib.rs @@ -326,6 +326,7 @@ fn register_builtins(store: &mut LintStore, no_interleave_lints: bool) { store.register_renamed("overlapping_patterns", "overlapping_range_endpoints"); store.register_renamed("safe_packed_borrows", "unaligned_references"); store.register_renamed("disjoint_capture_migration", "rust_2021_incompatible_closure_captures"); + store.register_renamed("or_patterns_back_compat", "rust_2021_incompatible_or_patterns"); // These were moved to tool lints, but rustc still sees them when compiling normally, before // tool lints are registered, so `check_tool_name_for_backwards_compat` doesn't work. Use diff --git a/compiler/rustc_lint_defs/src/builtin.rs b/compiler/rustc_lint_defs/src/builtin.rs index 5c0b7aaf11b..ed39815ff56 100644 --- a/compiler/rustc_lint_defs/src/builtin.rs +++ b/compiler/rustc_lint_defs/src/builtin.rs @@ -2970,7 +2970,7 @@ declare_lint_pass! { RUST_2021_INCOMPATIBLE_CLOSURE_CAPTURES, LEGACY_DERIVE_HELPERS, PROC_MACRO_BACK_COMPAT, - OR_PATTERNS_BACK_COMPAT, + RUST_2021_INCOMPATIBLE_OR_PATTERNS, LARGE_ASSIGNMENTS, FUTURE_PRELUDE_COLLISION, RESERVED_PREFIX, @@ -3183,12 +3183,12 @@ declare_lint! { } declare_lint! { - /// The `or_patterns_back_compat` lint detects usage of old versions of or-patterns. + /// The `rust_2021_incompatible_or_patterns` lint detects usage of old versions of or-patterns. /// /// ### Example /// /// ```rust,compile_fail - /// #![deny(or_patterns_back_compat)] + /// #![deny(rust_2021_incompatible_or_patterns)] /// macro_rules! match_any { /// ( $expr:expr , $( $( $pat:pat )|+ => $expr_arm:expr ),+ ) => { /// match $expr { @@ -3211,7 +3211,7 @@ declare_lint! { /// ### Explanation /// /// In Rust 2021, the pat matcher will match new patterns, which include the | character. - pub OR_PATTERNS_BACK_COMPAT, + pub RUST_2021_INCOMPATIBLE_OR_PATTERNS, Allow, "detects usage of old versions of or-patterns", @future_incompatible = FutureIncompatibleInfo { diff --git a/library/core/src/lib.rs b/library/core/src/lib.rs index 866cd5ec535..f0f0ba2e92f 100644 --- a/library/core/src/lib.rs +++ b/library/core/src/lib.rs @@ -164,6 +164,7 @@ #![feature(no_niche)] // rust-lang/rust#68303 #![feature(no_coverage)] // rust-lang/rust#84605 #![deny(unsafe_op_in_unsafe_fn)] +#![allow(renamed_and_removed_lints)] #![deny(or_patterns_back_compat)] // allow using `core::` in intra-doc links diff --git a/src/test/ui/macros/macro-or-patterns-back-compat.fixed b/src/test/ui/macros/macro-or-patterns-back-compat.fixed index f5a42670fdd..b0d56e9bb1e 100644 --- a/src/test/ui/macros/macro-or-patterns-back-compat.fixed +++ b/src/test/ui/macros/macro-or-patterns-back-compat.fixed @@ -1,7 +1,7 @@ // run-rustfix // aux-build:or-pattern.rs -#![deny(or_patterns_back_compat)] +#![deny(rust_2021_incompatible_or_patterns)] #![allow(unused_macros)] #[macro_use] diff --git a/src/test/ui/macros/macro-or-patterns-back-compat.rs b/src/test/ui/macros/macro-or-patterns-back-compat.rs index d6620f45f62..9e24b5106b8 100644 --- a/src/test/ui/macros/macro-or-patterns-back-compat.rs +++ b/src/test/ui/macros/macro-or-patterns-back-compat.rs @@ -1,7 +1,7 @@ // run-rustfix // aux-build:or-pattern.rs -#![deny(or_patterns_back_compat)] +#![deny(rust_2021_incompatible_or_patterns)] #![allow(unused_macros)] #[macro_use] diff --git a/src/test/ui/macros/macro-or-patterns-back-compat.stderr b/src/test/ui/macros/macro-or-patterns-back-compat.stderr index a48c9263154..eb6204fa02e 100644 --- a/src/test/ui/macros/macro-or-patterns-back-compat.stderr +++ b/src/test/ui/macros/macro-or-patterns-back-compat.stderr @@ -7,8 +7,8 @@ LL | macro_rules! foo { ($x:pat | $y:pat) => {} } note: the lint level is defined here --> $DIR/macro-or-patterns-back-compat.rs:4:9 | -LL | #![deny(or_patterns_back_compat)] - | ^^^^^^^^^^^^^^^^^^^^^^^ +LL | #![deny(rust_2021_incompatible_or_patterns)] + | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ = warning: this is accepted in the current edition (Rust 2015) but is a hard error in Rust 2021! = note: for more information, see issue #84869 From ecca9a8b1aecd6675d995e89ea2f93635b05500a Mon Sep 17 00:00:00 2001 From: Ryan Levick Date: Tue, 29 Jun 2021 16:53:44 +0200 Subject: [PATCH 10/19] Add s to FUTURE_PRELUDE_COLLISION --- compiler/rustc_lint_defs/src/builtin.rs | 8 ++++---- compiler/rustc_typeck/src/check/method/prelude2021.rs | 8 ++++---- .../ui/rust-2021/future-prelude-collision-imported.fixed | 2 +- .../ui/rust-2021/future-prelude-collision-imported.rs | 2 +- .../ui/rust-2021/future-prelude-collision-imported.stderr | 4 ++-- src/test/ui/rust-2021/future-prelude-collision-shadow.rs | 2 +- .../ui/rust-2021/future-prelude-collision-unneeded.rs | 6 ++++-- src/test/ui/rust-2021/future-prelude-collision.fixed | 2 +- src/test/ui/rust-2021/future-prelude-collision.rs | 2 +- src/test/ui/rust-2021/future-prelude-collision.stderr | 4 ++-- src/test/ui/rust-2021/generic-type-collision.fixed | 2 +- src/test/ui/rust-2021/generic-type-collision.rs | 2 +- src/test/ui/rust-2021/generic-type-collision.stderr | 4 ++-- src/test/ui/rust-2021/inherent-dyn-collision.fixed | 2 +- src/test/ui/rust-2021/inherent-dyn-collision.rs | 2 +- src/test/ui/rust-2021/inherent-dyn-collision.stderr | 4 ++-- src/test/ui/rust-2021/inherent-method-collision.rs | 2 +- 17 files changed, 30 insertions(+), 28 deletions(-) diff --git a/compiler/rustc_lint_defs/src/builtin.rs b/compiler/rustc_lint_defs/src/builtin.rs index ed39815ff56..a276cb14acb 100644 --- a/compiler/rustc_lint_defs/src/builtin.rs +++ b/compiler/rustc_lint_defs/src/builtin.rs @@ -2972,7 +2972,7 @@ declare_lint_pass! { PROC_MACRO_BACK_COMPAT, RUST_2021_INCOMPATIBLE_OR_PATTERNS, LARGE_ASSIGNMENTS, - FUTURE_PRELUDE_COLLISION, + FUTURE_PRELUDE_COLLISIONS, RESERVED_PREFIX, UNSUPPORTED_CALLING_CONVENTIONS, ] @@ -3221,13 +3221,13 @@ declare_lint! { } declare_lint! { - /// The `future_prelude_collision` lint detects the usage of trait methods which are ambiguous + /// The `future_prelude_collisions` lint detects the usage of trait methods which are ambiguous /// with traits added to the prelude in future editions. /// /// ### Example /// /// ```rust,compile_fail - /// #![deny(future_prelude_collision)] + /// #![deny(future_prelude_collisions)] /// /// trait Foo { /// fn try_into(self) -> Result; @@ -3259,7 +3259,7 @@ declare_lint! { /// is called directly on a type. /// /// [prelude changes]: https://blog.rust-lang.org/inside-rust/2021/03/04/planning-rust-2021.html#prelude-changes - pub FUTURE_PRELUDE_COLLISION, + pub FUTURE_PRELUDE_COLLISIONS, Allow, "detects the usage of trait methods which are ambiguous with traits added to the \ prelude in future editions", diff --git a/compiler/rustc_typeck/src/check/method/prelude2021.rs b/compiler/rustc_typeck/src/check/method/prelude2021.rs index e8748dd062f..cf17ff2eab5 100644 --- a/compiler/rustc_typeck/src/check/method/prelude2021.rs +++ b/compiler/rustc_typeck/src/check/method/prelude2021.rs @@ -5,7 +5,7 @@ use rustc_ast::Mutability; use rustc_errors::Applicability; use rustc_hir as hir; use rustc_middle::ty::{Ref, Ty}; -use rustc_session::lint::builtin::FUTURE_PRELUDE_COLLISION; +use rustc_session::lint::builtin::FUTURE_PRELUDE_COLLISIONS; use rustc_span::symbol::kw::Underscore; use rustc_span::symbol::{sym, Ident}; use rustc_span::Span; @@ -67,7 +67,7 @@ impl<'a, 'tcx> FnCtxt<'a, 'tcx> { // Inherent impls only require not relying on autoref and autoderef in order to // ensure that the trait implementation won't be used self.tcx.struct_span_lint_hir( - FUTURE_PRELUDE_COLLISION, + FUTURE_PRELUDE_COLLISIONS, self_expr.hir_id, self_expr.span, |lint| { @@ -128,7 +128,7 @@ impl<'a, 'tcx> FnCtxt<'a, 'tcx> { // trait implementations require full disambiguation to not clash with the new prelude // additions (i.e. convert from dot-call to fully-qualified call) self.tcx.struct_span_lint_hir( - FUTURE_PRELUDE_COLLISION, + FUTURE_PRELUDE_COLLISIONS, call_expr.hir_id, call_expr.span, |lint| { @@ -212,7 +212,7 @@ impl<'a, 'tcx> FnCtxt<'a, 'tcx> { return; } - self.tcx.struct_span_lint_hir(FUTURE_PRELUDE_COLLISION, expr_id, span, |lint| { + self.tcx.struct_span_lint_hir(FUTURE_PRELUDE_COLLISIONS, expr_id, span, |lint| { // "type" refers to either a type or, more likely, a trait from which // the associated function or method is from. let trait_path = self.trait_path_or_bare_name(span, expr_id, pick.item.container.id()); diff --git a/src/test/ui/rust-2021/future-prelude-collision-imported.fixed b/src/test/ui/rust-2021/future-prelude-collision-imported.fixed index 725d5aa234e..e37b4cd0960 100644 --- a/src/test/ui/rust-2021/future-prelude-collision-imported.fixed +++ b/src/test/ui/rust-2021/future-prelude-collision-imported.fixed @@ -1,7 +1,7 @@ // run-rustfix // edition:2018 // check-pass -#![warn(future_prelude_collision)] +#![warn(future_prelude_collisions)] #![allow(dead_code)] #![allow(unused_imports)] diff --git a/src/test/ui/rust-2021/future-prelude-collision-imported.rs b/src/test/ui/rust-2021/future-prelude-collision-imported.rs index 6ca9a919f3c..a560c4b92e1 100644 --- a/src/test/ui/rust-2021/future-prelude-collision-imported.rs +++ b/src/test/ui/rust-2021/future-prelude-collision-imported.rs @@ -1,7 +1,7 @@ // run-rustfix // edition:2018 // check-pass -#![warn(future_prelude_collision)] +#![warn(future_prelude_collisions)] #![allow(dead_code)] #![allow(unused_imports)] diff --git a/src/test/ui/rust-2021/future-prelude-collision-imported.stderr b/src/test/ui/rust-2021/future-prelude-collision-imported.stderr index 8889485c917..da455f2d15a 100644 --- a/src/test/ui/rust-2021/future-prelude-collision-imported.stderr +++ b/src/test/ui/rust-2021/future-prelude-collision-imported.stderr @@ -7,8 +7,8 @@ LL | let _: u32 = 3u8.try_into().unwrap(); note: the lint level is defined here --> $DIR/future-prelude-collision-imported.rs:4:9 | -LL | #![warn(future_prelude_collision)] - | ^^^^^^^^^^^^^^^^^^^^^^^^ +LL | #![warn(future_prelude_collisions)] + | ^^^^^^^^^^^^^^^^^^^^^^^^^ = warning: this is accepted in the current edition (Rust 2018) but is a hard error in Rust 2021! = note: for more information, see issue #85684 diff --git a/src/test/ui/rust-2021/future-prelude-collision-shadow.rs b/src/test/ui/rust-2021/future-prelude-collision-shadow.rs index c9d2529341f..7e64f9ae7bf 100644 --- a/src/test/ui/rust-2021/future-prelude-collision-shadow.rs +++ b/src/test/ui/rust-2021/future-prelude-collision-shadow.rs @@ -1,5 +1,5 @@ // edition:2018 -#![warn(future_prelude_collision)] +#![warn(future_prelude_collisions)] #![allow(dead_code)] #![allow(unused_imports)] diff --git a/src/test/ui/rust-2021/future-prelude-collision-unneeded.rs b/src/test/ui/rust-2021/future-prelude-collision-unneeded.rs index a4a5b6667df..1c809d0ba09 100644 --- a/src/test/ui/rust-2021/future-prelude-collision-unneeded.rs +++ b/src/test/ui/rust-2021/future-prelude-collision-unneeded.rs @@ -1,12 +1,14 @@ // edition:2018 // check-pass #![allow(unused)] -#![deny(future_prelude_collision)] +#![deny(future_prelude_collisions)] struct S; impl S { - fn try_into(self) -> S { S } + fn try_into(self) -> S { + S + } } // See https://github.com/rust-lang/rust/issues/86633 diff --git a/src/test/ui/rust-2021/future-prelude-collision.fixed b/src/test/ui/rust-2021/future-prelude-collision.fixed index 4bcbe6b094a..c8f29c325d9 100644 --- a/src/test/ui/rust-2021/future-prelude-collision.fixed +++ b/src/test/ui/rust-2021/future-prelude-collision.fixed @@ -1,7 +1,7 @@ // run-rustfix // edition:2018 // check-pass -#![warn(future_prelude_collision)] +#![warn(future_prelude_collisions)] trait TryIntoU32 { fn try_into(self) -> Result; diff --git a/src/test/ui/rust-2021/future-prelude-collision.rs b/src/test/ui/rust-2021/future-prelude-collision.rs index bc23a8a92a6..7059535b877 100644 --- a/src/test/ui/rust-2021/future-prelude-collision.rs +++ b/src/test/ui/rust-2021/future-prelude-collision.rs @@ -1,7 +1,7 @@ // run-rustfix // edition:2018 // check-pass -#![warn(future_prelude_collision)] +#![warn(future_prelude_collisions)] trait TryIntoU32 { fn try_into(self) -> Result; diff --git a/src/test/ui/rust-2021/future-prelude-collision.stderr b/src/test/ui/rust-2021/future-prelude-collision.stderr index e167468ab19..46e52baf838 100644 --- a/src/test/ui/rust-2021/future-prelude-collision.stderr +++ b/src/test/ui/rust-2021/future-prelude-collision.stderr @@ -7,8 +7,8 @@ LL | let _: u32 = 3u8.try_into().unwrap(); note: the lint level is defined here --> $DIR/future-prelude-collision.rs:4:9 | -LL | #![warn(future_prelude_collision)] - | ^^^^^^^^^^^^^^^^^^^^^^^^ +LL | #![warn(future_prelude_collisions)] + | ^^^^^^^^^^^^^^^^^^^^^^^^^ = warning: this is accepted in the current edition (Rust 2018) but is a hard error in Rust 2021! = note: for more information, see issue #85684 diff --git a/src/test/ui/rust-2021/generic-type-collision.fixed b/src/test/ui/rust-2021/generic-type-collision.fixed index d1a085f23a0..9851a1d42b6 100644 --- a/src/test/ui/rust-2021/generic-type-collision.fixed +++ b/src/test/ui/rust-2021/generic-type-collision.fixed @@ -1,7 +1,7 @@ // check-pass // run-rustfix // edition 2018 -#![warn(future_prelude_collision)] +#![warn(future_prelude_collisions)] trait MyTrait { fn from_iter(x: Option); diff --git a/src/test/ui/rust-2021/generic-type-collision.rs b/src/test/ui/rust-2021/generic-type-collision.rs index 5069fba396e..18deaa55cfe 100644 --- a/src/test/ui/rust-2021/generic-type-collision.rs +++ b/src/test/ui/rust-2021/generic-type-collision.rs @@ -1,7 +1,7 @@ // check-pass // run-rustfix // edition 2018 -#![warn(future_prelude_collision)] +#![warn(future_prelude_collisions)] trait MyTrait { fn from_iter(x: Option); diff --git a/src/test/ui/rust-2021/generic-type-collision.stderr b/src/test/ui/rust-2021/generic-type-collision.stderr index 05591c3d448..1839c3e7279 100644 --- a/src/test/ui/rust-2021/generic-type-collision.stderr +++ b/src/test/ui/rust-2021/generic-type-collision.stderr @@ -7,8 +7,8 @@ LL | >::from_iter(None); note: the lint level is defined here --> $DIR/generic-type-collision.rs:4:9 | -LL | #![warn(future_prelude_collision)] - | ^^^^^^^^^^^^^^^^^^^^^^^^ +LL | #![warn(future_prelude_collisions)] + | ^^^^^^^^^^^^^^^^^^^^^^^^^ = warning: this is accepted in the current edition (Rust 2015) but is a hard error in Rust 2021! = note: for more information, see issue #85684 diff --git a/src/test/ui/rust-2021/inherent-dyn-collision.fixed b/src/test/ui/rust-2021/inherent-dyn-collision.fixed index cf6287a758f..d6be9e56f96 100644 --- a/src/test/ui/rust-2021/inherent-dyn-collision.fixed +++ b/src/test/ui/rust-2021/inherent-dyn-collision.fixed @@ -5,7 +5,7 @@ // run-rustfix // edition:2018 -#![warn(future_prelude_collision)] +#![warn(future_prelude_collisions)] trait TryIntoU32 { fn try_into(&self) -> Result; diff --git a/src/test/ui/rust-2021/inherent-dyn-collision.rs b/src/test/ui/rust-2021/inherent-dyn-collision.rs index 0349ad5b641..67be6157d45 100644 --- a/src/test/ui/rust-2021/inherent-dyn-collision.rs +++ b/src/test/ui/rust-2021/inherent-dyn-collision.rs @@ -5,7 +5,7 @@ // run-rustfix // edition:2018 -#![warn(future_prelude_collision)] +#![warn(future_prelude_collisions)] trait TryIntoU32 { fn try_into(&self) -> Result; diff --git a/src/test/ui/rust-2021/inherent-dyn-collision.stderr b/src/test/ui/rust-2021/inherent-dyn-collision.stderr index 9e95419715e..4d7a04735ac 100644 --- a/src/test/ui/rust-2021/inherent-dyn-collision.stderr +++ b/src/test/ui/rust-2021/inherent-dyn-collision.stderr @@ -7,8 +7,8 @@ LL | get_dyn_trait().try_into().unwrap() note: the lint level is defined here --> $DIR/inherent-dyn-collision.rs:8:9 | -LL | #![warn(future_prelude_collision)] - | ^^^^^^^^^^^^^^^^^^^^^^^^ +LL | #![warn(future_prelude_collisions)] + | ^^^^^^^^^^^^^^^^^^^^^^^^^ = warning: this is accepted in the current edition (Rust 2018) but is a hard error in Rust 2021! = note: for more information, see issue #85684 diff --git a/src/test/ui/rust-2021/inherent-method-collision.rs b/src/test/ui/rust-2021/inherent-method-collision.rs index c638351d5fc..f99d98bd890 100644 --- a/src/test/ui/rust-2021/inherent-method-collision.rs +++ b/src/test/ui/rust-2021/inherent-method-collision.rs @@ -2,7 +2,7 @@ // // check-pass -#![deny(future_prelude_collision)] +#![deny(future_prelude_collisions)] pub struct MySeq {} From 6c87772e3cbeb575aaab2896ded3d16a89d9679d Mon Sep 17 00:00:00 2001 From: Ryan Levick Date: Tue, 29 Jun 2021 17:20:22 +0200 Subject: [PATCH 11/19] Rename reserved_prefix lint to reserved_prefixes --- compiler/rustc_lint_defs/src/builtin.rs | 8 ++++---- compiler/rustc_parse/src/lexer/mod.rs | 4 ++-- .../ui/rust-2021/reserved-prefixes-migration.fixed | 12 ++++++------ src/test/ui/rust-2021/reserved-prefixes-migration.rs | 12 ++++++------ .../ui/rust-2021/reserved-prefixes-migration.stderr | 4 ++-- 5 files changed, 20 insertions(+), 20 deletions(-) diff --git a/compiler/rustc_lint_defs/src/builtin.rs b/compiler/rustc_lint_defs/src/builtin.rs index a276cb14acb..52bdb4f3e41 100644 --- a/compiler/rustc_lint_defs/src/builtin.rs +++ b/compiler/rustc_lint_defs/src/builtin.rs @@ -2973,7 +2973,7 @@ declare_lint_pass! { RUST_2021_INCOMPATIBLE_OR_PATTERNS, LARGE_ASSIGNMENTS, FUTURE_PRELUDE_COLLISIONS, - RESERVED_PREFIX, + RESERVED_PREFIXES, UNSUPPORTED_CALLING_CONVENTIONS, ] } @@ -3270,13 +3270,13 @@ declare_lint! { } declare_lint! { - /// The `reserved_prefix` lint detects identifiers that will be parsed as a + /// The `reserved_prefixes` lint detects identifiers that will be parsed as a /// prefix instead in Rust 2021. /// /// ### Example /// /// ```rust,compile_fail - /// #![deny(reserved_prefix)] + /// #![deny(reserved_prefixes)] /// /// macro_rules! m { /// (z $x:expr) => (); @@ -3295,7 +3295,7 @@ declare_lint! { /// /// This lint suggests to add whitespace between the `z` and `"hey"` tokens /// to keep them separated in Rust 2021. - pub RESERVED_PREFIX, + pub RESERVED_PREFIXES, Allow, "identifiers that will be parsed as a prefix in Rust 2021", @future_incompatible = FutureIncompatibleInfo { diff --git a/compiler/rustc_parse/src/lexer/mod.rs b/compiler/rustc_parse/src/lexer/mod.rs index 87e60a48e44..3f58476296b 100644 --- a/compiler/rustc_parse/src/lexer/mod.rs +++ b/compiler/rustc_parse/src/lexer/mod.rs @@ -4,7 +4,7 @@ use rustc_ast::tokenstream::{Spacing, TokenStream}; use rustc_errors::{error_code, Applicability, DiagnosticBuilder, FatalError, PResult}; use rustc_lexer::unescape::{self, Mode}; use rustc_lexer::{Base, DocStyle, RawStrError}; -use rustc_session::lint::builtin::RESERVED_PREFIX; +use rustc_session::lint::builtin::RESERVED_PREFIXES; use rustc_session::lint::BuiltinLintDiagnostics; use rustc_session::parse::ParseSess; use rustc_span::symbol::{sym, Symbol}; @@ -526,7 +526,7 @@ impl<'a> StringReader<'a> { } else { // Before Rust 2021, only emit a lint for migration. self.sess.buffer_lint_with_diagnostic( - &RESERVED_PREFIX, + &RESERVED_PREFIXES, prefix_span, ast::CRATE_NODE_ID, &msg, diff --git a/src/test/ui/rust-2021/reserved-prefixes-migration.fixed b/src/test/ui/rust-2021/reserved-prefixes-migration.fixed index dbc2ec6d42e..f6b6f7405a6 100644 --- a/src/test/ui/rust-2021/reserved-prefixes-migration.fixed +++ b/src/test/ui/rust-2021/reserved-prefixes-migration.fixed @@ -2,7 +2,7 @@ // run-rustfix // compile-flags: -Z unstable-options --edition 2018 -#![warn(reserved_prefix)] +#![warn(reserved_prefixes)] macro_rules! m2 { ($a:tt $b:tt) => {}; @@ -14,16 +14,16 @@ macro_rules! m3 { fn main() { m2!(z "hey"); - //~^ WARNING prefix `z` is unknown [reserved_prefix] + //~^ WARNING prefix `z` is unknown [reserved_prefixes] //~| WARNING hard error in Rust 2021 m2!(prefix "hey"); - //~^ WARNING prefix `prefix` is unknown [reserved_prefix] + //~^ WARNING prefix `prefix` is unknown [reserved_prefixes] //~| WARNING hard error in Rust 2021 m3!(hey #123); - //~^ WARNING prefix `hey` is unknown [reserved_prefix] + //~^ WARNING prefix `hey` is unknown [reserved_prefixes] //~| WARNING hard error in Rust 2021 m3!(hey #hey); - //~^ WARNING prefix `hey` is unknown [reserved_prefix] + //~^ WARNING prefix `hey` is unknown [reserved_prefixes] //~| WARNING hard error in Rust 2021 } @@ -33,6 +33,6 @@ macro_rules! quote { quote! { #name = #kind #value - //~^ WARNING prefix `kind` is unknown [reserved_prefix] + //~^ WARNING prefix `kind` is unknown [reserved_prefixes] //~| WARNING hard error in Rust 2021 } diff --git a/src/test/ui/rust-2021/reserved-prefixes-migration.rs b/src/test/ui/rust-2021/reserved-prefixes-migration.rs index 6f7e3eb7a43..2b056245a99 100644 --- a/src/test/ui/rust-2021/reserved-prefixes-migration.rs +++ b/src/test/ui/rust-2021/reserved-prefixes-migration.rs @@ -2,7 +2,7 @@ // run-rustfix // compile-flags: -Z unstable-options --edition 2018 -#![warn(reserved_prefix)] +#![warn(reserved_prefixes)] macro_rules! m2 { ($a:tt $b:tt) => {}; @@ -14,16 +14,16 @@ macro_rules! m3 { fn main() { m2!(z"hey"); - //~^ WARNING prefix `z` is unknown [reserved_prefix] + //~^ WARNING prefix `z` is unknown [reserved_prefixes] //~| WARNING hard error in Rust 2021 m2!(prefix"hey"); - //~^ WARNING prefix `prefix` is unknown [reserved_prefix] + //~^ WARNING prefix `prefix` is unknown [reserved_prefixes] //~| WARNING hard error in Rust 2021 m3!(hey#123); - //~^ WARNING prefix `hey` is unknown [reserved_prefix] + //~^ WARNING prefix `hey` is unknown [reserved_prefixes] //~| WARNING hard error in Rust 2021 m3!(hey#hey); - //~^ WARNING prefix `hey` is unknown [reserved_prefix] + //~^ WARNING prefix `hey` is unknown [reserved_prefixes] //~| WARNING hard error in Rust 2021 } @@ -33,6 +33,6 @@ macro_rules! quote { quote! { #name = #kind#value - //~^ WARNING prefix `kind` is unknown [reserved_prefix] + //~^ WARNING prefix `kind` is unknown [reserved_prefixes] //~| WARNING hard error in Rust 2021 } diff --git a/src/test/ui/rust-2021/reserved-prefixes-migration.stderr b/src/test/ui/rust-2021/reserved-prefixes-migration.stderr index 28ac1966a1b..ec27b68e2df 100644 --- a/src/test/ui/rust-2021/reserved-prefixes-migration.stderr +++ b/src/test/ui/rust-2021/reserved-prefixes-migration.stderr @@ -7,8 +7,8 @@ LL | m2!(z"hey"); note: the lint level is defined here --> $DIR/reserved-prefixes-migration.rs:5:9 | -LL | #![warn(reserved_prefix)] - | ^^^^^^^^^^^^^^^ +LL | #![warn(reserved_prefixes)] + | ^^^^^^^^^^^^^^^^^ = warning: this is accepted in the current edition (Rust 2018) but is a hard error in Rust 2021! = note: for more information, see issue #84978 help: insert whitespace here to avoid this being parsed as a prefix in Rust 2021 From 3a45bb919c5aa1159939f6dfab2f79e55babf84c Mon Sep 17 00:00:00 2001 From: Ryan Levick Date: Tue, 29 Jun 2021 17:41:49 +0200 Subject: [PATCH 12/19] Fix mis-styled code --- compiler/rustc_typeck/src/check/upvar.rs | 5 ++++- 1 file changed, 4 insertions(+), 1 deletion(-) diff --git a/compiler/rustc_typeck/src/check/upvar.rs b/compiler/rustc_typeck/src/check/upvar.rs index da8e6746b22..1dcc4c2f2b8 100644 --- a/compiler/rustc_typeck/src/check/upvar.rs +++ b/compiler/rustc_typeck/src/check/upvar.rs @@ -1829,7 +1829,10 @@ fn var_name(tcx: TyCtxt<'_>, var_hir_id: hir::HirId) -> Symbol { tcx.hir().name(var_hir_id) } -fn should_do_rust_2021_incompatible_closure_captures_analysis(tcx: TyCtxt<'_>, closure_id: hir::HirId) -> bool { +fn should_do_rust_2021_incompatible_closure_captures_analysis( + tcx: TyCtxt<'_>, + closure_id: hir::HirId, +) -> bool { let (level, _) = tcx.lint_level_at_node(lint::builtin::RUST_2021_INCOMPATIBLE_CLOSURE_CAPTURES, closure_id); From 4e5b78fdcf29142a20c3ba1af6aac20f82833729 Mon Sep 17 00:00:00 2001 From: Ryan Levick Date: Tue, 29 Jun 2021 20:00:50 +0200 Subject: [PATCH 13/19] Allow lint names to have ascii numbers --- src/tools/lint-docs/src/lib.rs | 4 +++- 1 file changed, 3 insertions(+), 1 deletion(-) diff --git a/src/tools/lint-docs/src/lib.rs b/src/tools/lint-docs/src/lib.rs index ea54a351e03..e5c7f125712 100644 --- a/src/tools/lint-docs/src/lib.rs +++ b/src/tools/lint-docs/src/lib.rs @@ -467,7 +467,9 @@ fn lint_name(line: &str) -> Result { return Err("lint name should end with comma"); } let name = &name[..name.len() - 1]; - if !name.chars().all(|ch| ch.is_uppercase() || ch == '_') || name.is_empty() { + if !name.chars().all(|ch| ch.is_uppercase() || ch.is_ascii_digit() || ch == '_') + || name.is_empty() + { return Err("lint name did not have expected format"); } Ok(name.to_lowercase().to_string()) From a902e25f589b929b65bd0b55abdeb2f22796401a Mon Sep 17 00:00:00 2001 From: Ryan Levick Date: Tue, 29 Jun 2021 20:33:31 +0200 Subject: [PATCH 14/19] Add s to non_fmt_panic --- compiler/rustc_lint/src/lib.rs | 1 + compiler/rustc_lint/src/non_fmt_panic.rs | 12 ++++++------ library/core/src/lib.rs | 4 ++-- src/test/ui/consts/const-eval/const_panic.rs | 2 +- src/test/ui/fmt/format-args-capture.rs | 16 +++++++++------- src/test/ui/macros/assert-macro-owned.rs | 2 +- .../ui/macros/macro-comma-behavior-rpass.rs | 17 +++++++++++------ src/test/ui/non-fmt-panic.stderr | 2 +- src/test/ui/panics/explicit-panic-msg.rs | 2 +- src/test/ui/panics/panic-macro-any-wrapped.rs | 2 +- src/test/ui/panics/panic-macro-any.rs | 2 +- src/tools/clippy/CHANGELOG.md | 2 +- src/tools/clippy/clippy_lints/src/lib.rs | 2 +- .../clippy/tests/ui/assertions_on_constants.rs | 2 +- src/tools/clippy/tests/ui/deprecated.stderr | 4 ++-- 15 files changed, 40 insertions(+), 32 deletions(-) diff --git a/compiler/rustc_lint/src/lib.rs b/compiler/rustc_lint/src/lib.rs index 2e5ef8daf14..6225b716921 100644 --- a/compiler/rustc_lint/src/lib.rs +++ b/compiler/rustc_lint/src/lib.rs @@ -327,6 +327,7 @@ fn register_builtins(store: &mut LintStore, no_interleave_lints: bool) { store.register_renamed("safe_packed_borrows", "unaligned_references"); store.register_renamed("disjoint_capture_migration", "rust_2021_incompatible_closure_captures"); store.register_renamed("or_patterns_back_compat", "rust_2021_incompatible_or_patterns"); + store.register_renamed("non_fmt_panic", "non_fmt_panics"); // These were moved to tool lints, but rustc still sees them when compiling normally, before // tool lints are registered, so `check_tool_name_for_backwards_compat` doesn't work. Use diff --git a/compiler/rustc_lint/src/non_fmt_panic.rs b/compiler/rustc_lint/src/non_fmt_panic.rs index 3ea5a3bcc3b..99a88f6bf61 100644 --- a/compiler/rustc_lint/src/non_fmt_panic.rs +++ b/compiler/rustc_lint/src/non_fmt_panic.rs @@ -9,7 +9,7 @@ use rustc_span::edition::Edition; use rustc_span::{hygiene, sym, symbol::kw, symbol::SymbolStr, InnerSpan, Span, Symbol}; declare_lint! { - /// The `non_fmt_panic` lint detects `panic!(..)` invocations where the first + /// The `non_fmt_panics` lint detects `panic!(..)` invocations where the first /// argument is not a formatting string. /// /// ### Example @@ -29,7 +29,7 @@ declare_lint! { /// an `i32` as message. /// /// Rust 2021 always interprets the first argument as format string. - NON_FMT_PANIC, + NON_FMT_PANICS, Warn, "detect single-argument panic!() invocations in which the argument is not a format string", @future_incompatible = FutureIncompatibleInfo { @@ -39,7 +39,7 @@ declare_lint! { report_in_external_macro } -declare_lint_pass!(NonPanicFmt => [NON_FMT_PANIC]); +declare_lint_pass!(NonPanicFmt => [NON_FMT_PANICS]); impl<'tcx> LateLintPass<'tcx> for NonPanicFmt { fn check_expr(&mut self, cx: &LateContext<'tcx>, expr: &'tcx hir::Expr<'tcx>) { @@ -91,7 +91,7 @@ fn check_panic<'tcx>(cx: &LateContext<'tcx>, f: &'tcx hir::Expr<'tcx>, arg: &'tc arg_span = expn.call_site; } - cx.struct_span_lint(NON_FMT_PANIC, arg_span, |lint| { + cx.struct_span_lint(NON_FMT_PANICS, arg_span, |lint| { let mut l = lint.build("panic message is not a string literal"); l.note("this usage of panic!() is deprecated; it will be a hard error in Rust 2021"); l.note("for more information, see "); @@ -174,7 +174,7 @@ fn check_panic_str<'tcx>( [] => vec![fmt_span], v => v.iter().map(|span| fmt_span.from_inner(*span)).collect(), }; - cx.struct_span_lint(NON_FMT_PANIC, arg_spans, |lint| { + cx.struct_span_lint(NON_FMT_PANICS, arg_spans, |lint| { let mut l = lint.build(match n_arguments { 1 => "panic message contains an unused formatting placeholder", _ => "panic message contains unused formatting placeholders", @@ -208,7 +208,7 @@ fn check_panic_str<'tcx>( Some(v) if v.len() == 1 => "panic message contains a brace", _ => "panic message contains braces", }; - cx.struct_span_lint(NON_FMT_PANIC, brace_spans.unwrap_or_else(|| vec![span]), |lint| { + cx.struct_span_lint(NON_FMT_PANICS, brace_spans.unwrap_or_else(|| vec![span]), |lint| { let mut l = lint.build(msg); l.note("this message is not used as a format string, but will be in Rust 2021"); if span.contains(arg.span) { diff --git a/library/core/src/lib.rs b/library/core/src/lib.rs index f0f0ba2e92f..3557dbad90c 100644 --- a/library/core/src/lib.rs +++ b/library/core/src/lib.rs @@ -164,8 +164,8 @@ #![feature(no_niche)] // rust-lang/rust#68303 #![feature(no_coverage)] // rust-lang/rust#84605 #![deny(unsafe_op_in_unsafe_fn)] -#![allow(renamed_and_removed_lints)] -#![deny(or_patterns_back_compat)] +#![cfg_attr(bootstrap, deny(or_patterns_back_compat))] +#![cfg_attr(not(bootstrap), deny(rust_2021_incompatible_or_patterns))] // allow using `core::` in intra-doc links #[allow(unused_extern_crates)] diff --git a/src/test/ui/consts/const-eval/const_panic.rs b/src/test/ui/consts/const-eval/const_panic.rs index 5807c5659b6..e4455d86a14 100644 --- a/src/test/ui/consts/const-eval/const_panic.rs +++ b/src/test/ui/consts/const-eval/const_panic.rs @@ -1,5 +1,5 @@ #![feature(const_panic)] -#![allow(non_fmt_panic)] +#![allow(non_fmt_panics)] #![crate_type = "lib"] const MSG: &str = "hello"; diff --git a/src/test/ui/fmt/format-args-capture.rs b/src/test/ui/fmt/format-args-capture.rs index 6c97a807b05..b30e9a47a13 100644 --- a/src/test/ui/fmt/format-args-capture.rs +++ b/src/test/ui/fmt/format-args-capture.rs @@ -16,13 +16,13 @@ fn main() { fn named_argument_takes_precedence_to_captured() { let foo = "captured"; - let s = format!("{foo}", foo="named"); + let s = format!("{foo}", foo = "named"); assert_eq!(&s, "named"); - let s = format!("{foo}-{foo}-{foo}", foo="named"); + let s = format!("{foo}-{foo}-{foo}", foo = "named"); assert_eq!(&s, "named-named-named"); - let s = format!("{}-{bar}-{foo}", "positional", bar="named"); + let s = format!("{}-{bar}-{foo}", "positional", bar = "named"); assert_eq!(&s, "positional-named-captured"); } @@ -42,10 +42,11 @@ fn panic_with_single_argument_does_not_get_formatted() { // RFC #2795 suggests that this may need to change so that captured arguments are formatted. // For stability reasons this will need to part of an edition change. - #[allow(non_fmt_panic)] + #[allow(non_fmt_panics)] let msg = std::panic::catch_unwind(|| { panic!("{foo}"); - }).unwrap_err(); + }) + .unwrap_err(); assert_eq!(msg.downcast_ref::<&str>(), Some(&"{foo}")) } @@ -55,8 +56,9 @@ fn panic_with_multiple_arguments_is_formatted() { let foo = "captured"; let msg = std::panic::catch_unwind(|| { - panic!("{}-{bar}-{foo}", "positional", bar="named"); - }).unwrap_err(); + panic!("{}-{bar}-{foo}", "positional", bar = "named"); + }) + .unwrap_err(); assert_eq!(msg.downcast_ref::(), Some(&"positional-named-captured".to_string())) } diff --git a/src/test/ui/macros/assert-macro-owned.rs b/src/test/ui/macros/assert-macro-owned.rs index 2846f2a1f83..753675872b9 100644 --- a/src/test/ui/macros/assert-macro-owned.rs +++ b/src/test/ui/macros/assert-macro-owned.rs @@ -2,7 +2,7 @@ // error-pattern:panicked at 'test-assert-owned' // ignore-emscripten no processes -#![allow(non_fmt_panic)] +#![allow(non_fmt_panics)] fn main() { assert!(false, "test-assert-owned".to_string()); diff --git a/src/test/ui/macros/macro-comma-behavior-rpass.rs b/src/test/ui/macros/macro-comma-behavior-rpass.rs index fd2c590ae5f..780e158fe0b 100644 --- a/src/test/ui/macros/macro-comma-behavior-rpass.rs +++ b/src/test/ui/macros/macro-comma-behavior-rpass.rs @@ -14,11 +14,12 @@ // revisions: std core // ignore-wasm32-bare compiled with panic=abort by default - #![cfg_attr(core, no_std)] -#[cfg(std)] use std::fmt; -#[cfg(core)] use core::fmt; +#[cfg(core)] +use core::fmt; +#[cfg(std)] +use std::fmt; // an easy mistake in the implementation of 'assert!' // would cause this to say "explicit panic" @@ -57,7 +58,7 @@ fn writeln_1arg() { // // (Example: Issue #48042) #[test] -#[allow(non_fmt_panic)] +#[allow(non_fmt_panics)] fn to_format_or_not_to_format() { // ("{}" is the easiest string to test because if this gets // sent to format_args!, it'll simply fail to compile. @@ -80,13 +81,17 @@ fn to_format_or_not_to_format() { // format!("{}",); // see check-fail // format_args!("{}",); // see check-fail - if falsum() { panic!("{}",); } + if falsum() { + panic!("{}",); + } // print!("{}",); // see check-fail // println!("{}",); // see check-fail // unimplemented!("{}",); // see check-fail - if falsum() { unreachable!("{}",); } + if falsum() { + unreachable!("{}",); + } // write!(&mut stdout, "{}",); // see check-fail // writeln!(&mut stdout, "{}",); // see check-fail diff --git a/src/test/ui/non-fmt-panic.stderr b/src/test/ui/non-fmt-panic.stderr index 0f451c1e0a9..6aa2eb174e9 100644 --- a/src/test/ui/non-fmt-panic.stderr +++ b/src/test/ui/non-fmt-panic.stderr @@ -4,7 +4,7 @@ warning: panic message contains a brace LL | panic!("here's a brace: {"); | ^ | - = note: `#[warn(non_fmt_panic)]` on by default + = note: `#[warn(non_fmt_panics)]` on by default = note: this message is not used as a format string, but will be in Rust 2021 help: add a "{}" format string to use the message literally | diff --git a/src/test/ui/panics/explicit-panic-msg.rs b/src/test/ui/panics/explicit-panic-msg.rs index bfcc12cd186..9d803578734 100644 --- a/src/test/ui/panics/explicit-panic-msg.rs +++ b/src/test/ui/panics/explicit-panic-msg.rs @@ -1,6 +1,6 @@ #![allow(unused_assignments)] #![allow(unused_variables)] -#![allow(non_fmt_panic)] +#![allow(non_fmt_panics)] // run-fail // error-pattern:wooooo diff --git a/src/test/ui/panics/panic-macro-any-wrapped.rs b/src/test/ui/panics/panic-macro-any-wrapped.rs index 100ac10c767..663bf6713d0 100644 --- a/src/test/ui/panics/panic-macro-any-wrapped.rs +++ b/src/test/ui/panics/panic-macro-any-wrapped.rs @@ -2,7 +2,7 @@ // error-pattern:panicked at 'Box' // ignore-emscripten no processes -#![allow(non_fmt_panic)] +#![allow(non_fmt_panics)] fn main() { panic!(Box::new(612_i64)); diff --git a/src/test/ui/panics/panic-macro-any.rs b/src/test/ui/panics/panic-macro-any.rs index a5ba30220e8..08acc6e8078 100644 --- a/src/test/ui/panics/panic-macro-any.rs +++ b/src/test/ui/panics/panic-macro-any.rs @@ -3,7 +3,7 @@ // ignore-emscripten no processes #![feature(box_syntax)] -#![allow(non_fmt_panic)] +#![allow(non_fmt_panics)] fn main() { panic!(box 413 as Box); diff --git a/src/tools/clippy/CHANGELOG.md b/src/tools/clippy/CHANGELOG.md index f3a80703238..421614057c5 100644 --- a/src/tools/clippy/CHANGELOG.md +++ b/src/tools/clippy/CHANGELOG.md @@ -592,7 +592,7 @@ Released 2021-02-11 * Previously deprecated [`str_to_string`] and [`string_to_string`] have been un-deprecated as `restriction` lints [#6333](https://github.com/rust-lang/rust-clippy/pull/6333) -* Deprecate `panic_params` lint. This is now available in rustc as `non_fmt_panic` +* Deprecate `panic_params` lint. This is now available in rustc as `non_fmt_panics` [#6351](https://github.com/rust-lang/rust-clippy/pull/6351) * Move [`map_err_ignore`] to `restriction` [#6416](https://github.com/rust-lang/rust-clippy/pull/6416) diff --git a/src/tools/clippy/clippy_lints/src/lib.rs b/src/tools/clippy/clippy_lints/src/lib.rs index e0325738466..c29b3e7c74c 100644 --- a/src/tools/clippy/clippy_lints/src/lib.rs +++ b/src/tools/clippy/clippy_lints/src/lib.rs @@ -2171,7 +2171,7 @@ pub fn register_renamed(ls: &mut rustc_lint::LintStore) { ls.register_renamed("clippy::unused_label", "unused_labels"); ls.register_renamed("clippy::drop_bounds", "drop_bounds"); ls.register_renamed("clippy::temporary_cstring_as_ptr", "temporary_cstring_as_ptr"); - ls.register_renamed("clippy::panic_params", "non_fmt_panic"); + ls.register_renamed("clippy::panic_params", "non_fmt_panics"); ls.register_renamed("clippy::unknown_clippy_lints", "unknown_lints"); } diff --git a/src/tools/clippy/tests/ui/assertions_on_constants.rs b/src/tools/clippy/tests/ui/assertions_on_constants.rs index 6617ca183a8..2180f848d62 100644 --- a/src/tools/clippy/tests/ui/assertions_on_constants.rs +++ b/src/tools/clippy/tests/ui/assertions_on_constants.rs @@ -1,4 +1,4 @@ -#![allow(non_fmt_panic)] +#![allow(non_fmt_panics)] macro_rules! assert_const { ($len:expr) => { diff --git a/src/tools/clippy/tests/ui/deprecated.stderr b/src/tools/clippy/tests/ui/deprecated.stderr index 0af6b500115..c0002e53543 100644 --- a/src/tools/clippy/tests/ui/deprecated.stderr +++ b/src/tools/clippy/tests/ui/deprecated.stderr @@ -60,11 +60,11 @@ error: lint `clippy::temporary_cstring_as_ptr` has been renamed to `temporary_cs LL | #[warn(clippy::temporary_cstring_as_ptr)] | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ help: use the new name: `temporary_cstring_as_ptr` -error: lint `clippy::panic_params` has been renamed to `non_fmt_panic` +error: lint `clippy::panic_params` has been renamed to `non_fmt_panics` --> $DIR/deprecated.rs:11:8 | LL | #[warn(clippy::panic_params)] - | ^^^^^^^^^^^^^^^^^^^^ help: use the new name: `non_fmt_panic` + | ^^^^^^^^^^^^^^^^^^^^ help: use the new name: `non_fmt_panics` error: lint `clippy::unknown_clippy_lints` has been renamed to `unknown_lints` --> $DIR/deprecated.rs:12:8 From 81c11a212eda360ee3808dacf8065685f4a2e07b Mon Sep 17 00:00:00 2001 From: Ryan Levick Date: Wed, 30 Jun 2021 15:56:50 +0200 Subject: [PATCH 15/19] rust_2021_token_prefixes --- compiler/rustc_lint_defs/src/builtin.rs | 8 ++++---- compiler/rustc_parse/src/lexer/mod.rs | 4 ++-- .../ui/rust-2021/reserved-prefixes-migration.fixed | 12 ++++++------ src/test/ui/rust-2021/reserved-prefixes-migration.rs | 12 ++++++------ .../ui/rust-2021/reserved-prefixes-migration.stderr | 4 ++-- 5 files changed, 20 insertions(+), 20 deletions(-) diff --git a/compiler/rustc_lint_defs/src/builtin.rs b/compiler/rustc_lint_defs/src/builtin.rs index 52bdb4f3e41..9d809e388a1 100644 --- a/compiler/rustc_lint_defs/src/builtin.rs +++ b/compiler/rustc_lint_defs/src/builtin.rs @@ -2973,7 +2973,7 @@ declare_lint_pass! { RUST_2021_INCOMPATIBLE_OR_PATTERNS, LARGE_ASSIGNMENTS, FUTURE_PRELUDE_COLLISIONS, - RESERVED_PREFIXES, + RUST_2021_TOKEN_PREFIXES, UNSUPPORTED_CALLING_CONVENTIONS, ] } @@ -3270,13 +3270,13 @@ declare_lint! { } declare_lint! { - /// The `reserved_prefixes` lint detects identifiers that will be parsed as a + /// The `rust_2021_token_prefixes` lint detects identifiers that will be parsed as a /// prefix instead in Rust 2021. /// /// ### Example /// /// ```rust,compile_fail - /// #![deny(reserved_prefixes)] + /// #![deny(rust_2021_token_prefixes)] /// /// macro_rules! m { /// (z $x:expr) => (); @@ -3295,7 +3295,7 @@ declare_lint! { /// /// This lint suggests to add whitespace between the `z` and `"hey"` tokens /// to keep them separated in Rust 2021. - pub RESERVED_PREFIXES, + pub RUST_2021_TOKEN_PREFIXES, Allow, "identifiers that will be parsed as a prefix in Rust 2021", @future_incompatible = FutureIncompatibleInfo { diff --git a/compiler/rustc_parse/src/lexer/mod.rs b/compiler/rustc_parse/src/lexer/mod.rs index 3f58476296b..73ca9b04b37 100644 --- a/compiler/rustc_parse/src/lexer/mod.rs +++ b/compiler/rustc_parse/src/lexer/mod.rs @@ -4,7 +4,7 @@ use rustc_ast::tokenstream::{Spacing, TokenStream}; use rustc_errors::{error_code, Applicability, DiagnosticBuilder, FatalError, PResult}; use rustc_lexer::unescape::{self, Mode}; use rustc_lexer::{Base, DocStyle, RawStrError}; -use rustc_session::lint::builtin::RESERVED_PREFIXES; +use rustc_session::lint::builtin::RUST_2021_TOKEN_PREFIXES; use rustc_session::lint::BuiltinLintDiagnostics; use rustc_session::parse::ParseSess; use rustc_span::symbol::{sym, Symbol}; @@ -526,7 +526,7 @@ impl<'a> StringReader<'a> { } else { // Before Rust 2021, only emit a lint for migration. self.sess.buffer_lint_with_diagnostic( - &RESERVED_PREFIXES, + &RUST_2021_TOKEN_PREFIXES, prefix_span, ast::CRATE_NODE_ID, &msg, diff --git a/src/test/ui/rust-2021/reserved-prefixes-migration.fixed b/src/test/ui/rust-2021/reserved-prefixes-migration.fixed index f6b6f7405a6..3392970d8d3 100644 --- a/src/test/ui/rust-2021/reserved-prefixes-migration.fixed +++ b/src/test/ui/rust-2021/reserved-prefixes-migration.fixed @@ -2,7 +2,7 @@ // run-rustfix // compile-flags: -Z unstable-options --edition 2018 -#![warn(reserved_prefixes)] +#![warn(rust_2021_token_prefixes)] macro_rules! m2 { ($a:tt $b:tt) => {}; @@ -14,16 +14,16 @@ macro_rules! m3 { fn main() { m2!(z "hey"); - //~^ WARNING prefix `z` is unknown [reserved_prefixes] + //~^ WARNING prefix `z` is unknown [rust_2021_token_prefixes] //~| WARNING hard error in Rust 2021 m2!(prefix "hey"); - //~^ WARNING prefix `prefix` is unknown [reserved_prefixes] + //~^ WARNING prefix `prefix` is unknown [rust_2021_token_prefixes] //~| WARNING hard error in Rust 2021 m3!(hey #123); - //~^ WARNING prefix `hey` is unknown [reserved_prefixes] + //~^ WARNING prefix `hey` is unknown [rust_2021_token_prefixes] //~| WARNING hard error in Rust 2021 m3!(hey #hey); - //~^ WARNING prefix `hey` is unknown [reserved_prefixes] + //~^ WARNING prefix `hey` is unknown [rust_2021_token_prefixes] //~| WARNING hard error in Rust 2021 } @@ -33,6 +33,6 @@ macro_rules! quote { quote! { #name = #kind #value - //~^ WARNING prefix `kind` is unknown [reserved_prefixes] + //~^ WARNING prefix `kind` is unknown [rust_2021_token_prefixes] //~| WARNING hard error in Rust 2021 } diff --git a/src/test/ui/rust-2021/reserved-prefixes-migration.rs b/src/test/ui/rust-2021/reserved-prefixes-migration.rs index 2b056245a99..b8a75224f84 100644 --- a/src/test/ui/rust-2021/reserved-prefixes-migration.rs +++ b/src/test/ui/rust-2021/reserved-prefixes-migration.rs @@ -2,7 +2,7 @@ // run-rustfix // compile-flags: -Z unstable-options --edition 2018 -#![warn(reserved_prefixes)] +#![warn(rust_2021_token_prefixes)] macro_rules! m2 { ($a:tt $b:tt) => {}; @@ -14,16 +14,16 @@ macro_rules! m3 { fn main() { m2!(z"hey"); - //~^ WARNING prefix `z` is unknown [reserved_prefixes] + //~^ WARNING prefix `z` is unknown [rust_2021_token_prefixes] //~| WARNING hard error in Rust 2021 m2!(prefix"hey"); - //~^ WARNING prefix `prefix` is unknown [reserved_prefixes] + //~^ WARNING prefix `prefix` is unknown [rust_2021_token_prefixes] //~| WARNING hard error in Rust 2021 m3!(hey#123); - //~^ WARNING prefix `hey` is unknown [reserved_prefixes] + //~^ WARNING prefix `hey` is unknown [rust_2021_token_prefixes] //~| WARNING hard error in Rust 2021 m3!(hey#hey); - //~^ WARNING prefix `hey` is unknown [reserved_prefixes] + //~^ WARNING prefix `hey` is unknown [rust_2021_token_prefixes] //~| WARNING hard error in Rust 2021 } @@ -33,6 +33,6 @@ macro_rules! quote { quote! { #name = #kind#value - //~^ WARNING prefix `kind` is unknown [reserved_prefixes] + //~^ WARNING prefix `kind` is unknown [rust_2021_token_prefixes] //~| WARNING hard error in Rust 2021 } diff --git a/src/test/ui/rust-2021/reserved-prefixes-migration.stderr b/src/test/ui/rust-2021/reserved-prefixes-migration.stderr index ec27b68e2df..872aefc0715 100644 --- a/src/test/ui/rust-2021/reserved-prefixes-migration.stderr +++ b/src/test/ui/rust-2021/reserved-prefixes-migration.stderr @@ -7,8 +7,8 @@ LL | m2!(z"hey"); note: the lint level is defined here --> $DIR/reserved-prefixes-migration.rs:5:9 | -LL | #![warn(reserved_prefixes)] - | ^^^^^^^^^^^^^^^^^ +LL | #![warn(rust_2021_token_prefixes)] + | ^^^^^^^^^^^^^^^^^^^^^^^^ = warning: this is accepted in the current edition (Rust 2018) but is a hard error in Rust 2021! = note: for more information, see issue #84978 help: insert whitespace here to avoid this being parsed as a prefix in Rust 2021 From 941eb2adbd10988167e0fe23b87e795203df3977 Mon Sep 17 00:00:00 2001 From: Ryan Levick Date: Thu, 1 Jul 2021 13:35:33 +0200 Subject: [PATCH 16/19] Rename future_prelude_collisions to rust_2021_prelude_collisions --- compiler/rustc_lint_defs/src/builtin.rs | 8 ++++---- compiler/rustc_typeck/src/check/method/prelude2021.rs | 8 ++++---- .../ui/rust-2021/future-prelude-collision-imported.fixed | 2 +- .../ui/rust-2021/future-prelude-collision-imported.rs | 2 +- .../ui/rust-2021/future-prelude-collision-imported.stderr | 4 ++-- src/test/ui/rust-2021/future-prelude-collision-shadow.rs | 2 +- .../ui/rust-2021/future-prelude-collision-unneeded.rs | 2 +- src/test/ui/rust-2021/future-prelude-collision.fixed | 2 +- src/test/ui/rust-2021/future-prelude-collision.rs | 2 +- src/test/ui/rust-2021/future-prelude-collision.stderr | 4 ++-- src/test/ui/rust-2021/generic-type-collision.fixed | 2 +- src/test/ui/rust-2021/generic-type-collision.rs | 2 +- src/test/ui/rust-2021/generic-type-collision.stderr | 4 ++-- src/test/ui/rust-2021/inherent-dyn-collision.fixed | 2 +- src/test/ui/rust-2021/inherent-dyn-collision.rs | 2 +- src/test/ui/rust-2021/inherent-dyn-collision.stderr | 4 ++-- src/test/ui/rust-2021/inherent-method-collision.rs | 2 +- 17 files changed, 27 insertions(+), 27 deletions(-) diff --git a/compiler/rustc_lint_defs/src/builtin.rs b/compiler/rustc_lint_defs/src/builtin.rs index 9d809e388a1..3e30b6553db 100644 --- a/compiler/rustc_lint_defs/src/builtin.rs +++ b/compiler/rustc_lint_defs/src/builtin.rs @@ -2972,7 +2972,7 @@ declare_lint_pass! { PROC_MACRO_BACK_COMPAT, RUST_2021_INCOMPATIBLE_OR_PATTERNS, LARGE_ASSIGNMENTS, - FUTURE_PRELUDE_COLLISIONS, + RUST_2021_PRELUDE_COLLISIONS, RUST_2021_TOKEN_PREFIXES, UNSUPPORTED_CALLING_CONVENTIONS, ] @@ -3221,13 +3221,13 @@ declare_lint! { } declare_lint! { - /// The `future_prelude_collisions` lint detects the usage of trait methods which are ambiguous + /// The `rust_2021_prelude_collisions` lint detects the usage of trait methods which are ambiguous /// with traits added to the prelude in future editions. /// /// ### Example /// /// ```rust,compile_fail - /// #![deny(future_prelude_collisions)] + /// #![deny(rust_2021_prelude_collisions)] /// /// trait Foo { /// fn try_into(self) -> Result; @@ -3259,7 +3259,7 @@ declare_lint! { /// is called directly on a type. /// /// [prelude changes]: https://blog.rust-lang.org/inside-rust/2021/03/04/planning-rust-2021.html#prelude-changes - pub FUTURE_PRELUDE_COLLISIONS, + pub RUST_2021_PRELUDE_COLLISIONS, Allow, "detects the usage of trait methods which are ambiguous with traits added to the \ prelude in future editions", diff --git a/compiler/rustc_typeck/src/check/method/prelude2021.rs b/compiler/rustc_typeck/src/check/method/prelude2021.rs index cf17ff2eab5..6ca0b3ed66b 100644 --- a/compiler/rustc_typeck/src/check/method/prelude2021.rs +++ b/compiler/rustc_typeck/src/check/method/prelude2021.rs @@ -5,7 +5,7 @@ use rustc_ast::Mutability; use rustc_errors::Applicability; use rustc_hir as hir; use rustc_middle::ty::{Ref, Ty}; -use rustc_session::lint::builtin::FUTURE_PRELUDE_COLLISIONS; +use rustc_session::lint::builtin::RUST_2021_PRELUDE_COLLISIONS; use rustc_span::symbol::kw::Underscore; use rustc_span::symbol::{sym, Ident}; use rustc_span::Span; @@ -67,7 +67,7 @@ impl<'a, 'tcx> FnCtxt<'a, 'tcx> { // Inherent impls only require not relying on autoref and autoderef in order to // ensure that the trait implementation won't be used self.tcx.struct_span_lint_hir( - FUTURE_PRELUDE_COLLISIONS, + RUST_2021_PRELUDE_COLLISIONS, self_expr.hir_id, self_expr.span, |lint| { @@ -128,7 +128,7 @@ impl<'a, 'tcx> FnCtxt<'a, 'tcx> { // trait implementations require full disambiguation to not clash with the new prelude // additions (i.e. convert from dot-call to fully-qualified call) self.tcx.struct_span_lint_hir( - FUTURE_PRELUDE_COLLISIONS, + RUST_2021_PRELUDE_COLLISIONS, call_expr.hir_id, call_expr.span, |lint| { @@ -212,7 +212,7 @@ impl<'a, 'tcx> FnCtxt<'a, 'tcx> { return; } - self.tcx.struct_span_lint_hir(FUTURE_PRELUDE_COLLISIONS, expr_id, span, |lint| { + self.tcx.struct_span_lint_hir(RUST_2021_PRELUDE_COLLISIONS, expr_id, span, |lint| { // "type" refers to either a type or, more likely, a trait from which // the associated function or method is from. let trait_path = self.trait_path_or_bare_name(span, expr_id, pick.item.container.id()); diff --git a/src/test/ui/rust-2021/future-prelude-collision-imported.fixed b/src/test/ui/rust-2021/future-prelude-collision-imported.fixed index e37b4cd0960..c5ff0b4bcd0 100644 --- a/src/test/ui/rust-2021/future-prelude-collision-imported.fixed +++ b/src/test/ui/rust-2021/future-prelude-collision-imported.fixed @@ -1,7 +1,7 @@ // run-rustfix // edition:2018 // check-pass -#![warn(future_prelude_collisions)] +#![warn(rust_2021_prelude_collisions)] #![allow(dead_code)] #![allow(unused_imports)] diff --git a/src/test/ui/rust-2021/future-prelude-collision-imported.rs b/src/test/ui/rust-2021/future-prelude-collision-imported.rs index a560c4b92e1..cd39eec47f2 100644 --- a/src/test/ui/rust-2021/future-prelude-collision-imported.rs +++ b/src/test/ui/rust-2021/future-prelude-collision-imported.rs @@ -1,7 +1,7 @@ // run-rustfix // edition:2018 // check-pass -#![warn(future_prelude_collisions)] +#![warn(rust_2021_prelude_collisions)] #![allow(dead_code)] #![allow(unused_imports)] diff --git a/src/test/ui/rust-2021/future-prelude-collision-imported.stderr b/src/test/ui/rust-2021/future-prelude-collision-imported.stderr index da455f2d15a..61975876819 100644 --- a/src/test/ui/rust-2021/future-prelude-collision-imported.stderr +++ b/src/test/ui/rust-2021/future-prelude-collision-imported.stderr @@ -7,8 +7,8 @@ LL | let _: u32 = 3u8.try_into().unwrap(); note: the lint level is defined here --> $DIR/future-prelude-collision-imported.rs:4:9 | -LL | #![warn(future_prelude_collisions)] - | ^^^^^^^^^^^^^^^^^^^^^^^^^ +LL | #![warn(rust_2021_prelude_collisions)] + | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^ = warning: this is accepted in the current edition (Rust 2018) but is a hard error in Rust 2021! = note: for more information, see issue #85684 diff --git a/src/test/ui/rust-2021/future-prelude-collision-shadow.rs b/src/test/ui/rust-2021/future-prelude-collision-shadow.rs index 7e64f9ae7bf..27891a8d11d 100644 --- a/src/test/ui/rust-2021/future-prelude-collision-shadow.rs +++ b/src/test/ui/rust-2021/future-prelude-collision-shadow.rs @@ -1,5 +1,5 @@ // edition:2018 -#![warn(future_prelude_collisions)] +#![warn(rust_2021_prelude_collisions)] #![allow(dead_code)] #![allow(unused_imports)] diff --git a/src/test/ui/rust-2021/future-prelude-collision-unneeded.rs b/src/test/ui/rust-2021/future-prelude-collision-unneeded.rs index 1c809d0ba09..4be82056ad5 100644 --- a/src/test/ui/rust-2021/future-prelude-collision-unneeded.rs +++ b/src/test/ui/rust-2021/future-prelude-collision-unneeded.rs @@ -1,7 +1,7 @@ // edition:2018 // check-pass #![allow(unused)] -#![deny(future_prelude_collisions)] +#![deny(rust_2021_prelude_collisions)] struct S; diff --git a/src/test/ui/rust-2021/future-prelude-collision.fixed b/src/test/ui/rust-2021/future-prelude-collision.fixed index c8f29c325d9..43b0ec1c3e6 100644 --- a/src/test/ui/rust-2021/future-prelude-collision.fixed +++ b/src/test/ui/rust-2021/future-prelude-collision.fixed @@ -1,7 +1,7 @@ // run-rustfix // edition:2018 // check-pass -#![warn(future_prelude_collisions)] +#![warn(rust_2021_prelude_collisions)] trait TryIntoU32 { fn try_into(self) -> Result; diff --git a/src/test/ui/rust-2021/future-prelude-collision.rs b/src/test/ui/rust-2021/future-prelude-collision.rs index 7059535b877..4c7a47ffbe2 100644 --- a/src/test/ui/rust-2021/future-prelude-collision.rs +++ b/src/test/ui/rust-2021/future-prelude-collision.rs @@ -1,7 +1,7 @@ // run-rustfix // edition:2018 // check-pass -#![warn(future_prelude_collisions)] +#![warn(rust_2021_prelude_collisions)] trait TryIntoU32 { fn try_into(self) -> Result; diff --git a/src/test/ui/rust-2021/future-prelude-collision.stderr b/src/test/ui/rust-2021/future-prelude-collision.stderr index 46e52baf838..03b89da00d9 100644 --- a/src/test/ui/rust-2021/future-prelude-collision.stderr +++ b/src/test/ui/rust-2021/future-prelude-collision.stderr @@ -7,8 +7,8 @@ LL | let _: u32 = 3u8.try_into().unwrap(); note: the lint level is defined here --> $DIR/future-prelude-collision.rs:4:9 | -LL | #![warn(future_prelude_collisions)] - | ^^^^^^^^^^^^^^^^^^^^^^^^^ +LL | #![warn(rust_2021_prelude_collisions)] + | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^ = warning: this is accepted in the current edition (Rust 2018) but is a hard error in Rust 2021! = note: for more information, see issue #85684 diff --git a/src/test/ui/rust-2021/generic-type-collision.fixed b/src/test/ui/rust-2021/generic-type-collision.fixed index 9851a1d42b6..feba7d19b66 100644 --- a/src/test/ui/rust-2021/generic-type-collision.fixed +++ b/src/test/ui/rust-2021/generic-type-collision.fixed @@ -1,7 +1,7 @@ // check-pass // run-rustfix // edition 2018 -#![warn(future_prelude_collisions)] +#![warn(rust_2021_prelude_collisions)] trait MyTrait { fn from_iter(x: Option); diff --git a/src/test/ui/rust-2021/generic-type-collision.rs b/src/test/ui/rust-2021/generic-type-collision.rs index 18deaa55cfe..335e7e520a4 100644 --- a/src/test/ui/rust-2021/generic-type-collision.rs +++ b/src/test/ui/rust-2021/generic-type-collision.rs @@ -1,7 +1,7 @@ // check-pass // run-rustfix // edition 2018 -#![warn(future_prelude_collisions)] +#![warn(rust_2021_prelude_collisions)] trait MyTrait { fn from_iter(x: Option); diff --git a/src/test/ui/rust-2021/generic-type-collision.stderr b/src/test/ui/rust-2021/generic-type-collision.stderr index 1839c3e7279..d4999201c27 100644 --- a/src/test/ui/rust-2021/generic-type-collision.stderr +++ b/src/test/ui/rust-2021/generic-type-collision.stderr @@ -7,8 +7,8 @@ LL | >::from_iter(None); note: the lint level is defined here --> $DIR/generic-type-collision.rs:4:9 | -LL | #![warn(future_prelude_collisions)] - | ^^^^^^^^^^^^^^^^^^^^^^^^^ +LL | #![warn(rust_2021_prelude_collisions)] + | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^ = warning: this is accepted in the current edition (Rust 2015) but is a hard error in Rust 2021! = note: for more information, see issue #85684 diff --git a/src/test/ui/rust-2021/inherent-dyn-collision.fixed b/src/test/ui/rust-2021/inherent-dyn-collision.fixed index d6be9e56f96..5789a90393b 100644 --- a/src/test/ui/rust-2021/inherent-dyn-collision.fixed +++ b/src/test/ui/rust-2021/inherent-dyn-collision.fixed @@ -5,7 +5,7 @@ // run-rustfix // edition:2018 -#![warn(future_prelude_collisions)] +#![warn(rust_2021_prelude_collisions)] trait TryIntoU32 { fn try_into(&self) -> Result; diff --git a/src/test/ui/rust-2021/inherent-dyn-collision.rs b/src/test/ui/rust-2021/inherent-dyn-collision.rs index 67be6157d45..a3893c033e9 100644 --- a/src/test/ui/rust-2021/inherent-dyn-collision.rs +++ b/src/test/ui/rust-2021/inherent-dyn-collision.rs @@ -5,7 +5,7 @@ // run-rustfix // edition:2018 -#![warn(future_prelude_collisions)] +#![warn(rust_2021_prelude_collisions)] trait TryIntoU32 { fn try_into(&self) -> Result; diff --git a/src/test/ui/rust-2021/inherent-dyn-collision.stderr b/src/test/ui/rust-2021/inherent-dyn-collision.stderr index 4d7a04735ac..605f9ced9eb 100644 --- a/src/test/ui/rust-2021/inherent-dyn-collision.stderr +++ b/src/test/ui/rust-2021/inherent-dyn-collision.stderr @@ -7,8 +7,8 @@ LL | get_dyn_trait().try_into().unwrap() note: the lint level is defined here --> $DIR/inherent-dyn-collision.rs:8:9 | -LL | #![warn(future_prelude_collisions)] - | ^^^^^^^^^^^^^^^^^^^^^^^^^ +LL | #![warn(rust_2021_prelude_collisions)] + | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^ = warning: this is accepted in the current edition (Rust 2018) but is a hard error in Rust 2021! = note: for more information, see issue #85684 diff --git a/src/test/ui/rust-2021/inherent-method-collision.rs b/src/test/ui/rust-2021/inherent-method-collision.rs index f99d98bd890..507105207d6 100644 --- a/src/test/ui/rust-2021/inherent-method-collision.rs +++ b/src/test/ui/rust-2021/inherent-method-collision.rs @@ -2,7 +2,7 @@ // // check-pass -#![deny(future_prelude_collisions)] +#![deny(rust_2021_prelude_collisions)] pub struct MySeq {} From d4e384bc1de0c11f3bc6fffc013358de85ad2982 Mon Sep 17 00:00:00 2001 From: Ryan Levick Date: Tue, 6 Jul 2021 16:33:11 +0200 Subject: [PATCH 17/19] rename rust_2021_token_prefixes to rust_2021_prefixes_incompatible_syntax --- compiler/rustc_lint_defs/src/builtin.rs | 8 ++++---- compiler/rustc_parse/src/lexer/mod.rs | 4 ++-- .../ui/rust-2021/reserved-prefixes-migration.fixed | 12 ++++++------ src/test/ui/rust-2021/reserved-prefixes-migration.rs | 12 ++++++------ .../ui/rust-2021/reserved-prefixes-migration.stderr | 4 ++-- 5 files changed, 20 insertions(+), 20 deletions(-) diff --git a/compiler/rustc_lint_defs/src/builtin.rs b/compiler/rustc_lint_defs/src/builtin.rs index 3e30b6553db..01291de51bd 100644 --- a/compiler/rustc_lint_defs/src/builtin.rs +++ b/compiler/rustc_lint_defs/src/builtin.rs @@ -2973,7 +2973,7 @@ declare_lint_pass! { RUST_2021_INCOMPATIBLE_OR_PATTERNS, LARGE_ASSIGNMENTS, RUST_2021_PRELUDE_COLLISIONS, - RUST_2021_TOKEN_PREFIXES, + RUST_2021_PREFIXES_INCOMPATIBLE_SYNTAX, UNSUPPORTED_CALLING_CONVENTIONS, ] } @@ -3270,13 +3270,13 @@ declare_lint! { } declare_lint! { - /// The `rust_2021_token_prefixes` lint detects identifiers that will be parsed as a + /// The `rust_2021_prefixes_incompatible_syntax` lint detects identifiers that will be parsed as a /// prefix instead in Rust 2021. /// /// ### Example /// /// ```rust,compile_fail - /// #![deny(rust_2021_token_prefixes)] + /// #![deny(rust_2021_prefixes_incompatible_syntax)] /// /// macro_rules! m { /// (z $x:expr) => (); @@ -3295,7 +3295,7 @@ declare_lint! { /// /// This lint suggests to add whitespace between the `z` and `"hey"` tokens /// to keep them separated in Rust 2021. - pub RUST_2021_TOKEN_PREFIXES, + pub RUST_2021_PREFIXES_INCOMPATIBLE_SYNTAX, Allow, "identifiers that will be parsed as a prefix in Rust 2021", @future_incompatible = FutureIncompatibleInfo { diff --git a/compiler/rustc_parse/src/lexer/mod.rs b/compiler/rustc_parse/src/lexer/mod.rs index 73ca9b04b37..98befe4066b 100644 --- a/compiler/rustc_parse/src/lexer/mod.rs +++ b/compiler/rustc_parse/src/lexer/mod.rs @@ -4,7 +4,7 @@ use rustc_ast::tokenstream::{Spacing, TokenStream}; use rustc_errors::{error_code, Applicability, DiagnosticBuilder, FatalError, PResult}; use rustc_lexer::unescape::{self, Mode}; use rustc_lexer::{Base, DocStyle, RawStrError}; -use rustc_session::lint::builtin::RUST_2021_TOKEN_PREFIXES; +use rustc_session::lint::builtin::RUST_2021_PREFIXES_INCOMPATIBLE_SYNTAX; use rustc_session::lint::BuiltinLintDiagnostics; use rustc_session::parse::ParseSess; use rustc_span::symbol::{sym, Symbol}; @@ -526,7 +526,7 @@ impl<'a> StringReader<'a> { } else { // Before Rust 2021, only emit a lint for migration. self.sess.buffer_lint_with_diagnostic( - &RUST_2021_TOKEN_PREFIXES, + &RUST_2021_PREFIXES_INCOMPATIBLE_SYNTAX, prefix_span, ast::CRATE_NODE_ID, &msg, diff --git a/src/test/ui/rust-2021/reserved-prefixes-migration.fixed b/src/test/ui/rust-2021/reserved-prefixes-migration.fixed index 3392970d8d3..e026f01e93f 100644 --- a/src/test/ui/rust-2021/reserved-prefixes-migration.fixed +++ b/src/test/ui/rust-2021/reserved-prefixes-migration.fixed @@ -2,7 +2,7 @@ // run-rustfix // compile-flags: -Z unstable-options --edition 2018 -#![warn(rust_2021_token_prefixes)] +#![warn(rust_2021_prefixes_incompatible_syntax)] macro_rules! m2 { ($a:tt $b:tt) => {}; @@ -14,16 +14,16 @@ macro_rules! m3 { fn main() { m2!(z "hey"); - //~^ WARNING prefix `z` is unknown [rust_2021_token_prefixes] + //~^ WARNING prefix `z` is unknown [rust_2021_prefixes_incompatible_syntax] //~| WARNING hard error in Rust 2021 m2!(prefix "hey"); - //~^ WARNING prefix `prefix` is unknown [rust_2021_token_prefixes] + //~^ WARNING prefix `prefix` is unknown [rust_2021_prefixes_incompatible_syntax] //~| WARNING hard error in Rust 2021 m3!(hey #123); - //~^ WARNING prefix `hey` is unknown [rust_2021_token_prefixes] + //~^ WARNING prefix `hey` is unknown [rust_2021_prefixes_incompatible_syntax] //~| WARNING hard error in Rust 2021 m3!(hey #hey); - //~^ WARNING prefix `hey` is unknown [rust_2021_token_prefixes] + //~^ WARNING prefix `hey` is unknown [rust_2021_prefixes_incompatible_syntax] //~| WARNING hard error in Rust 2021 } @@ -33,6 +33,6 @@ macro_rules! quote { quote! { #name = #kind #value - //~^ WARNING prefix `kind` is unknown [rust_2021_token_prefixes] + //~^ WARNING prefix `kind` is unknown [rust_2021_prefixes_incompatible_syntax] //~| WARNING hard error in Rust 2021 } diff --git a/src/test/ui/rust-2021/reserved-prefixes-migration.rs b/src/test/ui/rust-2021/reserved-prefixes-migration.rs index b8a75224f84..d24f2963480 100644 --- a/src/test/ui/rust-2021/reserved-prefixes-migration.rs +++ b/src/test/ui/rust-2021/reserved-prefixes-migration.rs @@ -2,7 +2,7 @@ // run-rustfix // compile-flags: -Z unstable-options --edition 2018 -#![warn(rust_2021_token_prefixes)] +#![warn(rust_2021_prefixes_incompatible_syntax)] macro_rules! m2 { ($a:tt $b:tt) => {}; @@ -14,16 +14,16 @@ macro_rules! m3 { fn main() { m2!(z"hey"); - //~^ WARNING prefix `z` is unknown [rust_2021_token_prefixes] + //~^ WARNING prefix `z` is unknown [rust_2021_prefixes_incompatible_syntax] //~| WARNING hard error in Rust 2021 m2!(prefix"hey"); - //~^ WARNING prefix `prefix` is unknown [rust_2021_token_prefixes] + //~^ WARNING prefix `prefix` is unknown [rust_2021_prefixes_incompatible_syntax] //~| WARNING hard error in Rust 2021 m3!(hey#123); - //~^ WARNING prefix `hey` is unknown [rust_2021_token_prefixes] + //~^ WARNING prefix `hey` is unknown [rust_2021_prefixes_incompatible_syntax] //~| WARNING hard error in Rust 2021 m3!(hey#hey); - //~^ WARNING prefix `hey` is unknown [rust_2021_token_prefixes] + //~^ WARNING prefix `hey` is unknown [rust_2021_prefixes_incompatible_syntax] //~| WARNING hard error in Rust 2021 } @@ -33,6 +33,6 @@ macro_rules! quote { quote! { #name = #kind#value - //~^ WARNING prefix `kind` is unknown [rust_2021_token_prefixes] + //~^ WARNING prefix `kind` is unknown [rust_2021_prefixes_incompatible_syntax] //~| WARNING hard error in Rust 2021 } diff --git a/src/test/ui/rust-2021/reserved-prefixes-migration.stderr b/src/test/ui/rust-2021/reserved-prefixes-migration.stderr index 872aefc0715..95105f932dc 100644 --- a/src/test/ui/rust-2021/reserved-prefixes-migration.stderr +++ b/src/test/ui/rust-2021/reserved-prefixes-migration.stderr @@ -7,8 +7,8 @@ LL | m2!(z"hey"); note: the lint level is defined here --> $DIR/reserved-prefixes-migration.rs:5:9 | -LL | #![warn(rust_2021_token_prefixes)] - | ^^^^^^^^^^^^^^^^^^^^^^^^ +LL | #![warn(rust_2021_prefixes_incompatible_syntax)] + | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ = warning: this is accepted in the current edition (Rust 2018) but is a hard error in Rust 2021! = note: for more information, see issue #84978 help: insert whitespace here to avoid this being parsed as a prefix in Rust 2021 From fb464a3b39bd4657bbf98a6d445cb12a14dd7ed6 Mon Sep 17 00:00:00 2001 From: Godmar Back Date: Tue, 6 Jul 2021 15:50:42 -0400 Subject: [PATCH 18/19] rewrote documentation for thread::yield_now() The old documentation suggested the use of yield_now for repeated polling instead of discouraging it; it also made the false claim that channels are implementing using yield_now. (They are not, except for a corner case). --- library/std/src/thread/mod.rs | 27 ++++++++++++++------------- 1 file changed, 14 insertions(+), 13 deletions(-) diff --git a/library/std/src/thread/mod.rs b/library/std/src/thread/mod.rs index f7e79141903..da2d1160493 100644 --- a/library/std/src/thread/mod.rs +++ b/library/std/src/thread/mod.rs @@ -651,22 +651,23 @@ pub fn current() -> Thread { /// Cooperatively gives up a timeslice to the OS scheduler. /// -/// This is used when the programmer knows that the thread will have nothing -/// to do for some time, and thus avoid wasting computing time. +/// This calls the underlying OS scheduler's yield primitive, signaling +/// that the calling thread is willing to give up its remaining timeslice +/// so that the OS may schedule other threads on the CPU. /// -/// For example when polling on a resource, it is common to check that it is -/// available, and if not to yield in order to avoid busy waiting. +/// A drawback of yielding in a loop is that if the OS does not have any +/// other ready threads to run on the current CPU, the thread will effectively +/// busy-wait, which wastes CPU time and energy. /// -/// Thus the pattern of `yield`ing after a failed poll is rather common when -/// implementing low-level shared resources or synchronization primitives. +/// Therefore, when waiting for events of interest, a programmer's first +/// choice should be to use synchronization devices such as [`channel`]s, +/// [`Condvar`]s, [`Mutex`]es or [`join`] since these primitives are +/// implemented in a blocking manner, giving up the CPU until the event +/// of interest has occurred which avoids repeated yielding. /// -/// However programmers will usually prefer to use [`channel`]s, [`Condvar`]s, -/// [`Mutex`]es or [`join`] for their synchronization routines, as they avoid -/// thinking about thread scheduling. -/// -/// Note that [`channel`]s for example are implemented using this primitive. -/// Indeed when you call `send` or `recv`, which are blocking, they will yield -/// if the channel is not available. +/// `yield_now` should thus be used only rarely, mostly in situations where +/// repeated polling is required because there is no other suitable way to +/// learn when an event of interest has occurred. /// /// # Examples /// From 1b4704d200c28c91e89a73e07fd6c8c7b646506d Mon Sep 17 00:00:00 2001 From: Eric Huss Date: Tue, 6 Jul 2021 17:07:35 -0700 Subject: [PATCH 19/19] Update books --- src/doc/book | 2 +- src/doc/edition-guide | 2 +- src/doc/embedded-book | 2 +- src/doc/nomicon | 2 +- src/doc/reference | 2 +- src/doc/rust-by-example | 2 +- src/doc/rustc-dev-guide | 2 +- 7 files changed, 7 insertions(+), 7 deletions(-) diff --git a/src/doc/book b/src/doc/book index 55a26488dde..a90f07f1e9a 160000 --- a/src/doc/book +++ b/src/doc/book @@ -1 +1 @@ -Subproject commit 55a26488ddefc8433e73a2e8352d70f7a5c7fc2b +Subproject commit a90f07f1e9a7fc75dc9105a6c6f16d5c13edceb0 diff --git a/src/doc/edition-guide b/src/doc/edition-guide index c74b2a0d6bf..5d57b3832f8 160000 --- a/src/doc/edition-guide +++ b/src/doc/edition-guide @@ -1 +1 @@ -Subproject commit c74b2a0d6bf55774cf15d69f05dfe05408b8f81a +Subproject commit 5d57b3832f8d308a9f478ce0a69799548f27ad4d diff --git a/src/doc/embedded-book b/src/doc/embedded-book index cbec77fbd8e..506840eb73b 160000 --- a/src/doc/embedded-book +++ b/src/doc/embedded-book @@ -1 +1 @@ -Subproject commit cbec77fbd8eea0c13e390dd9eded1ae200e811d1 +Subproject commit 506840eb73b0749336e1d5274e16d6393892ee82 diff --git a/src/doc/nomicon b/src/doc/nomicon index b9ca313e687..7a13537f96a 160000 --- a/src/doc/nomicon +++ b/src/doc/nomicon @@ -1 +1 @@ -Subproject commit b9ca313e687c991223e23e5520529815dc281205 +Subproject commit 7a13537f96af4b9b8e3ea296d6e5c3c7ab72ce9f diff --git a/src/doc/reference b/src/doc/reference index d9699fa8f31..ab60513a3a5 160000 --- a/src/doc/reference +++ b/src/doc/reference @@ -1 +1 @@ -Subproject commit d9699fa8f3186440fdaadd703d63d8d42322c176 +Subproject commit ab60513a3a5a0591e237fddff5d027a982648392 diff --git a/src/doc/rust-by-example b/src/doc/rust-by-example index 805e016c579..028f93a6150 160000 --- a/src/doc/rust-by-example +++ b/src/doc/rust-by-example @@ -1 +1 @@ -Subproject commit 805e016c5792ad2adabb66e348233067d5ea9f10 +Subproject commit 028f93a61500fe8f746ee7cc6b204ea6c9f42935 diff --git a/src/doc/rustc-dev-guide b/src/doc/rustc-dev-guide index fe34beddb41..60e28255910 160000 --- a/src/doc/rustc-dev-guide +++ b/src/doc/rustc-dev-guide @@ -1 +1 @@ -Subproject commit fe34beddb41dea5cb891032512a8d5b842b99696 +Subproject commit 60e282559104035985331645907c3d9f842312c5