1
1
//! Checks for uses of const which the type is not `Freeze` (`Cell`-free).
2
2
//!
3
- //! This lint is **deny ** by default.
3
+ //! This lint is **warn ** by default.
4
4
5
5
use std:: ptr;
6
6
@@ -17,6 +17,8 @@ use rustc_typeck::hir_ty_to_ty;
17
17
use crate :: utils:: { in_constant, qpath_res, span_lint_and_then} ;
18
18
use if_chain:: if_chain;
19
19
20
+ // FIXME: this is a correctness problem but there's no suitable
21
+ // warn-by-default category.
20
22
declare_clippy_lint ! {
21
23
/// **What it does:** Checks for declaration of `const` items which is interior
22
24
/// mutable (e.g., contains a `Cell`, `Mutex`, `AtomicXxxx`, etc.).
@@ -34,6 +36,15 @@ declare_clippy_lint! {
34
36
/// `std::sync::ONCE_INIT` constant). In this case the use of `const` is legit,
35
37
/// and this lint should be suppressed.
36
38
///
39
+ /// When an enum has variants with interior mutability, use of its non interior mutable
40
+ /// variants can generate false positives. See issue
41
+ /// [#3962](https://github.com/rust-lang/rust-clippy/issues/3962)
42
+ ///
43
+ /// Types that have underlying or potential interior mutability trigger the lint whether
44
+ /// the interior mutable field is used or not. See issues
45
+ /// [#5812](https://github.com/rust-lang/rust-clippy/issues/5812) and
46
+ /// [#3825](https://github.com/rust-lang/rust-clippy/issues/3825)
47
+ ///
37
48
/// **Example:**
38
49
/// ```rust
39
50
/// use std::sync::atomic::{AtomicUsize, Ordering::SeqCst};
@@ -49,10 +60,12 @@ declare_clippy_lint! {
49
60
/// assert_eq!(STATIC_ATOM.load(SeqCst), 9); // use a `static` item to refer to the same instance
50
61
/// ```
51
62
pub DECLARE_INTERIOR_MUTABLE_CONST ,
52
- correctness ,
63
+ style ,
53
64
"declaring `const` with interior mutability"
54
65
}
55
66
67
+ // FIXME: this is a correctness problem but there's no suitable
68
+ // warn-by-default category.
56
69
declare_clippy_lint ! {
57
70
/// **What it does:** Checks if `const` items which is interior mutable (e.g.,
58
71
/// contains a `Cell`, `Mutex`, `AtomicXxxx`, etc.) has been borrowed directly.
@@ -64,7 +77,14 @@ declare_clippy_lint! {
64
77
///
65
78
/// The `const` value should be stored inside a `static` item.
66
79
///
67
- /// **Known problems:** None
80
+ /// **Known problems:** When an enum has variants with interior mutability, use of its non
81
+ /// interior mutable variants can generate false positives. See issue
82
+ /// [#3962](https://github.com/rust-lang/rust-clippy/issues/3962)
83
+ ///
84
+ /// Types that have underlying or potential interior mutability trigger the lint whether
85
+ /// the interior mutable field is used or not. See issues
86
+ /// [#5812](https://github.com/rust-lang/rust-clippy/issues/5812) and
87
+ /// [#3825](https://github.com/rust-lang/rust-clippy/issues/3825)
68
88
///
69
89
/// **Example:**
70
90
/// ```rust
@@ -81,7 +101,7 @@ declare_clippy_lint! {
81
101
/// assert_eq!(STATIC_ATOM.load(SeqCst), 9); // use a `static` item to refer to the same instance
82
102
/// ```
83
103
pub BORROW_INTERIOR_MUTABLE_CONST ,
84
- correctness ,
104
+ style ,
85
105
"referencing `const` with interior mutability"
86
106
}
87
107
0 commit comments