Skip to content

Commit f7050b0

Browse files
committed
resolve code review comments
1 parent 625091d commit f7050b0

File tree

6 files changed

+43
-44
lines changed

6 files changed

+43
-44
lines changed

clippy_lints/src/await_holding_invalid.rs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -15,7 +15,7 @@ declare_clippy_lint! {
1515
/// `MutexGuard`.
1616
///
1717
/// ### Why is this bad?
18-
/// The Mutex types found in [`std::sync`] and
18+
/// The Mutex types found in [`std::sync`][https://doc.rust-lang.org/stable/std/sync/] and
1919
/// [`parking_lot`](https://docs.rs/parking_lot/latest/parking_lot/) are
2020
/// not designed to operate in an async context across await points.
2121
///

clippy_lints/src/casts/mod.rs

Lines changed: 6 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -244,9 +244,9 @@ declare_clippy_lint! {
244244
///
245245
/// ### Why is this bad?
246246
/// Casting a function pointer to anything other than `usize`/`isize` is
247-
/// not portable across architectures. It either loses bits if the target
248-
/// type is too small, or creates extra bits that waste space and bloat the
249-
/// resulting binary.
247+
/// not portable across architectures. If the target type is too small the
248+
/// address would be truncated, and target types larger than `usize` are
249+
/// unnecessary.
250250
///
251251
/// Casting to `isize` also doesn't make sense, since addresses are never
252252
/// signed.
@@ -373,7 +373,7 @@ declare_clippy_lint! {
373373

374374
declare_clippy_lint! {
375375
/// ### What it does
376-
/// Checks for `as` casts on a raw pointer that don't change its
376+
/// Checks for `as` casts between raw pointers that don't change their
377377
/// mutability, namely `*const T` to `*const U` and `*mut T` to `*mut U`.
378378
///
379379
/// ### Why is this bad?
@@ -398,12 +398,12 @@ declare_clippy_lint! {
398398
#[clippy::version = "1.51.0"]
399399
pub PTR_AS_PTR,
400400
pedantic,
401-
"casting using `as` on a raw pointer that doesn't change its mutability, where `pointer::cast` could take the place of `as`"
401+
"casting using `as` between raw pointers that doesn't change their constness, where `pointer::cast` could take the place of `as`"
402402
}
403403

404404
declare_clippy_lint! {
405405
/// ### What it does
406-
/// Checks for `as` casts on a raw pointer that change its constness, namely `*const T` to
406+
/// Checks for `as` casts between raw pointers that change their constness, namely `*const T` to
407407
/// `*mut T` and `*mut T` to `*const T`.
408408
///
409409
/// ### Why is this bad?

clippy_lints/src/casts/ptr_as_ptr.rs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -92,7 +92,7 @@ pub(super) fn check(cx: &LateContext<'_>, expr: &Expr<'_>, msrv: &Msrv) {
9292
cx,
9393
PTR_AS_PTR,
9494
expr.span,
95-
"`as` casting between raw pointers without changing its mutability",
95+
"`as` casting between raw pointers without changing their constness",
9696
help,
9797
final_suggestion,
9898
app,

clippy_lints/src/methods/mod.rs

Lines changed: 1 addition & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -632,8 +632,7 @@ declare_clippy_lint! {
632632
/// or `_.or_else(|x| Err(y))`.
633633
///
634634
/// ### Why is this bad?
635-
/// This can be written more concisely as `_.map(|x| y)` or `_.map_err(|x|
636-
/// y)`.
635+
/// This can be written more concisely as `_.map(|x| y)` or `_.map_err(|x| y)`.
637636
///
638637
/// ### Example
639638
/// ```no_run

tests/ui/crashes/ice-12616.stderr

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,4 @@
1-
error: `as` casting between raw pointers without changing its mutability
1+
error: `as` casting between raw pointers without changing their constness
22
--> tests/ui/crashes/ice-12616.rs:6:5
33
|
44
LL | s() as *const ();

tests/ui/ptr_as_ptr.stderr

Lines changed: 33 additions & 33 deletions
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,4 @@
1-
error: `as` casting between raw pointers without changing its mutability
1+
error: `as` casting between raw pointers without changing their constness
22
--> tests/ui/ptr_as_ptr.rs:18:33
33
|
44
LL | *unsafe { Box::from_raw(Box::into_raw(Box::new(o)) as *mut super::issue_11278_a::T<String>) }
@@ -7,195 +7,195 @@ LL | *unsafe { Box::from_raw(Box::into_raw(Box::new(o)) as *mut super::i
77
= note: `-D clippy::ptr-as-ptr` implied by `-D warnings`
88
= help: to override `-D warnings` add `#[allow(clippy::ptr_as_ptr)]`
99

10-
error: `as` casting between raw pointers without changing its mutability
10+
error: `as` casting between raw pointers without changing their constness
1111
--> tests/ui/ptr_as_ptr.rs:27:13
1212
|
1313
LL | let _ = ptr as *const i32;
1414
| ^^^^^^^^^^^^^^^^^ help: try `pointer::cast`, a safer alternative: `ptr.cast::<i32>()`
1515

16-
error: `as` casting between raw pointers without changing its mutability
16+
error: `as` casting between raw pointers without changing their constness
1717
--> tests/ui/ptr_as_ptr.rs:28:13
1818
|
1919
LL | let _ = mut_ptr as *mut i32;
2020
| ^^^^^^^^^^^^^^^^^^^ help: try `pointer::cast`, a safer alternative: `mut_ptr.cast::<i32>()`
2121

22-
error: `as` casting between raw pointers without changing its mutability
22+
error: `as` casting between raw pointers without changing their constness
2323
--> tests/ui/ptr_as_ptr.rs:33:17
2424
|
2525
LL | let _ = *ptr_ptr as *const i32;
2626
| ^^^^^^^^^^^^^^^^^^^^^^ help: try `pointer::cast`, a safer alternative: `(*ptr_ptr).cast::<i32>()`
2727

28-
error: `as` casting between raw pointers without changing its mutability
28+
error: `as` casting between raw pointers without changing their constness
2929
--> tests/ui/ptr_as_ptr.rs:46:25
3030
|
3131
LL | let _: *const i32 = ptr as *const _;
3232
| ^^^^^^^^^^^^^^^ help: try `pointer::cast`, a safer alternative: `ptr.cast()`
3333

34-
error: `as` casting between raw pointers without changing its mutability
34+
error: `as` casting between raw pointers without changing their constness
3535
--> tests/ui/ptr_as_ptr.rs:47:23
3636
|
3737
LL | let _: *mut i32 = mut_ptr as _;
3838
| ^^^^^^^^^^^^ help: try `pointer::cast`, a safer alternative: `mut_ptr.cast()`
3939

40-
error: `as` casting between raw pointers without changing its mutability
40+
error: `as` casting between raw pointers without changing their constness
4141
--> tests/ui/ptr_as_ptr.rs:50:21
4242
|
4343
LL | let _ = inline!($ptr as *const i32);
4444
| ^^^^^^^^^^^^^^^^^^ help: try `pointer::cast`, a safer alternative: `$ptr.cast::<i32>()`
4545
|
4646
= note: this error originates in the macro `__inline_mac_fn_main` (in Nightly builds, run with -Z macro-backtrace for more info)
4747

48-
error: `as` casting between raw pointers without changing its mutability
48+
error: `as` casting between raw pointers without changing their constness
4949
--> tests/ui/ptr_as_ptr.rs:71:13
5050
|
5151
LL | let _ = ptr as *const i32;
5252
| ^^^^^^^^^^^^^^^^^ help: try `pointer::cast`, a safer alternative: `ptr.cast::<i32>()`
5353

54-
error: `as` casting between raw pointers without changing its mutability
54+
error: `as` casting between raw pointers without changing their constness
5555
--> tests/ui/ptr_as_ptr.rs:72:13
5656
|
5757
LL | let _ = mut_ptr as *mut i32;
5858
| ^^^^^^^^^^^^^^^^^^^ help: try `pointer::cast`, a safer alternative: `mut_ptr.cast::<i32>()`
5959

60-
error: `as` casting between raw pointers without changing its mutability
60+
error: `as` casting between raw pointers without changing their constness
6161
--> tests/ui/ptr_as_ptr.rs:79:9
6262
|
6363
LL | ptr::null_mut() as *mut u32
6464
| ^^^^^^^^^^^^^^^^^^^^^^^^^^^ help: try call directly: `ptr::null_mut::<u32>()`
6565

66-
error: `as` casting between raw pointers without changing its mutability
66+
error: `as` casting between raw pointers without changing their constness
6767
--> tests/ui/ptr_as_ptr.rs:83:9
6868
|
6969
LL | std::ptr::null_mut() as *mut u32
7070
| ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ help: try call directly: `std::ptr::null_mut::<u32>()`
7171

72-
error: `as` casting between raw pointers without changing its mutability
72+
error: `as` casting between raw pointers without changing their constness
7373
--> tests/ui/ptr_as_ptr.rs:88:9
7474
|
7575
LL | ptr::null_mut() as *mut u32
7676
| ^^^^^^^^^^^^^^^^^^^^^^^^^^^ help: try call directly: `ptr::null_mut::<u32>()`
7777

78-
error: `as` casting between raw pointers without changing its mutability
78+
error: `as` casting between raw pointers without changing their constness
7979
--> tests/ui/ptr_as_ptr.rs:92:9
8080
|
8181
LL | core::ptr::null_mut() as *mut u32
8282
| ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ help: try call directly: `core::ptr::null_mut::<u32>()`
8383

84-
error: `as` casting between raw pointers without changing its mutability
84+
error: `as` casting between raw pointers without changing their constness
8585
--> tests/ui/ptr_as_ptr.rs:97:9
8686
|
8787
LL | ptr::null() as *const u32
8888
| ^^^^^^^^^^^^^^^^^^^^^^^^^ help: try call directly: `ptr::null::<u32>()`
8989

90-
error: `as` casting between raw pointers without changing its mutability
90+
error: `as` casting between raw pointers without changing their constness
9191
--> tests/ui/ptr_as_ptr.rs:101:9
9292
|
9393
LL | std::ptr::null() as *const u32
9494
| ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ help: try call directly: `std::ptr::null::<u32>()`
9595

96-
error: `as` casting between raw pointers without changing its mutability
96+
error: `as` casting between raw pointers without changing their constness
9797
--> tests/ui/ptr_as_ptr.rs:106:9
9898
|
9999
LL | ptr::null() as *const u32
100100
| ^^^^^^^^^^^^^^^^^^^^^^^^^ help: try call directly: `ptr::null::<u32>()`
101101

102-
error: `as` casting between raw pointers without changing its mutability
102+
error: `as` casting between raw pointers without changing their constness
103103
--> tests/ui/ptr_as_ptr.rs:110:9
104104
|
105105
LL | core::ptr::null() as *const u32
106106
| ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ help: try call directly: `core::ptr::null::<u32>()`
107107

108-
error: `as` casting between raw pointers without changing its mutability
108+
error: `as` casting between raw pointers without changing their constness
109109
--> tests/ui/ptr_as_ptr.rs:117:9
110110
|
111111
LL | ptr::null_mut() as *mut _
112112
| ^^^^^^^^^^^^^^^^^^^^^^^^^ help: try call directly: `ptr::null_mut()`
113113

114-
error: `as` casting between raw pointers without changing its mutability
114+
error: `as` casting between raw pointers without changing their constness
115115
--> tests/ui/ptr_as_ptr.rs:121:9
116116
|
117117
LL | std::ptr::null_mut() as *mut _
118118
| ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ help: try call directly: `std::ptr::null_mut()`
119119

120-
error: `as` casting between raw pointers without changing its mutability
120+
error: `as` casting between raw pointers without changing their constness
121121
--> tests/ui/ptr_as_ptr.rs:126:9
122122
|
123123
LL | ptr::null_mut() as *mut _
124124
| ^^^^^^^^^^^^^^^^^^^^^^^^^ help: try call directly: `ptr::null_mut()`
125125

126-
error: `as` casting between raw pointers without changing its mutability
126+
error: `as` casting between raw pointers without changing their constness
127127
--> tests/ui/ptr_as_ptr.rs:130:9
128128
|
129129
LL | core::ptr::null_mut() as *mut _
130130
| ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ help: try call directly: `core::ptr::null_mut()`
131131

132-
error: `as` casting between raw pointers without changing its mutability
132+
error: `as` casting between raw pointers without changing their constness
133133
--> tests/ui/ptr_as_ptr.rs:135:9
134134
|
135135
LL | ptr::null() as *const _
136136
| ^^^^^^^^^^^^^^^^^^^^^^^ help: try call directly: `ptr::null()`
137137

138-
error: `as` casting between raw pointers without changing its mutability
138+
error: `as` casting between raw pointers without changing their constness
139139
--> tests/ui/ptr_as_ptr.rs:139:9
140140
|
141141
LL | std::ptr::null() as *const _
142142
| ^^^^^^^^^^^^^^^^^^^^^^^^^^^^ help: try call directly: `std::ptr::null()`
143143

144-
error: `as` casting between raw pointers without changing its mutability
144+
error: `as` casting between raw pointers without changing their constness
145145
--> tests/ui/ptr_as_ptr.rs:144:9
146146
|
147147
LL | ptr::null() as *const _
148148
| ^^^^^^^^^^^^^^^^^^^^^^^ help: try call directly: `ptr::null()`
149149

150-
error: `as` casting between raw pointers without changing its mutability
150+
error: `as` casting between raw pointers without changing their constness
151151
--> tests/ui/ptr_as_ptr.rs:148:9
152152
|
153153
LL | core::ptr::null() as *const _
154154
| ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ help: try call directly: `core::ptr::null()`
155155

156-
error: `as` casting between raw pointers without changing its mutability
156+
error: `as` casting between raw pointers without changing their constness
157157
--> tests/ui/ptr_as_ptr.rs:155:9
158158
|
159159
LL | ptr::null_mut() as _
160160
| ^^^^^^^^^^^^^^^^^^^^ help: try call directly: `ptr::null_mut()`
161161

162-
error: `as` casting between raw pointers without changing its mutability
162+
error: `as` casting between raw pointers without changing their constness
163163
--> tests/ui/ptr_as_ptr.rs:159:9
164164
|
165165
LL | std::ptr::null_mut() as _
166166
| ^^^^^^^^^^^^^^^^^^^^^^^^^ help: try call directly: `std::ptr::null_mut()`
167167

168-
error: `as` casting between raw pointers without changing its mutability
168+
error: `as` casting between raw pointers without changing their constness
169169
--> tests/ui/ptr_as_ptr.rs:164:9
170170
|
171171
LL | ptr::null_mut() as _
172172
| ^^^^^^^^^^^^^^^^^^^^ help: try call directly: `ptr::null_mut()`
173173

174-
error: `as` casting between raw pointers without changing its mutability
174+
error: `as` casting between raw pointers without changing their constness
175175
--> tests/ui/ptr_as_ptr.rs:168:9
176176
|
177177
LL | core::ptr::null_mut() as _
178178
| ^^^^^^^^^^^^^^^^^^^^^^^^^^ help: try call directly: `core::ptr::null_mut()`
179179

180-
error: `as` casting between raw pointers without changing its mutability
180+
error: `as` casting between raw pointers without changing their constness
181181
--> tests/ui/ptr_as_ptr.rs:173:9
182182
|
183183
LL | ptr::null() as _
184184
| ^^^^^^^^^^^^^^^^ help: try call directly: `ptr::null()`
185185

186-
error: `as` casting between raw pointers without changing its mutability
186+
error: `as` casting between raw pointers without changing their constness
187187
--> tests/ui/ptr_as_ptr.rs:177:9
188188
|
189189
LL | std::ptr::null() as _
190190
| ^^^^^^^^^^^^^^^^^^^^^ help: try call directly: `std::ptr::null()`
191191

192-
error: `as` casting between raw pointers without changing its mutability
192+
error: `as` casting between raw pointers without changing their constness
193193
--> tests/ui/ptr_as_ptr.rs:182:9
194194
|
195195
LL | ptr::null() as _
196196
| ^^^^^^^^^^^^^^^^ help: try call directly: `ptr::null()`
197197

198-
error: `as` casting between raw pointers without changing its mutability
198+
error: `as` casting between raw pointers without changing their constness
199199
--> tests/ui/ptr_as_ptr.rs:186:9
200200
|
201201
LL | core::ptr::null() as _

0 commit comments

Comments
 (0)