Migrate "function cannot return without recursing" diagnostic
This commit is contained in:
parent
65c53c3bb6
commit
82f05446a5
7 changed files with 27 additions and 14 deletions
|
@ -1,3 +1,4 @@
|
|||
use crate::errors::UnconditionalRecursion;
|
||||
use rustc_data_structures::graph::iterate::{
|
||||
NodeStatus, TriColorDepthFirstSearch, TriColorVisitor,
|
||||
};
|
||||
|
@ -36,20 +37,10 @@ pub(crate) fn check<'tcx>(tcx: TyCtxt<'tcx>, body: &Body<'tcx>) {
|
|||
|
||||
let sp = tcx.def_span(def_id);
|
||||
let hir_id = tcx.hir().local_def_id_to_hir_id(def_id);
|
||||
tcx.struct_span_lint_hir(
|
||||
UNCONDITIONAL_RECURSION,
|
||||
hir_id,
|
||||
sp,
|
||||
"function cannot return without recursing",
|
||||
|lint| {
|
||||
lint.span_label(sp, "cannot return without recursing");
|
||||
// offer some help to the programmer.
|
||||
for call_span in vis.reachable_recursive_calls {
|
||||
lint.span_label(call_span, "recursive call site");
|
||||
}
|
||||
lint.help("a `loop` may express intention better if this is on purpose")
|
||||
},
|
||||
);
|
||||
tcx.emit_spanned_lint(UNCONDITIONAL_RECURSION, hir_id, sp, UnconditionalRecursion {
|
||||
span: sp,
|
||||
call_sites: vis.reachable_recursive_calls,
|
||||
});
|
||||
}
|
||||
}
|
||||
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue