|
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}; |
5 | 2 | use rustc_middle::ty::{self, Ty, TyCtxt};
|
6 | 3 | use rustc_span::Span;
|
7 | 4 |
|
@@ -261,23 +258,23 @@ impl<'cx, 'tcx> crate::MirBorrowckCtxt<'cx, 'tcx> {
|
261 | 258 | is_arg: bool,
|
262 | 259 | ) -> DiagnosticBuilder<'cx, ErrorGuaranteed> {
|
263 | 260 | 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) |
265 | 262 | }
|
266 | 263 |
|
267 | 264 | pub(crate) fn cannot_assign(
|
268 | 265 | &self,
|
269 | 266 | span: Span,
|
270 | 267 | desc: &str,
|
271 | 268 | ) -> 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) |
273 | 270 | }
|
274 | 271 |
|
275 | 272 | pub(crate) fn cannot_move_out_of(
|
276 | 273 | &self,
|
277 | 274 | move_from_span: Span,
|
278 | 275 | move_from_desc: &str,
|
279 | 276 | ) -> 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) |
281 | 278 | }
|
282 | 279 |
|
283 | 280 | /// Signal an error due to an attempt to move out of the interior
|
@@ -348,7 +345,7 @@ impl<'cx, 'tcx> crate::MirBorrowckCtxt<'cx, 'tcx> {
|
348 | 345 | path: &str,
|
349 | 346 | reason: &str,
|
350 | 347 | ) -> 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,) |
352 | 349 | }
|
353 | 350 |
|
354 | 351 | pub(crate) fn cannot_mutate_in_immutable_section(
|
@@ -406,7 +403,7 @@ impl<'cx, 'tcx> crate::MirBorrowckCtxt<'cx, 'tcx> {
|
406 | 403 | span: Span,
|
407 | 404 | path: &str,
|
408 | 405 | ) -> 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,) |
410 | 407 | }
|
411 | 408 |
|
412 | 409 | pub(crate) fn cannot_return_reference_to_local(
|
@@ -458,25 +455,19 @@ impl<'cx, 'tcx> crate::MirBorrowckCtxt<'cx, 'tcx> {
|
458 | 455 | &self,
|
459 | 456 | span: Span,
|
460 | 457 | ) -> 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 | + ) |
462 | 464 | }
|
463 | 465 |
|
464 | 466 | pub(crate) fn temporary_value_borrowed_for_too_long(
|
465 | 467 | &self,
|
466 | 468 | span: Span,
|
467 | 469 | ) -> 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",) |
480 | 471 | }
|
481 | 472 | }
|
482 | 473 |
|
|
0 commit comments