Skip to content

Commit 03a39ec

Browse files
committed
Revert "replace inline!, a proc-macro, with a MBE"
This reverts commit 0470d0f. `is_from_proc_macro` is just broken..
1 parent 0470d0f commit 03a39ec

File tree

3 files changed

+41
-60
lines changed

3 files changed

+41
-60
lines changed

tests/ui/ptr_as_ptr.fixed

Lines changed: 4 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -3,7 +3,7 @@
33
#![warn(clippy::ptr_as_ptr)]
44

55
extern crate proc_macros;
6-
use proc_macros::{external, with_span};
6+
use proc_macros::{external, inline_macros, with_span};
77

88
mod issue_11278_a {
99
#[derive(Debug)]
@@ -20,6 +20,7 @@ mod issue_11278_b {
2020
}
2121
}
2222

23+
#[inline_macros]
2324
fn main() {
2425
let ptr: *const u32 = &42_u32;
2526
let mut_ptr: *mut u32 = &mut 42_u32;
@@ -52,13 +53,8 @@ fn main() {
5253
//~^ ptr_as_ptr
5354

5455
// Make sure the lint is triggered inside a macro
55-
macro_rules! foo {
56-
() => {
57-
ptr.cast::<i32>()
58-
//~^ ptr_as_ptr
59-
};
60-
};
61-
foo!();
56+
// FIXME: `is_from_proc_macro` incorrectly stops the lint from firing here
57+
let _ = inline!($ptr as *const i32);
6258

6359
// Do not lint inside macros from external crates
6460
let _ = external!($ptr as *const i32);

tests/ui/ptr_as_ptr.rs

Lines changed: 4 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -3,7 +3,7 @@
33
#![warn(clippy::ptr_as_ptr)]
44

55
extern crate proc_macros;
6-
use proc_macros::{external, with_span};
6+
use proc_macros::{external, inline_macros, with_span};
77

88
mod issue_11278_a {
99
#[derive(Debug)]
@@ -20,6 +20,7 @@ mod issue_11278_b {
2020
}
2121
}
2222

23+
#[inline_macros]
2324
fn main() {
2425
let ptr: *const u32 = &42_u32;
2526
let mut_ptr: *mut u32 = &mut 42_u32;
@@ -52,13 +53,8 @@ fn main() {
5253
//~^ ptr_as_ptr
5354

5455
// Make sure the lint is triggered inside a macro
55-
macro_rules! foo {
56-
() => {
57-
ptr as *const i32
58-
//~^ ptr_as_ptr
59-
};
60-
};
61-
foo!();
56+
// FIXME: `is_from_proc_macro` incorrectly stops the lint from firing here
57+
let _ = inline!($ptr as *const i32);
6258

6359
// Do not lint inside macros from external crates
6460
let _ = external!($ptr as *const i32);

tests/ui/ptr_as_ptr.stderr

Lines changed: 33 additions & 44 deletions
Original file line numberDiff line numberDiff line change
@@ -8,207 +8,196 @@ 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 their constness
11-
--> tests/ui/ptr_as_ptr.rs:27:13
11+
--> tests/ui/ptr_as_ptr.rs:28: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 their constness
17-
--> tests/ui/ptr_as_ptr.rs:29:13
17+
--> tests/ui/ptr_as_ptr.rs:30: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 their constness
23-
--> tests/ui/ptr_as_ptr.rs:35:17
23+
--> tests/ui/ptr_as_ptr.rs:36: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 their constness
29-
--> tests/ui/ptr_as_ptr.rs:49:25
29+
--> tests/ui/ptr_as_ptr.rs:50: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 their constness
35-
--> tests/ui/ptr_as_ptr.rs:51:23
35+
--> tests/ui/ptr_as_ptr.rs:52: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 their constness
41-
--> tests/ui/ptr_as_ptr.rs:57:13
42-
|
43-
LL | ptr as *const i32
44-
| ^^^^^^^^^^^^^^^^^ help: try `pointer::cast`, a safer alternative: `ptr.cast::<i32>()`
45-
...
46-
LL | foo!();
47-
| ------ in this macro invocation
48-
|
49-
= note: this error originates in the macro `foo` (in Nightly builds, run with -Z macro-backtrace for more info)
50-
51-
error: `as` casting between raw pointers without changing their constness
52-
--> tests/ui/ptr_as_ptr.rs:84:13
41+
--> tests/ui/ptr_as_ptr.rs:80:13
5342
|
5443
LL | let _ = ptr as *const i32;
5544
| ^^^^^^^^^^^^^^^^^ help: try `pointer::cast`, a safer alternative: `ptr.cast::<i32>()`
5645

5746
error: `as` casting between raw pointers without changing their constness
58-
--> tests/ui/ptr_as_ptr.rs:86:13
47+
--> tests/ui/ptr_as_ptr.rs:82:13
5948
|
6049
LL | let _ = mut_ptr as *mut i32;
6150
| ^^^^^^^^^^^^^^^^^^^ help: try `pointer::cast`, a safer alternative: `mut_ptr.cast::<i32>()`
6251

6352
error: `as` casting between raw pointers without changing their constness
64-
--> tests/ui/ptr_as_ptr.rs:94:9
53+
--> tests/ui/ptr_as_ptr.rs:90:9
6554
|
6655
LL | ptr::null_mut() as *mut u32
6756
| ^^^^^^^^^^^^^^^^^^^^^^^^^^^ help: try call directly: `ptr::null_mut::<u32>()`
6857

6958
error: `as` casting between raw pointers without changing their constness
70-
--> tests/ui/ptr_as_ptr.rs:99:9
59+
--> tests/ui/ptr_as_ptr.rs:95:9
7160
|
7261
LL | std::ptr::null_mut() as *mut u32
7362
| ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ help: try call directly: `std::ptr::null_mut::<u32>()`
7463

7564
error: `as` casting between raw pointers without changing their constness
76-
--> tests/ui/ptr_as_ptr.rs:105:9
65+
--> tests/ui/ptr_as_ptr.rs:101:9
7766
|
7867
LL | ptr::null_mut() as *mut u32
7968
| ^^^^^^^^^^^^^^^^^^^^^^^^^^^ help: try call directly: `ptr::null_mut::<u32>()`
8069

8170
error: `as` casting between raw pointers without changing their constness
82-
--> tests/ui/ptr_as_ptr.rs:110:9
71+
--> tests/ui/ptr_as_ptr.rs:106:9
8372
|
8473
LL | core::ptr::null_mut() as *mut u32
8574
| ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ help: try call directly: `core::ptr::null_mut::<u32>()`
8675

8776
error: `as` casting between raw pointers without changing their constness
88-
--> tests/ui/ptr_as_ptr.rs:116:9
77+
--> tests/ui/ptr_as_ptr.rs:112:9
8978
|
9079
LL | ptr::null() as *const u32
9180
| ^^^^^^^^^^^^^^^^^^^^^^^^^ help: try call directly: `ptr::null::<u32>()`
9281

9382
error: `as` casting between raw pointers without changing their constness
94-
--> tests/ui/ptr_as_ptr.rs:121:9
83+
--> tests/ui/ptr_as_ptr.rs:117:9
9584
|
9685
LL | std::ptr::null() as *const u32
9786
| ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ help: try call directly: `std::ptr::null::<u32>()`
9887

9988
error: `as` casting between raw pointers without changing their constness
100-
--> tests/ui/ptr_as_ptr.rs:127:9
89+
--> tests/ui/ptr_as_ptr.rs:123:9
10190
|
10291
LL | ptr::null() as *const u32
10392
| ^^^^^^^^^^^^^^^^^^^^^^^^^ help: try call directly: `ptr::null::<u32>()`
10493

10594
error: `as` casting between raw pointers without changing their constness
106-
--> tests/ui/ptr_as_ptr.rs:132:9
95+
--> tests/ui/ptr_as_ptr.rs:128:9
10796
|
10897
LL | core::ptr::null() as *const u32
10998
| ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ help: try call directly: `core::ptr::null::<u32>()`
11099

111100
error: `as` casting between raw pointers without changing their constness
112-
--> tests/ui/ptr_as_ptr.rs:140:9
101+
--> tests/ui/ptr_as_ptr.rs:136:9
113102
|
114103
LL | ptr::null_mut() as *mut _
115104
| ^^^^^^^^^^^^^^^^^^^^^^^^^ help: try call directly: `ptr::null_mut()`
116105

117106
error: `as` casting between raw pointers without changing their constness
118-
--> tests/ui/ptr_as_ptr.rs:145:9
107+
--> tests/ui/ptr_as_ptr.rs:141:9
119108
|
120109
LL | std::ptr::null_mut() as *mut _
121110
| ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ help: try call directly: `std::ptr::null_mut()`
122111

123112
error: `as` casting between raw pointers without changing their constness
124-
--> tests/ui/ptr_as_ptr.rs:151:9
113+
--> tests/ui/ptr_as_ptr.rs:147:9
125114
|
126115
LL | ptr::null_mut() as *mut _
127116
| ^^^^^^^^^^^^^^^^^^^^^^^^^ help: try call directly: `ptr::null_mut()`
128117

129118
error: `as` casting between raw pointers without changing their constness
130-
--> tests/ui/ptr_as_ptr.rs:156:9
119+
--> tests/ui/ptr_as_ptr.rs:152:9
131120
|
132121
LL | core::ptr::null_mut() as *mut _
133122
| ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ help: try call directly: `core::ptr::null_mut()`
134123

135124
error: `as` casting between raw pointers without changing their constness
136-
--> tests/ui/ptr_as_ptr.rs:162:9
125+
--> tests/ui/ptr_as_ptr.rs:158:9
137126
|
138127
LL | ptr::null() as *const _
139128
| ^^^^^^^^^^^^^^^^^^^^^^^ help: try call directly: `ptr::null()`
140129

141130
error: `as` casting between raw pointers without changing their constness
142-
--> tests/ui/ptr_as_ptr.rs:167:9
131+
--> tests/ui/ptr_as_ptr.rs:163:9
143132
|
144133
LL | std::ptr::null() as *const _
145134
| ^^^^^^^^^^^^^^^^^^^^^^^^^^^^ help: try call directly: `std::ptr::null()`
146135

147136
error: `as` casting between raw pointers without changing their constness
148-
--> tests/ui/ptr_as_ptr.rs:173:9
137+
--> tests/ui/ptr_as_ptr.rs:169:9
149138
|
150139
LL | ptr::null() as *const _
151140
| ^^^^^^^^^^^^^^^^^^^^^^^ help: try call directly: `ptr::null()`
152141

153142
error: `as` casting between raw pointers without changing their constness
154-
--> tests/ui/ptr_as_ptr.rs:178:9
143+
--> tests/ui/ptr_as_ptr.rs:174:9
155144
|
156145
LL | core::ptr::null() as *const _
157146
| ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ help: try call directly: `core::ptr::null()`
158147

159148
error: `as` casting between raw pointers without changing their constness
160-
--> tests/ui/ptr_as_ptr.rs:186:9
149+
--> tests/ui/ptr_as_ptr.rs:182:9
161150
|
162151
LL | ptr::null_mut() as _
163152
| ^^^^^^^^^^^^^^^^^^^^ help: try call directly: `ptr::null_mut()`
164153

165154
error: `as` casting between raw pointers without changing their constness
166-
--> tests/ui/ptr_as_ptr.rs:191:9
155+
--> tests/ui/ptr_as_ptr.rs:187:9
167156
|
168157
LL | std::ptr::null_mut() as _
169158
| ^^^^^^^^^^^^^^^^^^^^^^^^^ help: try call directly: `std::ptr::null_mut()`
170159

171160
error: `as` casting between raw pointers without changing their constness
172-
--> tests/ui/ptr_as_ptr.rs:197:9
161+
--> tests/ui/ptr_as_ptr.rs:193:9
173162
|
174163
LL | ptr::null_mut() as _
175164
| ^^^^^^^^^^^^^^^^^^^^ help: try call directly: `ptr::null_mut()`
176165

177166
error: `as` casting between raw pointers without changing their constness
178-
--> tests/ui/ptr_as_ptr.rs:202:9
167+
--> tests/ui/ptr_as_ptr.rs:198:9
179168
|
180169
LL | core::ptr::null_mut() as _
181170
| ^^^^^^^^^^^^^^^^^^^^^^^^^^ help: try call directly: `core::ptr::null_mut()`
182171

183172
error: `as` casting between raw pointers without changing their constness
184-
--> tests/ui/ptr_as_ptr.rs:208:9
173+
--> tests/ui/ptr_as_ptr.rs:204:9
185174
|
186175
LL | ptr::null() as _
187176
| ^^^^^^^^^^^^^^^^ help: try call directly: `ptr::null()`
188177

189178
error: `as` casting between raw pointers without changing their constness
190-
--> tests/ui/ptr_as_ptr.rs:213:9
179+
--> tests/ui/ptr_as_ptr.rs:209:9
191180
|
192181
LL | std::ptr::null() as _
193182
| ^^^^^^^^^^^^^^^^^^^^^ help: try call directly: `std::ptr::null()`
194183

195184
error: `as` casting between raw pointers without changing their constness
196-
--> tests/ui/ptr_as_ptr.rs:219:9
185+
--> tests/ui/ptr_as_ptr.rs:215:9
197186
|
198187
LL | ptr::null() as _
199188
| ^^^^^^^^^^^^^^^^ help: try call directly: `ptr::null()`
200189

201190
error: `as` casting between raw pointers without changing their constness
202-
--> tests/ui/ptr_as_ptr.rs:224:9
191+
--> tests/ui/ptr_as_ptr.rs:220:9
203192
|
204193
LL | core::ptr::null() as _
205194
| ^^^^^^^^^^^^^^^^^^^^^^ help: try call directly: `core::ptr::null()`
206195

207196
error: `as` casting between raw pointers without changing their constness
208-
--> tests/ui/ptr_as_ptr.rs:232:43
197+
--> tests/ui/ptr_as_ptr.rs:228:43
209198
|
210199
LL | let _: fn() = std::mem::transmute(std::ptr::null::<()>() as *const u8);
211200
| ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ help: try call directly: `std::ptr::null::<u8>()`
212201

213-
error: aborting due to 34 previous errors
202+
error: aborting due to 33 previous errors
214203

0 commit comments

Comments
 (0)