]> git.lizzy.rs Git - rust.git/blobdiff - tests/ui/try_err.rs
Merge commit '7ea7cd165ad6705603852771bf82cc2fd6560db5' into clippyup2
[rust.git] / tests / ui / try_err.rs
index 828cf639a1b3598c83d8936826f311b206a370c9..5e85d091a2ae73359046f06a82d7e3ce744d9672 100644 (file)
@@ -1,7 +1,11 @@
 // run-rustfix
+// aux-build:macro_rules.rs
 
 #![deny(clippy::try_err)]
 
+#[macro_use]
+extern crate macro_rules;
+
 // Tests that a simple case works
 // Should flag `Err(err)?`
 pub fn basic_test() -> Result<i32, i32> {
@@ -77,4 +81,26 @@ fn main() {
     negative_test().unwrap();
     closure_matches_test().unwrap();
     closure_into_test().unwrap();
+
+    // We don't want to lint in external macros
+    try_err!();
+}
+
+macro_rules! bar {
+    () => {
+        String::from("aasdfasdfasdfa")
+    };
+}
+
+macro_rules! foo {
+    () => {
+        bar!()
+    };
+}
+
+pub fn macro_inside(fail: bool) -> Result<i32, String> {
+    if fail {
+        Err(foo!())?;
+    }
+    Ok(0)
 }