]> git.lizzy.rs Git - rust.git/blobdiff - compiler/rustc_mir_build/src/lints.rs
Rollup merge of #105847 - compiler-errors:issue-104396, r=oli-obk
[rust.git] / compiler / rustc_mir_build / src / lints.rs
index 54d549fd66c95b2ce39cf40c8be61858cda61825..8529c64cd5cca64213f3b1efedb38df29c0094b5 100644 (file)
@@ -1,3 +1,4 @@
+use crate::errors::UnconditionalRecursion;
 use rustc_data_structures::graph::iterate::{
     NodeStatus, TriColorDepthFirstSearch, TriColorVisitor,
 };
@@ -36,16 +37,12 @@ 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.emit_spanned_lint(
+            UNCONDITIONAL_RECURSION,
+            hir_id,
+            sp,
+            UnconditionalRecursion { span: sp, call_sites: vis.reachable_recursive_calls },
+        );
     }
 }