Skip to content

Commit 8a1a0de

Browse files
committed
Remove MirBorrowckCtxt methods that duplicate DiagCtxt methods.
1 parent eb0e067 commit 8a1a0de

File tree

2 files changed

+14
-23
lines changed

2 files changed

+14
-23
lines changed

compiler/rustc_borrowck/src/borrowck_errors.rs

+13-22
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,4 @@
1-
use rustc_errors::{
2-
struct_span_err, DiagCtxt, DiagnosticBuilder, DiagnosticId, DiagnosticMessage, ErrorGuaranteed,
3-
MultiSpan,
4-
};
1+
use rustc_errors::{struct_span_err, DiagCtxt, DiagnosticBuilder, ErrorGuaranteed};
52
use rustc_middle::ty::{self, Ty, TyCtxt};
63
use rustc_span::Span;
74

@@ -261,23 +258,23 @@ impl<'cx, 'tcx> crate::MirBorrowckCtxt<'cx, 'tcx> {
261258
is_arg: bool,
262259
) -> DiagnosticBuilder<'cx, ErrorGuaranteed> {
263260
let msg = if is_arg { "to immutable argument" } else { "twice to immutable variable" };
264-
struct_span_err!(self, span, E0384, "cannot assign {} {}", msg, desc)
261+
struct_span_err!(self.dcx(), span, E0384, "cannot assign {} {}", msg, desc)
265262
}
266263

267264
pub(crate) fn cannot_assign(
268265
&self,
269266
span: Span,
270267
desc: &str,
271268
) -> DiagnosticBuilder<'tcx, ErrorGuaranteed> {
272-
struct_span_err!(self, span, E0594, "cannot assign to {}", desc)
269+
struct_span_err!(self.dcx(), span, E0594, "cannot assign to {}", desc)
273270
}
274271

275272
pub(crate) fn cannot_move_out_of(
276273
&self,
277274
move_from_span: Span,
278275
move_from_desc: &str,
279276
) -> DiagnosticBuilder<'cx, ErrorGuaranteed> {
280-
struct_span_err!(self, move_from_span, E0507, "cannot move out of {}", move_from_desc)
277+
struct_span_err!(self.dcx(), move_from_span, E0507, "cannot move out of {}", move_from_desc)
281278
}
282279

283280
/// Signal an error due to an attempt to move out of the interior
@@ -348,7 +345,7 @@ impl<'cx, 'tcx> crate::MirBorrowckCtxt<'cx, 'tcx> {
348345
path: &str,
349346
reason: &str,
350347
) -> DiagnosticBuilder<'tcx, ErrorGuaranteed> {
351-
struct_span_err!(self, span, E0596, "cannot borrow {} as mutable{}", path, reason,)
348+
struct_span_err!(self.dcx(), span, E0596, "cannot borrow {} as mutable{}", path, reason,)
352349
}
353350

354351
pub(crate) fn cannot_mutate_in_immutable_section(
@@ -406,7 +403,7 @@ impl<'cx, 'tcx> crate::MirBorrowckCtxt<'cx, 'tcx> {
406403
span: Span,
407404
path: &str,
408405
) -> DiagnosticBuilder<'tcx, ErrorGuaranteed> {
409-
struct_span_err!(self, span, E0597, "{} does not live long enough", path,)
406+
struct_span_err!(self.dcx(), span, E0597, "{} does not live long enough", path,)
410407
}
411408

412409
pub(crate) fn cannot_return_reference_to_local(
@@ -458,25 +455,19 @@ impl<'cx, 'tcx> crate::MirBorrowckCtxt<'cx, 'tcx> {
458455
&self,
459456
span: Span,
460457
) -> DiagnosticBuilder<'tcx, ErrorGuaranteed> {
461-
struct_span_err!(self, span, E0712, "thread-local variable borrowed past end of function",)
458+
struct_span_err!(
459+
self.dcx(),
460+
span,
461+
E0712,
462+
"thread-local variable borrowed past end of function",
463+
)
462464
}
463465

464466
pub(crate) fn temporary_value_borrowed_for_too_long(
465467
&self,
466468
span: Span,
467469
) -> DiagnosticBuilder<'tcx, ErrorGuaranteed> {
468-
struct_span_err!(self, span, E0716, "temporary value dropped while borrowed",)
469-
}
470-
471-
#[rustc_lint_diagnostics]
472-
#[track_caller]
473-
pub(crate) fn struct_span_err_with_code<S: Into<MultiSpan>>(
474-
&self,
475-
sp: S,
476-
msg: impl Into<DiagnosticMessage>,
477-
code: DiagnosticId,
478-
) -> DiagnosticBuilder<'tcx, ErrorGuaranteed> {
479-
self.dcx().struct_span_err_with_code(sp, msg, code)
470+
struct_span_err!(self.dcx(), span, E0716, "temporary value dropped while borrowed",)
480471
}
481472
}
482473

compiler/rustc_borrowck/src/diagnostics/conflict_errors.rs

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

554554
let used = desired_action.as_general_verb_in_past_tense();
555555
let mut err =
556-
struct_span_err!(self, span, E0381, "{used} binding {desc}{isnt_initialized}");
556+
struct_span_err!(self.dcx(), span, E0381, "{used} binding {desc}{isnt_initialized}");
557557
use_spans.var_path_only_subdiag(&mut err, desired_action);
558558

559559
if let InitializationRequiringAction::PartialAssignment

0 commit comments

Comments
 (0)