Add const_item_interior_mutations lint

This commit is contained in:
Urgau 2025-11-02 15:19:33 +01:00
parent 0e8d1e1f8e
commit dc2a61eccd
12 changed files with 2532 additions and 0 deletions

View file

@ -193,6 +193,14 @@ lint_confusable_identifier_pair = found both `{$existing_sym}` and `{$sym}` as i
.current_use = this identifier can be confused with `{$existing_sym}`
.other_use = other identifier used here
lint_const_item_interior_mutations =
mutation of an interior mutable `const` item with call to `{$method_name}`
.label = `{$const_name}` is a interior mutable `const` item of type `{$const_ty}`
.temporary = each usage of a `const` item creates a new temporary
.never_original = only the temporaries and never the original `const {$const_name}` will be modified
.suggestion_static = for a shared instance of `{$const_name}`, consider making it a `static` item instead
.help = for more details on interior mutability see <https://doc.rust-lang.org/reference/interior-mutability.html>
lint_dangling_pointers_from_locals = {$fn_kind} returns a dangling pointer to dropped local variable `{$local_var_name}`
.ret_ty = return type is `{$ret_ty}`
.local_var = local variable `{$local_var_name}` is dropped at the end of the {$fn_kind}

View file

@ -0,0 +1,122 @@
use rustc_hir::attrs::AttributeKind;
use rustc_hir::def::{DefKind, Res};
use rustc_hir::{Expr, ExprKind, ItemKind, Node, find_attr};
use rustc_session::{declare_lint, declare_lint_pass};
use crate::lints::{ConstItemInteriorMutationsDiag, ConstItemInteriorMutationsSuggestionStatic};
use crate::{LateContext, LateLintPass, LintContext};
declare_lint! {
/// The `const_item_interior_mutations` lint checks for calls which
/// mutates an interior mutable const-item.
///
/// ### Example
///
/// ```rust
/// use std::sync::Once;
///
/// const INIT: Once = Once::new(); // using `INIT` will always create a temporary and
/// // never modify it-self on use, should be a `static`
/// // instead for shared use
///
/// fn init() {
/// INIT.call_once(|| {
/// println!("Once::call_once first call");
/// });
/// INIT.call_once(|| { // this second will also print
/// println!("Once::call_once second call"); // as each call to `INIT` creates
/// }); // new temporary
/// }
/// ```
///
/// {{produces}}
///
/// ### Explanation
///
/// Calling a method which mutates an interior mutable type has no effect as const-item
/// are essentially inlined wherever they are used, meaning that they are copied
/// directly into the relevant context when used rendering modification through
/// interior mutability ineffective across usage of that const-item.
///
/// The current implementation of this lint only warns on significant `std` and
/// `core` interior mutable types, like `Once`, `AtomicI32`, ... this is done out
/// of prudence to avoid false-positive and may be extended in the future.
pub CONST_ITEM_INTERIOR_MUTATIONS,
Warn,
"checks for calls which mutates a interior mutable const-item"
}
declare_lint_pass!(InteriorMutableConsts => [CONST_ITEM_INTERIOR_MUTATIONS]);
impl<'tcx> LateLintPass<'tcx> for InteriorMutableConsts {
fn check_expr(&mut self, cx: &LateContext<'tcx>, expr: &'tcx Expr<'tcx>) {
let typeck = cx.typeck_results();
let (method_did, receiver) = match expr.kind {
// matching on `<receiver>.method(..)`
ExprKind::MethodCall(_, receiver, _, _) => {
(typeck.type_dependent_def_id(expr.hir_id), receiver)
}
// matching on `function(&<receiver>, ...)`
ExprKind::Call(path, [receiver, ..]) => match receiver.kind {
ExprKind::AddrOf(_, _, receiver) => match path.kind {
ExprKind::Path(ref qpath) => {
(cx.qpath_res(qpath, path.hir_id).opt_def_id(), receiver)
}
_ => return,
},
_ => return,
},
_ => return,
};
let Some(method_did) = method_did else {
return;
};
if let ExprKind::Path(qpath) = &receiver.kind
&& let Res::Def(DefKind::Const | DefKind::AssocConst, const_did) =
typeck.qpath_res(qpath, receiver.hir_id)
// Let's do the attribute check after the other checks for perf reasons
&& find_attr!(
cx.tcx.get_all_attrs(method_did),
AttributeKind::RustcShouldNotBeCalledOnConstItems(_)
)
&& let Some(method_name) = cx.tcx.opt_item_ident(method_did)
&& let Some(const_name) = cx.tcx.opt_item_ident(const_did)
&& let Some(const_ty) = typeck.node_type_opt(receiver.hir_id)
{
// Find the local `const`-item and create the suggestion to use `static` instead
let sugg_static = if let Some(Node::Item(const_item)) =
cx.tcx.hir_get_if_local(const_did)
&& let ItemKind::Const(ident, _generics, _ty, _body_id) = const_item.kind
{
if let Some(vis_span) = const_item.vis_span.find_ancestor_inside(const_item.span)
&& const_item.span.can_be_used_for_suggestions()
&& vis_span.can_be_used_for_suggestions()
{
Some(ConstItemInteriorMutationsSuggestionStatic::Spanful {
const_: const_item.vis_span.between(ident.span),
before: if !vis_span.is_empty() { " " } else { "" },
})
} else {
Some(ConstItemInteriorMutationsSuggestionStatic::Spanless)
}
} else {
None
};
cx.emit_span_lint(
CONST_ITEM_INTERIOR_MUTATIONS,
expr.span,
ConstItemInteriorMutationsDiag {
method_name,
const_name,
const_ty,
receiver_span: receiver.span,
sugg_static,
},
);
}
}
}

View file

@ -48,6 +48,7 @@ mod foreign_modules;
mod function_cast_as_integer;
mod if_let_rescope;
mod impl_trait_overcaptures;
mod interior_mutable_consts;
mod internal;
mod invalid_from_utf8;
mod late;
@ -93,6 +94,7 @@ use for_loops_over_fallibles::*;
use function_cast_as_integer::*;
use if_let_rescope::IfLetRescope;
use impl_trait_overcaptures::ImplTraitOvercaptures;
use interior_mutable_consts::*;
use internal::*;
use invalid_from_utf8::*;
use let_underscore::*;
@ -239,6 +241,7 @@ late_lint_methods!(
AsyncClosureUsage: AsyncClosureUsage,
AsyncFnInTrait: AsyncFnInTrait,
NonLocalDefinitions: NonLocalDefinitions::default(),
InteriorMutableConsts: InteriorMutableConsts,
ImplTraitOvercaptures: ImplTraitOvercaptures,
IfLetRescope: IfLetRescope::default(),
StaticMutRefs: StaticMutRefs,

View file

@ -784,6 +784,39 @@ pub(crate) enum InvalidFromUtf8Diag {
},
}
// interior_mutable_consts.rs
#[derive(LintDiagnostic)]
#[diag(lint_const_item_interior_mutations)]
#[note(lint_temporary)]
#[note(lint_never_original)]
#[help]
pub(crate) struct ConstItemInteriorMutationsDiag<'tcx> {
pub method_name: Ident,
pub const_name: Ident,
pub const_ty: Ty<'tcx>,
#[label]
pub receiver_span: Span,
#[subdiagnostic]
pub sugg_static: Option<ConstItemInteriorMutationsSuggestionStatic>,
}
#[derive(Subdiagnostic)]
pub(crate) enum ConstItemInteriorMutationsSuggestionStatic {
#[suggestion(
lint_suggestion_static,
code = "{before}static ",
style = "verbose",
applicability = "maybe-incorrect"
)]
Spanful {
#[primary_span]
const_: Span,
before: &'static str,
},
#[help(lint_suggestion_static)]
Spanless,
}
// reference_casting.rs
#[derive(LintDiagnostic)]
pub(crate) enum InvalidReferenceCastingDiag<'tcx> {

View file

@ -0,0 +1,164 @@
//@ check-pass
//@ run-rustfix
#![allow(deprecated)]
#![allow(dead_code)]
#![feature(atomic_try_update)]
use std::sync::atomic::{AtomicBool, AtomicPtr, AtomicU32, Ordering};
fn atomic_bool() {
static A: AtomicBool = AtomicBool::new(false);
let _a = A.store(true, Ordering::SeqCst);
//~^ WARN mutation of an interior mutable `const` item with call to `store`
let _a = A.swap(true, Ordering::SeqCst);
//~^ WARN mutation of an interior mutable `const` item with call to `swap`
let _a = A.compare_and_swap(false, true, Ordering::SeqCst);
//~^ WARN mutation of an interior mutable `const` item with call to `compare_and_swap`
let _a = A.compare_exchange(false, true, Ordering::SeqCst, Ordering::Relaxed);
//~^ WARN mutation of an interior mutable `const` item with call to `compare_exchange`
let _a = A.compare_exchange_weak(false, true, Ordering::SeqCst, Ordering::Relaxed);
//~^ WARN mutation of an interior mutable `const` item with call to `compare_exchange_weak`
let _a = A.fetch_and(true, Ordering::SeqCst);
//~^ WARN mutation of an interior mutable `const` item with call to `fetch_and`
let _a = A.fetch_nand(true, Ordering::SeqCst);
//~^ WARN mutation of an interior mutable `const` item with call to `fetch_nand`
let _a = A.fetch_or(true, Ordering::SeqCst);
//~^ WARN mutation of an interior mutable `const` item with call to `fetch_or`
let _a = A.fetch_xor(true, Ordering::SeqCst);
//~^ WARN mutation of an interior mutable `const` item with call to `fetch_xor`
let _a = A.fetch_not(Ordering::SeqCst);
//~^ WARN mutation of an interior mutable `const` item with call to `fetch_not`
let _a = A.fetch_update(Ordering::SeqCst, Ordering::Relaxed, |_| Some(true));
//~^ WARN mutation of an interior mutable `const` item with call to `fetch_update`
let _a = A.try_update(Ordering::SeqCst, Ordering::Relaxed, |_| Some(false));
//~^ WARN mutation of an interior mutable `const` item with call to `try_update`
let _a = A.update(Ordering::SeqCst, Ordering::Relaxed, |_| true);
//~^ WARN mutation of an interior mutable `const` item with call to `update`
}
fn atomic_ptr() {
static A: AtomicPtr<i32> = AtomicPtr::new(std::ptr::null_mut());
let _a = A.store(std::ptr::null_mut(), Ordering::SeqCst);
//~^ WARN mutation of an interior mutable `const` item with call to `store`
let _a = A.swap(std::ptr::null_mut(), Ordering::SeqCst);
//~^ WARN mutation of an interior mutable `const` item with call to `swap`
let _a = A.compare_and_swap(std::ptr::null_mut(), std::ptr::null_mut(), Ordering::SeqCst);
//~^ WARN mutation of an interior mutable `const` item with call to `compare_and_swap`
let _a = A.compare_exchange(
//~^ WARN mutation of an interior mutable `const` item with call to `compare_exchange`
std::ptr::null_mut(),
std::ptr::null_mut(),
Ordering::SeqCst,
Ordering::Relaxed,
);
let _a = A.compare_exchange_weak(
//~^ WARN mutation of an interior mutable `const` item with call to `compare_exchange_weak`
std::ptr::null_mut(),
std::ptr::null_mut(),
Ordering::SeqCst,
Ordering::Relaxed,
);
let _a = A.fetch_update(Ordering::SeqCst, Ordering::Relaxed, |_| Some(std::ptr::null_mut()));
//~^ WARN mutation of an interior mutable `const` item with call to `fetch_update`
let _a = A.try_update(Ordering::SeqCst, Ordering::Relaxed, |_| Some(std::ptr::null_mut()));
//~^ WARN mutation of an interior mutable `const` item with call to `try_update`
let _a = A.update(Ordering::SeqCst, Ordering::Relaxed, |_| std::ptr::null_mut());
//~^ WARN mutation of an interior mutable `const` item with call to `update`
let _a = A.fetch_ptr_add(1, Ordering::SeqCst);
//~^ WARN mutation of an interior mutable `const` item with call to `fetch_ptr_add`
let _a = A.fetch_ptr_sub(1, Ordering::SeqCst);
//~^ WARN mutation of an interior mutable `const` item with call to `fetch_ptr_sub`
let _a = A.fetch_byte_add(1, Ordering::SeqCst);
//~^ WARN mutation of an interior mutable `const` item with call to `fetch_byte_add`
let _a = A.fetch_byte_sub(1, Ordering::SeqCst);
//~^ WARN mutation of an interior mutable `const` item with call to `fetch_byte_sub`
let _a = A.fetch_and(1, Ordering::SeqCst);
//~^ WARN mutation of an interior mutable `const` item with call to `fetch_and`
let _a = A.fetch_or(1, Ordering::SeqCst);
//~^ WARN mutation of an interior mutable `const` item with call to `fetch_or`
let _a = A.fetch_xor(1, Ordering::SeqCst);
//~^ WARN mutation of an interior mutable `const` item with call to `fetch_xor`
}
fn atomic_u32() {
static A: AtomicU32 = AtomicU32::new(0);
let _a = A.store(1, Ordering::SeqCst);
//~^ WARN mutation of an interior mutable `const` item with call to `store`
let _a = A.swap(2, Ordering::SeqCst);
//~^ WARN mutation of an interior mutable `const` item with call to `swap`
let _a = A.compare_and_swap(2, 3, Ordering::SeqCst);
//~^ WARN mutation of an interior mutable `const` item with call to `compare_and_swap`
let _a = A.compare_exchange(3, 4, Ordering::SeqCst, Ordering::Relaxed);
//~^ WARN mutation of an interior mutable `const` item with call to `compare_exchange`
let _a = A.compare_exchange_weak(4, 5, Ordering::SeqCst, Ordering::Relaxed);
//~^ WARN mutation of an interior mutable `const` item with call to `compare_exchange_weak`
let _a = A.fetch_add(1, Ordering::SeqCst);
//~^ WARN mutation of an interior mutable `const` item with call to `fetch_add`
let _a = A.fetch_sub(1, Ordering::SeqCst);
//~^ WARN mutation of an interior mutable `const` item with call to `fetch_sub`
let _a = A.fetch_add(2, Ordering::SeqCst);
//~^ WARN mutation of an interior mutable `const` item with call to `fetch_add`
let _a = A.fetch_nand(1, Ordering::SeqCst);
//~^ WARN mutation of an interior mutable `const` item with call to `fetch_nand`
let _a = A.fetch_or(1, Ordering::SeqCst);
//~^ WARN mutation of an interior mutable `const` item with call to `fetch_or`
let _a = A.fetch_xor(1, Ordering::SeqCst);
//~^ WARN mutation of an interior mutable `const` item with call to `fetch_xor`
let _a = A.fetch_update(Ordering::SeqCst, Ordering::Relaxed, |_| Some(10));
//~^ WARN mutation of an interior mutable `const` item with call to `fetch_update`
let _a = A.try_update(Ordering::SeqCst, Ordering::Relaxed, |_| Some(11));
//~^ WARN mutation of an interior mutable `const` item with call to `try_update`
let _a = A.update(Ordering::SeqCst, Ordering::Relaxed, |_| 12);
//~^ WARN mutation of an interior mutable `const` item with call to `update`
let _a = A.fetch_max(20, Ordering::SeqCst);
//~^ WARN mutation of an interior mutable `const` item with call to `fetch_max`
let _a = A.fetch_min(5, Ordering::SeqCst);
//~^ WARN mutation of an interior mutable `const` item with call to `fetch_min`
}
fn main() {}

View file

@ -0,0 +1,164 @@
//@ check-pass
//@ run-rustfix
#![allow(deprecated)]
#![allow(dead_code)]
#![feature(atomic_try_update)]
use std::sync::atomic::{AtomicBool, AtomicPtr, AtomicU32, Ordering};
fn atomic_bool() {
const A: AtomicBool = AtomicBool::new(false);
let _a = A.store(true, Ordering::SeqCst);
//~^ WARN mutation of an interior mutable `const` item with call to `store`
let _a = A.swap(true, Ordering::SeqCst);
//~^ WARN mutation of an interior mutable `const` item with call to `swap`
let _a = A.compare_and_swap(false, true, Ordering::SeqCst);
//~^ WARN mutation of an interior mutable `const` item with call to `compare_and_swap`
let _a = A.compare_exchange(false, true, Ordering::SeqCst, Ordering::Relaxed);
//~^ WARN mutation of an interior mutable `const` item with call to `compare_exchange`
let _a = A.compare_exchange_weak(false, true, Ordering::SeqCst, Ordering::Relaxed);
//~^ WARN mutation of an interior mutable `const` item with call to `compare_exchange_weak`
let _a = A.fetch_and(true, Ordering::SeqCst);
//~^ WARN mutation of an interior mutable `const` item with call to `fetch_and`
let _a = A.fetch_nand(true, Ordering::SeqCst);
//~^ WARN mutation of an interior mutable `const` item with call to `fetch_nand`
let _a = A.fetch_or(true, Ordering::SeqCst);
//~^ WARN mutation of an interior mutable `const` item with call to `fetch_or`
let _a = A.fetch_xor(true, Ordering::SeqCst);
//~^ WARN mutation of an interior mutable `const` item with call to `fetch_xor`
let _a = A.fetch_not(Ordering::SeqCst);
//~^ WARN mutation of an interior mutable `const` item with call to `fetch_not`
let _a = A.fetch_update(Ordering::SeqCst, Ordering::Relaxed, |_| Some(true));
//~^ WARN mutation of an interior mutable `const` item with call to `fetch_update`
let _a = A.try_update(Ordering::SeqCst, Ordering::Relaxed, |_| Some(false));
//~^ WARN mutation of an interior mutable `const` item with call to `try_update`
let _a = A.update(Ordering::SeqCst, Ordering::Relaxed, |_| true);
//~^ WARN mutation of an interior mutable `const` item with call to `update`
}
fn atomic_ptr() {
const A: AtomicPtr<i32> = AtomicPtr::new(std::ptr::null_mut());
let _a = A.store(std::ptr::null_mut(), Ordering::SeqCst);
//~^ WARN mutation of an interior mutable `const` item with call to `store`
let _a = A.swap(std::ptr::null_mut(), Ordering::SeqCst);
//~^ WARN mutation of an interior mutable `const` item with call to `swap`
let _a = A.compare_and_swap(std::ptr::null_mut(), std::ptr::null_mut(), Ordering::SeqCst);
//~^ WARN mutation of an interior mutable `const` item with call to `compare_and_swap`
let _a = A.compare_exchange(
//~^ WARN mutation of an interior mutable `const` item with call to `compare_exchange`
std::ptr::null_mut(),
std::ptr::null_mut(),
Ordering::SeqCst,
Ordering::Relaxed,
);
let _a = A.compare_exchange_weak(
//~^ WARN mutation of an interior mutable `const` item with call to `compare_exchange_weak`
std::ptr::null_mut(),
std::ptr::null_mut(),
Ordering::SeqCst,
Ordering::Relaxed,
);
let _a = A.fetch_update(Ordering::SeqCst, Ordering::Relaxed, |_| Some(std::ptr::null_mut()));
//~^ WARN mutation of an interior mutable `const` item with call to `fetch_update`
let _a = A.try_update(Ordering::SeqCst, Ordering::Relaxed, |_| Some(std::ptr::null_mut()));
//~^ WARN mutation of an interior mutable `const` item with call to `try_update`
let _a = A.update(Ordering::SeqCst, Ordering::Relaxed, |_| std::ptr::null_mut());
//~^ WARN mutation of an interior mutable `const` item with call to `update`
let _a = A.fetch_ptr_add(1, Ordering::SeqCst);
//~^ WARN mutation of an interior mutable `const` item with call to `fetch_ptr_add`
let _a = A.fetch_ptr_sub(1, Ordering::SeqCst);
//~^ WARN mutation of an interior mutable `const` item with call to `fetch_ptr_sub`
let _a = A.fetch_byte_add(1, Ordering::SeqCst);
//~^ WARN mutation of an interior mutable `const` item with call to `fetch_byte_add`
let _a = A.fetch_byte_sub(1, Ordering::SeqCst);
//~^ WARN mutation of an interior mutable `const` item with call to `fetch_byte_sub`
let _a = A.fetch_and(1, Ordering::SeqCst);
//~^ WARN mutation of an interior mutable `const` item with call to `fetch_and`
let _a = A.fetch_or(1, Ordering::SeqCst);
//~^ WARN mutation of an interior mutable `const` item with call to `fetch_or`
let _a = A.fetch_xor(1, Ordering::SeqCst);
//~^ WARN mutation of an interior mutable `const` item with call to `fetch_xor`
}
fn atomic_u32() {
const A: AtomicU32 = AtomicU32::new(0);
let _a = A.store(1, Ordering::SeqCst);
//~^ WARN mutation of an interior mutable `const` item with call to `store`
let _a = A.swap(2, Ordering::SeqCst);
//~^ WARN mutation of an interior mutable `const` item with call to `swap`
let _a = A.compare_and_swap(2, 3, Ordering::SeqCst);
//~^ WARN mutation of an interior mutable `const` item with call to `compare_and_swap`
let _a = A.compare_exchange(3, 4, Ordering::SeqCst, Ordering::Relaxed);
//~^ WARN mutation of an interior mutable `const` item with call to `compare_exchange`
let _a = A.compare_exchange_weak(4, 5, Ordering::SeqCst, Ordering::Relaxed);
//~^ WARN mutation of an interior mutable `const` item with call to `compare_exchange_weak`
let _a = A.fetch_add(1, Ordering::SeqCst);
//~^ WARN mutation of an interior mutable `const` item with call to `fetch_add`
let _a = A.fetch_sub(1, Ordering::SeqCst);
//~^ WARN mutation of an interior mutable `const` item with call to `fetch_sub`
let _a = A.fetch_add(2, Ordering::SeqCst);
//~^ WARN mutation of an interior mutable `const` item with call to `fetch_add`
let _a = A.fetch_nand(1, Ordering::SeqCst);
//~^ WARN mutation of an interior mutable `const` item with call to `fetch_nand`
let _a = A.fetch_or(1, Ordering::SeqCst);
//~^ WARN mutation of an interior mutable `const` item with call to `fetch_or`
let _a = A.fetch_xor(1, Ordering::SeqCst);
//~^ WARN mutation of an interior mutable `const` item with call to `fetch_xor`
let _a = A.fetch_update(Ordering::SeqCst, Ordering::Relaxed, |_| Some(10));
//~^ WARN mutation of an interior mutable `const` item with call to `fetch_update`
let _a = A.try_update(Ordering::SeqCst, Ordering::Relaxed, |_| Some(11));
//~^ WARN mutation of an interior mutable `const` item with call to `try_update`
let _a = A.update(Ordering::SeqCst, Ordering::Relaxed, |_| 12);
//~^ WARN mutation of an interior mutable `const` item with call to `update`
let _a = A.fetch_max(20, Ordering::SeqCst);
//~^ WARN mutation of an interior mutable `const` item with call to `fetch_max`
let _a = A.fetch_min(5, Ordering::SeqCst);
//~^ WARN mutation of an interior mutable `const` item with call to `fetch_min`
}
fn main() {}

View file

@ -0,0 +1,765 @@
warning: mutation of an interior mutable `const` item with call to `store`
--> $DIR/const-item-interior-mutations-const-atomics.rs:13:14
|
LL | let _a = A.store(true, Ordering::SeqCst);
| -^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
| |
| `A` is a interior mutable `const` item of type `AtomicBool`
|
= note: each usage of a `const` item creates a new temporary
= note: only the temporaries and never the original `const A` will be modified
= help: for more details on interior mutability see <https://doc.rust-lang.org/reference/interior-mutability.html>
= note: `#[warn(const_item_interior_mutations)]` on by default
help: for a shared instance of `A`, consider making it a `static` item instead
|
LL - const A: AtomicBool = AtomicBool::new(false);
LL + static A: AtomicBool = AtomicBool::new(false);
|
warning: mutation of an interior mutable `const` item with call to `swap`
--> $DIR/const-item-interior-mutations-const-atomics.rs:16:14
|
LL | let _a = A.swap(true, Ordering::SeqCst);
| -^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
| |
| `A` is a interior mutable `const` item of type `AtomicBool`
|
= note: each usage of a `const` item creates a new temporary
= note: only the temporaries and never the original `const A` will be modified
= help: for more details on interior mutability see <https://doc.rust-lang.org/reference/interior-mutability.html>
help: for a shared instance of `A`, consider making it a `static` item instead
|
LL - const A: AtomicBool = AtomicBool::new(false);
LL + static A: AtomicBool = AtomicBool::new(false);
|
warning: mutation of an interior mutable `const` item with call to `compare_and_swap`
--> $DIR/const-item-interior-mutations-const-atomics.rs:19:14
|
LL | let _a = A.compare_and_swap(false, true, Ordering::SeqCst);
| -^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
| |
| `A` is a interior mutable `const` item of type `AtomicBool`
|
= note: each usage of a `const` item creates a new temporary
= note: only the temporaries and never the original `const A` will be modified
= help: for more details on interior mutability see <https://doc.rust-lang.org/reference/interior-mutability.html>
help: for a shared instance of `A`, consider making it a `static` item instead
|
LL - const A: AtomicBool = AtomicBool::new(false);
LL + static A: AtomicBool = AtomicBool::new(false);
|
warning: mutation of an interior mutable `const` item with call to `compare_exchange`
--> $DIR/const-item-interior-mutations-const-atomics.rs:22:14
|
LL | let _a = A.compare_exchange(false, true, Ordering::SeqCst, Ordering::Relaxed);
| -^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
| |
| `A` is a interior mutable `const` item of type `AtomicBool`
|
= note: each usage of a `const` item creates a new temporary
= note: only the temporaries and never the original `const A` will be modified
= help: for more details on interior mutability see <https://doc.rust-lang.org/reference/interior-mutability.html>
help: for a shared instance of `A`, consider making it a `static` item instead
|
LL - const A: AtomicBool = AtomicBool::new(false);
LL + static A: AtomicBool = AtomicBool::new(false);
|
warning: mutation of an interior mutable `const` item with call to `compare_exchange_weak`
--> $DIR/const-item-interior-mutations-const-atomics.rs:25:14
|
LL | let _a = A.compare_exchange_weak(false, true, Ordering::SeqCst, Ordering::Relaxed);
| -^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
| |
| `A` is a interior mutable `const` item of type `AtomicBool`
|
= note: each usage of a `const` item creates a new temporary
= note: only the temporaries and never the original `const A` will be modified
= help: for more details on interior mutability see <https://doc.rust-lang.org/reference/interior-mutability.html>
help: for a shared instance of `A`, consider making it a `static` item instead
|
LL - const A: AtomicBool = AtomicBool::new(false);
LL + static A: AtomicBool = AtomicBool::new(false);
|
warning: mutation of an interior mutable `const` item with call to `fetch_and`
--> $DIR/const-item-interior-mutations-const-atomics.rs:28:14
|
LL | let _a = A.fetch_and(true, Ordering::SeqCst);
| -^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
| |
| `A` is a interior mutable `const` item of type `AtomicBool`
|
= note: each usage of a `const` item creates a new temporary
= note: only the temporaries and never the original `const A` will be modified
= help: for more details on interior mutability see <https://doc.rust-lang.org/reference/interior-mutability.html>
help: for a shared instance of `A`, consider making it a `static` item instead
|
LL - const A: AtomicBool = AtomicBool::new(false);
LL + static A: AtomicBool = AtomicBool::new(false);
|
warning: mutation of an interior mutable `const` item with call to `fetch_nand`
--> $DIR/const-item-interior-mutations-const-atomics.rs:31:14
|
LL | let _a = A.fetch_nand(true, Ordering::SeqCst);
| -^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
| |
| `A` is a interior mutable `const` item of type `AtomicBool`
|
= note: each usage of a `const` item creates a new temporary
= note: only the temporaries and never the original `const A` will be modified
= help: for more details on interior mutability see <https://doc.rust-lang.org/reference/interior-mutability.html>
help: for a shared instance of `A`, consider making it a `static` item instead
|
LL - const A: AtomicBool = AtomicBool::new(false);
LL + static A: AtomicBool = AtomicBool::new(false);
|
warning: mutation of an interior mutable `const` item with call to `fetch_or`
--> $DIR/const-item-interior-mutations-const-atomics.rs:34:14
|
LL | let _a = A.fetch_or(true, Ordering::SeqCst);
| -^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
| |
| `A` is a interior mutable `const` item of type `AtomicBool`
|
= note: each usage of a `const` item creates a new temporary
= note: only the temporaries and never the original `const A` will be modified
= help: for more details on interior mutability see <https://doc.rust-lang.org/reference/interior-mutability.html>
help: for a shared instance of `A`, consider making it a `static` item instead
|
LL - const A: AtomicBool = AtomicBool::new(false);
LL + static A: AtomicBool = AtomicBool::new(false);
|
warning: mutation of an interior mutable `const` item with call to `fetch_xor`
--> $DIR/const-item-interior-mutations-const-atomics.rs:37:14
|
LL | let _a = A.fetch_xor(true, Ordering::SeqCst);
| -^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
| |
| `A` is a interior mutable `const` item of type `AtomicBool`
|
= note: each usage of a `const` item creates a new temporary
= note: only the temporaries and never the original `const A` will be modified
= help: for more details on interior mutability see <https://doc.rust-lang.org/reference/interior-mutability.html>
help: for a shared instance of `A`, consider making it a `static` item instead
|
LL - const A: AtomicBool = AtomicBool::new(false);
LL + static A: AtomicBool = AtomicBool::new(false);
|
warning: mutation of an interior mutable `const` item with call to `fetch_not`
--> $DIR/const-item-interior-mutations-const-atomics.rs:40:14
|
LL | let _a = A.fetch_not(Ordering::SeqCst);
| -^^^^^^^^^^^^^^^^^^^^^^^^^^^^
| |
| `A` is a interior mutable `const` item of type `AtomicBool`
|
= note: each usage of a `const` item creates a new temporary
= note: only the temporaries and never the original `const A` will be modified
= help: for more details on interior mutability see <https://doc.rust-lang.org/reference/interior-mutability.html>
help: for a shared instance of `A`, consider making it a `static` item instead
|
LL - const A: AtomicBool = AtomicBool::new(false);
LL + static A: AtomicBool = AtomicBool::new(false);
|
warning: mutation of an interior mutable `const` item with call to `fetch_update`
--> $DIR/const-item-interior-mutations-const-atomics.rs:43:14
|
LL | let _a = A.fetch_update(Ordering::SeqCst, Ordering::Relaxed, |_| Some(true));
| -^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
| |
| `A` is a interior mutable `const` item of type `AtomicBool`
|
= note: each usage of a `const` item creates a new temporary
= note: only the temporaries and never the original `const A` will be modified
= help: for more details on interior mutability see <https://doc.rust-lang.org/reference/interior-mutability.html>
help: for a shared instance of `A`, consider making it a `static` item instead
|
LL - const A: AtomicBool = AtomicBool::new(false);
LL + static A: AtomicBool = AtomicBool::new(false);
|
warning: mutation of an interior mutable `const` item with call to `try_update`
--> $DIR/const-item-interior-mutations-const-atomics.rs:46:14
|
LL | let _a = A.try_update(Ordering::SeqCst, Ordering::Relaxed, |_| Some(false));
| -^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
| |
| `A` is a interior mutable `const` item of type `AtomicBool`
|
= note: each usage of a `const` item creates a new temporary
= note: only the temporaries and never the original `const A` will be modified
= help: for more details on interior mutability see <https://doc.rust-lang.org/reference/interior-mutability.html>
help: for a shared instance of `A`, consider making it a `static` item instead
|
LL - const A: AtomicBool = AtomicBool::new(false);
LL + static A: AtomicBool = AtomicBool::new(false);
|
warning: mutation of an interior mutable `const` item with call to `update`
--> $DIR/const-item-interior-mutations-const-atomics.rs:49:14
|
LL | let _a = A.update(Ordering::SeqCst, Ordering::Relaxed, |_| true);
| -^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
| |
| `A` is a interior mutable `const` item of type `AtomicBool`
|
= note: each usage of a `const` item creates a new temporary
= note: only the temporaries and never the original `const A` will be modified
= help: for more details on interior mutability see <https://doc.rust-lang.org/reference/interior-mutability.html>
help: for a shared instance of `A`, consider making it a `static` item instead
|
LL - const A: AtomicBool = AtomicBool::new(false);
LL + static A: AtomicBool = AtomicBool::new(false);
|
warning: mutation of an interior mutable `const` item with call to `store`
--> $DIR/const-item-interior-mutations-const-atomics.rs:56:14
|
LL | let _a = A.store(std::ptr::null_mut(), Ordering::SeqCst);
| -^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
| |
| `A` is a interior mutable `const` item of type `AtomicPtr<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
= help: for more details on interior mutability see <https://doc.rust-lang.org/reference/interior-mutability.html>
help: for a shared instance of `A`, consider making it a `static` item instead
|
LL - const A: AtomicPtr<i32> = AtomicPtr::new(std::ptr::null_mut());
LL + static A: AtomicPtr<i32> = AtomicPtr::new(std::ptr::null_mut());
|
warning: mutation of an interior mutable `const` item with call to `swap`
--> $DIR/const-item-interior-mutations-const-atomics.rs:59:14
|
LL | let _a = A.swap(std::ptr::null_mut(), Ordering::SeqCst);
| -^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
| |
| `A` is a interior mutable `const` item of type `AtomicPtr<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
= help: for more details on interior mutability see <https://doc.rust-lang.org/reference/interior-mutability.html>
help: for a shared instance of `A`, consider making it a `static` item instead
|
LL - const A: AtomicPtr<i32> = AtomicPtr::new(std::ptr::null_mut());
LL + static A: AtomicPtr<i32> = AtomicPtr::new(std::ptr::null_mut());
|
warning: mutation of an interior mutable `const` item with call to `compare_and_swap`
--> $DIR/const-item-interior-mutations-const-atomics.rs:62:14
|
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 `AtomicPtr<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
= help: for more details on interior mutability see <https://doc.rust-lang.org/reference/interior-mutability.html>
help: for a shared instance of `A`, consider making it a `static` item instead
|
LL - const A: AtomicPtr<i32> = AtomicPtr::new(std::ptr::null_mut());
LL + static A: AtomicPtr<i32> = AtomicPtr::new(std::ptr::null_mut());
|
warning: mutation of an interior mutable `const` item with call to `compare_exchange`
--> $DIR/const-item-interior-mutations-const-atomics.rs:65:14
|
LL | let _a = A.compare_exchange(
| ^ `A` is a interior mutable `const` item of type `AtomicPtr<i32>`
| ______________|
| |
LL | |
LL | | std::ptr::null_mut(),
LL | | std::ptr::null_mut(),
LL | | Ordering::SeqCst,
LL | | Ordering::Relaxed,
LL | | );
| |_____^
|
= note: each usage of a `const` item creates a new temporary
= note: only the temporaries and never the original `const A` will be modified
= help: for more details on interior mutability see <https://doc.rust-lang.org/reference/interior-mutability.html>
help: for a shared instance of `A`, consider making it a `static` item instead
|
LL - const A: AtomicPtr<i32> = AtomicPtr::new(std::ptr::null_mut());
LL + static A: AtomicPtr<i32> = AtomicPtr::new(std::ptr::null_mut());
|
warning: mutation of an interior mutable `const` item with call to `compare_exchange_weak`
--> $DIR/const-item-interior-mutations-const-atomics.rs:73:14
|
LL | let _a = A.compare_exchange_weak(
| ^ `A` is a interior mutable `const` item of type `AtomicPtr<i32>`
| ______________|
| |
LL | |
LL | | std::ptr::null_mut(),
LL | | std::ptr::null_mut(),
LL | | Ordering::SeqCst,
LL | | Ordering::Relaxed,
LL | | );
| |_____^
|
= note: each usage of a `const` item creates a new temporary
= note: only the temporaries and never the original `const A` will be modified
= help: for more details on interior mutability see <https://doc.rust-lang.org/reference/interior-mutability.html>
help: for a shared instance of `A`, consider making it a `static` item instead
|
LL - const A: AtomicPtr<i32> = AtomicPtr::new(std::ptr::null_mut());
LL + static A: AtomicPtr<i32> = AtomicPtr::new(std::ptr::null_mut());
|
warning: mutation of an interior mutable `const` item with call to `fetch_update`
--> $DIR/const-item-interior-mutations-const-atomics.rs:81:14
|
LL | let _a = A.fetch_update(Ordering::SeqCst, Ordering::Relaxed, |_| Some(std::ptr::null_mut()));
| -^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
| |
| `A` is a interior mutable `const` item of type `AtomicPtr<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
= help: for more details on interior mutability see <https://doc.rust-lang.org/reference/interior-mutability.html>
help: for a shared instance of `A`, consider making it a `static` item instead
|
LL - const A: AtomicPtr<i32> = AtomicPtr::new(std::ptr::null_mut());
LL + static A: AtomicPtr<i32> = AtomicPtr::new(std::ptr::null_mut());
|
warning: mutation of an interior mutable `const` item with call to `try_update`
--> $DIR/const-item-interior-mutations-const-atomics.rs:84:14
|
LL | let _a = A.try_update(Ordering::SeqCst, Ordering::Relaxed, |_| Some(std::ptr::null_mut()));
| -^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
| |
| `A` is a interior mutable `const` item of type `AtomicPtr<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
= help: for more details on interior mutability see <https://doc.rust-lang.org/reference/interior-mutability.html>
help: for a shared instance of `A`, consider making it a `static` item instead
|
LL - const A: AtomicPtr<i32> = AtomicPtr::new(std::ptr::null_mut());
LL + static A: AtomicPtr<i32> = AtomicPtr::new(std::ptr::null_mut());
|
warning: mutation of an interior mutable `const` item with call to `update`
--> $DIR/const-item-interior-mutations-const-atomics.rs:87:14
|
LL | let _a = A.update(Ordering::SeqCst, Ordering::Relaxed, |_| std::ptr::null_mut());
| -^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
| |
| `A` is a interior mutable `const` item of type `AtomicPtr<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
= help: for more details on interior mutability see <https://doc.rust-lang.org/reference/interior-mutability.html>
help: for a shared instance of `A`, consider making it a `static` item instead
|
LL - const A: AtomicPtr<i32> = AtomicPtr::new(std::ptr::null_mut());
LL + static A: AtomicPtr<i32> = AtomicPtr::new(std::ptr::null_mut());
|
warning: mutation of an interior mutable `const` item with call to `fetch_ptr_add`
--> $DIR/const-item-interior-mutations-const-atomics.rs:90:14
|
LL | let _a = A.fetch_ptr_add(1, Ordering::SeqCst);
| -^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
| |
| `A` is a interior mutable `const` item of type `AtomicPtr<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
= help: for more details on interior mutability see <https://doc.rust-lang.org/reference/interior-mutability.html>
help: for a shared instance of `A`, consider making it a `static` item instead
|
LL - const A: AtomicPtr<i32> = AtomicPtr::new(std::ptr::null_mut());
LL + static A: AtomicPtr<i32> = AtomicPtr::new(std::ptr::null_mut());
|
warning: mutation of an interior mutable `const` item with call to `fetch_ptr_sub`
--> $DIR/const-item-interior-mutations-const-atomics.rs:93:14
|
LL | let _a = A.fetch_ptr_sub(1, Ordering::SeqCst);
| -^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
| |
| `A` is a interior mutable `const` item of type `AtomicPtr<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
= help: for more details on interior mutability see <https://doc.rust-lang.org/reference/interior-mutability.html>
help: for a shared instance of `A`, consider making it a `static` item instead
|
LL - const A: AtomicPtr<i32> = AtomicPtr::new(std::ptr::null_mut());
LL + static A: AtomicPtr<i32> = AtomicPtr::new(std::ptr::null_mut());
|
warning: mutation of an interior mutable `const` item with call to `fetch_byte_add`
--> $DIR/const-item-interior-mutations-const-atomics.rs:96:14
|
LL | let _a = A.fetch_byte_add(1, Ordering::SeqCst);
| -^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
| |
| `A` is a interior mutable `const` item of type `AtomicPtr<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
= help: for more details on interior mutability see <https://doc.rust-lang.org/reference/interior-mutability.html>
help: for a shared instance of `A`, consider making it a `static` item instead
|
LL - const A: AtomicPtr<i32> = AtomicPtr::new(std::ptr::null_mut());
LL + static A: AtomicPtr<i32> = AtomicPtr::new(std::ptr::null_mut());
|
warning: mutation of an interior mutable `const` item with call to `fetch_byte_sub`
--> $DIR/const-item-interior-mutations-const-atomics.rs:99:14
|
LL | let _a = A.fetch_byte_sub(1, Ordering::SeqCst);
| -^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
| |
| `A` is a interior mutable `const` item of type `AtomicPtr<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
= help: for more details on interior mutability see <https://doc.rust-lang.org/reference/interior-mutability.html>
help: for a shared instance of `A`, consider making it a `static` item instead
|
LL - const A: AtomicPtr<i32> = AtomicPtr::new(std::ptr::null_mut());
LL + static A: AtomicPtr<i32> = AtomicPtr::new(std::ptr::null_mut());
|
warning: mutation of an interior mutable `const` item with call to `fetch_and`
--> $DIR/const-item-interior-mutations-const-atomics.rs:102:14
|
LL | let _a = A.fetch_and(1, Ordering::SeqCst);
| -^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
| |
| `A` is a interior mutable `const` item of type `AtomicPtr<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
= help: for more details on interior mutability see <https://doc.rust-lang.org/reference/interior-mutability.html>
help: for a shared instance of `A`, consider making it a `static` item instead
|
LL - const A: AtomicPtr<i32> = AtomicPtr::new(std::ptr::null_mut());
LL + static A: AtomicPtr<i32> = AtomicPtr::new(std::ptr::null_mut());
|
warning: mutation of an interior mutable `const` item with call to `fetch_or`
--> $DIR/const-item-interior-mutations-const-atomics.rs:105:14
|
LL | let _a = A.fetch_or(1, Ordering::SeqCst);
| -^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
| |
| `A` is a interior mutable `const` item of type `AtomicPtr<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
= help: for more details on interior mutability see <https://doc.rust-lang.org/reference/interior-mutability.html>
help: for a shared instance of `A`, consider making it a `static` item instead
|
LL - const A: AtomicPtr<i32> = AtomicPtr::new(std::ptr::null_mut());
LL + static A: AtomicPtr<i32> = AtomicPtr::new(std::ptr::null_mut());
|
warning: mutation of an interior mutable `const` item with call to `fetch_xor`
--> $DIR/const-item-interior-mutations-const-atomics.rs:108:14
|
LL | let _a = A.fetch_xor(1, Ordering::SeqCst);
| -^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
| |
| `A` is a interior mutable `const` item of type `AtomicPtr<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
= help: for more details on interior mutability see <https://doc.rust-lang.org/reference/interior-mutability.html>
help: for a shared instance of `A`, consider making it a `static` item instead
|
LL - const A: AtomicPtr<i32> = AtomicPtr::new(std::ptr::null_mut());
LL + static A: AtomicPtr<i32> = AtomicPtr::new(std::ptr::null_mut());
|
warning: mutation of an interior mutable `const` item with call to `store`
--> $DIR/const-item-interior-mutations-const-atomics.rs:115:14
|
LL | let _a = A.store(1, Ordering::SeqCst);
| -^^^^^^^^^^^^^^^^^^^^^^^^^^^
| |
| `A` is a interior mutable `const` item of type `AtomicU32`
|
= note: each usage of a `const` item creates a new temporary
= note: only the temporaries and never the original `const A` will be modified
= help: for more details on interior mutability see <https://doc.rust-lang.org/reference/interior-mutability.html>
help: for a shared instance of `A`, consider making it a `static` item instead
|
LL - const A: AtomicU32 = AtomicU32::new(0);
LL + static A: AtomicU32 = AtomicU32::new(0);
|
warning: mutation of an interior mutable `const` item with call to `swap`
--> $DIR/const-item-interior-mutations-const-atomics.rs:118:14
|
LL | let _a = A.swap(2, Ordering::SeqCst);
| -^^^^^^^^^^^^^^^^^^^^^^^^^^
| |
| `A` is a interior mutable `const` item of type `AtomicU32`
|
= note: each usage of a `const` item creates a new temporary
= note: only the temporaries and never the original `const A` will be modified
= help: for more details on interior mutability see <https://doc.rust-lang.org/reference/interior-mutability.html>
help: for a shared instance of `A`, consider making it a `static` item instead
|
LL - const A: AtomicU32 = AtomicU32::new(0);
LL + static A: AtomicU32 = AtomicU32::new(0);
|
warning: mutation of an interior mutable `const` item with call to `compare_and_swap`
--> $DIR/const-item-interior-mutations-const-atomics.rs:121:14
|
LL | let _a = A.compare_and_swap(2, 3, Ordering::SeqCst);
| -^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
| |
| `A` is a interior mutable `const` item of type `AtomicU32`
|
= note: each usage of a `const` item creates a new temporary
= note: only the temporaries and never the original `const A` will be modified
= help: for more details on interior mutability see <https://doc.rust-lang.org/reference/interior-mutability.html>
help: for a shared instance of `A`, consider making it a `static` item instead
|
LL - const A: AtomicU32 = AtomicU32::new(0);
LL + static A: AtomicU32 = AtomicU32::new(0);
|
warning: mutation of an interior mutable `const` item with call to `compare_exchange`
--> $DIR/const-item-interior-mutations-const-atomics.rs:124:14
|
LL | let _a = A.compare_exchange(3, 4, Ordering::SeqCst, Ordering::Relaxed);
| -^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
| |
| `A` is a interior mutable `const` item of type `AtomicU32`
|
= note: each usage of a `const` item creates a new temporary
= note: only the temporaries and never the original `const A` will be modified
= help: for more details on interior mutability see <https://doc.rust-lang.org/reference/interior-mutability.html>
help: for a shared instance of `A`, consider making it a `static` item instead
|
LL - const A: AtomicU32 = AtomicU32::new(0);
LL + static A: AtomicU32 = AtomicU32::new(0);
|
warning: mutation of an interior mutable `const` item with call to `compare_exchange_weak`
--> $DIR/const-item-interior-mutations-const-atomics.rs:127:14
|
LL | let _a = A.compare_exchange_weak(4, 5, Ordering::SeqCst, Ordering::Relaxed);
| -^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
| |
| `A` is a interior mutable `const` item of type `AtomicU32`
|
= note: each usage of a `const` item creates a new temporary
= note: only the temporaries and never the original `const A` will be modified
= help: for more details on interior mutability see <https://doc.rust-lang.org/reference/interior-mutability.html>
help: for a shared instance of `A`, consider making it a `static` item instead
|
LL - const A: AtomicU32 = AtomicU32::new(0);
LL + static A: AtomicU32 = AtomicU32::new(0);
|
warning: mutation of an interior mutable `const` item with call to `fetch_add`
--> $DIR/const-item-interior-mutations-const-atomics.rs:130:14
|
LL | let _a = A.fetch_add(1, Ordering::SeqCst);
| -^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
| |
| `A` is a interior mutable `const` item of type `AtomicU32`
|
= note: each usage of a `const` item creates a new temporary
= note: only the temporaries and never the original `const A` will be modified
= help: for more details on interior mutability see <https://doc.rust-lang.org/reference/interior-mutability.html>
help: for a shared instance of `A`, consider making it a `static` item instead
|
LL - const A: AtomicU32 = AtomicU32::new(0);
LL + static A: AtomicU32 = AtomicU32::new(0);
|
warning: mutation of an interior mutable `const` item with call to `fetch_sub`
--> $DIR/const-item-interior-mutations-const-atomics.rs:133:14
|
LL | let _a = A.fetch_sub(1, Ordering::SeqCst);
| -^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
| |
| `A` is a interior mutable `const` item of type `AtomicU32`
|
= note: each usage of a `const` item creates a new temporary
= note: only the temporaries and never the original `const A` will be modified
= help: for more details on interior mutability see <https://doc.rust-lang.org/reference/interior-mutability.html>
help: for a shared instance of `A`, consider making it a `static` item instead
|
LL - const A: AtomicU32 = AtomicU32::new(0);
LL + static A: AtomicU32 = AtomicU32::new(0);
|
warning: mutation of an interior mutable `const` item with call to `fetch_add`
--> $DIR/const-item-interior-mutations-const-atomics.rs:136:14
|
LL | let _a = A.fetch_add(2, Ordering::SeqCst);
| -^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
| |
| `A` is a interior mutable `const` item of type `AtomicU32`
|
= note: each usage of a `const` item creates a new temporary
= note: only the temporaries and never the original `const A` will be modified
= help: for more details on interior mutability see <https://doc.rust-lang.org/reference/interior-mutability.html>
help: for a shared instance of `A`, consider making it a `static` item instead
|
LL - const A: AtomicU32 = AtomicU32::new(0);
LL + static A: AtomicU32 = AtomicU32::new(0);
|
warning: mutation of an interior mutable `const` item with call to `fetch_nand`
--> $DIR/const-item-interior-mutations-const-atomics.rs:139:14
|
LL | let _a = A.fetch_nand(1, Ordering::SeqCst);
| -^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
| |
| `A` is a interior mutable `const` item of type `AtomicU32`
|
= note: each usage of a `const` item creates a new temporary
= note: only the temporaries and never the original `const A` will be modified
= help: for more details on interior mutability see <https://doc.rust-lang.org/reference/interior-mutability.html>
help: for a shared instance of `A`, consider making it a `static` item instead
|
LL - const A: AtomicU32 = AtomicU32::new(0);
LL + static A: AtomicU32 = AtomicU32::new(0);
|
warning: mutation of an interior mutable `const` item with call to `fetch_or`
--> $DIR/const-item-interior-mutations-const-atomics.rs:142:14
|
LL | let _a = A.fetch_or(1, Ordering::SeqCst);
| -^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
| |
| `A` is a interior mutable `const` item of type `AtomicU32`
|
= note: each usage of a `const` item creates a new temporary
= note: only the temporaries and never the original `const A` will be modified
= help: for more details on interior mutability see <https://doc.rust-lang.org/reference/interior-mutability.html>
help: for a shared instance of `A`, consider making it a `static` item instead
|
LL - const A: AtomicU32 = AtomicU32::new(0);
LL + static A: AtomicU32 = AtomicU32::new(0);
|
warning: mutation of an interior mutable `const` item with call to `fetch_xor`
--> $DIR/const-item-interior-mutations-const-atomics.rs:145:14
|
LL | let _a = A.fetch_xor(1, Ordering::SeqCst);
| -^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
| |
| `A` is a interior mutable `const` item of type `AtomicU32`
|
= note: each usage of a `const` item creates a new temporary
= note: only the temporaries and never the original `const A` will be modified
= help: for more details on interior mutability see <https://doc.rust-lang.org/reference/interior-mutability.html>
help: for a shared instance of `A`, consider making it a `static` item instead
|
LL - const A: AtomicU32 = AtomicU32::new(0);
LL + static A: AtomicU32 = AtomicU32::new(0);
|
warning: mutation of an interior mutable `const` item with call to `fetch_update`
--> $DIR/const-item-interior-mutations-const-atomics.rs:148:14
|
LL | let _a = A.fetch_update(Ordering::SeqCst, Ordering::Relaxed, |_| Some(10));
| -^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
| |
| `A` is a interior mutable `const` item of type `AtomicU32`
|
= note: each usage of a `const` item creates a new temporary
= note: only the temporaries and never the original `const A` will be modified
= help: for more details on interior mutability see <https://doc.rust-lang.org/reference/interior-mutability.html>
help: for a shared instance of `A`, consider making it a `static` item instead
|
LL - const A: AtomicU32 = AtomicU32::new(0);
LL + static A: AtomicU32 = AtomicU32::new(0);
|
warning: mutation of an interior mutable `const` item with call to `try_update`
--> $DIR/const-item-interior-mutations-const-atomics.rs:151:14
|
LL | let _a = A.try_update(Ordering::SeqCst, Ordering::Relaxed, |_| Some(11));
| -^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
| |
| `A` is a interior mutable `const` item of type `AtomicU32`
|
= note: each usage of a `const` item creates a new temporary
= note: only the temporaries and never the original `const A` will be modified
= help: for more details on interior mutability see <https://doc.rust-lang.org/reference/interior-mutability.html>
help: for a shared instance of `A`, consider making it a `static` item instead
|
LL - const A: AtomicU32 = AtomicU32::new(0);
LL + static A: AtomicU32 = AtomicU32::new(0);
|
warning: mutation of an interior mutable `const` item with call to `update`
--> $DIR/const-item-interior-mutations-const-atomics.rs:154:14
|
LL | let _a = A.update(Ordering::SeqCst, Ordering::Relaxed, |_| 12);
| -^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
| |
| `A` is a interior mutable `const` item of type `AtomicU32`
|
= note: each usage of a `const` item creates a new temporary
= note: only the temporaries and never the original `const A` will be modified
= help: for more details on interior mutability see <https://doc.rust-lang.org/reference/interior-mutability.html>
help: for a shared instance of `A`, consider making it a `static` item instead
|
LL - const A: AtomicU32 = AtomicU32::new(0);
LL + static A: AtomicU32 = AtomicU32::new(0);
|
warning: mutation of an interior mutable `const` item with call to `fetch_max`
--> $DIR/const-item-interior-mutations-const-atomics.rs:157:14
|
LL | let _a = A.fetch_max(20, Ordering::SeqCst);
| -^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
| |
| `A` is a interior mutable `const` item of type `AtomicU32`
|
= note: each usage of a `const` item creates a new temporary
= note: only the temporaries and never the original `const A` will be modified
= help: for more details on interior mutability see <https://doc.rust-lang.org/reference/interior-mutability.html>
help: for a shared instance of `A`, consider making it a `static` item instead
|
LL - const A: AtomicU32 = AtomicU32::new(0);
LL + static A: AtomicU32 = AtomicU32::new(0);
|
warning: mutation of an interior mutable `const` item with call to `fetch_min`
--> $DIR/const-item-interior-mutations-const-atomics.rs:160:14
|
LL | let _a = A.fetch_min(5, Ordering::SeqCst);
| -^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
| |
| `A` is a interior mutable `const` item of type `AtomicU32`
|
= note: each usage of a `const` item creates a new temporary
= note: only the temporaries and never the original `const A` will be modified
= help: for more details on interior mutability see <https://doc.rust-lang.org/reference/interior-mutability.html>
help: for a shared instance of `A`, consider making it a `static` item instead
|
LL - const A: AtomicU32 = AtomicU32::new(0);
LL + static A: AtomicU32 = AtomicU32::new(0);
|
warning: 44 warnings emitted

View file

@ -0,0 +1,105 @@
//@ check-pass
#![feature(unsafe_cell_access)]
#![feature(sync_unsafe_cell)]
#![feature(once_cell_try_insert)]
#![feature(once_cell_try)]
#![feature(lazy_get)]
use std::cell::{Cell, RefCell, SyncUnsafeCell, UnsafeCell};
use std::cell::{LazyCell, OnceCell};
use std::ops::Deref;
fn lazy_cell() {
const A: LazyCell<i32> = LazyCell::new(|| 0);
let _ = LazyCell::force(&A);
//~^ WARN mutation of an interior mutable `const` item with call to `force`
}
fn once_cell() {
const A: OnceCell<i32> = OnceCell::new();
let _ = A.set(10);
//~^ WARN mutation of an interior mutable `const` item with call to `set`
let _ = A.try_insert(20);
//~^ WARN mutation of an interior mutable `const` item with call to `try_insert`
let _ = A.get_or_init(|| 30);
//~^ WARN mutation of an interior mutable `const` item with call to `get_or_init`
let _ = A.get_or_try_init(|| Ok::<_, ()>(40));
//~^ WARN mutation of an interior mutable `const` item with call to `get_or_try_init`
}
fn cell() {
const A: Cell<i32> = Cell::new(0);
let _ = A.set(1);
//~^ WARN mutation of an interior mutable `const` item with call to `set`
let _ = A.swap(&A);
//~^ WARN mutation of an interior mutable `const` item with call to `swap`
let _ = A.replace(2);
//~^ WARN mutation of an interior mutable `const` item with call to `replace`
let _ = A.get();
//~^ WARN mutation of an interior mutable `const` item with call to `get`
let _ = A.update(|x| x + 1);
//~^ WARN mutation of an interior mutable `const` item with call to `update`
}
fn ref_cell() {
const A: RefCell<i32> = RefCell::new(0);
let _ = A.replace(1);
//~^ WARN mutation of an interior mutable `const` item with call to `replace`
let _ = A.replace_with(|x| *x + 2);
//~^ WARN mutation of an interior mutable `const` item with call to `replace_with`
let _ = A.swap(&A);
//~^ WARN mutation of an interior mutable `const` item with call to `swap`
let _ = A.borrow();
//~^ WARN mutation of an interior mutable `const` item with call to `borrow`
let _ = A.try_borrow();
//~^ WARN mutation of an interior mutable `const` item with call to `try_borrow`
let _ = A.borrow_mut();
//~^ WARN mutation of an interior mutable `const` item with call to `borrow_mut`
let _ = A.try_borrow_mut();
//~^ WARN mutation of an interior mutable `const` item with call to `try_borrow_mut`
}
fn unsafe_cell() {
const A: UnsafeCell<i32> = UnsafeCell::new(0);
let _ = unsafe { A.replace(1) };
//~^ WARN mutation of an interior mutable `const` item with call to `replace`
let _ = A.get();
//~^ WARN mutation of an interior mutable `const` item with call to `get`
unsafe {
let _ = A.as_ref_unchecked();
//~^ WARN mutation of an interior mutable `const` item with call to `as_ref_unchecked`
let _ = A.as_mut_unchecked();
//~^ WARN mutation of an interior mutable `const` item with call to `as_mut_unchecked`
}
}
fn sync_unsafe_cell() {
const A: SyncUnsafeCell<i32> = SyncUnsafeCell::new(0);
let _ = A.get();
//~^ WARN mutation of an interior mutable `const` item with call to `get`
}
fn main() {}

View file

@ -0,0 +1,377 @@
warning: mutation of an interior mutable `const` item with call to `force`
--> $DIR/const-item-interior-mutations-const-cell.rs:16:13
|
LL | let _ = LazyCell::force(&A);
| ^^^^^^^^^^^^^^^^^-^
| |
| `A` is a interior mutable `const` item of type `LazyCell<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
= help: for more details on interior mutability see <https://doc.rust-lang.org/reference/interior-mutability.html>
= note: `#[warn(const_item_interior_mutations)]` on by default
help: for a shared instance of `A`, consider making it a `static` item instead
|
LL - const A: LazyCell<i32> = LazyCell::new(|| 0);
LL + static A: LazyCell<i32> = LazyCell::new(|| 0);
|
warning: mutation of an interior mutable `const` item with call to `set`
--> $DIR/const-item-interior-mutations-const-cell.rs:23:13
|
LL | let _ = A.set(10);
| -^^^^^^^^
| |
| `A` is a interior mutable `const` item of type `OnceCell<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
= help: for more details on interior mutability see <https://doc.rust-lang.org/reference/interior-mutability.html>
help: for a shared instance of `A`, consider making it a `static` item instead
|
LL - const A: OnceCell<i32> = OnceCell::new();
LL + static A: OnceCell<i32> = OnceCell::new();
|
warning: mutation of an interior mutable `const` item with call to `try_insert`
--> $DIR/const-item-interior-mutations-const-cell.rs:26:13
|
LL | let _ = A.try_insert(20);
| -^^^^^^^^^^^^^^^
| |
| `A` is a interior mutable `const` item of type `OnceCell<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
= help: for more details on interior mutability see <https://doc.rust-lang.org/reference/interior-mutability.html>
help: for a shared instance of `A`, consider making it a `static` item instead
|
LL - const A: OnceCell<i32> = OnceCell::new();
LL + static A: OnceCell<i32> = OnceCell::new();
|
warning: mutation of an interior mutable `const` item with call to `get_or_init`
--> $DIR/const-item-interior-mutations-const-cell.rs:29:13
|
LL | let _ = A.get_or_init(|| 30);
| -^^^^^^^^^^^^^^^^^^^
| |
| `A` is a interior mutable `const` item of type `OnceCell<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
= help: for more details on interior mutability see <https://doc.rust-lang.org/reference/interior-mutability.html>
help: for a shared instance of `A`, consider making it a `static` item instead
|
LL - const A: OnceCell<i32> = OnceCell::new();
LL + static A: OnceCell<i32> = OnceCell::new();
|
warning: mutation of an interior mutable `const` item with call to `get_or_try_init`
--> $DIR/const-item-interior-mutations-const-cell.rs:32:13
|
LL | let _ = A.get_or_try_init(|| Ok::<_, ()>(40));
| -^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
| |
| `A` is a interior mutable `const` item of type `OnceCell<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
= help: for more details on interior mutability see <https://doc.rust-lang.org/reference/interior-mutability.html>
help: for a shared instance of `A`, consider making it a `static` item instead
|
LL - const A: OnceCell<i32> = OnceCell::new();
LL + static A: OnceCell<i32> = OnceCell::new();
|
warning: mutation of an interior mutable `const` item with call to `set`
--> $DIR/const-item-interior-mutations-const-cell.rs:39:13
|
LL | let _ = A.set(1);
| -^^^^^^^
| |
| `A` is a interior mutable `const` item of type `Cell<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
= help: for more details on interior mutability see <https://doc.rust-lang.org/reference/interior-mutability.html>
help: for a shared instance of `A`, consider making it a `static` item instead
|
LL - const A: Cell<i32> = Cell::new(0);
LL + static A: Cell<i32> = Cell::new(0);
|
warning: mutation of an interior mutable `const` item with call to `swap`
--> $DIR/const-item-interior-mutations-const-cell.rs:42:13
|
LL | let _ = A.swap(&A);
| -^^^^^^^^^
| |
| `A` is a interior mutable `const` item of type `Cell<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
= help: for more details on interior mutability see <https://doc.rust-lang.org/reference/interior-mutability.html>
help: for a shared instance of `A`, consider making it a `static` item instead
|
LL - const A: Cell<i32> = Cell::new(0);
LL + static A: Cell<i32> = Cell::new(0);
|
warning: mutation of an interior mutable `const` item with call to `replace`
--> $DIR/const-item-interior-mutations-const-cell.rs:45:13
|
LL | let _ = A.replace(2);
| -^^^^^^^^^^^
| |
| `A` is a interior mutable `const` item of type `Cell<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
= help: for more details on interior mutability see <https://doc.rust-lang.org/reference/interior-mutability.html>
help: for a shared instance of `A`, consider making it a `static` item instead
|
LL - const A: Cell<i32> = Cell::new(0);
LL + static A: Cell<i32> = Cell::new(0);
|
warning: mutation of an interior mutable `const` item with call to `get`
--> $DIR/const-item-interior-mutations-const-cell.rs:48:13
|
LL | let _ = A.get();
| -^^^^^^
| |
| `A` is a interior mutable `const` item of type `Cell<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
= help: for more details on interior mutability see <https://doc.rust-lang.org/reference/interior-mutability.html>
help: for a shared instance of `A`, consider making it a `static` item instead
|
LL - const A: Cell<i32> = Cell::new(0);
LL + static A: Cell<i32> = Cell::new(0);
|
warning: mutation of an interior mutable `const` item with call to `update`
--> $DIR/const-item-interior-mutations-const-cell.rs:51:13
|
LL | let _ = A.update(|x| x + 1);
| -^^^^^^^^^^^^^^^^^^
| |
| `A` is a interior mutable `const` item of type `Cell<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
= help: for more details on interior mutability see <https://doc.rust-lang.org/reference/interior-mutability.html>
help: for a shared instance of `A`, consider making it a `static` item instead
|
LL - const A: Cell<i32> = Cell::new(0);
LL + static A: Cell<i32> = Cell::new(0);
|
warning: mutation of an interior mutable `const` item with call to `replace`
--> $DIR/const-item-interior-mutations-const-cell.rs:58:13
|
LL | let _ = A.replace(1);
| -^^^^^^^^^^^
| |
| `A` is a interior mutable `const` item of type `RefCell<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
= help: for more details on interior mutability see <https://doc.rust-lang.org/reference/interior-mutability.html>
help: for a shared instance of `A`, consider making it a `static` item instead
|
LL - const A: RefCell<i32> = RefCell::new(0);
LL + static A: RefCell<i32> = RefCell::new(0);
|
warning: mutation of an interior mutable `const` item with call to `replace_with`
--> $DIR/const-item-interior-mutations-const-cell.rs:61:13
|
LL | let _ = A.replace_with(|x| *x + 2);
| -^^^^^^^^^^^^^^^^^^^^^^^^^
| |
| `A` is a interior mutable `const` item of type `RefCell<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
= help: for more details on interior mutability see <https://doc.rust-lang.org/reference/interior-mutability.html>
help: for a shared instance of `A`, consider making it a `static` item instead
|
LL - const A: RefCell<i32> = RefCell::new(0);
LL + static A: RefCell<i32> = RefCell::new(0);
|
warning: mutation of an interior mutable `const` item with call to `swap`
--> $DIR/const-item-interior-mutations-const-cell.rs:64:13
|
LL | let _ = A.swap(&A);
| -^^^^^^^^^
| |
| `A` is a interior mutable `const` item of type `RefCell<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
= help: for more details on interior mutability see <https://doc.rust-lang.org/reference/interior-mutability.html>
help: for a shared instance of `A`, consider making it a `static` item instead
|
LL - const A: RefCell<i32> = RefCell::new(0);
LL + static A: RefCell<i32> = RefCell::new(0);
|
warning: mutation of an interior mutable `const` item with call to `borrow`
--> $DIR/const-item-interior-mutations-const-cell.rs:67:13
|
LL | let _ = A.borrow();
| -^^^^^^^^^
| |
| `A` is a interior mutable `const` item of type `RefCell<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
= help: for more details on interior mutability see <https://doc.rust-lang.org/reference/interior-mutability.html>
help: for a shared instance of `A`, consider making it a `static` item instead
|
LL - const A: RefCell<i32> = RefCell::new(0);
LL + static A: RefCell<i32> = RefCell::new(0);
|
warning: mutation of an interior mutable `const` item with call to `try_borrow`
--> $DIR/const-item-interior-mutations-const-cell.rs:70:13
|
LL | let _ = A.try_borrow();
| -^^^^^^^^^^^^^
| |
| `A` is a interior mutable `const` item of type `RefCell<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
= help: for more details on interior mutability see <https://doc.rust-lang.org/reference/interior-mutability.html>
help: for a shared instance of `A`, consider making it a `static` item instead
|
LL - const A: RefCell<i32> = RefCell::new(0);
LL + static A: RefCell<i32> = RefCell::new(0);
|
warning: mutation of an interior mutable `const` item with call to `borrow_mut`
--> $DIR/const-item-interior-mutations-const-cell.rs:73:13
|
LL | let _ = A.borrow_mut();
| -^^^^^^^^^^^^^
| |
| `A` is a interior mutable `const` item of type `RefCell<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
= help: for more details on interior mutability see <https://doc.rust-lang.org/reference/interior-mutability.html>
help: for a shared instance of `A`, consider making it a `static` item instead
|
LL - const A: RefCell<i32> = RefCell::new(0);
LL + static A: RefCell<i32> = RefCell::new(0);
|
warning: mutation of an interior mutable `const` item with call to `try_borrow_mut`
--> $DIR/const-item-interior-mutations-const-cell.rs:76:13
|
LL | let _ = A.try_borrow_mut();
| -^^^^^^^^^^^^^^^^^
| |
| `A` is a interior mutable `const` item of type `RefCell<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
= help: for more details on interior mutability see <https://doc.rust-lang.org/reference/interior-mutability.html>
help: for a shared instance of `A`, consider making it a `static` item instead
|
LL - const A: RefCell<i32> = RefCell::new(0);
LL + static A: RefCell<i32> = RefCell::new(0);
|
warning: mutation of an interior mutable `const` item with call to `replace`
--> $DIR/const-item-interior-mutations-const-cell.rs:83:22
|
LL | let _ = unsafe { A.replace(1) };
| -^^^^^^^^^^^
| |
| `A` is a interior mutable `const` item of type `UnsafeCell<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
= help: for more details on interior mutability see <https://doc.rust-lang.org/reference/interior-mutability.html>
help: for a shared instance of `A`, consider making it a `static` item instead
|
LL - const A: UnsafeCell<i32> = UnsafeCell::new(0);
LL + static A: UnsafeCell<i32> = UnsafeCell::new(0);
|
warning: mutation of an interior mutable `const` item with call to `get`
--> $DIR/const-item-interior-mutations-const-cell.rs:86:13
|
LL | let _ = A.get();
| -^^^^^^
| |
| `A` is a interior mutable `const` item of type `UnsafeCell<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
= help: for more details on interior mutability see <https://doc.rust-lang.org/reference/interior-mutability.html>
help: for a shared instance of `A`, consider making it a `static` item instead
|
LL - const A: UnsafeCell<i32> = UnsafeCell::new(0);
LL + static A: UnsafeCell<i32> = UnsafeCell::new(0);
|
warning: mutation of an interior mutable `const` item with call to `as_ref_unchecked`
--> $DIR/const-item-interior-mutations-const-cell.rs:90:17
|
LL | let _ = A.as_ref_unchecked();
| -^^^^^^^^^^^^^^^^^^^
| |
| `A` is a interior mutable `const` item of type `UnsafeCell<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
= help: for more details on interior mutability see <https://doc.rust-lang.org/reference/interior-mutability.html>
help: for a shared instance of `A`, consider making it a `static` item instead
|
LL - const A: UnsafeCell<i32> = UnsafeCell::new(0);
LL + static A: UnsafeCell<i32> = UnsafeCell::new(0);
|
warning: mutation of an interior mutable `const` item with call to `as_mut_unchecked`
--> $DIR/const-item-interior-mutations-const-cell.rs:93:17
|
LL | let _ = A.as_mut_unchecked();
| -^^^^^^^^^^^^^^^^^^^
| |
| `A` is a interior mutable `const` item of type `UnsafeCell<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
= help: for more details on interior mutability see <https://doc.rust-lang.org/reference/interior-mutability.html>
help: for a shared instance of `A`, consider making it a `static` item instead
|
LL - const A: UnsafeCell<i32> = UnsafeCell::new(0);
LL + static A: UnsafeCell<i32> = UnsafeCell::new(0);
|
warning: mutation of an interior mutable `const` item with call to `get`
--> $DIR/const-item-interior-mutations-const-cell.rs:101:13
|
LL | let _ = A.get();
| -^^^^^^
| |
| `A` is a interior mutable `const` item of type `SyncUnsafeCell<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
= help: for more details on interior mutability see <https://doc.rust-lang.org/reference/interior-mutability.html>
help: for a shared instance of `A`, consider making it a `static` item instead
|
LL - const A: SyncUnsafeCell<i32> = SyncUnsafeCell::new(0);
LL + static A: SyncUnsafeCell<i32> = SyncUnsafeCell::new(0);
|
warning: 22 warnings emitted

View file

@ -0,0 +1,139 @@
//@ check-pass
//@ run-rustfix
#![allow(deprecated)]
#![allow(dead_code)]
#![feature(lock_value_accessors)]
#![feature(once_cell_try_insert)]
#![feature(once_cell_try)]
#![feature(lazy_get)]
use std::sync::{Condvar, LazyLock, Mutex, Once, OnceLock, RwLock};
use std::time::Duration;
fn mutex() {
static A: Mutex<i32> = Mutex::new(0);
let _a = A.set(1);
//~^ WARN mutation of an interior mutable `const` item with call to `set`
let _a = A.replace(2);
//~^ WARN mutation of an interior mutable `const` item with call to `replace`
drop(A.lock());
//~^ WARN mutation of an interior mutable `const` item with call to `lock`
drop(A.try_lock());
//~^ WARN mutation of an interior mutable `const` item with call to `try_lock`
let _a = A.clear_poison();
//~^ WARN mutation of an interior mutable `const` item with call to `clear_poison`
}
fn once() {
static A: Once = Once::new();
let _a = A.call_once(|| {});
//~^ WARN mutation of an interior mutable `const` item with call to `call_once`
let _a = A.call_once_force(|_| {});
//~^ WARN mutation of an interior mutable `const` item with call to `call_once_force`
let _a = A.wait();
//~^ WARN mutation of an interior mutable `const` item with call to `wait`
let _a = A.wait_force();
//~^ WARN mutation of an interior mutable `const` item with call to `wait_force`
}
fn rwlock() {
static A: RwLock<i32> = RwLock::new(0);
let _a = A.set(1);
//~^ WARN mutation of an interior mutable `const` item with call to `set`
let _a = A.replace(2);
//~^ WARN mutation of an interior mutable `const` item with call to `replace`
drop(A.read());
//~^ WARN mutation of an interior mutable `const` item with call to `read`
drop(A.try_read());
//~^ WARN mutation of an interior mutable `const` item with call to `try_read`
drop(A.write());
//~^ WARN mutation of an interior mutable `const` item with call to `write`
drop(A.try_write());
//~^ WARN mutation of an interior mutable `const` item with call to `try_write`
}
fn lazy_lock() {
static A: LazyLock<i32> = LazyLock::new(|| 0);
let _a = LazyLock::force(&A);
//~^ WARN mutation of an interior mutable `const` item with call to `force`
let _a = LazyLock::get(&A);
//~^ WARN mutation of an interior mutable `const` item with call to `get`
}
fn once_lock() {
static A: OnceLock<i32> = OnceLock::new();
let _a = A.get();
//~^ WARN mutation of an interior mutable `const` item with call to `get`
let _a = A.wait();
//~^ WARN mutation of an interior mutable `const` item with call to `wait`
let _a = A.set(10);
//~^ WARN mutation of an interior mutable `const` item with call to `set`
let _a = A.try_insert(20);
//~^ WARN mutation of an interior mutable `const` item with call to `try_insert`
let _a = A.get_or_init(|| 30);
//~^ WARN mutation of an interior mutable `const` item with call to `get_or_init`
let _a = A.get_or_try_init(|| Ok::<_, ()>(40));
//~^ WARN mutation of an interior mutable `const` item with call to `get_or_try_init`
}
fn condvar() {
static A: Condvar = Condvar::new();
let mutex = Mutex::new(0);
let guard = mutex.lock().unwrap();
let _a = A.wait(guard);
//~^ WARN mutation of an interior mutable `const` item with call to `wait`
let mutex = Mutex::new(0);
let guard = mutex.lock().unwrap();
let _a = A.wait_while(guard, |x| *x == 0);
//~^ WARN mutation of an interior mutable `const` item with call to `wait_while`
let mutex = Mutex::new(0);
let guard = mutex.lock().unwrap();
let _a = A.wait_timeout_ms(guard, 10);
//~^ WARN mutation of an interior mutable `const` item with call to `wait_timeout_ms`
let mutex = Mutex::new(0);
let guard = mutex.lock().unwrap();
let _a = A.wait_timeout(guard, Duration::from_millis(10));
//~^ WARN mutation of an interior mutable `const` item with call to `wait_timeout`
let mutex = Mutex::new(0);
let guard = mutex.lock().unwrap();
let _a = A.wait_timeout_while(guard, Duration::from_millis(10), |x| *x == 0);
//~^ WARN mutation of an interior mutable `const` item with call to `wait_timeout_while`
let _a = A.notify_one();
//~^ WARN mutation of an interior mutable `const` item with call to `notify_one`
let _a = A.notify_all();
//~^ WARN mutation of an interior mutable `const` item with call to `notify_all`
}
fn main() {}

View file

@ -0,0 +1,139 @@
//@ check-pass
//@ run-rustfix
#![allow(deprecated)]
#![allow(dead_code)]
#![feature(lock_value_accessors)]
#![feature(once_cell_try_insert)]
#![feature(once_cell_try)]
#![feature(lazy_get)]
use std::sync::{Condvar, LazyLock, Mutex, Once, OnceLock, RwLock};
use std::time::Duration;
fn mutex() {
const A: Mutex<i32> = Mutex::new(0);
let _a = A.set(1);
//~^ WARN mutation of an interior mutable `const` item with call to `set`
let _a = A.replace(2);
//~^ WARN mutation of an interior mutable `const` item with call to `replace`
drop(A.lock());
//~^ WARN mutation of an interior mutable `const` item with call to `lock`
drop(A.try_lock());
//~^ WARN mutation of an interior mutable `const` item with call to `try_lock`
let _a = A.clear_poison();
//~^ WARN mutation of an interior mutable `const` item with call to `clear_poison`
}
fn once() {
const A: Once = Once::new();
let _a = A.call_once(|| {});
//~^ WARN mutation of an interior mutable `const` item with call to `call_once`
let _a = A.call_once_force(|_| {});
//~^ WARN mutation of an interior mutable `const` item with call to `call_once_force`
let _a = A.wait();
//~^ WARN mutation of an interior mutable `const` item with call to `wait`
let _a = A.wait_force();
//~^ WARN mutation of an interior mutable `const` item with call to `wait_force`
}
fn rwlock() {
const A: RwLock<i32> = RwLock::new(0);
let _a = A.set(1);
//~^ WARN mutation of an interior mutable `const` item with call to `set`
let _a = A.replace(2);
//~^ WARN mutation of an interior mutable `const` item with call to `replace`
drop(A.read());
//~^ WARN mutation of an interior mutable `const` item with call to `read`
drop(A.try_read());
//~^ WARN mutation of an interior mutable `const` item with call to `try_read`
drop(A.write());
//~^ WARN mutation of an interior mutable `const` item with call to `write`
drop(A.try_write());
//~^ WARN mutation of an interior mutable `const` item with call to `try_write`
}
fn lazy_lock() {
const A: LazyLock<i32> = LazyLock::new(|| 0);
let _a = LazyLock::force(&A);
//~^ WARN mutation of an interior mutable `const` item with call to `force`
let _a = LazyLock::get(&A);
//~^ WARN mutation of an interior mutable `const` item with call to `get`
}
fn once_lock() {
const A: OnceLock<i32> = OnceLock::new();
let _a = A.get();
//~^ WARN mutation of an interior mutable `const` item with call to `get`
let _a = A.wait();
//~^ WARN mutation of an interior mutable `const` item with call to `wait`
let _a = A.set(10);
//~^ WARN mutation of an interior mutable `const` item with call to `set`
let _a = A.try_insert(20);
//~^ WARN mutation of an interior mutable `const` item with call to `try_insert`
let _a = A.get_or_init(|| 30);
//~^ WARN mutation of an interior mutable `const` item with call to `get_or_init`
let _a = A.get_or_try_init(|| Ok::<_, ()>(40));
//~^ WARN mutation of an interior mutable `const` item with call to `get_or_try_init`
}
fn condvar() {
const A: Condvar = Condvar::new();
let mutex = Mutex::new(0);
let guard = mutex.lock().unwrap();
let _a = A.wait(guard);
//~^ WARN mutation of an interior mutable `const` item with call to `wait`
let mutex = Mutex::new(0);
let guard = mutex.lock().unwrap();
let _a = A.wait_while(guard, |x| *x == 0);
//~^ WARN mutation of an interior mutable `const` item with call to `wait_while`
let mutex = Mutex::new(0);
let guard = mutex.lock().unwrap();
let _a = A.wait_timeout_ms(guard, 10);
//~^ WARN mutation of an interior mutable `const` item with call to `wait_timeout_ms`
let mutex = Mutex::new(0);
let guard = mutex.lock().unwrap();
let _a = A.wait_timeout(guard, Duration::from_millis(10));
//~^ WARN mutation of an interior mutable `const` item with call to `wait_timeout`
let mutex = Mutex::new(0);
let guard = mutex.lock().unwrap();
let _a = A.wait_timeout_while(guard, Duration::from_millis(10), |x| *x == 0);
//~^ WARN mutation of an interior mutable `const` item with call to `wait_timeout_while`
let _a = A.notify_one();
//~^ WARN mutation of an interior mutable `const` item with call to `notify_one`
let _a = A.notify_all();
//~^ WARN mutation of an interior mutable `const` item with call to `notify_all`
}
fn main() {}

View file

@ -0,0 +1,513 @@
warning: mutation of an interior mutable `const` item with call to `set`
--> $DIR/const-item-interior-mutations-const.rs:17:14
|
LL | let _a = A.set(1);
| -^^^^^^^
| |
| `A` is a interior mutable `const` item of type `std::sync::Mutex<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
= help: for more details on interior mutability see <https://doc.rust-lang.org/reference/interior-mutability.html>
= note: `#[warn(const_item_interior_mutations)]` on by default
help: for a shared instance of `A`, consider making it a `static` item instead
|
LL - const A: Mutex<i32> = Mutex::new(0);
LL + static A: Mutex<i32> = Mutex::new(0);
|
warning: mutation of an interior mutable `const` item with call to `replace`
--> $DIR/const-item-interior-mutations-const.rs:20:14
|
LL | let _a = A.replace(2);
| -^^^^^^^^^^^
| |
| `A` is a interior mutable `const` item of type `std::sync::Mutex<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
= help: for more details on interior mutability see <https://doc.rust-lang.org/reference/interior-mutability.html>
help: for a shared instance of `A`, consider making it a `static` item instead
|
LL - const A: Mutex<i32> = Mutex::new(0);
LL + static A: Mutex<i32> = Mutex::new(0);
|
warning: mutation of an interior mutable `const` item with call to `lock`
--> $DIR/const-item-interior-mutations-const.rs:23:10
|
LL | drop(A.lock());
| -^^^^^^^
| |
| `A` is a interior mutable `const` item of type `std::sync::Mutex<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
= help: for more details on interior mutability see <https://doc.rust-lang.org/reference/interior-mutability.html>
help: for a shared instance of `A`, consider making it a `static` item instead
|
LL - const A: Mutex<i32> = Mutex::new(0);
LL + static A: Mutex<i32> = Mutex::new(0);
|
warning: mutation of an interior mutable `const` item with call to `try_lock`
--> $DIR/const-item-interior-mutations-const.rs:26:10
|
LL | drop(A.try_lock());
| -^^^^^^^^^^^
| |
| `A` is a interior mutable `const` item of type `std::sync::Mutex<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
= help: for more details on interior mutability see <https://doc.rust-lang.org/reference/interior-mutability.html>
help: for a shared instance of `A`, consider making it a `static` item instead
|
LL - const A: Mutex<i32> = Mutex::new(0);
LL + static A: Mutex<i32> = Mutex::new(0);
|
warning: mutation of an interior mutable `const` item with call to `clear_poison`
--> $DIR/const-item-interior-mutations-const.rs:29:14
|
LL | let _a = A.clear_poison();
| -^^^^^^^^^^^^^^^
| |
| `A` is a interior mutable `const` item of type `std::sync::Mutex<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
= help: for more details on interior mutability see <https://doc.rust-lang.org/reference/interior-mutability.html>
help: for a shared instance of `A`, consider making it a `static` item instead
|
LL - const A: Mutex<i32> = Mutex::new(0);
LL + static A: Mutex<i32> = Mutex::new(0);
|
warning: mutation of an interior mutable `const` item with call to `call_once`
--> $DIR/const-item-interior-mutations-const.rs:36:14
|
LL | let _a = A.call_once(|| {});
| -^^^^^^^^^^^^^^^^^
| |
| `A` is a 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
= help: for more details on interior mutability see <https://doc.rust-lang.org/reference/interior-mutability.html>
help: for a shared instance of `A`, consider making it a `static` item instead
|
LL - const A: Once = Once::new();
LL + static A: Once = Once::new();
|
warning: mutation of an interior mutable `const` item with call to `call_once_force`
--> $DIR/const-item-interior-mutations-const.rs:39:14
|
LL | let _a = A.call_once_force(|_| {});
| -^^^^^^^^^^^^^^^^^^^^^^^^
| |
| `A` is a 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
= help: for more details on interior mutability see <https://doc.rust-lang.org/reference/interior-mutability.html>
help: for a shared instance of `A`, consider making it a `static` item instead
|
LL - const A: Once = Once::new();
LL + static A: Once = Once::new();
|
warning: mutation of an interior mutable `const` item with call to `wait`
--> $DIR/const-item-interior-mutations-const.rs:42:14
|
LL | let _a = A.wait();
| -^^^^^^^
| |
| `A` is a 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
= help: for more details on interior mutability see <https://doc.rust-lang.org/reference/interior-mutability.html>
help: for a shared instance of `A`, consider making it a `static` item instead
|
LL - const A: Once = Once::new();
LL + static A: Once = Once::new();
|
warning: mutation of an interior mutable `const` item with call to `wait_force`
--> $DIR/const-item-interior-mutations-const.rs:45:14
|
LL | let _a = A.wait_force();
| -^^^^^^^^^^^^^
| |
| `A` is a 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
= help: for more details on interior mutability see <https://doc.rust-lang.org/reference/interior-mutability.html>
help: for a shared instance of `A`, consider making it a `static` item instead
|
LL - const A: Once = Once::new();
LL + static A: Once = Once::new();
|
warning: mutation of an interior mutable `const` item with call to `set`
--> $DIR/const-item-interior-mutations-const.rs:52:14
|
LL | let _a = A.set(1);
| -^^^^^^^
| |
| `A` is a interior mutable `const` item of type `std::sync::RwLock<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
= help: for more details on interior mutability see <https://doc.rust-lang.org/reference/interior-mutability.html>
help: for a shared instance of `A`, consider making it a `static` item instead
|
LL - const A: RwLock<i32> = RwLock::new(0);
LL + static A: RwLock<i32> = RwLock::new(0);
|
warning: mutation of an interior mutable `const` item with call to `replace`
--> $DIR/const-item-interior-mutations-const.rs:55:14
|
LL | let _a = A.replace(2);
| -^^^^^^^^^^^
| |
| `A` is a interior mutable `const` item of type `std::sync::RwLock<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
= help: for more details on interior mutability see <https://doc.rust-lang.org/reference/interior-mutability.html>
help: for a shared instance of `A`, consider making it a `static` item instead
|
LL - const A: RwLock<i32> = RwLock::new(0);
LL + static A: RwLock<i32> = RwLock::new(0);
|
warning: mutation of an interior mutable `const` item with call to `read`
--> $DIR/const-item-interior-mutations-const.rs:58:10
|
LL | drop(A.read());
| -^^^^^^^
| |
| `A` is a interior mutable `const` item of type `std::sync::RwLock<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
= help: for more details on interior mutability see <https://doc.rust-lang.org/reference/interior-mutability.html>
help: for a shared instance of `A`, consider making it a `static` item instead
|
LL - const A: RwLock<i32> = RwLock::new(0);
LL + static A: RwLock<i32> = RwLock::new(0);
|
warning: mutation of an interior mutable `const` item with call to `try_read`
--> $DIR/const-item-interior-mutations-const.rs:61:10
|
LL | drop(A.try_read());
| -^^^^^^^^^^^
| |
| `A` is a interior mutable `const` item of type `std::sync::RwLock<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
= help: for more details on interior mutability see <https://doc.rust-lang.org/reference/interior-mutability.html>
help: for a shared instance of `A`, consider making it a `static` item instead
|
LL - const A: RwLock<i32> = RwLock::new(0);
LL + static A: RwLock<i32> = RwLock::new(0);
|
warning: mutation of an interior mutable `const` item with call to `write`
--> $DIR/const-item-interior-mutations-const.rs:64:10
|
LL | drop(A.write());
| -^^^^^^^^
| |
| `A` is a interior mutable `const` item of type `std::sync::RwLock<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
= help: for more details on interior mutability see <https://doc.rust-lang.org/reference/interior-mutability.html>
help: for a shared instance of `A`, consider making it a `static` item instead
|
LL - const A: RwLock<i32> = RwLock::new(0);
LL + static A: RwLock<i32> = RwLock::new(0);
|
warning: mutation of an interior mutable `const` item with call to `try_write`
--> $DIR/const-item-interior-mutations-const.rs:67:10
|
LL | drop(A.try_write());
| -^^^^^^^^^^^^
| |
| `A` is a interior mutable `const` item of type `std::sync::RwLock<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
= help: for more details on interior mutability see <https://doc.rust-lang.org/reference/interior-mutability.html>
help: for a shared instance of `A`, consider making it a `static` item instead
|
LL - const A: RwLock<i32> = RwLock::new(0);
LL + static A: RwLock<i32> = RwLock::new(0);
|
warning: mutation of an interior mutable `const` item with call to `force`
--> $DIR/const-item-interior-mutations-const.rs:74:14
|
LL | let _a = LazyLock::force(&A);
| ^^^^^^^^^^^^^^^^^-^
| |
| `A` is a interior mutable `const` item of type `LazyLock<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
= help: for more details on interior mutability see <https://doc.rust-lang.org/reference/interior-mutability.html>
help: for a shared instance of `A`, consider making it a `static` item instead
|
LL - const A: LazyLock<i32> = LazyLock::new(|| 0);
LL + static A: LazyLock<i32> = LazyLock::new(|| 0);
|
warning: mutation of an interior mutable `const` item with call to `get`
--> $DIR/const-item-interior-mutations-const.rs:77:14
|
LL | let _a = LazyLock::get(&A);
| ^^^^^^^^^^^^^^^-^
| |
| `A` is a interior mutable `const` item of type `LazyLock<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
= help: for more details on interior mutability see <https://doc.rust-lang.org/reference/interior-mutability.html>
help: for a shared instance of `A`, consider making it a `static` item instead
|
LL - const A: LazyLock<i32> = LazyLock::new(|| 0);
LL + static A: LazyLock<i32> = LazyLock::new(|| 0);
|
warning: mutation of an interior mutable `const` item with call to `get`
--> $DIR/const-item-interior-mutations-const.rs:84:14
|
LL | let _a = A.get();
| -^^^^^^
| |
| `A` is a interior mutable `const` item of type `OnceLock<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
= help: for more details on interior mutability see <https://doc.rust-lang.org/reference/interior-mutability.html>
help: for a shared instance of `A`, consider making it a `static` item instead
|
LL - const A: OnceLock<i32> = OnceLock::new();
LL + static A: OnceLock<i32> = OnceLock::new();
|
warning: mutation of an interior mutable `const` item with call to `wait`
--> $DIR/const-item-interior-mutations-const.rs:87:14
|
LL | let _a = A.wait();
| -^^^^^^^
| |
| `A` is a interior mutable `const` item of type `OnceLock<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
= help: for more details on interior mutability see <https://doc.rust-lang.org/reference/interior-mutability.html>
help: for a shared instance of `A`, consider making it a `static` item instead
|
LL - const A: OnceLock<i32> = OnceLock::new();
LL + static A: OnceLock<i32> = OnceLock::new();
|
warning: mutation of an interior mutable `const` item with call to `set`
--> $DIR/const-item-interior-mutations-const.rs:90:14
|
LL | let _a = A.set(10);
| -^^^^^^^^
| |
| `A` is a interior mutable `const` item of type `OnceLock<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
= help: for more details on interior mutability see <https://doc.rust-lang.org/reference/interior-mutability.html>
help: for a shared instance of `A`, consider making it a `static` item instead
|
LL - const A: OnceLock<i32> = OnceLock::new();
LL + static A: OnceLock<i32> = OnceLock::new();
|
warning: mutation of an interior mutable `const` item with call to `try_insert`
--> $DIR/const-item-interior-mutations-const.rs:93:14
|
LL | let _a = A.try_insert(20);
| -^^^^^^^^^^^^^^^
| |
| `A` is a interior mutable `const` item of type `OnceLock<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
= help: for more details on interior mutability see <https://doc.rust-lang.org/reference/interior-mutability.html>
help: for a shared instance of `A`, consider making it a `static` item instead
|
LL - const A: OnceLock<i32> = OnceLock::new();
LL + static A: OnceLock<i32> = OnceLock::new();
|
warning: mutation of an interior mutable `const` item with call to `get_or_init`
--> $DIR/const-item-interior-mutations-const.rs:96:14
|
LL | let _a = A.get_or_init(|| 30);
| -^^^^^^^^^^^^^^^^^^^
| |
| `A` is a interior mutable `const` item of type `OnceLock<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
= help: for more details on interior mutability see <https://doc.rust-lang.org/reference/interior-mutability.html>
help: for a shared instance of `A`, consider making it a `static` item instead
|
LL - const A: OnceLock<i32> = OnceLock::new();
LL + static A: OnceLock<i32> = OnceLock::new();
|
warning: mutation of an interior mutable `const` item with call to `get_or_try_init`
--> $DIR/const-item-interior-mutations-const.rs:99:14
|
LL | let _a = A.get_or_try_init(|| Ok::<_, ()>(40));
| -^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
| |
| `A` is a interior mutable `const` item of type `OnceLock<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
= help: for more details on interior mutability see <https://doc.rust-lang.org/reference/interior-mutability.html>
help: for a shared instance of `A`, consider making it a `static` item instead
|
LL - const A: OnceLock<i32> = OnceLock::new();
LL + static A: OnceLock<i32> = OnceLock::new();
|
warning: mutation of an interior mutable `const` item with call to `wait`
--> $DIR/const-item-interior-mutations-const.rs:109:14
|
LL | let _a = A.wait(guard);
| -^^^^^^^^^^^^
| |
| `A` is a 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
= help: for more details on interior mutability see <https://doc.rust-lang.org/reference/interior-mutability.html>
help: for a shared instance of `A`, consider making it a `static` item instead
|
LL - const A: Condvar = Condvar::new();
LL + static A: Condvar = Condvar::new();
|
warning: mutation of an interior mutable `const` item with call to `wait_while`
--> $DIR/const-item-interior-mutations-const.rs:114:14
|
LL | let _a = A.wait_while(guard, |x| *x == 0);
| -^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
| |
| `A` is a 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
= help: for more details on interior mutability see <https://doc.rust-lang.org/reference/interior-mutability.html>
help: for a shared instance of `A`, consider making it a `static` item instead
|
LL - const A: Condvar = Condvar::new();
LL + static A: Condvar = Condvar::new();
|
warning: mutation of an interior mutable `const` item with call to `wait_timeout_ms`
--> $DIR/const-item-interior-mutations-const.rs:119:14
|
LL | let _a = A.wait_timeout_ms(guard, 10);
| -^^^^^^^^^^^^^^^^^^^^^^^^^^^
| |
| `A` is a 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
= help: for more details on interior mutability see <https://doc.rust-lang.org/reference/interior-mutability.html>
help: for a shared instance of `A`, consider making it a `static` item instead
|
LL - const A: Condvar = Condvar::new();
LL + static A: Condvar = Condvar::new();
|
warning: mutation of an interior mutable `const` item with call to `wait_timeout`
--> $DIR/const-item-interior-mutations-const.rs:124:14
|
LL | let _a = A.wait_timeout(guard, Duration::from_millis(10));
| -^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
| |
| `A` is a 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
= help: for more details on interior mutability see <https://doc.rust-lang.org/reference/interior-mutability.html>
help: for a shared instance of `A`, consider making it a `static` item instead
|
LL - const A: Condvar = Condvar::new();
LL + static A: Condvar = Condvar::new();
|
warning: mutation of an interior mutable `const` item with call to `wait_timeout_while`
--> $DIR/const-item-interior-mutations-const.rs:129:14
|
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`
|
= note: each usage of a `const` item creates a new temporary
= note: only the temporaries and never the original `const A` will be modified
= help: for more details on interior mutability see <https://doc.rust-lang.org/reference/interior-mutability.html>
help: for a shared instance of `A`, consider making it a `static` item instead
|
LL - const A: Condvar = Condvar::new();
LL + static A: Condvar = Condvar::new();
|
warning: mutation of an interior mutable `const` item with call to `notify_one`
--> $DIR/const-item-interior-mutations-const.rs:132:14
|
LL | let _a = A.notify_one();
| -^^^^^^^^^^^^^
| |
| `A` is a 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
= help: for more details on interior mutability see <https://doc.rust-lang.org/reference/interior-mutability.html>
help: for a shared instance of `A`, consider making it a `static` item instead
|
LL - const A: Condvar = Condvar::new();
LL + static A: Condvar = Condvar::new();
|
warning: mutation of an interior mutable `const` item with call to `notify_all`
--> $DIR/const-item-interior-mutations-const.rs:135:14
|
LL | let _a = A.notify_all();
| -^^^^^^^^^^^^^
| |
| `A` is a 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
= help: for more details on interior mutability see <https://doc.rust-lang.org/reference/interior-mutability.html>
help: for a shared instance of `A`, consider making it a `static` item instead
|
LL - const A: Condvar = Condvar::new();
LL + static A: Condvar = Condvar::new();
|
warning: 30 warnings emitted