diff --git a/compiler/rustc_lint/src/diagnostics.rs b/compiler/rustc_lint/src/diagnostics.rs index 3565df367aa89..a3663ca96af6c 100644 --- a/compiler/rustc_lint/src/diagnostics.rs +++ b/compiler/rustc_lint/src/diagnostics.rs @@ -1101,7 +1101,7 @@ pub(crate) struct ConstItemInteriorMutationsDiag<'tcx> { pub method_name: Ident, pub const_name: Ident, pub const_ty: Ty<'tcx>, - #[label("`{$const_name}` is a interior mutable `const` item of type `{$const_ty}`")] + #[label("`{$const_name}` is an interior mutable `const` item of type `{$const_ty}`")] pub receiver_span: Span, #[subdiagnostic] pub sugg_static: Option, diff --git a/library/core/src/time.rs b/library/core/src/time.rs index 6fc40b4c25c2e..b8661462d20e9 100644 --- a/library/core/src/time.rs +++ b/library/core/src/time.rs @@ -722,6 +722,99 @@ impl Duration { self.secs as u128 * NANOS_PER_SEC as u128 + self.nanos.as_inner() as u128 } + /// Returns the number of _whole_ weeks contained by this `Duration`. + /// + /// The returned value does not include any fractional component + /// corresponding to units less than a week of the duration. + /// + /// For this method, one week is defined as 7 days, or 604,800 seconds. + /// + /// # Examples + /// + /// ``` + /// #![feature(duration_extractors)] + /// #![feature(duration_constructors)] + /// use std::time::Duration; + /// + /// let duration = Duration::from_days(40); + /// assert_eq!(duration.as_weeks(), 5); + /// ``` + #[unstable(feature = "duration_extractors", issue = "165786")] + #[must_use] + #[inline] + pub const fn as_weeks(&self) -> u64 { + self.as_secs() / (SECS_PER_MINUTE * MINS_PER_HOUR * HOURS_PER_DAY * DAYS_PER_WEEK) + } + + /// Returns the number of _whole_ days contained by this `Duration`. + /// + /// The returned value does not include any fractional component + /// corresponding to units less than a day of the duration. + /// + /// For this method, one day is defined as 24 hours, or 86,400 seconds. + /// + /// # Examples + /// + /// ``` + /// #![feature(duration_extractors)] + /// use std::time::Duration; + /// + /// let duration = Duration::from_hours(130); + /// assert_eq!(duration.as_days(), 5); + /// ``` + #[unstable(feature = "duration_extractors", issue = "165786")] + #[must_use] + #[inline] + pub const fn as_days(&self) -> u64 { + self.as_secs() / (SECS_PER_MINUTE * MINS_PER_HOUR * HOURS_PER_DAY) + } + + /// Returns the number of _whole_ hours contained by this `Duration`. + /// + /// The returned value does not include any fractional component + /// corresponding to units less than an hour of the duration. + /// + /// For this method, one hour is defined as 60 minutes, or 3,600 seconds. + /// + /// # Examples + /// + /// ``` + /// #![feature(duration_extractors_lite)] + /// use std::time::Duration; + /// + /// let duration = Duration::from_mins(320); + /// assert_eq!(duration.as_hours(), 5); + /// ``` + #[unstable(feature = "duration_extractors_lite", issue = "165784")] + #[must_use] + #[inline] + pub const fn as_hours(&self) -> u64 { + self.as_secs() / (SECS_PER_MINUTE * MINS_PER_HOUR) + } + + /// Returns the number of _whole_ minutes contained by this `Duration`. + /// + /// The returned value does not include any fractional component + /// corresponding to units less than a minute of the duration. + /// + /// For this method, one minute is defined as 60 seconds. + /// + /// # Examples + /// + /// ``` + /// #![feature(duration_extractors_lite)] + /// use std::time::Duration; + /// + /// let duration = Duration::from_secs(320); + /// assert_eq!(duration.as_mins(), 5); + /// ``` + #[unstable(feature = "duration_extractors_lite", issue = "165784")] + #[must_use] + #[inline] + pub const fn as_mins(&self) -> u64 { + self.as_secs() / SECS_PER_MINUTE + } + /// Computes the absolute difference between `self` and `other`. /// /// # Examples diff --git a/library/coretests/tests/lib.rs b/library/coretests/tests/lib.rs index f3ef2e79b5927..690d8569ec70c 100644 --- a/library/coretests/tests/lib.rs +++ b/library/coretests/tests/lib.rs @@ -56,6 +56,8 @@ #![feature(duration_constants)] #![feature(duration_constructors)] #![feature(duration_display_seconds)] +#![feature(duration_extractors)] +#![feature(duration_extractors_lite)] #![feature(exact_div)] #![feature(exact_size_is_empty)] #![feature(extend_one)] diff --git a/library/coretests/tests/time.rs b/library/coretests/tests/time.rs index c5ad53346f8ae..1fa905e50ca3e 100644 --- a/library/coretests/tests/time.rs +++ b/library/coretests/tests/time.rs @@ -641,6 +641,30 @@ fn duration_const() { const FROM_NANOS_U128: Duration = Duration::from_nanos_u128(NANOS); assert_eq!(FROM_NANOS_U128, Duration::SECOND); + const WEEKS: u64 = Duration::WEEK.as_weeks(); + assert_eq!(WEEKS, 1); + + const FROM_WEEKS: Duration = Duration::from_weeks(1); + assert_eq!(FROM_WEEKS, 604_800 * Duration::SECOND); + + const DAYS: u64 = Duration::DAY.as_days(); + assert_eq!(DAYS, 1); + + const FROM_DAYS: Duration = Duration::from_days(1); + assert_eq!(FROM_DAYS, 86400 * Duration::SECOND); + + const HOURS: u64 = Duration::HOUR.as_hours(); + assert_eq!(HOURS, 1); + + const FROM_HOURS: Duration = Duration::from_hours(1); + assert_eq!(FROM_HOURS, 3600 * Duration::SECOND); + + const MINUTES: u64 = Duration::MINUTE.as_mins(); + assert_eq!(MINUTES, 1); + + const FROM_MINUTES: Duration = Duration::from_mins(1); + assert_eq!(FROM_MINUTES, 60 * Duration::SECOND); + const MAX: Duration = Duration::new(u64::MAX, 999_999_999); const CHECKED_ADD: Option = MAX.checked_add(Duration::SECOND); diff --git a/src/bootstrap/src/core/build_steps/test.rs b/src/bootstrap/src/core/build_steps/test.rs index 5841fc7196773..27249a76bd952 100644 --- a/src/bootstrap/src/core/build_steps/test.rs +++ b/src/bootstrap/src/core/build_steps/test.rs @@ -1071,12 +1071,17 @@ pub struct IntrinsicTest { host: TargetSelection, } +impl IntrinsicTest { + const ALIAS: &'static str = "stdarch-intrinsic-test"; +} + impl CommandLineStep for IntrinsicTest { type Output = (); const IS_HOST: bool = true; fn should_run(run: ShouldRun<'_>) -> ShouldRun<'_> { - run.alias("intrinsic-test") + // Not using a path since we don't want this to be part of `./x test library`. + run.alias(Self::ALIAS) } fn is_default_step(_builder: &Builder<'_>) -> bool { @@ -1087,12 +1092,12 @@ impl CommandLineStep for IntrinsicTest { let target = run.target; let builder = run.builder; - let is_explicit = - builder.config.paths.iter().any(|p| p.to_string_lossy() == "intrinsic-test"); + let is_explicit = builder.config.paths.iter().any(|p| p.to_string_lossy() == Self::ALIAS); if target.contains("x86_64-unknown-linux") && builder.config.sde.is_none() && is_explicit { panic!( - "SDE is required to run intrinsic-test. Please configure `build.sde` in config.toml." + "SDE is required to run {}. Please configure `build.sde` in config.toml.", + Self::ALIAS ); } diff --git a/src/bootstrap/src/core/builder/cli_paths/snapshots/x_test.snap b/src/bootstrap/src/core/builder/cli_paths/snapshots/x_test.snap index b01ccfcba50b5..6ce5a96dfe5b8 100644 --- a/src/bootstrap/src/core/builder/cli_paths/snapshots/x_test.snap +++ b/src/bootstrap/src/core/builder/cli_paths/snapshots/x_test.snap @@ -228,4 +228,4 @@ expression: test - Suite(tests/run-make-cargo) [Test] test::IntrinsicTest targets: [x86_64-unknown-linux-gnu] - - Set({intrinsic-test}) + - Set({stdarch-intrinsic-test}) diff --git a/src/bootstrap/src/core/builder/cli_paths/snapshots/x_test_skip_coverage.snap b/src/bootstrap/src/core/builder/cli_paths/snapshots/x_test_skip_coverage.snap index 0a4ccdbd86e3d..f7c447b2d6ae4 100644 --- a/src/bootstrap/src/core/builder/cli_paths/snapshots/x_test_skip_coverage.snap +++ b/src/bootstrap/src/core/builder/cli_paths/snapshots/x_test_skip_coverage.snap @@ -225,4 +225,4 @@ expression: test --skip=coverage - Suite(tests/run-make-cargo) [Test] test::IntrinsicTest targets: [x86_64-unknown-linux-gnu] - - Set({intrinsic-test}) + - Set({stdarch-intrinsic-test}) diff --git a/src/bootstrap/src/core/builder/cli_paths/snapshots/x_test_skip_coverage_map.snap b/src/bootstrap/src/core/builder/cli_paths/snapshots/x_test_skip_coverage_map.snap index 89f26ad80b322..e4e77171cfbe6 100644 --- a/src/bootstrap/src/core/builder/cli_paths/snapshots/x_test_skip_coverage_map.snap +++ b/src/bootstrap/src/core/builder/cli_paths/snapshots/x_test_skip_coverage_map.snap @@ -228,4 +228,4 @@ expression: test --skip=coverage-map - Suite(tests/run-make-cargo) [Test] test::IntrinsicTest targets: [x86_64-unknown-linux-gnu] - - Set({intrinsic-test}) + - Set({stdarch-intrinsic-test}) diff --git a/src/bootstrap/src/core/builder/cli_paths/snapshots/x_test_skip_coverage_run.snap b/src/bootstrap/src/core/builder/cli_paths/snapshots/x_test_skip_coverage_run.snap index b0b5ba9c3e116..30b0495b0499b 100644 --- a/src/bootstrap/src/core/builder/cli_paths/snapshots/x_test_skip_coverage_run.snap +++ b/src/bootstrap/src/core/builder/cli_paths/snapshots/x_test_skip_coverage_run.snap @@ -228,4 +228,4 @@ expression: test --skip=coverage-run - Suite(tests/run-make-cargo) [Test] test::IntrinsicTest targets: [x86_64-unknown-linux-gnu] - - Set({intrinsic-test}) + - Set({stdarch-intrinsic-test}) diff --git a/src/bootstrap/src/core/builder/cli_paths/snapshots/x_test_skip_tests.snap b/src/bootstrap/src/core/builder/cli_paths/snapshots/x_test_skip_tests.snap index 95472f161268e..29c900f1bc258 100644 --- a/src/bootstrap/src/core/builder/cli_paths/snapshots/x_test_skip_tests.snap +++ b/src/bootstrap/src/core/builder/cli_paths/snapshots/x_test_skip_tests.snap @@ -168,4 +168,4 @@ expression: test --skip=tests - Set({compiler-builtins}) [Test] test::IntrinsicTest targets: [x86_64-unknown-linux-gnu] - - Set({intrinsic-test}) + - Set({stdarch-intrinsic-test}) diff --git a/src/bootstrap/src/core/builder/cli_paths/snapshots/x_test_skip_tests_coverage.snap b/src/bootstrap/src/core/builder/cli_paths/snapshots/x_test_skip_tests_coverage.snap index 8c9faca01e50c..598e41393f740 100644 --- a/src/bootstrap/src/core/builder/cli_paths/snapshots/x_test_skip_tests_coverage.snap +++ b/src/bootstrap/src/core/builder/cli_paths/snapshots/x_test_skip_tests_coverage.snap @@ -225,4 +225,4 @@ expression: test --skip=tests/coverage - Suite(tests/run-make-cargo) [Test] test::IntrinsicTest targets: [x86_64-unknown-linux-gnu] - - Set({intrinsic-test}) + - Set({stdarch-intrinsic-test}) diff --git a/src/bootstrap/src/core/builder/cli_paths/snapshots/x_test_skip_tests_etc.snap b/src/bootstrap/src/core/builder/cli_paths/snapshots/x_test_skip_tests_etc.snap index 9c276798d948e..25899cf1d214f 100644 --- a/src/bootstrap/src/core/builder/cli_paths/snapshots/x_test_skip_tests_etc.snap +++ b/src/bootstrap/src/core/builder/cli_paths/snapshots/x_test_skip_tests_etc.snap @@ -148,4 +148,4 @@ expression: test --skip=tests --skip=library --skip=tidyselftest - Set({compiler-builtins}) [Test] test::IntrinsicTest targets: [x86_64-unknown-linux-gnu] - - Set({intrinsic-test}) + - Set({stdarch-intrinsic-test}) diff --git a/tests/ui/lifetimes/where-bound-with-lifetime-53156.current.stderr b/tests/ui/lifetimes/where-bound-with-lifetime-53156.current.stderr new file mode 100644 index 0000000000000..b9d50d4f5354d --- /dev/null +++ b/tests/ui/lifetimes/where-bound-with-lifetime-53156.current.stderr @@ -0,0 +1,26 @@ +error: lifetime may not live long enough + --> $DIR/where-bound-with-lifetime-53156.rs:35:9 + | +LL | impl<'a, B> OwnedWrap + | -- lifetime `'a` defined here +... +LL | pub fn to_arc_aac(&self) -> Arc { + | - let's call the lifetime of this reference `'1` +LL | let OwnedWrap(ref owned) = *self; +LL | owned.borrow().into() + | ^^^^^^^^^^^^^^^^^^^^^ argument requires that `'1` must outlive `'a` + +error[E0621]: explicit lifetime required in the type of `wrap` + --> $DIR/where-bound-with-lifetime-53156.rs:135:5 + | +LL | owned.borrow().into() + | ^^^^^^^^^^^^^^^^^^^^^ lifetime `'a` required + | +help: add explicit lifetime `'a` to the type of `wrap` + | +LL | fn to_arc_aac<'a, B>(wrap: &'a OwnedWrap) -> Arc + | ++ + +error: aborting due to 2 previous errors + +For more information about this error, try `rustc --explain E0621`. diff --git a/tests/ui/lifetimes/where-bound-with-lifetime-53156.next.stderr b/tests/ui/lifetimes/where-bound-with-lifetime-53156.next.stderr new file mode 100644 index 0000000000000..b9d50d4f5354d --- /dev/null +++ b/tests/ui/lifetimes/where-bound-with-lifetime-53156.next.stderr @@ -0,0 +1,26 @@ +error: lifetime may not live long enough + --> $DIR/where-bound-with-lifetime-53156.rs:35:9 + | +LL | impl<'a, B> OwnedWrap + | -- lifetime `'a` defined here +... +LL | pub fn to_arc_aac(&self) -> Arc { + | - let's call the lifetime of this reference `'1` +LL | let OwnedWrap(ref owned) = *self; +LL | owned.borrow().into() + | ^^^^^^^^^^^^^^^^^^^^^ argument requires that `'1` must outlive `'a` + +error[E0621]: explicit lifetime required in the type of `wrap` + --> $DIR/where-bound-with-lifetime-53156.rs:135:5 + | +LL | owned.borrow().into() + | ^^^^^^^^^^^^^^^^^^^^^ lifetime `'a` required + | +help: add explicit lifetime `'a` to the type of `wrap` + | +LL | fn to_arc_aac<'a, B>(wrap: &'a OwnedWrap) -> Arc + | ++ + +error: aborting due to 2 previous errors + +For more information about this error, try `rustc --explain E0621`. diff --git a/tests/ui/lifetimes/where-bound-with-lifetime-53156.rs b/tests/ui/lifetimes/where-bound-with-lifetime-53156.rs new file mode 100644 index 0000000000000..10663bdb5f578 --- /dev/null +++ b/tests/ui/lifetimes/where-bound-with-lifetime-53156.rs @@ -0,0 +1,235 @@ +//! Regression test for . +//! Second where bound was causing incorrect rejection of acceptable lifetime. + +//@ revisions: current next +//@ ignore-compare-mode-next-solver (explicit revisions) +//@[next] compile-flags: -Znext-solver + +use std::borrow::Borrow; +use std::sync::Arc; + +struct OwnedWrap(::Owned); + +impl<'a, B> OwnedWrap +where + B: 'a + ToOwned + ?Sized, + &'a B: Into>, // 1a +{ + // 1a-2a-3a + pub fn to_arc_aaa(&self) -> Arc { + let OwnedWrap(ref owned) = *self; + let b: &B = owned.borrow(); + unimplemented!() + } + + // 1a-2a-3b + pub fn to_arc_aab(&self) -> Arc { + let OwnedWrap(ref owned) = *self; + let _: &B = owned.borrow(); + unimplemented!() + } + + // 1a-2a-3c + pub fn to_arc_aac(&self) -> Arc { + let OwnedWrap(ref owned) = *self; + owned.borrow().into() + //~^ ERROR lifetime may not live long enough + } + + // 1a-2b-3a + pub fn to_arc_aba(&'a self) -> Arc { + let OwnedWrap(ref owned) = *self; + let b: &B = owned.borrow(); + unimplemented!() + } + + // 1a-2b-3b + pub fn to_arc_abb(&'a self) -> Arc { + let OwnedWrap(ref owned) = *self; + let _: &B = owned.borrow(); + unimplemented!() + } + + // 1a-2b-3c + pub fn to_arc_abc(&'a self) -> Arc { + let OwnedWrap(ref owned) = *self; + owned.borrow().into() + } +} + +impl<'a, B> OwnedWrap +where + B: 'a + ToOwned + ?Sized, + for<'b> &'b B: Into> // 1b +{ + // 1b-2a-3a + pub fn to_arc_baa(&self) -> Arc { + let OwnedWrap(ref owned) = *self; + let b: &B = owned.borrow(); + unimplemented!() + } + + // 1b-2a-3b + pub fn to_arc_bab(&self) -> Arc { + let OwnedWrap(ref owned) = *self; + let _: &B = owned.borrow(); + unimplemented!() + } + + // 1b-2a-3c + pub fn to_arc_bac(&self) -> Arc { + let OwnedWrap(ref owned) = *self; + owned.borrow().into() + } + + // 1b-2b-3a + pub fn to_arc_bba(&'a self) -> Arc { + let OwnedWrap(ref owned) = *self; + let b: &B = owned.borrow(); + unimplemented!() + } + + // 1b-2b-3b + pub fn to_arc_bbb(&'a self) -> Arc { + let OwnedWrap(ref owned) = *self; + let _: &B = owned.borrow(); + unimplemented!() + } + + // 1b-2b-3c + pub fn to_arc_bbc(&'a self) -> Arc { + let OwnedWrap(ref owned) = *self; + owned.borrow().into() + } +} + +// 1a-2a-3a +fn to_arc_aaa<'a, B>(wrap: &OwnedWrap) -> Arc +where + B: 'a + ToOwned + ?Sized, + &'a B: Into>, // 1a +{ + let OwnedWrap(ref owned) = *wrap; + let b: &B = owned.borrow(); + unimplemented!() +} + +// 1a-2a-3b +fn to_arc_aab<'a, B>(wrap: &OwnedWrap) -> Arc +where + B: 'a + ToOwned + ?Sized, + &'a B: Into>, // 1a +{ + let OwnedWrap(ref owned) = *wrap; + let _: &B = owned.borrow(); + unimplemented!() +} + +// 1a-2a-3c +fn to_arc_aac<'a, B>(wrap: &OwnedWrap) -> Arc +where + B: 'a + ToOwned + ?Sized, + &'a B: Into>, // 1a +{ + let OwnedWrap(ref owned) = *wrap; + owned.borrow().into() + //~^ ERROR explicit lifetime required in the type of `wrap` +} + +// 1a-2b-3a +fn to_arc_aba<'a, B>(wrap: &'a OwnedWrap) -> Arc +where + B: 'a + ToOwned + ?Sized, + &'a B: Into>, // 1a +{ + let OwnedWrap(ref owned) = *wrap; + let b: &B = owned.borrow(); + unimplemented!() +} + +// 1a-2b-3b +fn to_arc_abb<'a, B>(wrap: &'a OwnedWrap) -> Arc +where + B: 'a + ToOwned + ?Sized, + &'a B: Into>, // 1a +{ + let OwnedWrap(ref owned) = *wrap; + let _: &B = owned.borrow(); + unimplemented!() +} + +// 1a-2b-3c +fn to_arc_abc<'a, B>(wrap: &'a OwnedWrap) -> Arc +where + B: 'a + ToOwned + ?Sized, + &'a B: Into>, // 1a +{ + let OwnedWrap(ref owned) = *wrap; + owned.borrow().into() +} + +// 1b-2a-3a +fn to_arc_baa<'a, B>(wrap: &OwnedWrap) -> Arc +where + B: 'a + ToOwned + ?Sized, + for<'b> &'b B: Into> // 1b +{ + let OwnedWrap(ref owned) = *wrap; + let b: &B = owned.borrow(); + unimplemented!() +} + +// 1b-2a-3b +fn to_arc_bab<'a, B>(wrap: &OwnedWrap) -> Arc +where + B: 'a + ToOwned + ?Sized, + for<'b> &'b B: Into> // 1b +{ + let OwnedWrap(ref owned) = *wrap; + let _: &B = owned.borrow(); + unimplemented!() +} + +// 1b-2a-3c +fn to_arc_bac<'a, B>(wrap: &OwnedWrap) -> Arc +where + B: 'a + ToOwned + ?Sized, + for<'b> &'b B: Into> // 1b +{ + let OwnedWrap(ref owned) = *wrap; + owned.borrow().into() +} + +// 1b-2b-3a +fn to_arc_bba<'a, B>(wrap: &'a OwnedWrap) -> Arc +where + B: 'a + ToOwned + ?Sized, + for<'b> &'b B: Into> // 1b +{ + let OwnedWrap(ref owned) = *wrap; + let b: &B = owned.borrow(); + unimplemented!() +} + +// 1b-2b-3b +fn to_arc_bbb<'a, B>(wrap: &'a OwnedWrap) -> Arc +where + B: 'a + ToOwned + ?Sized, + for<'b> &'b B: Into> // 1b +{ + let OwnedWrap(ref owned) = *wrap; + let _: &B = owned.borrow(); + unimplemented!() +} + +// 1b-2b-3c +fn to_arc_bbc<'a, B>(wrap: &'a OwnedWrap) -> Arc +where + B: 'a + ToOwned + ?Sized, + for<'b> &'b B: Into> // 1b +{ + let OwnedWrap(ref owned) = *wrap; + owned.borrow().into() +} + +fn main() {} diff --git a/tests/ui/lint/const-item-interior-mutations-const-atomics.stderr b/tests/ui/lint/const-item-interior-mutations-const-atomics.stderr index dd6f561f5b799..d82944bbd88c7 100644 --- a/tests/ui/lint/const-item-interior-mutations-const-atomics.stderr +++ b/tests/ui/lint/const-item-interior-mutations-const-atomics.stderr @@ -4,7 +4,7 @@ warning: mutation of an interior mutable `const` item with call to `store` LL | let _a = A.store(true, Ordering::SeqCst); | -^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ | | - | `A` is a interior mutable `const` item of type `Atomic` + | `A` is an interior mutable `const` item of type `Atomic` | = note: each usage of a `const` item creates a new temporary = note: only the temporaries and never the original `const A` will be modified @@ -22,7 +22,7 @@ warning: mutation of an interior mutable `const` item with call to `swap` LL | let _a = A.swap(true, Ordering::SeqCst); | -^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ | | - | `A` is a interior mutable `const` item of type `Atomic` + | `A` is an interior mutable `const` item of type `Atomic` | = note: each usage of a `const` item creates a new temporary = note: only the temporaries and never the original `const A` will be modified @@ -39,7 +39,7 @@ warning: mutation of an interior mutable `const` item with call to `compare_and_ LL | let _a = A.compare_and_swap(false, true, Ordering::SeqCst); | -^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ | | - | `A` is a interior mutable `const` item of type `Atomic` + | `A` is an interior mutable `const` item of type `Atomic` | = note: each usage of a `const` item creates a new temporary = note: only the temporaries and never the original `const A` will be modified @@ -56,7 +56,7 @@ warning: mutation of an interior mutable `const` item with call to `compare_exch LL | let _a = A.compare_exchange(false, true, Ordering::SeqCst, Ordering::Relaxed); | -^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ | | - | `A` is a interior mutable `const` item of type `Atomic` + | `A` is an interior mutable `const` item of type `Atomic` | = note: each usage of a `const` item creates a new temporary = note: only the temporaries and never the original `const A` will be modified @@ -73,7 +73,7 @@ warning: mutation of an interior mutable `const` item with call to `compare_exch LL | let _a = A.compare_exchange_weak(false, true, Ordering::SeqCst, Ordering::Relaxed); | -^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ | | - | `A` is a interior mutable `const` item of type `Atomic` + | `A` is an interior mutable `const` item of type `Atomic` | = note: each usage of a `const` item creates a new temporary = note: only the temporaries and never the original `const A` will be modified @@ -90,7 +90,7 @@ warning: mutation of an interior mutable `const` item with call to `fetch_and` LL | let _a = A.fetch_and(true, Ordering::SeqCst); | -^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ | | - | `A` is a interior mutable `const` item of type `Atomic` + | `A` is an interior mutable `const` item of type `Atomic` | = note: each usage of a `const` item creates a new temporary = note: only the temporaries and never the original `const A` will be modified @@ -107,7 +107,7 @@ warning: mutation of an interior mutable `const` item with call to `fetch_nand` LL | let _a = A.fetch_nand(true, Ordering::SeqCst); | -^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ | | - | `A` is a interior mutable `const` item of type `Atomic` + | `A` is an interior mutable `const` item of type `Atomic` | = note: each usage of a `const` item creates a new temporary = note: only the temporaries and never the original `const A` will be modified @@ -124,7 +124,7 @@ warning: mutation of an interior mutable `const` item with call to `fetch_or` LL | let _a = A.fetch_or(true, Ordering::SeqCst); | -^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ | | - | `A` is a interior mutable `const` item of type `Atomic` + | `A` is an interior mutable `const` item of type `Atomic` | = note: each usage of a `const` item creates a new temporary = note: only the temporaries and never the original `const A` will be modified @@ -141,7 +141,7 @@ warning: mutation of an interior mutable `const` item with call to `fetch_xor` LL | let _a = A.fetch_xor(true, Ordering::SeqCst); | -^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ | | - | `A` is a interior mutable `const` item of type `Atomic` + | `A` is an interior mutable `const` item of type `Atomic` | = note: each usage of a `const` item creates a new temporary = note: only the temporaries and never the original `const A` will be modified @@ -158,7 +158,7 @@ warning: mutation of an interior mutable `const` item with call to `fetch_not` LL | let _a = A.fetch_not(Ordering::SeqCst); | -^^^^^^^^^^^^^^^^^^^^^^^^^^^^ | | - | `A` is a interior mutable `const` item of type `Atomic` + | `A` is an interior mutable `const` item of type `Atomic` | = note: each usage of a `const` item creates a new temporary = note: only the temporaries and never the original `const A` will be modified @@ -175,7 +175,7 @@ warning: mutation of an interior mutable `const` item with call to `fetch_update LL | let _a = A.fetch_update(Ordering::SeqCst, Ordering::Relaxed, |_| Some(true)); | -^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ | | - | `A` is a interior mutable `const` item of type `Atomic` + | `A` is an interior mutable `const` item of type `Atomic` | = note: each usage of a `const` item creates a new temporary = note: only the temporaries and never the original `const A` will be modified @@ -192,7 +192,7 @@ warning: mutation of an interior mutable `const` item with call to `try_update` LL | let _a = A.try_update(Ordering::SeqCst, Ordering::Relaxed, |_| Some(false)); | -^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ | | - | `A` is a interior mutable `const` item of type `Atomic` + | `A` is an interior mutable `const` item of type `Atomic` | = note: each usage of a `const` item creates a new temporary = note: only the temporaries and never the original `const A` will be modified @@ -209,7 +209,7 @@ warning: mutation of an interior mutable `const` item with call to `update` LL | let _a = A.update(Ordering::SeqCst, Ordering::Relaxed, |_| true); | -^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ | | - | `A` is a interior mutable `const` item of type `Atomic` + | `A` is an interior mutable `const` item of type `Atomic` | = note: each usage of a `const` item creates a new temporary = note: only the temporaries and never the original `const A` will be modified @@ -226,7 +226,7 @@ warning: mutation of an interior mutable `const` item with call to `store` LL | let _a = A.store(std::ptr::null_mut(), Ordering::SeqCst); | -^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ | | - | `A` is a interior mutable `const` item of type `Atomic<*mut i32>` + | `A` is an interior mutable `const` item of type `Atomic<*mut i32>` | = note: each usage of a `const` item creates a new temporary = note: only the temporaries and never the original `const A` will be modified @@ -243,7 +243,7 @@ warning: mutation of an interior mutable `const` item with call to `swap` LL | let _a = A.swap(std::ptr::null_mut(), Ordering::SeqCst); | -^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ | | - | `A` is a interior mutable `const` item of type `Atomic<*mut i32>` + | `A` is an interior mutable `const` item of type `Atomic<*mut i32>` | = note: each usage of a `const` item creates a new temporary = note: only the temporaries and never the original `const A` will be modified @@ -260,7 +260,7 @@ warning: mutation of an interior mutable `const` item with call to `compare_and_ LL | let _a = A.compare_and_swap(std::ptr::null_mut(), std::ptr::null_mut(), Ordering::SeqCst); | -^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ | | - | `A` is a interior mutable `const` item of type `Atomic<*mut i32>` + | `A` is an interior mutable `const` item of type `Atomic<*mut i32>` | = note: each usage of a `const` item creates a new temporary = note: only the temporaries and never the original `const A` will be modified @@ -275,7 +275,7 @@ warning: mutation of an interior mutable `const` item with call to `compare_exch --> $DIR/const-item-interior-mutations-const-atomics.rs:64:14 | LL | let _a = A.compare_exchange( - | ^ `A` is a interior mutable `const` item of type `Atomic<*mut i32>` + | ^ `A` is an interior mutable `const` item of type `Atomic<*mut i32>` | ______________| | | LL | | @@ -299,7 +299,7 @@ warning: mutation of an interior mutable `const` item with call to `compare_exch --> $DIR/const-item-interior-mutations-const-atomics.rs:72:14 | LL | let _a = A.compare_exchange_weak( - | ^ `A` is a interior mutable `const` item of type `Atomic<*mut i32>` + | ^ `A` is an interior mutable `const` item of type `Atomic<*mut i32>` | ______________| | | LL | | @@ -325,7 +325,7 @@ warning: mutation of an interior mutable `const` item with call to `fetch_update LL | let _a = A.fetch_update(Ordering::SeqCst, Ordering::Relaxed, |_| Some(std::ptr::null_mut())); | -^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ | | - | `A` is a interior mutable `const` item of type `Atomic<*mut i32>` + | `A` is an interior mutable `const` item of type `Atomic<*mut i32>` | = note: each usage of a `const` item creates a new temporary = note: only the temporaries and never the original `const A` will be modified @@ -342,7 +342,7 @@ warning: mutation of an interior mutable `const` item with call to `try_update` LL | let _a = A.try_update(Ordering::SeqCst, Ordering::Relaxed, |_| Some(std::ptr::null_mut())); | -^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ | | - | `A` is a interior mutable `const` item of type `Atomic<*mut i32>` + | `A` is an interior mutable `const` item of type `Atomic<*mut i32>` | = note: each usage of a `const` item creates a new temporary = note: only the temporaries and never the original `const A` will be modified @@ -359,7 +359,7 @@ warning: mutation of an interior mutable `const` item with call to `update` LL | let _a = A.update(Ordering::SeqCst, Ordering::Relaxed, |_| std::ptr::null_mut()); | -^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ | | - | `A` is a interior mutable `const` item of type `Atomic<*mut i32>` + | `A` is an interior mutable `const` item of type `Atomic<*mut i32>` | = note: each usage of a `const` item creates a new temporary = note: only the temporaries and never the original `const A` will be modified @@ -376,7 +376,7 @@ warning: mutation of an interior mutable `const` item with call to `fetch_ptr_ad LL | let _a = A.fetch_ptr_add(1, Ordering::SeqCst); | -^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ | | - | `A` is a interior mutable `const` item of type `Atomic<*mut i32>` + | `A` is an interior mutable `const` item of type `Atomic<*mut i32>` | = note: each usage of a `const` item creates a new temporary = note: only the temporaries and never the original `const A` will be modified @@ -393,7 +393,7 @@ warning: mutation of an interior mutable `const` item with call to `fetch_ptr_su LL | let _a = A.fetch_ptr_sub(1, Ordering::SeqCst); | -^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ | | - | `A` is a interior mutable `const` item of type `Atomic<*mut i32>` + | `A` is an interior mutable `const` item of type `Atomic<*mut i32>` | = note: each usage of a `const` item creates a new temporary = note: only the temporaries and never the original `const A` will be modified @@ -410,7 +410,7 @@ warning: mutation of an interior mutable `const` item with call to `fetch_byte_a LL | let _a = A.fetch_byte_add(1, Ordering::SeqCst); | -^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ | | - | `A` is a interior mutable `const` item of type `Atomic<*mut i32>` + | `A` is an interior mutable `const` item of type `Atomic<*mut i32>` | = note: each usage of a `const` item creates a new temporary = note: only the temporaries and never the original `const A` will be modified @@ -427,7 +427,7 @@ warning: mutation of an interior mutable `const` item with call to `fetch_byte_s LL | let _a = A.fetch_byte_sub(1, Ordering::SeqCst); | -^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ | | - | `A` is a interior mutable `const` item of type `Atomic<*mut i32>` + | `A` is an interior mutable `const` item of type `Atomic<*mut i32>` | = note: each usage of a `const` item creates a new temporary = note: only the temporaries and never the original `const A` will be modified @@ -444,7 +444,7 @@ warning: mutation of an interior mutable `const` item with call to `fetch_and` LL | let _a = A.fetch_and(1, Ordering::SeqCst); | -^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ | | - | `A` is a interior mutable `const` item of type `Atomic<*mut i32>` + | `A` is an interior mutable `const` item of type `Atomic<*mut i32>` | = note: each usage of a `const` item creates a new temporary = note: only the temporaries and never the original `const A` will be modified @@ -461,7 +461,7 @@ warning: mutation of an interior mutable `const` item with call to `fetch_or` LL | let _a = A.fetch_or(1, Ordering::SeqCst); | -^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ | | - | `A` is a interior mutable `const` item of type `Atomic<*mut i32>` + | `A` is an interior mutable `const` item of type `Atomic<*mut i32>` | = note: each usage of a `const` item creates a new temporary = note: only the temporaries and never the original `const A` will be modified @@ -478,7 +478,7 @@ warning: mutation of an interior mutable `const` item with call to `fetch_xor` LL | let _a = A.fetch_xor(1, Ordering::SeqCst); | -^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ | | - | `A` is a interior mutable `const` item of type `Atomic<*mut i32>` + | `A` is an interior mutable `const` item of type `Atomic<*mut i32>` | = note: each usage of a `const` item creates a new temporary = note: only the temporaries and never the original `const A` will be modified @@ -495,7 +495,7 @@ warning: mutation of an interior mutable `const` item with call to `store` LL | let _a = A.store(1, Ordering::SeqCst); | -^^^^^^^^^^^^^^^^^^^^^^^^^^^ | | - | `A` is a interior mutable `const` item of type `Atomic` + | `A` is an interior mutable `const` item of type `Atomic` | = note: each usage of a `const` item creates a new temporary = note: only the temporaries and never the original `const A` will be modified @@ -512,7 +512,7 @@ warning: mutation of an interior mutable `const` item with call to `swap` LL | let _a = A.swap(2, Ordering::SeqCst); | -^^^^^^^^^^^^^^^^^^^^^^^^^^ | | - | `A` is a interior mutable `const` item of type `Atomic` + | `A` is an interior mutable `const` item of type `Atomic` | = note: each usage of a `const` item creates a new temporary = note: only the temporaries and never the original `const A` will be modified @@ -529,7 +529,7 @@ warning: mutation of an interior mutable `const` item with call to `compare_and_ LL | let _a = A.compare_and_swap(2, 3, Ordering::SeqCst); | -^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ | | - | `A` is a interior mutable `const` item of type `Atomic` + | `A` is an interior mutable `const` item of type `Atomic` | = note: each usage of a `const` item creates a new temporary = note: only the temporaries and never the original `const A` will be modified @@ -546,7 +546,7 @@ warning: mutation of an interior mutable `const` item with call to `compare_exch LL | let _a = A.compare_exchange(3, 4, Ordering::SeqCst, Ordering::Relaxed); | -^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ | | - | `A` is a interior mutable `const` item of type `Atomic` + | `A` is an interior mutable `const` item of type `Atomic` | = note: each usage of a `const` item creates a new temporary = note: only the temporaries and never the original `const A` will be modified @@ -563,7 +563,7 @@ warning: mutation of an interior mutable `const` item with call to `compare_exch LL | let _a = A.compare_exchange_weak(4, 5, Ordering::SeqCst, Ordering::Relaxed); | -^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ | | - | `A` is a interior mutable `const` item of type `Atomic` + | `A` is an interior mutable `const` item of type `Atomic` | = note: each usage of a `const` item creates a new temporary = note: only the temporaries and never the original `const A` will be modified @@ -580,7 +580,7 @@ warning: mutation of an interior mutable `const` item with call to `fetch_add` LL | let _a = A.fetch_add(1, Ordering::SeqCst); | -^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ | | - | `A` is a interior mutable `const` item of type `Atomic` + | `A` is an interior mutable `const` item of type `Atomic` | = note: each usage of a `const` item creates a new temporary = note: only the temporaries and never the original `const A` will be modified @@ -597,7 +597,7 @@ warning: mutation of an interior mutable `const` item with call to `fetch_sub` LL | let _a = A.fetch_sub(1, Ordering::SeqCst); | -^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ | | - | `A` is a interior mutable `const` item of type `Atomic` + | `A` is an interior mutable `const` item of type `Atomic` | = note: each usage of a `const` item creates a new temporary = note: only the temporaries and never the original `const A` will be modified @@ -614,7 +614,7 @@ warning: mutation of an interior mutable `const` item with call to `fetch_add` LL | let _a = A.fetch_add(2, Ordering::SeqCst); | -^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ | | - | `A` is a interior mutable `const` item of type `Atomic` + | `A` is an interior mutable `const` item of type `Atomic` | = note: each usage of a `const` item creates a new temporary = note: only the temporaries and never the original `const A` will be modified @@ -631,7 +631,7 @@ warning: mutation of an interior mutable `const` item with call to `fetch_nand` LL | let _a = A.fetch_nand(1, Ordering::SeqCst); | -^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ | | - | `A` is a interior mutable `const` item of type `Atomic` + | `A` is an interior mutable `const` item of type `Atomic` | = note: each usage of a `const` item creates a new temporary = note: only the temporaries and never the original `const A` will be modified @@ -648,7 +648,7 @@ warning: mutation of an interior mutable `const` item with call to `fetch_or` LL | let _a = A.fetch_or(1, Ordering::SeqCst); | -^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ | | - | `A` is a interior mutable `const` item of type `Atomic` + | `A` is an interior mutable `const` item of type `Atomic` | = note: each usage of a `const` item creates a new temporary = note: only the temporaries and never the original `const A` will be modified @@ -665,7 +665,7 @@ warning: mutation of an interior mutable `const` item with call to `fetch_xor` LL | let _a = A.fetch_xor(1, Ordering::SeqCst); | -^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ | | - | `A` is a interior mutable `const` item of type `Atomic` + | `A` is an interior mutable `const` item of type `Atomic` | = note: each usage of a `const` item creates a new temporary = note: only the temporaries and never the original `const A` will be modified @@ -682,7 +682,7 @@ warning: mutation of an interior mutable `const` item with call to `fetch_update LL | let _a = A.fetch_update(Ordering::SeqCst, Ordering::Relaxed, |_| Some(10)); | -^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ | | - | `A` is a interior mutable `const` item of type `Atomic` + | `A` is an interior mutable `const` item of type `Atomic` | = note: each usage of a `const` item creates a new temporary = note: only the temporaries and never the original `const A` will be modified @@ -699,7 +699,7 @@ warning: mutation of an interior mutable `const` item with call to `try_update` LL | let _a = A.try_update(Ordering::SeqCst, Ordering::Relaxed, |_| Some(11)); | -^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ | | - | `A` is a interior mutable `const` item of type `Atomic` + | `A` is an interior mutable `const` item of type `Atomic` | = note: each usage of a `const` item creates a new temporary = note: only the temporaries and never the original `const A` will be modified @@ -716,7 +716,7 @@ warning: mutation of an interior mutable `const` item with call to `update` LL | let _a = A.update(Ordering::SeqCst, Ordering::Relaxed, |_| 12); | -^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ | | - | `A` is a interior mutable `const` item of type `Atomic` + | `A` is an interior mutable `const` item of type `Atomic` | = note: each usage of a `const` item creates a new temporary = note: only the temporaries and never the original `const A` will be modified @@ -733,7 +733,7 @@ warning: mutation of an interior mutable `const` item with call to `fetch_max` LL | let _a = A.fetch_max(20, Ordering::SeqCst); | -^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ | | - | `A` is a interior mutable `const` item of type `Atomic` + | `A` is an interior mutable `const` item of type `Atomic` | = note: each usage of a `const` item creates a new temporary = note: only the temporaries and never the original `const A` will be modified @@ -750,7 +750,7 @@ warning: mutation of an interior mutable `const` item with call to `fetch_min` LL | let _a = A.fetch_min(5, Ordering::SeqCst); | -^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ | | - | `A` is a interior mutable `const` item of type `Atomic` + | `A` is an interior mutable `const` item of type `Atomic` | = note: each usage of a `const` item creates a new temporary = note: only the temporaries and never the original `const A` will be modified diff --git a/tests/ui/lint/const-item-interior-mutations-const-cell.stderr b/tests/ui/lint/const-item-interior-mutations-const-cell.stderr index ec3a5f4e38eed..c9b95a64200bc 100644 --- a/tests/ui/lint/const-item-interior-mutations-const-cell.stderr +++ b/tests/ui/lint/const-item-interior-mutations-const-cell.stderr @@ -4,7 +4,7 @@ warning: mutation of an interior mutable `const` item with call to `force` LL | let _ = LazyCell::force(&A); | ^^^^^^^^^^^^^^^^^-^ | | - | `A` is a interior mutable `const` item of type `LazyCell` + | `A` is an interior mutable `const` item of type `LazyCell` | = note: each usage of a `const` item creates a new temporary = note: only the temporaries and never the original `const A` will be modified @@ -22,7 +22,7 @@ warning: mutation of an interior mutable `const` item with call to `set` LL | let _ = A.set(10); | -^^^^^^^^ | | - | `A` is a interior mutable `const` item of type `OnceCell` + | `A` is an interior mutable `const` item of type `OnceCell` | = note: each usage of a `const` item creates a new temporary = note: only the temporaries and never the original `const A` will be modified @@ -39,7 +39,7 @@ warning: mutation of an interior mutable `const` item with call to `try_insert` LL | let _ = A.try_insert(20); | -^^^^^^^^^^^^^^^ | | - | `A` is a interior mutable `const` item of type `OnceCell` + | `A` is an interior mutable `const` item of type `OnceCell` | = note: each usage of a `const` item creates a new temporary = note: only the temporaries and never the original `const A` will be modified @@ -56,7 +56,7 @@ warning: mutation of an interior mutable `const` item with call to `get_or_init` LL | let _ = A.get_or_init(|| 30); | -^^^^^^^^^^^^^^^^^^^ | | - | `A` is a interior mutable `const` item of type `OnceCell` + | `A` is an interior mutable `const` item of type `OnceCell` | = note: each usage of a `const` item creates a new temporary = note: only the temporaries and never the original `const A` will be modified @@ -73,7 +73,7 @@ warning: mutation of an interior mutable `const` item with call to `get_or_try_i LL | let _ = A.get_or_try_init(|| Ok::<_, ()>(40)); | -^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ | | - | `A` is a interior mutable `const` item of type `OnceCell` + | `A` is an interior mutable `const` item of type `OnceCell` | = note: each usage of a `const` item creates a new temporary = note: only the temporaries and never the original `const A` will be modified @@ -90,7 +90,7 @@ warning: mutation of an interior mutable `const` item with call to `set` LL | let _ = A.set(1); | -^^^^^^^ | | - | `A` is a interior mutable `const` item of type `Cell` + | `A` is an interior mutable `const` item of type `Cell` | = note: each usage of a `const` item creates a new temporary = note: only the temporaries and never the original `const A` will be modified @@ -107,7 +107,7 @@ warning: mutation of an interior mutable `const` item with call to `swap` LL | let _ = A.swap(&A); | -^^^^^^^^^ | | - | `A` is a interior mutable `const` item of type `Cell` + | `A` is an interior mutable `const` item of type `Cell` | = note: each usage of a `const` item creates a new temporary = note: only the temporaries and never the original `const A` will be modified @@ -124,7 +124,7 @@ warning: mutation of an interior mutable `const` item with call to `replace` LL | let _ = A.replace(2); | -^^^^^^^^^^^ | | - | `A` is a interior mutable `const` item of type `Cell` + | `A` is an interior mutable `const` item of type `Cell` | = note: each usage of a `const` item creates a new temporary = note: only the temporaries and never the original `const A` will be modified @@ -141,7 +141,7 @@ warning: mutation of an interior mutable `const` item with call to `get` LL | let _ = A.get(); | -^^^^^^ | | - | `A` is a interior mutable `const` item of type `Cell` + | `A` is an interior mutable `const` item of type `Cell` | = note: each usage of a `const` item creates a new temporary = note: only the temporaries and never the original `const A` will be modified @@ -158,7 +158,7 @@ warning: mutation of an interior mutable `const` item with call to `update` LL | let _ = A.update(|x| x + 1); | -^^^^^^^^^^^^^^^^^^ | | - | `A` is a interior mutable `const` item of type `Cell` + | `A` is an interior mutable `const` item of type `Cell` | = note: each usage of a `const` item creates a new temporary = note: only the temporaries and never the original `const A` will be modified @@ -175,7 +175,7 @@ warning: mutation of an interior mutable `const` item with call to `replace` LL | let _ = A.replace(1); | -^^^^^^^^^^^ | | - | `A` is a interior mutable `const` item of type `RefCell` + | `A` is an interior mutable `const` item of type `RefCell` | = note: each usage of a `const` item creates a new temporary = note: only the temporaries and never the original `const A` will be modified @@ -192,7 +192,7 @@ warning: mutation of an interior mutable `const` item with call to `replace_with LL | let _ = A.replace_with(|x| *x + 2); | -^^^^^^^^^^^^^^^^^^^^^^^^^ | | - | `A` is a interior mutable `const` item of type `RefCell` + | `A` is an interior mutable `const` item of type `RefCell` | = note: each usage of a `const` item creates a new temporary = note: only the temporaries and never the original `const A` will be modified @@ -209,7 +209,7 @@ warning: mutation of an interior mutable `const` item with call to `swap` LL | let _ = A.swap(&A); | -^^^^^^^^^ | | - | `A` is a interior mutable `const` item of type `RefCell` + | `A` is an interior mutable `const` item of type `RefCell` | = note: each usage of a `const` item creates a new temporary = note: only the temporaries and never the original `const A` will be modified @@ -226,7 +226,7 @@ warning: mutation of an interior mutable `const` item with call to `borrow` LL | let _ = A.borrow(); | -^^^^^^^^^ | | - | `A` is a interior mutable `const` item of type `RefCell` + | `A` is an interior mutable `const` item of type `RefCell` | = note: each usage of a `const` item creates a new temporary = note: only the temporaries and never the original `const A` will be modified @@ -243,7 +243,7 @@ warning: mutation of an interior mutable `const` item with call to `try_borrow` LL | let _ = A.try_borrow(); | -^^^^^^^^^^^^^ | | - | `A` is a interior mutable `const` item of type `RefCell` + | `A` is an interior mutable `const` item of type `RefCell` | = note: each usage of a `const` item creates a new temporary = note: only the temporaries and never the original `const A` will be modified @@ -260,7 +260,7 @@ warning: mutation of an interior mutable `const` item with call to `borrow_mut` LL | let _ = A.borrow_mut(); | -^^^^^^^^^^^^^ | | - | `A` is a interior mutable `const` item of type `RefCell` + | `A` is an interior mutable `const` item of type `RefCell` | = note: each usage of a `const` item creates a new temporary = note: only the temporaries and never the original `const A` will be modified @@ -277,7 +277,7 @@ warning: mutation of an interior mutable `const` item with call to `try_borrow_m LL | let _ = A.try_borrow_mut(); | -^^^^^^^^^^^^^^^^^ | | - | `A` is a interior mutable `const` item of type `RefCell` + | `A` is an interior mutable `const` item of type `RefCell` | = note: each usage of a `const` item creates a new temporary = note: only the temporaries and never the original `const A` will be modified @@ -294,7 +294,7 @@ warning: mutation of an interior mutable `const` item with call to `replace` LL | let _ = unsafe { A.replace(1) }; | -^^^^^^^^^^^ | | - | `A` is a interior mutable `const` item of type `UnsafeCell` + | `A` is an interior mutable `const` item of type `UnsafeCell` | = note: each usage of a `const` item creates a new temporary = note: only the temporaries and never the original `const A` will be modified @@ -311,7 +311,7 @@ warning: mutation of an interior mutable `const` item with call to `get` LL | let _ = A.get(); | -^^^^^^ | | - | `A` is a interior mutable `const` item of type `UnsafeCell` + | `A` is an interior mutable `const` item of type `UnsafeCell` | = note: each usage of a `const` item creates a new temporary = note: only the temporaries and never the original `const A` will be modified @@ -328,7 +328,7 @@ warning: mutation of an interior mutable `const` item with call to `as_ref_unche LL | let _ = A.as_ref_unchecked(); | -^^^^^^^^^^^^^^^^^^^ | | - | `A` is a interior mutable `const` item of type `UnsafeCell` + | `A` is an interior mutable `const` item of type `UnsafeCell` | = note: each usage of a `const` item creates a new temporary = note: only the temporaries and never the original `const A` will be modified @@ -345,7 +345,7 @@ warning: mutation of an interior mutable `const` item with call to `as_mut_unche LL | let _ = A.as_mut_unchecked(); | -^^^^^^^^^^^^^^^^^^^ | | - | `A` is a interior mutable `const` item of type `UnsafeCell` + | `A` is an interior mutable `const` item of type `UnsafeCell` | = note: each usage of a `const` item creates a new temporary = note: only the temporaries and never the original `const A` will be modified @@ -362,7 +362,7 @@ warning: mutation of an interior mutable `const` item with call to `get` LL | let _ = A.get(); | -^^^^^^ | | - | `A` is a interior mutable `const` item of type `SyncUnsafeCell` + | `A` is an interior mutable `const` item of type `SyncUnsafeCell` | = note: each usage of a `const` item creates a new temporary = note: only the temporaries and never the original `const A` will be modified diff --git a/tests/ui/lint/const-item-interior-mutations-const.stderr b/tests/ui/lint/const-item-interior-mutations-const.stderr index 2fe8f190dbed8..f615f6ecabf93 100644 --- a/tests/ui/lint/const-item-interior-mutations-const.stderr +++ b/tests/ui/lint/const-item-interior-mutations-const.stderr @@ -4,7 +4,7 @@ warning: mutation of an interior mutable `const` item with call to `set` LL | let _a = A.set(1); | -^^^^^^^ | | - | `A` is a interior mutable `const` item of type `std::sync::Mutex` + | `A` is an interior mutable `const` item of type `std::sync::Mutex` | = note: each usage of a `const` item creates a new temporary = note: only the temporaries and never the original `const A` will be modified @@ -22,7 +22,7 @@ warning: mutation of an interior mutable `const` item with call to `replace` LL | let _a = A.replace(2); | -^^^^^^^^^^^ | | - | `A` is a interior mutable `const` item of type `std::sync::Mutex` + | `A` is an interior mutable `const` item of type `std::sync::Mutex` | = note: each usage of a `const` item creates a new temporary = note: only the temporaries and never the original `const A` will be modified @@ -39,7 +39,7 @@ warning: mutation of an interior mutable `const` item with call to `lock` LL | drop(A.lock()); | -^^^^^^^ | | - | `A` is a interior mutable `const` item of type `std::sync::Mutex` + | `A` is an interior mutable `const` item of type `std::sync::Mutex` | = note: each usage of a `const` item creates a new temporary = note: only the temporaries and never the original `const A` will be modified @@ -56,7 +56,7 @@ warning: mutation of an interior mutable `const` item with call to `try_lock` LL | drop(A.try_lock()); | -^^^^^^^^^^^ | | - | `A` is a interior mutable `const` item of type `std::sync::Mutex` + | `A` is an interior mutable `const` item of type `std::sync::Mutex` | = note: each usage of a `const` item creates a new temporary = note: only the temporaries and never the original `const A` will be modified @@ -73,7 +73,7 @@ warning: mutation of an interior mutable `const` item with call to `clear_poison LL | let _a = A.clear_poison(); | -^^^^^^^^^^^^^^^ | | - | `A` is a interior mutable `const` item of type `std::sync::Mutex` + | `A` is an interior mutable `const` item of type `std::sync::Mutex` | = note: each usage of a `const` item creates a new temporary = note: only the temporaries and never the original `const A` will be modified @@ -90,7 +90,7 @@ warning: mutation of an interior mutable `const` item with call to `call_once` LL | let _a = A.call_once(|| {}); | -^^^^^^^^^^^^^^^^^ | | - | `A` is a interior mutable `const` item of type `std::sync::Once` + | `A` is an interior mutable `const` item of type `std::sync::Once` | = note: each usage of a `const` item creates a new temporary = note: only the temporaries and never the original `const A` will be modified @@ -107,7 +107,7 @@ warning: mutation of an interior mutable `const` item with call to `call_once_fo LL | let _a = A.call_once_force(|_| {}); | -^^^^^^^^^^^^^^^^^^^^^^^^ | | - | `A` is a interior mutable `const` item of type `std::sync::Once` + | `A` is an interior mutable `const` item of type `std::sync::Once` | = note: each usage of a `const` item creates a new temporary = note: only the temporaries and never the original `const A` will be modified @@ -124,7 +124,7 @@ warning: mutation of an interior mutable `const` item with call to `wait` LL | let _a = A.wait(); | -^^^^^^^ | | - | `A` is a interior mutable `const` item of type `std::sync::Once` + | `A` is an interior mutable `const` item of type `std::sync::Once` | = note: each usage of a `const` item creates a new temporary = note: only the temporaries and never the original `const A` will be modified @@ -141,7 +141,7 @@ warning: mutation of an interior mutable `const` item with call to `wait_force` LL | let _a = A.wait_force(); | -^^^^^^^^^^^^^ | | - | `A` is a interior mutable `const` item of type `std::sync::Once` + | `A` is an interior mutable `const` item of type `std::sync::Once` | = note: each usage of a `const` item creates a new temporary = note: only the temporaries and never the original `const A` will be modified @@ -158,7 +158,7 @@ warning: mutation of an interior mutable `const` item with call to `set` LL | let _a = A.set(1); | -^^^^^^^ | | - | `A` is a interior mutable `const` item of type `std::sync::RwLock` + | `A` is an interior mutable `const` item of type `std::sync::RwLock` | = note: each usage of a `const` item creates a new temporary = note: only the temporaries and never the original `const A` will be modified @@ -175,7 +175,7 @@ warning: mutation of an interior mutable `const` item with call to `replace` LL | let _a = A.replace(2); | -^^^^^^^^^^^ | | - | `A` is a interior mutable `const` item of type `std::sync::RwLock` + | `A` is an interior mutable `const` item of type `std::sync::RwLock` | = note: each usage of a `const` item creates a new temporary = note: only the temporaries and never the original `const A` will be modified @@ -192,7 +192,7 @@ warning: mutation of an interior mutable `const` item with call to `read` LL | drop(A.read()); | -^^^^^^^ | | - | `A` is a interior mutable `const` item of type `std::sync::RwLock` + | `A` is an interior mutable `const` item of type `std::sync::RwLock` | = note: each usage of a `const` item creates a new temporary = note: only the temporaries and never the original `const A` will be modified @@ -209,7 +209,7 @@ warning: mutation of an interior mutable `const` item with call to `try_read` LL | drop(A.try_read()); | -^^^^^^^^^^^ | | - | `A` is a interior mutable `const` item of type `std::sync::RwLock` + | `A` is an interior mutable `const` item of type `std::sync::RwLock` | = note: each usage of a `const` item creates a new temporary = note: only the temporaries and never the original `const A` will be modified @@ -226,7 +226,7 @@ warning: mutation of an interior mutable `const` item with call to `write` LL | drop(A.write()); | -^^^^^^^^ | | - | `A` is a interior mutable `const` item of type `std::sync::RwLock` + | `A` is an interior mutable `const` item of type `std::sync::RwLock` | = note: each usage of a `const` item creates a new temporary = note: only the temporaries and never the original `const A` will be modified @@ -243,7 +243,7 @@ warning: mutation of an interior mutable `const` item with call to `try_write` LL | drop(A.try_write()); | -^^^^^^^^^^^^ | | - | `A` is a interior mutable `const` item of type `std::sync::RwLock` + | `A` is an interior mutable `const` item of type `std::sync::RwLock` | = note: each usage of a `const` item creates a new temporary = note: only the temporaries and never the original `const A` will be modified @@ -260,7 +260,7 @@ warning: mutation of an interior mutable `const` item with call to `force` LL | let _a = LazyLock::force(&A); | ^^^^^^^^^^^^^^^^^-^ | | - | `A` is a interior mutable `const` item of type `LazyLock` + | `A` is an interior mutable `const` item of type `LazyLock` | = note: each usage of a `const` item creates a new temporary = note: only the temporaries and never the original `const A` will be modified @@ -277,7 +277,7 @@ warning: mutation of an interior mutable `const` item with call to `get` LL | let _a = LazyLock::get(&A); | ^^^^^^^^^^^^^^^-^ | | - | `A` is a interior mutable `const` item of type `LazyLock` + | `A` is an interior mutable `const` item of type `LazyLock` | = note: each usage of a `const` item creates a new temporary = note: only the temporaries and never the original `const A` will be modified @@ -294,7 +294,7 @@ warning: mutation of an interior mutable `const` item with call to `get` LL | let _a = A.get(); | -^^^^^^ | | - | `A` is a interior mutable `const` item of type `OnceLock` + | `A` is an interior mutable `const` item of type `OnceLock` | = note: each usage of a `const` item creates a new temporary = note: only the temporaries and never the original `const A` will be modified @@ -311,7 +311,7 @@ warning: mutation of an interior mutable `const` item with call to `wait` LL | let _a = A.wait(); | -^^^^^^^ | | - | `A` is a interior mutable `const` item of type `OnceLock` + | `A` is an interior mutable `const` item of type `OnceLock` | = note: each usage of a `const` item creates a new temporary = note: only the temporaries and never the original `const A` will be modified @@ -328,7 +328,7 @@ warning: mutation of an interior mutable `const` item with call to `set` LL | let _a = A.set(10); | -^^^^^^^^ | | - | `A` is a interior mutable `const` item of type `OnceLock` + | `A` is an interior mutable `const` item of type `OnceLock` | = note: each usage of a `const` item creates a new temporary = note: only the temporaries and never the original `const A` will be modified @@ -345,7 +345,7 @@ warning: mutation of an interior mutable `const` item with call to `try_insert` LL | let _a = A.try_insert(20); | -^^^^^^^^^^^^^^^ | | - | `A` is a interior mutable `const` item of type `OnceLock` + | `A` is an interior mutable `const` item of type `OnceLock` | = note: each usage of a `const` item creates a new temporary = note: only the temporaries and never the original `const A` will be modified @@ -362,7 +362,7 @@ warning: mutation of an interior mutable `const` item with call to `get_or_init` LL | let _a = A.get_or_init(|| 30); | -^^^^^^^^^^^^^^^^^^^ | | - | `A` is a interior mutable `const` item of type `OnceLock` + | `A` is an interior mutable `const` item of type `OnceLock` | = note: each usage of a `const` item creates a new temporary = note: only the temporaries and never the original `const A` will be modified @@ -379,7 +379,7 @@ warning: mutation of an interior mutable `const` item with call to `get_or_try_i LL | let _a = A.get_or_try_init(|| Ok::<_, ()>(40)); | -^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ | | - | `A` is a interior mutable `const` item of type `OnceLock` + | `A` is an interior mutable `const` item of type `OnceLock` | = note: each usage of a `const` item creates a new temporary = note: only the temporaries and never the original `const A` will be modified @@ -396,7 +396,7 @@ warning: mutation of an interior mutable `const` item with call to `wait` LL | let _a = A.wait(guard); | -^^^^^^^^^^^^ | | - | `A` is a interior mutable `const` item of type `std::sync::Condvar` + | `A` is an interior mutable `const` item of type `std::sync::Condvar` | = note: each usage of a `const` item creates a new temporary = note: only the temporaries and never the original `const A` will be modified @@ -413,7 +413,7 @@ warning: mutation of an interior mutable `const` item with call to `wait_while` LL | let _a = A.wait_while(guard, |x| *x == 0); | -^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ | | - | `A` is a interior mutable `const` item of type `std::sync::Condvar` + | `A` is an interior mutable `const` item of type `std::sync::Condvar` | = note: each usage of a `const` item creates a new temporary = note: only the temporaries and never the original `const A` will be modified @@ -430,7 +430,7 @@ warning: mutation of an interior mutable `const` item with call to `wait_timeout LL | let _a = A.wait_timeout_ms(guard, 10); | -^^^^^^^^^^^^^^^^^^^^^^^^^^^ | | - | `A` is a interior mutable `const` item of type `std::sync::Condvar` + | `A` is an interior mutable `const` item of type `std::sync::Condvar` | = note: each usage of a `const` item creates a new temporary = note: only the temporaries and never the original `const A` will be modified @@ -447,7 +447,7 @@ warning: mutation of an interior mutable `const` item with call to `wait_timeout LL | let _a = A.wait_timeout(guard, Duration::from_millis(10)); | -^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ | | - | `A` is a interior mutable `const` item of type `std::sync::Condvar` + | `A` is an interior mutable `const` item of type `std::sync::Condvar` | = note: each usage of a `const` item creates a new temporary = note: only the temporaries and never the original `const A` will be modified @@ -464,7 +464,7 @@ warning: mutation of an interior mutable `const` item with call to `wait_timeout LL | let _a = A.wait_timeout_while(guard, Duration::from_millis(10), |x| *x == 0); | -^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ | | - | `A` is a interior mutable `const` item of type `std::sync::Condvar` + | `A` is an interior mutable `const` item of type `std::sync::Condvar` | = note: each usage of a `const` item creates a new temporary = note: only the temporaries and never the original `const A` will be modified @@ -481,7 +481,7 @@ warning: mutation of an interior mutable `const` item with call to `notify_one` LL | let _a = A.notify_one(); | -^^^^^^^^^^^^^ | | - | `A` is a interior mutable `const` item of type `std::sync::Condvar` + | `A` is an interior mutable `const` item of type `std::sync::Condvar` | = note: each usage of a `const` item creates a new temporary = note: only the temporaries and never the original `const A` will be modified @@ -498,7 +498,7 @@ warning: mutation of an interior mutable `const` item with call to `notify_all` LL | let _a = A.notify_all(); | -^^^^^^^^^^^^^ | | - | `A` is a interior mutable `const` item of type `std::sync::Condvar` + | `A` is an interior mutable `const` item of type `std::sync::Condvar` | = note: each usage of a `const` item creates a new temporary = note: only the temporaries and never the original `const A` will be modified diff --git a/tests/ui/target-feature/target-feature-detection.rs b/tests/ui/target-feature/target-feature-detection.rs index 9a9102bf7d54d..22ff8442e3ed2 100644 --- a/tests/ui/target-feature/target-feature-detection.rs +++ b/tests/ui/target-feature/target-feature-detection.rs @@ -1,5 +1,5 @@ -//! Check that `cfg!(target_feature = "...")` correctly detects available CPU features, -//! specifically `sse2` on x86/x86_64 platforms, and correctly reports absent features. +//! Check that `cfg!(target_feature = "...")` correctly detects available CPU features from the base +//! target, specifically `sse2` on x86/x86_64 platforms, and correctly reports absent features. //@ run-pass //@ ignore-i586 (no SSE2) diff --git a/tests/ui/target-feature/target-feature-flag-sets-cfg.rs b/tests/ui/target-feature/target-feature-flag-sets-cfg.rs new file mode 100644 index 0000000000000..d1d778ce85901 --- /dev/null +++ b/tests/ui/target-feature/target-feature-flag-sets-cfg.rs @@ -0,0 +1,23 @@ +//! Ensure ABI-incompatible features cannot be enabled via `-Ctarget-feature`. +// These are just warnings for now. +//@ check-pass +//@ compile-flags: --crate-type=lib +//@ revisions: x86 riscv +//@[x86] compile-flags: --target=x86_64-unknown-linux-gnu -Ctarget-feature=+avx512f +//@[x86] needs-llvm-components: x86 +//@[riscv] compile-flags: --target=riscv64im-unknown-none-elf -Ctarget-feature=+d +//@[riscv] needs-llvm-components: riscv +//@ add-minicore + +#![feature(no_core, riscv_target_feature)] +#![no_core] + +extern crate minicore; +use minicore::*; + +// Ensure we can "see" the enabled target feature, and its implications. +#[cfg(not(any( + all(target_arch = "x86_64", target_feature = "avx512f", target_feature = "avx2"), + all(target_arch = "riscv64", target_feature = "d", target_feature = "f") +)))] +compile_error!("target feature has not been set in cfg");