about summary refs log tree commit diff
diff options
context:
space:
mode:
authorbors <bors@rust-lang.org>2020-11-23 13:26:28 +0000
committerbors <bors@rust-lang.org>2020-11-23 13:26:28 +0000
commit723ac0faf18613f7652583f83854664e1dc6a89b (patch)
treea417c629e00222a023682b73594e29435cdcdd7a
parent3e7c6dec244539970b593824334876f8b6ed0b18 (diff)
parentfaa3e233169523f6bb1537d9b6b2aabe66efd01b (diff)
downloadrust-723ac0faf18613f7652583f83854664e1dc6a89b.tar.gz
rust-723ac0faf18613f7652583f83854664e1dc6a89b.zip
Auto merge of #6317 - chansuke:add-external-macro, r=llogiq
Add exteranal macros for as_conversions

Added external macros to this PR https://github.com/rust-lang/rust-clippy/pull/4888.

r? `@llogiq`

changelog: none
-rw-r--r--tests/ui/as_conversions.rs14
-rw-r--r--tests/ui/as_conversions.stderr6
-rw-r--r--tests/ui/auxiliary/macro_rules.rs14
3 files changed, 30 insertions, 4 deletions
diff --git a/tests/ui/as_conversions.rs b/tests/ui/as_conversions.rs
index e01ba0c64df..cd745feec6d 100644
--- a/tests/ui/as_conversions.rs
+++ b/tests/ui/as_conversions.rs
@@ -1,7 +1,19 @@
-#[warn(clippy::as_conversions)]
+// aux-build:macro_rules.rs
+
+#![warn(clippy::as_conversions)]
+
+#[macro_use]
+extern crate macro_rules;
+
+fn with_external_macro() {
+    as_conv_with_arg!(0u32 as u64);
+    as_conv!();
+}
 
 fn main() {
     let i = 0u32 as u64;
 
     let j = &i as *const u64 as *mut u64;
+
+    with_external_macro();
 }
diff --git a/tests/ui/as_conversions.stderr b/tests/ui/as_conversions.stderr
index 312d3a7460e..f5f75d3aee0 100644
--- a/tests/ui/as_conversions.stderr
+++ b/tests/ui/as_conversions.stderr
@@ -1,5 +1,5 @@
 error: using a potentially dangerous silent `as` conversion
-  --> $DIR/as_conversions.rs:4:13
+  --> $DIR/as_conversions.rs:14:13
    |
 LL |     let i = 0u32 as u64;
    |             ^^^^^^^^^^^
@@ -8,7 +8,7 @@ LL |     let i = 0u32 as u64;
    = help: consider using a safe wrapper for this conversion
 
 error: using a potentially dangerous silent `as` conversion
-  --> $DIR/as_conversions.rs:6:13
+  --> $DIR/as_conversions.rs:16:13
    |
 LL |     let j = &i as *const u64 as *mut u64;
    |             ^^^^^^^^^^^^^^^^^^^^^^^^^^^^
@@ -16,7 +16,7 @@ LL |     let j = &i as *const u64 as *mut u64;
    = help: consider using a safe wrapper for this conversion
 
 error: using a potentially dangerous silent `as` conversion
-  --> $DIR/as_conversions.rs:6:13
+  --> $DIR/as_conversions.rs:16:13
    |
 LL |     let j = &i as *const u64 as *mut u64;
    |             ^^^^^^^^^^^^^^^^
diff --git a/tests/ui/auxiliary/macro_rules.rs b/tests/ui/auxiliary/macro_rules.rs
index 93303865e17..f985a15eda2 100644
--- a/tests/ui/auxiliary/macro_rules.rs
+++ b/tests/ui/auxiliary/macro_rules.rs
@@ -70,3 +70,17 @@ macro_rules! ref_arg_function {
         fn fun_example(ref _x: usize) {}
     };
 }
+
+#[macro_export]
+macro_rules! as_conv_with_arg {
+    (0u32 as u64) => {
+        ()
+    };
+}
+
+#[macro_export]
+macro_rules! as_conv {
+    () => {
+        0u32 as u64
+    };
+}