This commit is contained in:
Philipp Hansch 2019-01-02 08:15:32 +01:00
parent 0c54913afe
commit c84a894ed7
No known key found for this signature in database
GPG key ID: B6FA06A6E0E2665B
2 changed files with 7 additions and 13 deletions

View file

@ -2,7 +2,9 @@
/// The lints included in `option_methods()` should not lint if the call to map is partially
/// within a macro
macro_rules! opt_map {
($opt:expr, $map:expr) => {($opt).map($map)};
($opt:expr, $map:expr) => {
($opt).map($map)
};
}
/// Struct to generate false positive for Iterator-based lints

View file

@ -18,18 +18,10 @@ fn result_methods() {
// Check RESULT_MAP_UNWRAP_OR_ELSE
// single line case
let _ = res.map(|x| x + 1)
.unwrap_or_else(|e| 0); // should lint even though this call is on a separate line
// multi line cases
let _ = res.map(|x| {
x + 1
}
).unwrap_or_else(|e| 0);
let _ = res.map(|x| x + 1)
.unwrap_or_else(|e|
0
);
let _ = res.map(|x| x + 1).unwrap_or_else(|e| 0); // should lint even though this call is on a separate line
// multi line cases
let _ = res.map(|x| x + 1).unwrap_or_else(|e| 0);
let _ = res.map(|x| x + 1).unwrap_or_else(|e| 0);
// macro case
let _ = opt_map!(res, |x| x + 1).unwrap_or_else(|e| 0); // should not lint
}