1
Fork 0

Refactor rustc lint API

This commit is contained in:
Maybe Waffle 2022-09-16 11:01:02 +04:00
parent 65445a571c
commit a8f7e244b7
64 changed files with 1760 additions and 1555 deletions

View file

@ -36,16 +36,20 @@ 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, |lint| {
let mut db = lint.build("function cannot return without recursing");
db.span_label(sp, "cannot return without recursing");
// offer some help to the programmer.
for call_span in vis.reachable_recursive_calls {
db.span_label(call_span, "recursive call site");
}
db.help("a `loop` may express intention better if this is on purpose");
db.emit();
});
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")
},
);
}
}