diff options
| author | bors <bors@rust-lang.org> | 2024-01-10 18:03:53 +0000 |
|---|---|---|
| committer | bors <bors@rust-lang.org> | 2024-01-10 18:03:53 +0000 |
| commit | a2d9d73e608f1b24eba840c4fd2d68dbe3b65e01 (patch) | |
| tree | 42523e01769059455f89af632b53b841b1401d69 /compiler/rustc_middle/src | |
| parent | e9271846294c4ee5bd7706df68180320c0b5ff20 (diff) | |
| parent | 700a3965202f4f403956fcce744ce5ba6adf2ddb (diff) | |
| download | rust-a2d9d73e608f1b24eba840c4fd2d68dbe3b65e01.tar.gz rust-a2d9d73e608f1b24eba840c4fd2d68dbe3b65e01.zip | |
Auto merge of #119751 - nnethercote:error-api-fixes, r=oli-obk
Diagnostic API fixes Some improvements to diagnostic APIs: improve some naming, use shortcuts in more places, and add a couple of missing methods. r? `@compiler-errors`
Diffstat (limited to 'compiler/rustc_middle/src')
| -rw-r--r-- | compiler/rustc_middle/src/mir/interpret/allocation.rs | 5 | ||||
| -rw-r--r-- | compiler/rustc_middle/src/query/plumbing.rs | 2 | ||||
| -rw-r--r-- | compiler/rustc_middle/src/ty/layout.rs | 2 | ||||
| -rw-r--r-- | compiler/rustc_middle/src/ty/opaque_types.rs | 2 | ||||
| -rw-r--r-- | compiler/rustc_middle/src/ty/util.rs | 2 | ||||
| -rw-r--r-- | compiler/rustc_middle/src/values.rs | 8 |
6 files changed, 9 insertions, 12 deletions
diff --git a/compiler/rustc_middle/src/mir/interpret/allocation.rs b/compiler/rustc_middle/src/mir/interpret/allocation.rs index a92b85a716f..4047891d769 100644 --- a/compiler/rustc_middle/src/mir/interpret/allocation.rs +++ b/compiler/rustc_middle/src/mir/interpret/allocation.rs @@ -14,7 +14,6 @@ use either::{Left, Right}; use rustc_ast::Mutability; use rustc_data_structures::intern::Interned; -use rustc_span::DUMMY_SP; use rustc_target::abi::{Align, HasDataLayout, Size}; use super::{ @@ -314,9 +313,7 @@ impl<Prov: Provenance, Bytes: AllocBytes> Allocation<Prov, (), Bytes> { /// available to the compiler to do so. pub fn try_uninit<'tcx>(size: Size, align: Align) -> InterpResult<'tcx, Self> { Self::uninit_inner(size, align, || { - ty::tls::with(|tcx| { - tcx.dcx().span_delayed_bug(DUMMY_SP, "exhausted memory during interpretation") - }); + ty::tls::with(|tcx| tcx.dcx().delayed_bug("exhausted memory during interpretation")); InterpError::ResourceExhaustion(ResourceExhaustionInfo::MemoryExhausted).into() }) } diff --git a/compiler/rustc_middle/src/query/plumbing.rs b/compiler/rustc_middle/src/query/plumbing.rs index 414d4c8d949..a41d4f1ad58 100644 --- a/compiler/rustc_middle/src/query/plumbing.rs +++ b/compiler/rustc_middle/src/query/plumbing.rs @@ -551,7 +551,7 @@ macro_rules! define_feedable { // We have an inconsistency. This can happen if one of the two // results is tainted by errors. In this case, delay a bug to // ensure compilation is doomed, and keep the `old` value. - tcx.dcx().span_delayed_bug(DUMMY_SP, format!( + tcx.dcx().delayed_bug(format!( "Trying to feed an already recorded value for query {} key={key:?}:\n\ old value: {old:?}\nnew value: {value:?}", stringify!($name), diff --git a/compiler/rustc_middle/src/ty/layout.rs b/compiler/rustc_middle/src/ty/layout.rs index 5cc0ce87c9b..25473f52c03 100644 --- a/compiler/rustc_middle/src/ty/layout.rs +++ b/compiler/rustc_middle/src/ty/layout.rs @@ -284,7 +284,7 @@ impl<'tcx> LayoutCalculator for LayoutCx<'tcx, TyCtxt<'tcx>> { type TargetDataLayoutRef = &'tcx TargetDataLayout; fn delayed_bug(&self, txt: String) { - self.tcx.dcx().span_delayed_bug(DUMMY_SP, txt); + self.tcx.dcx().delayed_bug(txt); } fn current_data_layout(&self) -> Self::TargetDataLayoutRef { diff --git a/compiler/rustc_middle/src/ty/opaque_types.rs b/compiler/rustc_middle/src/ty/opaque_types.rs index d9bcd8d3ae7..5ca88ec3102 100644 --- a/compiler/rustc_middle/src/ty/opaque_types.rs +++ b/compiler/rustc_middle/src/ty/opaque_types.rs @@ -132,7 +132,7 @@ impl<'tcx> TypeFolder<TyCtxt<'tcx>> for ReverseMapper<'tcx> { .tcx .dcx() .struct_span_err(self.span, "non-defining opaque type use in defining scope") - .span_label_mv( + .with_span_label( self.span, format!( "lifetime `{r}` is part of concrete type but not used in \ diff --git a/compiler/rustc_middle/src/ty/util.rs b/compiler/rustc_middle/src/ty/util.rs index 7285cdb830e..372f11a5acc 100644 --- a/compiler/rustc_middle/src/ty/util.rs +++ b/compiler/rustc_middle/src/ty/util.rs @@ -369,7 +369,7 @@ impl<'tcx> TyCtxt<'tcx> { if let Some((old_item_id, _)) = dtor_candidate { self.dcx() .struct_span_err(self.def_span(item_id), "multiple drop impls found") - .span_note_mv(self.def_span(old_item_id), "other impl here") + .with_span_note(self.def_span(old_item_id), "other impl here") .delay_as_bug(); } diff --git a/compiler/rustc_middle/src/values.rs b/compiler/rustc_middle/src/values.rs index 27d04dbe331..6a03bf243eb 100644 --- a/compiler/rustc_middle/src/values.rs +++ b/compiler/rustc_middle/src/values.rs @@ -1,7 +1,7 @@ use crate::dep_graph::dep_kinds; use crate::query::plumbing::CyclePlaceholder; use rustc_data_structures::fx::FxHashSet; -use rustc_errors::{pluralize, struct_span_err, Applicability, MultiSpan}; +use rustc_errors::{pluralize, struct_span_code_err, Applicability, MultiSpan}; use rustc_hir as hir; use rustc_hir::def::{DefKind, Res}; use rustc_middle::ty::Representability; @@ -175,7 +175,7 @@ impl<'tcx, T> Value<TyCtxt<'tcx>> for Result<T, &'_ ty::layout::LayoutError<'_>> } else { tcx.def_span(def_id) }; - let mut diag = struct_span_err!( + let mut diag = struct_span_code_err!( tcx.sess.dcx(), span, E0733, @@ -309,7 +309,7 @@ pub fn recursive_type_error( } s }; - struct_span_err!( + struct_span_code_err!( tcx.dcx(), err_span, E0072, @@ -318,7 +318,7 @@ pub fn recursive_type_error( items_list, pluralize!("has", cycle_len), ) - .multipart_suggestion_mv( + .with_multipart_suggestion( "insert some indirection (e.g., a `Box`, `Rc`, or `&`) to break the cycle", suggestion, Applicability::HasPlaceholders, |
