Skip to content
This repository was archived by the owner on May 28, 2025. It is now read-only.

Commit 1317378

Browse files
committed
fix todo item check, remove unimplemented
1 parent 61a2f97 commit 1317378

File tree

3 files changed

+13
-4
lines changed

3 files changed

+13
-4
lines changed

clippy_lints/src/loops/never_loop.rs

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -7,7 +7,7 @@ use clippy_utils::source::snippet;
77
use rustc_errors::Applicability;
88
use rustc_hir::{Block, Destination, Expr, ExprKind, HirId, InlineAsmOperand, Pat, Stmt, StmtKind};
99
use rustc_lint::LateContext;
10-
use rustc_span::Span;
10+
use rustc_span::{sym, Span};
1111
use std::iter::{once, Iterator};
1212

1313
pub(super) fn check<'tcx>(
@@ -273,7 +273,7 @@ fn never_loop_expr<'tcx>(
273273
});
274274
if let NeverLoopResult::Diverging = result &&
275275
let Some(macro_call) = root_macro_call_first_node(cx, expr) &&
276-
let "todo" | "unimplemented" = cx.tcx.item_name(macro_call.def_id).as_str()
276+
let Some(sym::todo_macro) = cx.tcx.get_diagnostic_name(macro_call.def_id)
277277
{
278278
// We return MayContinueMainLoop here because we treat `todo!()` and
279279
// `unimplemented!()` macros as potentially containing any code,

tests/ui/never_loop.rs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -391,7 +391,7 @@ pub fn test32() {
391391
panic!("oh no");
392392
}
393393
loop {
394-
// no error
394+
//~^ ERROR: this loop never actually loops
395395
unimplemented!("not yet");
396396
}
397397
loop {

tests/ui/never_loop.stderr

Lines changed: 10 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -170,5 +170,14 @@ LL | | panic!("oh no");
170170
LL | | }
171171
| |_____^
172172

173-
error: aborting due to 15 previous errors
173+
error: this loop never actually loops
174+
--> $DIR/never_loop.rs:393:5
175+
|
176+
LL | / loop {
177+
LL | |
178+
LL | | unimplemented!("not yet");
179+
LL | | }
180+
| |_____^
181+
182+
error: aborting due to 16 previous errors
174183

0 commit comments

Comments
 (0)