Skip to content

Commit 15f79af

Browse files
committed
Auto merge of #12673 - Luv-Ray:fix-ptr-as-ptr-duplicate-errors, r=blyxyas
[`ptr_as_ptr`]: Fix duplicate diagnostics Relates to #12379 `ptr_as_ptr::check` is called twice in `clippy_lints/src/casts/mod.rs` --- changelog: [`ptr_as_ptr`]: Fix duplicate diagnostics
2 parents 7063e34 + c64342c commit 15f79af

File tree

5 files changed

+34
-45
lines changed

5 files changed

+34
-45
lines changed

Diff for: clippy_lints/src/casts/mod.rs

-1
Original file line numberDiff line numberDiff line change
@@ -757,7 +757,6 @@ impl<'tcx> LateLintPass<'tcx> for Casts {
757757
if in_external_macro(cx.sess(), expr.span) {
758758
return;
759759
}
760-
ptr_as_ptr::check(cx, expr, &self.msrv);
761760

762761
if let ExprKind::Cast(cast_expr, cast_to_hir) = expr.kind {
763762
if is_hir_ty_cfg_dependant(cx, cast_to_hir) {

Diff for: tests/ui/crashes/ice-12616.stderr

+1-9
Original file line numberDiff line numberDiff line change
@@ -7,13 +7,5 @@ LL | s() as *const ();
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
11-
--> tests/ui/crashes/ice-12616.rs:6:5
12-
|
13-
LL | s() as *const ();
14-
| ^^^^^^^^^^^^^^^^ help: try `pointer::cast`, a safer alternative: `s().cast::<()>()`
15-
|
16-
= note: duplicate diagnostic emitted due to `-Z deduplicate-diagnostics=no`
17-
18-
error: aborting due to 2 previous errors
10+
error: aborting due to 1 previous error
1911

Diff for: tests/ui/ptr_as_ptr.fixed

-1
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,4 @@
11
//@aux-build:proc_macros.rs
2-
//@compile-flags: -Zdeduplicate-diagnostics=yes
32

43
#![warn(clippy::ptr_as_ptr)]
54

Diff for: tests/ui/ptr_as_ptr.rs

-1
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,4 @@
11
//@aux-build:proc_macros.rs
2-
//@compile-flags: -Zdeduplicate-diagnostics=yes
32

43
#![warn(clippy::ptr_as_ptr)]
54

Diff for: tests/ui/ptr_as_ptr.stderr

+33-33
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,5 @@
11
error: `as` casting between raw pointers without changing its mutability
2-
--> tests/ui/ptr_as_ptr.rs:19:33
2+
--> 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>) }
55
| ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ help: try `pointer::cast`, a safer alternative: `Box::into_raw(Box::new(o)).cast::<super::issue_11278_a::T<String>>()`
@@ -8,195 +8,195 @@ LL | *unsafe { Box::from_raw(Box::into_raw(Box::new(o)) as *mut super::i
88
= help: to override `-D warnings` add `#[allow(clippy::ptr_as_ptr)]`
99

1010
error: `as` casting between raw pointers without changing its mutability
11-
--> tests/ui/ptr_as_ptr.rs:28:13
11+
--> 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

1616
error: `as` casting between raw pointers without changing its mutability
17-
--> tests/ui/ptr_as_ptr.rs:29:13
17+
--> 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

2222
error: `as` casting between raw pointers without changing its mutability
23-
--> tests/ui/ptr_as_ptr.rs:34:17
23+
--> 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

2828
error: `as` casting between raw pointers without changing its mutability
29-
--> tests/ui/ptr_as_ptr.rs:47:25
29+
--> 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

3434
error: `as` casting between raw pointers without changing its mutability
35-
--> tests/ui/ptr_as_ptr.rs:48:23
35+
--> 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

4040
error: `as` casting between raw pointers without changing its mutability
41-
--> tests/ui/ptr_as_ptr.rs:51:21
41+
--> 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

4848
error: `as` casting between raw pointers without changing its mutability
49-
--> tests/ui/ptr_as_ptr.rs:72:13
49+
--> 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

5454
error: `as` casting between raw pointers without changing its mutability
55-
--> tests/ui/ptr_as_ptr.rs:73:13
55+
--> 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

6060
error: `as` casting between raw pointers without changing its mutability
61-
--> tests/ui/ptr_as_ptr.rs:80:9
61+
--> 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

6666
error: `as` casting between raw pointers without changing its mutability
67-
--> tests/ui/ptr_as_ptr.rs:84:9
67+
--> 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

7272
error: `as` casting between raw pointers without changing its mutability
73-
--> tests/ui/ptr_as_ptr.rs:89:9
73+
--> 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

7878
error: `as` casting between raw pointers without changing its mutability
79-
--> tests/ui/ptr_as_ptr.rs:93:9
79+
--> 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

8484
error: `as` casting between raw pointers without changing its mutability
85-
--> tests/ui/ptr_as_ptr.rs:98:9
85+
--> 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

9090
error: `as` casting between raw pointers without changing its mutability
91-
--> tests/ui/ptr_as_ptr.rs:102:9
91+
--> 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

9696
error: `as` casting between raw pointers without changing its mutability
97-
--> tests/ui/ptr_as_ptr.rs:107:9
97+
--> 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

102102
error: `as` casting between raw pointers without changing its mutability
103-
--> tests/ui/ptr_as_ptr.rs:111:9
103+
--> 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

108108
error: `as` casting between raw pointers without changing its mutability
109-
--> tests/ui/ptr_as_ptr.rs:118:9
109+
--> 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

114114
error: `as` casting between raw pointers without changing its mutability
115-
--> tests/ui/ptr_as_ptr.rs:122:9
115+
--> 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

120120
error: `as` casting between raw pointers without changing its mutability
121-
--> tests/ui/ptr_as_ptr.rs:127:9
121+
--> 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

126126
error: `as` casting between raw pointers without changing its mutability
127-
--> tests/ui/ptr_as_ptr.rs:131:9
127+
--> 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

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

138138
error: `as` casting between raw pointers without changing its mutability
139-
--> tests/ui/ptr_as_ptr.rs:140:9
139+
--> 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

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

150150
error: `as` casting between raw pointers without changing its mutability
151-
--> tests/ui/ptr_as_ptr.rs:149:9
151+
--> 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

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

162162
error: `as` casting between raw pointers without changing its mutability
163-
--> tests/ui/ptr_as_ptr.rs:160:9
163+
--> 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

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

174174
error: `as` casting between raw pointers without changing its mutability
175-
--> tests/ui/ptr_as_ptr.rs:169:9
175+
--> 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

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

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

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

198198
error: `as` casting between raw pointers without changing its mutability
199-
--> tests/ui/ptr_as_ptr.rs:187:9
199+
--> tests/ui/ptr_as_ptr.rs:186:9
200200
|
201201
LL | core::ptr::null() as _
202202
| ^^^^^^^^^^^^^^^^^^^^^^ help: try call directly: `core::ptr::null()`

0 commit comments

Comments
 (0)