fix todo item check, remove unimplemented

This commit is contained in:
Mario Carneiro 2023-09-03 17:16:06 +02:00
parent 61a2f972b3
commit 1317378b9e
3 changed files with 13 additions and 4 deletions

View file

@ -7,7 +7,7 @@ use clippy_utils::source::snippet;
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,

View file

@ -391,7 +391,7 @@ pub fn test32() {
panic!("oh no");
}
loop {
// no error
//~^ ERROR: this loop never actually loops
unimplemented!("not yet");
}
loop {

View file

@ -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