about summary refs log tree commit diff
path: root/compiler/rustc_borrowck/src/lib.rs
diff options
context:
space:
mode:
authorMichael Goulet <michael@errs.io>2022-08-26 15:56:30 -0700
committerGitHub <noreply@github.com>2022-08-26 15:56:30 -0700
commit96ceadde76e204a269252b1252b916278ecc4ea7 (patch)
tree1bf54b2c1b9b15bbf1e7d4726d50101901b2aed6 /compiler/rustc_borrowck/src/lib.rs
parente7d870b1883f6861e825abf3896110e2a795ccf9 (diff)
parent622217da59ae7b4d1d5128255c9517aeb2174ea6 (diff)
downloadrust-96ceadde76e204a269252b1252b916278ecc4ea7.tar.gz
rust-96ceadde76e204a269252b1252b916278ecc4ea7.zip
Rollup merge of #100900 - AndyJado:diag-migrate, r=davidtwco
on `region_errors.rs`

`@rustbot` label +A-translation
Diffstat (limited to 'compiler/rustc_borrowck/src/lib.rs')
-rw-r--r--compiler/rustc_borrowck/src/lib.rs18
1 files changed, 6 insertions, 12 deletions
diff --git a/compiler/rustc_borrowck/src/lib.rs b/compiler/rustc_borrowck/src/lib.rs
index 4ad9a970bc1..0f8afb038f4 100644
--- a/compiler/rustc_borrowck/src/lib.rs
+++ b/compiler/rustc_borrowck/src/lib.rs
@@ -18,7 +18,7 @@ extern crate tracing;
 
 use rustc_data_structures::fx::{FxHashMap, FxHashSet};
 use rustc_data_structures::graph::dominators::Dominators;
-use rustc_errors::{Applicability, Diagnostic, DiagnosticBuilder, ErrorGuaranteed};
+use rustc_errors::{Diagnostic, DiagnosticBuilder, ErrorGuaranteed};
 use rustc_hir as hir;
 use rustc_hir::def_id::LocalDefId;
 use rustc_index::bit_set::ChunkedBitSet;
@@ -50,6 +50,8 @@ use rustc_mir_dataflow::move_paths::{InitLocation, LookupResult, MoveData, MoveE
 use rustc_mir_dataflow::Analysis;
 use rustc_mir_dataflow::MoveDataParamEnv;
 
+use crate::session_diagnostics::VarNeedNotMut;
+
 use self::diagnostics::{AccessKind, RegionName};
 use self::location::LocationTable;
 use self::prefixes::PrefixSet;
@@ -424,17 +426,9 @@ fn do_mir_borrowck<'a, 'tcx>(
             continue;
         }
 
-        tcx.struct_span_lint_hir(UNUSED_MUT, lint_root, span, |lint| {
-            let mut_span = tcx.sess.source_map().span_until_non_whitespace(span);
-            lint.build("variable does not need to be mutable")
-                .span_suggestion_short(
-                    mut_span,
-                    "remove this `mut`",
-                    "",
-                    Applicability::MachineApplicable,
-                )
-                .emit();
-        })
+        let mut_span = tcx.sess.source_map().span_until_non_whitespace(span);
+
+        tcx.emit_spanned_lint(UNUSED_MUT, lint_root, span, VarNeedNotMut { span: mut_span })
     }
 
     let tainted_by_errors = mbcx.emit_errors();