mirror of
https://github.com/rust-lang/rust-clippy
synced 2024-11-27 15:11:30 +00:00
Auto merge of #5992 - giraffate:fix_wrong_seggestion_in_collapsible_if, r=yaahc
Fix the wrong suggestion when using macro in `collapsible_if` Fix #5962 changelog: Fix the wrong suggestion when using macro in `collapsible_if`
This commit is contained in:
commit
066f105d67
4 changed files with 22 additions and 2 deletions
|
@ -132,7 +132,11 @@ impl<'a> Sugg<'a> {
|
|||
pub fn ast(cx: &EarlyContext<'_>, expr: &ast::Expr, default: &'a str) -> Self {
|
||||
use rustc_ast::ast::RangeLimits;
|
||||
|
||||
let snippet = snippet(cx, expr.span, default);
|
||||
let snippet = if expr.span.from_expansion() {
|
||||
snippet_with_macro_callsite(cx, expr.span, default)
|
||||
} else {
|
||||
snippet(cx, expr.span, default)
|
||||
};
|
||||
|
||||
match expr.kind {
|
||||
ast::ExprKind::AddrOf(..)
|
||||
|
|
|
@ -135,4 +135,7 @@ fn main() {
|
|||
if truth() {}
|
||||
}
|
||||
}
|
||||
|
||||
// Fix #5962
|
||||
if matches!(true, true) && matches!(true, true) {}
|
||||
}
|
||||
|
|
|
@ -149,4 +149,9 @@ fn main() {
|
|||
if truth() {}
|
||||
}
|
||||
}
|
||||
|
||||
// Fix #5962
|
||||
if matches!(true, true) {
|
||||
if matches!(true, true) {}
|
||||
}
|
||||
}
|
||||
|
|
|
@ -118,5 +118,13 @@ LL | println!("Hello world!");
|
|||
LL | }
|
||||
|
|
||||
|
||||
error: aborting due to 7 previous errors
|
||||
error: this `if` statement can be collapsed
|
||||
--> $DIR/collapsible_if.rs:154:5
|
||||
|
|
||||
LL | / if matches!(true, true) {
|
||||
LL | | if matches!(true, true) {}
|
||||
LL | | }
|
||||
| |_____^ help: collapse nested if block: `if matches!(true, true) && matches!(true, true) {}`
|
||||
|
||||
error: aborting due to 8 previous errors
|
||||
|
||||
|
|
Loading…
Reference in a new issue