Diverging subexpression lint should not fire on todo!()
This commit is contained in:
parent
5da97d006e
commit
9732128e83
@ -1,4 +1,5 @@
|
|||||||
use clippy_utils::diagnostics::{span_lint, span_lint_and_then};
|
use clippy_utils::diagnostics::{span_lint, span_lint_and_then};
|
||||||
|
use clippy_utils::macros::root_macro_call_first_node;
|
||||||
use clippy_utils::{get_parent_expr, path_to_local, path_to_local_id};
|
use clippy_utils::{get_parent_expr, path_to_local, path_to_local_id};
|
||||||
use rustc_hir::intravisit::{walk_expr, Visitor};
|
use rustc_hir::intravisit::{walk_expr, Visitor};
|
||||||
use rustc_hir::{BinOpKind, Block, Expr, ExprKind, HirId, LetStmt, Node, Stmt, StmtKind};
|
use rustc_hir::{BinOpKind, Block, Expr, ExprKind, HirId, LetStmt, Node, Stmt, StmtKind};
|
||||||
@ -134,6 +135,11 @@ fn maybe_walk_expr(&mut self, e: &'tcx Expr<'_>) {
|
|||||||
}
|
}
|
||||||
|
|
||||||
fn report_diverging_sub_expr(&mut self, e: &Expr<'_>) {
|
fn report_diverging_sub_expr(&mut self, e: &Expr<'_>) {
|
||||||
|
if let Some(macro_call) = root_macro_call_first_node(self.cx, e) {
|
||||||
|
if self.cx.tcx.item_name(macro_call.def_id).as_str() == "todo" {
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
}
|
||||||
span_lint(self.cx, DIVERGING_SUB_EXPRESSION, e.span, "sub-expression diverges");
|
span_lint(self.cx, DIVERGING_SUB_EXPRESSION, e.span, "sub-expression diverges");
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
@ -67,3 +67,9 @@ fn foobar() {
|
|||||||
};
|
};
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
#[allow(unused)]
|
||||||
|
fn ignore_todo() {
|
||||||
|
let x: u32 = todo!();
|
||||||
|
println!("{x}");
|
||||||
|
}
|
||||||
|
Loading…
Reference in New Issue
Block a user