Skip to content

Commit e52c5d0

Browse files
committed
Reword declare_interior_mutable_const and borrow_interior_mutable_const messages to be less assertive.
Update documentation for both lints.
1 parent aecbb28 commit e52c5d0

File tree

7 files changed

+248
-223
lines changed

7 files changed

+248
-223
lines changed

clippy_lints/src/non_copy_const.rs

+132-114
Large diffs are not rendered by default.
Original file line numberDiff line numberDiff line change
@@ -1,55 +1,55 @@
1-
error: a `const` item with interior mutability should not be borrowed
1+
error: borrow of a named constant with interior mutability
22
--> tests/ui/borrow_interior_mutable_const/enums.rs:22:13
33
|
44
LL | let _ = &UNFROZEN_VARIANT;
55
| ^^^^^^^^^^^^^^^^^
66
|
7-
= help: assign this const to a local or static variable, and use the variable here
7+
= help: this lint can be silenced by assigning the value to a local variable before borrowing
88
note: the lint level is defined here
99
--> tests/ui/borrow_interior_mutable_const/enums.rs:3:9
1010
|
1111
LL | #![deny(clippy::borrow_interior_mutable_const)]
1212
| ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
1313

14-
error: a `const` item with interior mutability should not be borrowed
14+
error: borrow of a named constant with interior mutability
1515
--> tests/ui/borrow_interior_mutable_const/enums.rs:50:17
1616
|
1717
LL | let _ = &<Self as AssocConsts>::TO_BE_UNFROZEN_VARIANT;
1818
| ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
1919
|
20-
= help: assign this const to a local or static variable, and use the variable here
20+
= help: this lint can be silenced by assigning the value to a local variable before borrowing
2121

22-
error: a `const` item with interior mutability should not be borrowed
22+
error: borrow of a named constant with interior mutability
2323
--> tests/ui/borrow_interior_mutable_const/enums.rs:52:17
2424
|
2525
LL | let _ = &Self::DEFAULTED_ON_UNFROZEN_VARIANT;
2626
| ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
2727
|
28-
= help: assign this const to a local or static variable, and use the variable here
28+
= help: this lint can be silenced by assigning the value to a local variable before borrowing
2929

30-
error: a `const` item with interior mutability should not be borrowed
30+
error: borrow of a named constant with interior mutability
3131
--> tests/ui/borrow_interior_mutable_const/enums.rs:74:17
3232
|
3333
LL | let _ = &<Self as AssocTypes>::TO_BE_UNFROZEN_VARIANT;
3434
| ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
3535
|
36-
= help: assign this const to a local or static variable, and use the variable here
36+
= help: this lint can be silenced by assigning the value to a local variable before borrowing
3737

38-
error: a `const` item with interior mutability should not be borrowed
38+
error: borrow of a named constant with interior mutability
3939
--> tests/ui/borrow_interior_mutable_const/enums.rs:91:17
4040
|
4141
LL | let _ = &Self::UNFROZEN_VARIANT;
4242
| ^^^^^^^^^^^^^^^^^^^^^^^
4343
|
44-
= help: assign this const to a local or static variable, and use the variable here
44+
= help: this lint can be silenced by assigning the value to a local variable before borrowing
4545

46-
error: a `const` item with interior mutability should not be borrowed
46+
error: borrow of a named constant with interior mutability
4747
--> tests/ui/borrow_interior_mutable_const/enums.rs:99:13
4848
|
4949
LL | let _ = &helper::WRAPPED_PRIVATE_UNFROZEN_VARIANT;
5050
| ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
5151
|
52-
= help: assign this const to a local or static variable, and use the variable here
52+
= help: this lint can be silenced by assigning the value to a local variable before borrowing
5353

5454
error: aborting due to 6 previous errors
5555

Original file line numberDiff line numberDiff line change
@@ -1,127 +1,132 @@
1-
error: a `const` item with interior mutability should not be borrowed
1+
error: borrow of a named constant with interior mutability
22
--> tests/ui/borrow_interior_mutable_const/others.rs:54:5
33
|
44
LL | ATOMIC.store(1, Ordering::SeqCst);
55
| ^^^^^^
66
|
7-
= help: assign this const to a local or static variable, and use the variable here
7+
= help: this lint can be silenced by assigning the value to a local variable before borrowing
8+
= note: there is a compiler inserted borrow here
89
note: the lint level is defined here
910
--> tests/ui/borrow_interior_mutable_const/others.rs:1:9
1011
|
1112
LL | #![deny(clippy::borrow_interior_mutable_const)]
1213
| ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
1314

14-
error: a `const` item with interior mutability should not be borrowed
15+
error: borrow of a named constant with interior mutability
1516
--> tests/ui/borrow_interior_mutable_const/others.rs:55:16
1617
|
1718
LL | assert_eq!(ATOMIC.load(Ordering::SeqCst), 5);
1819
| ^^^^^^
1920
|
20-
= help: assign this const to a local or static variable, and use the variable here
21+
= help: this lint can be silenced by assigning the value to a local variable before borrowing
22+
= note: there is a compiler inserted borrow here
2123

22-
error: a `const` item with interior mutability should not be borrowed
24+
error: borrow of a named constant with interior mutability
2325
--> tests/ui/borrow_interior_mutable_const/others.rs:58:21
2426
|
2527
LL | let _once_ref = &ONCE_INIT;
2628
| ^^^^^^^^^^
2729
|
28-
= help: assign this const to a local or static variable, and use the variable here
30+
= help: this lint can be silenced by assigning the value to a local variable before borrowing
2931

30-
error: a `const` item with interior mutability should not be borrowed
32+
error: borrow of a named constant with interior mutability
3133
--> tests/ui/borrow_interior_mutable_const/others.rs:59:24
3234
|
3335
LL | let _once_ref_2 = &&ONCE_INIT;
3436
| ^^^^^^^^^^
3537
|
36-
= help: assign this const to a local or static variable, and use the variable here
38+
= help: this lint can be silenced by assigning the value to a local variable before borrowing
3739

38-
error: a `const` item with interior mutability should not be borrowed
40+
error: borrow of a named constant with interior mutability
3941
--> tests/ui/borrow_interior_mutable_const/others.rs:60:26
4042
|
4143
LL | let _once_ref_4 = &&&&ONCE_INIT;
4244
| ^^^^^^^^^^
4345
|
44-
= help: assign this const to a local or static variable, and use the variable here
46+
= help: this lint can be silenced by assigning the value to a local variable before borrowing
4547

46-
error: a `const` item with interior mutability should not be borrowed
48+
error: borrow of a named constant with interior mutability
4749
--> tests/ui/borrow_interior_mutable_const/others.rs:61:21
4850
|
4951
LL | let _once_mut = &mut ONCE_INIT;
5052
| ^^^^^^^^^^^^^^
5153
|
52-
= help: assign this const to a local or static variable, and use the variable here
54+
= help: this lint can be silenced by assigning the value to a local variable before borrowing
5355

54-
error: a `const` item with interior mutability should not be borrowed
56+
error: borrow of a named constant with interior mutability
5557
--> tests/ui/borrow_interior_mutable_const/others.rs:72:13
5658
|
5759
LL | let _ = &ATOMIC_TUPLE;
5860
| ^^^^^^^^^^^^^
5961
|
60-
= help: assign this const to a local or static variable, and use the variable here
62+
= help: this lint can be silenced by assigning the value to a local variable before borrowing
6163

62-
error: a `const` item with interior mutability should not be borrowed
64+
error: borrow of a named constant with interior mutability
6365
--> tests/ui/borrow_interior_mutable_const/others.rs:73:13
6466
|
6567
LL | let _ = &ATOMIC_TUPLE.0;
6668
| ^^^^^^^^^^^^^^^
6769
|
68-
= help: assign this const to a local or static variable, and use the variable here
70+
= help: this lint can be silenced by assigning the value to a local variable before borrowing
6971

70-
error: a `const` item with interior mutability should not be borrowed
72+
error: borrow of a named constant with interior mutability
7173
--> tests/ui/borrow_interior_mutable_const/others.rs:74:18
7274
|
7375
LL | let _ = &(&&&&ATOMIC_TUPLE).0;
7476
| ^^^^^^^^^^^^^
7577
|
76-
= help: assign this const to a local or static variable, and use the variable here
78+
= help: this lint can be silenced by assigning the value to a local variable before borrowing
7779

78-
error: a `const` item with interior mutability should not be borrowed
80+
error: borrow of a named constant with interior mutability
7981
--> tests/ui/borrow_interior_mutable_const/others.rs:75:13
8082
|
8183
LL | let _ = &ATOMIC_TUPLE.0[0];
8284
| ^^^^^^^^^^^^^^^^^^
8385
|
84-
= help: assign this const to a local or static variable, and use the variable here
86+
= help: this lint can be silenced by assigning the value to a local variable before borrowing
8587

86-
error: a `const` item with interior mutability should not be borrowed
88+
error: borrow of a named constant with interior mutability
8789
--> tests/ui/borrow_interior_mutable_const/others.rs:76:13
8890
|
8991
LL | let _ = ATOMIC_TUPLE.0[0].load(Ordering::SeqCst);
9092
| ^^^^^^^^^^^^^^^^^
9193
|
92-
= help: assign this const to a local or static variable, and use the variable here
94+
= help: this lint can be silenced by assigning the value to a local variable before borrowing
95+
= note: there is a compiler inserted borrow here
9396

94-
error: a `const` item with interior mutability should not be borrowed
97+
error: borrow of a named constant with interior mutability
9598
--> tests/ui/borrow_interior_mutable_const/others.rs:79:17
9699
|
97100
LL | let _ = (&&&&ATOMIC_TUPLE).0;
98101
| ^^^^^^^^^^^^^
99102
|
100-
= help: assign this const to a local or static variable, and use the variable here
103+
= help: this lint can be silenced by assigning the value to a local variable before borrowing
101104

102-
error: a `const` item with interior mutability should not be borrowed
105+
error: borrow of a named constant with interior mutability
103106
--> tests/ui/borrow_interior_mutable_const/others.rs:80:17
104107
|
105108
LL | let _ = (&&&&ATOMIC_TUPLE).2;
106109
| ^^^^^^^^^^^^^
107110
|
108-
= help: assign this const to a local or static variable, and use the variable here
111+
= help: this lint can be silenced by assigning the value to a local variable before borrowing
109112

110-
error: a `const` item with interior mutability should not be borrowed
113+
error: borrow of a named constant with interior mutability
111114
--> tests/ui/borrow_interior_mutable_const/others.rs:87:5
112115
|
113116
LL | CELL.set(2);
114117
| ^^^^
115118
|
116-
= help: assign this const to a local or static variable, and use the variable here
119+
= help: this lint can be silenced by assigning the value to a local variable before borrowing
120+
= note: there is a compiler inserted borrow here
117121

118-
error: a `const` item with interior mutability should not be borrowed
122+
error: borrow of a named constant with interior mutability
119123
--> tests/ui/borrow_interior_mutable_const/others.rs:88:16
120124
|
121125
LL | assert_eq!(CELL.get(), 6);
122126
| ^^^^
123127
|
124-
= help: assign this const to a local or static variable, and use the variable here
128+
= help: this lint can be silenced by assigning the value to a local variable before borrowing
129+
= note: there is a compiler inserted borrow here
125130

126131
error: aborting due to 15 previous errors
127132

0 commit comments

Comments
 (0)