Skip to content

Commit e23b087

Browse files
committed
Auto merge of #6317 - chansuke:add-external-macro, r=llogiq
Add exteranal macros for as_conversions Added external macros to this PR #4888. r? `@llogiq`
2 parents 0402c6a + faa3e23 commit e23b087

File tree

3 files changed

+30
-4
lines changed

3 files changed

+30
-4
lines changed

tests/ui/as_conversions.rs

Lines changed: 13 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,19 @@
1-
#[warn(clippy::as_conversions)]
1+
// aux-build:macro_rules.rs
2+
3+
#![warn(clippy::as_conversions)]
4+
5+
#[macro_use]
6+
extern crate macro_rules;
7+
8+
fn with_external_macro() {
9+
as_conv_with_arg!(0u32 as u64);
10+
as_conv!();
11+
}
212

313
fn main() {
414
let i = 0u32 as u64;
515

616
let j = &i as *const u64 as *mut u64;
17+
18+
with_external_macro();
719
}

tests/ui/as_conversions.stderr

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,5 @@
11
error: using a potentially dangerous silent `as` conversion
2-
--> $DIR/as_conversions.rs:4:13
2+
--> $DIR/as_conversions.rs:14:13
33
|
44
LL | let i = 0u32 as u64;
55
| ^^^^^^^^^^^
@@ -8,15 +8,15 @@ LL | let i = 0u32 as u64;
88
= help: consider using a safe wrapper for this conversion
99

1010
error: using a potentially dangerous silent `as` conversion
11-
--> $DIR/as_conversions.rs:6:13
11+
--> $DIR/as_conversions.rs:16:13
1212
|
1313
LL | let j = &i as *const u64 as *mut u64;
1414
| ^^^^^^^^^^^^^^^^^^^^^^^^^^^^
1515
|
1616
= help: consider using a safe wrapper for this conversion
1717

1818
error: using a potentially dangerous silent `as` conversion
19-
--> $DIR/as_conversions.rs:6:13
19+
--> $DIR/as_conversions.rs:16:13
2020
|
2121
LL | let j = &i as *const u64 as *mut u64;
2222
| ^^^^^^^^^^^^^^^^

tests/ui/auxiliary/macro_rules.rs

Lines changed: 14 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -70,3 +70,17 @@ macro_rules! ref_arg_function {
7070
fn fun_example(ref _x: usize) {}
7171
};
7272
}
73+
74+
#[macro_export]
75+
macro_rules! as_conv_with_arg {
76+
(0u32 as u64) => {
77+
()
78+
};
79+
}
80+
81+
#[macro_export]
82+
macro_rules! as_conv {
83+
() => {
84+
0u32 as u64
85+
};
86+
}

0 commit comments

Comments
 (0)