|
1 | | -use rustc_errors::{ |
2 | | - struct_span_err, DiagCtxt, DiagnosticBuilder, DiagnosticId, DiagnosticMessage, MultiSpan, |
3 | | -}; |
| 1 | +use rustc_errors::{struct_span_err, DiagCtxt, DiagnosticBuilder}; |
4 | 2 | use rustc_middle::ty::{self, Ty, TyCtxt}; |
5 | 3 | use rustc_span::Span; |
6 | 4 |
|
@@ -260,19 +258,19 @@ impl<'cx, 'tcx> crate::MirBorrowckCtxt<'cx, 'tcx> { |
260 | 258 | is_arg: bool, |
261 | 259 | ) -> DiagnosticBuilder<'cx> { |
262 | 260 | 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) |
264 | 262 | } |
265 | 263 |
|
266 | 264 | 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) |
268 | 266 | } |
269 | 267 |
|
270 | 268 | pub(crate) fn cannot_move_out_of( |
271 | 269 | &self, |
272 | 270 | move_from_span: Span, |
273 | 271 | move_from_desc: &str, |
274 | 272 | ) -> 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) |
276 | 274 | } |
277 | 275 |
|
278 | 276 | /// Signal an error due to an attempt to move out of the interior |
@@ -343,7 +341,7 @@ impl<'cx, 'tcx> crate::MirBorrowckCtxt<'cx, 'tcx> { |
343 | 341 | path: &str, |
344 | 342 | reason: &str, |
345 | 343 | ) -> 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) |
347 | 345 | } |
348 | 346 |
|
349 | 347 | pub(crate) fn cannot_mutate_in_immutable_section( |
@@ -401,7 +399,7 @@ impl<'cx, 'tcx> crate::MirBorrowckCtxt<'cx, 'tcx> { |
401 | 399 | span: Span, |
402 | 400 | path: &str, |
403 | 401 | ) -> 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,) |
405 | 403 | } |
406 | 404 |
|
407 | 405 | pub(crate) fn cannot_return_reference_to_local( |
@@ -453,25 +451,19 @@ impl<'cx, 'tcx> crate::MirBorrowckCtxt<'cx, 'tcx> { |
453 | 451 | &self, |
454 | 452 | span: Span, |
455 | 453 | ) -> 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 | + ) |
457 | 460 | } |
458 | 461 |
|
459 | 462 | pub(crate) fn temporary_value_borrowed_for_too_long( |
460 | 463 | &self, |
461 | 464 | span: Span, |
462 | 465 | ) -> 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",) |
475 | 467 | } |
476 | 468 | } |
477 | 469 |
|
|
0 commit comments