From 1317378b9e31306f45ece0be21104a798b4ba73c Mon Sep 17 00:00:00 2001 From: Mario Carneiro Date: Sun, 3 Sep 2023 17:16:06 +0200 Subject: [PATCH] fix todo item check, remove unimplemented --- clippy_lints/src/loops/never_loop.rs | 4 ++-- tests/ui/never_loop.rs | 2 +- tests/ui/never_loop.stderr | 11 ++++++++++- 3 files changed, 13 insertions(+), 4 deletions(-) diff --git a/clippy_lints/src/loops/never_loop.rs b/clippy_lints/src/loops/never_loop.rs index 5845be870d4..7b27c4132de 100644 --- a/clippy_lints/src/loops/never_loop.rs +++ b/clippy_lints/src/loops/never_loop.rs @@ -7,7 +7,7 @@ use rustc_errors::Applicability; use rustc_hir::{Block, Destination, Expr, ExprKind, HirId, InlineAsmOperand, Pat, Stmt, StmtKind}; use rustc_lint::LateContext; -use rustc_span::Span; +use rustc_span::{sym, Span}; use std::iter::{once, Iterator}; pub(super) fn check<'tcx>( @@ -273,7 +273,7 @@ fn never_loop_expr<'tcx>( }); if let NeverLoopResult::Diverging = result && let Some(macro_call) = root_macro_call_first_node(cx, expr) && - let "todo" | "unimplemented" = cx.tcx.item_name(macro_call.def_id).as_str() + let Some(sym::todo_macro) = cx.tcx.get_diagnostic_name(macro_call.def_id) { // We return MayContinueMainLoop here because we treat `todo!()` and // `unimplemented!()` macros as potentially containing any code, diff --git a/tests/ui/never_loop.rs b/tests/ui/never_loop.rs index cee52dfd85b..c67a6d4494e 100644 --- a/tests/ui/never_loop.rs +++ b/tests/ui/never_loop.rs @@ -391,7 +391,7 @@ pub fn test32() { panic!("oh no"); } loop { - // no error + //~^ ERROR: this loop never actually loops unimplemented!("not yet"); } loop { diff --git a/tests/ui/never_loop.stderr b/tests/ui/never_loop.stderr index 37ccd63d27c..50cec32cabd 100644 --- a/tests/ui/never_loop.stderr +++ b/tests/ui/never_loop.stderr @@ -170,5 +170,14 @@ LL | | panic!("oh no"); LL | | } | |_____^ -error: aborting due to 15 previous errors +error: this loop never actually loops + --> $DIR/never_loop.rs:393:5 + | +LL | / loop { +LL | | +LL | | unimplemented!("not yet"); +LL | | } + | |_____^ + +error: aborting due to 16 previous errors