Skip to content

Commit 8af3d8d

Browse files
committed
Remove MirBorrowckCtxt methods that duplicate DiagCtxt methods.
1 parent 99472c7 commit 8af3d8d

File tree

2 files changed

+14
-22
lines changed

2 files changed

+14
-22
lines changed

compiler/rustc_borrowck/src/borrowck_errors.rs

+13-21
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,4 @@
1-
use rustc_errors::{
2-
struct_span_err, DiagCtxt, DiagnosticBuilder, DiagnosticId, DiagnosticMessage, MultiSpan,
3-
};
1+
use rustc_errors::{struct_span_err, DiagCtxt, DiagnosticBuilder};
42
use rustc_middle::ty::{self, Ty, TyCtxt};
53
use rustc_span::Span;
64

@@ -260,19 +258,19 @@ impl<'cx, 'tcx> crate::MirBorrowckCtxt<'cx, 'tcx> {
260258
is_arg: bool,
261259
) -> DiagnosticBuilder<'cx> {
262260
let msg = if is_arg { "to immutable argument" } else { "twice to immutable variable" };
263-
struct_span_err!(self, span, E0384, "cannot assign {} {}", msg, desc)
261+
struct_span_err!(self.dcx(), span, E0384, "cannot assign {} {}", msg, desc)
264262
}
265263

266264
pub(crate) fn cannot_assign(&self, span: Span, desc: &str) -> DiagnosticBuilder<'tcx> {
267-
struct_span_err!(self, span, E0594, "cannot assign to {}", desc)
265+
struct_span_err!(self.dcx(), span, E0594, "cannot assign to {}", desc)
268266
}
269267

270268
pub(crate) fn cannot_move_out_of(
271269
&self,
272270
move_from_span: Span,
273271
move_from_desc: &str,
274272
) -> DiagnosticBuilder<'cx> {
275-
struct_span_err!(self, move_from_span, E0507, "cannot move out of {}", move_from_desc)
273+
struct_span_err!(self.dcx(), move_from_span, E0507, "cannot move out of {}", move_from_desc)
276274
}
277275

278276
/// Signal an error due to an attempt to move out of the interior
@@ -343,7 +341,7 @@ impl<'cx, 'tcx> crate::MirBorrowckCtxt<'cx, 'tcx> {
343341
path: &str,
344342
reason: &str,
345343
) -> DiagnosticBuilder<'tcx> {
346-
struct_span_err!(self, span, E0596, "cannot borrow {} as mutable{}", path, reason,)
344+
struct_span_err!(self.dcx(), span, E0596, "cannot borrow {} as mutable{}", path, reason)
347345
}
348346

349347
pub(crate) fn cannot_mutate_in_immutable_section(
@@ -401,7 +399,7 @@ impl<'cx, 'tcx> crate::MirBorrowckCtxt<'cx, 'tcx> {
401399
span: Span,
402400
path: &str,
403401
) -> DiagnosticBuilder<'tcx> {
404-
struct_span_err!(self, span, E0597, "{} does not live long enough", path,)
402+
struct_span_err!(self.dcx(), span, E0597, "{} does not live long enough", path,)
405403
}
406404

407405
pub(crate) fn cannot_return_reference_to_local(
@@ -453,25 +451,19 @@ impl<'cx, 'tcx> crate::MirBorrowckCtxt<'cx, 'tcx> {
453451
&self,
454452
span: Span,
455453
) -> DiagnosticBuilder<'tcx> {
456-
struct_span_err!(self, span, E0712, "thread-local variable borrowed past end of function",)
454+
struct_span_err!(
455+
self.dcx(),
456+
span,
457+
E0712,
458+
"thread-local variable borrowed past end of function",
459+
)
457460
}
458461

459462
pub(crate) fn temporary_value_borrowed_for_too_long(
460463
&self,
461464
span: Span,
462465
) -> DiagnosticBuilder<'tcx> {
463-
struct_span_err!(self, span, E0716, "temporary value dropped while borrowed",)
464-
}
465-
466-
#[rustc_lint_diagnostics]
467-
#[track_caller]
468-
pub(crate) fn struct_span_err_with_code<S: Into<MultiSpan>>(
469-
&self,
470-
sp: S,
471-
msg: impl Into<DiagnosticMessage>,
472-
code: DiagnosticId,
473-
) -> DiagnosticBuilder<'tcx> {
474-
self.dcx().struct_span_err_with_code(sp, msg, code)
466+
struct_span_err!(self.dcx(), span, E0716, "temporary value dropped while borrowed",)
475467
}
476468
}
477469

compiler/rustc_borrowck/src/diagnostics/conflict_errors.rs

+1-1
Original file line numberDiff line numberDiff line change
@@ -551,7 +551,7 @@ impl<'cx, 'tcx> MirBorrowckCtxt<'cx, 'tcx> {
551551

552552
let used = desired_action.as_general_verb_in_past_tense();
553553
let mut err =
554-
struct_span_err!(self, span, E0381, "{used} binding {desc}{isnt_initialized}");
554+
struct_span_err!(self.dcx(), span, E0381, "{used} binding {desc}{isnt_initialized}");
555555
use_spans.var_path_only_subdiag(&mut err, desired_action);
556556

557557
if let InitializationRequiringAction::PartialAssignment

0 commit comments

Comments
 (0)