Auto merge of #4355 - lzutao:macro_expn_try_err, r=flip1995

Fix macro expansion in try_err lint

Fixes #4309

changelog: none
This commit is contained in:
bors 2019-08-08 15:16:17 +00:00
commit 4465e2fbb8
4 changed files with 54 additions and 5 deletions

View file

@ -78,3 +78,22 @@ fn main() {
closure_matches_test().unwrap();
closure_into_test().unwrap();
}
macro_rules! bar {
() => {
String::from("aasdfasdfasdfa")
};
}
macro_rules! foo {
() => {
bar!()
};
}
pub fn macro_inside(fail: bool) -> Result<i32, String> {
if fail {
return Err(foo!());
}
Ok(0)
}

View file

@ -78,3 +78,22 @@ fn main() {
closure_matches_test().unwrap();
closure_into_test().unwrap();
}
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)
}

View file

@ -28,5 +28,11 @@ error: returning an `Err(_)` with the `?` operator
LL | Err(err)?;
| ^^^^^^^^^ help: try this: `return Err(err.into())`
error: aborting due to 4 previous errors
error: returning an `Err(_)` with the `?` operator
--> $DIR/try_err.rs:96:9
|
LL | Err(foo!())?;
| ^^^^^^^^^^^^ help: try this: `return Err(foo!())`
error: aborting due to 5 previous errors