diff options
Diffstat (limited to 'compiler/rustc_trait_selection/src/traits')
8 files changed, 37 insertions, 42 deletions
diff --git a/compiler/rustc_trait_selection/src/traits/const_evaluatable.rs b/compiler/rustc_trait_selection/src/traits/const_evaluatable.rs index e119ddeb4c6..522c645253a 100644 --- a/compiler/rustc_trait_selection/src/traits/const_evaluatable.rs +++ b/compiler/rustc_trait_selection/src/traits/const_evaluatable.rs @@ -122,8 +122,8 @@ pub fn is_const_evaluatable<'tcx>( if span == rustc_span::DUMMY_SP { tcx.def_span(uv.def) } else { span }, "failed to evaluate generic const expression", ) - .note_mv("the crate this constant originates from uses `#![feature(generic_const_exprs)]`") - .span_suggestion_verbose_mv( + .with_note("the crate this constant originates from uses `#![feature(generic_const_exprs)]`") + .with_span_suggestion_verbose( rustc_span::DUMMY_SP, "consider enabling this feature", "#![feature(generic_const_exprs)]\n", diff --git a/compiler/rustc_trait_selection/src/traits/error_reporting/infer_ctxt_ext.rs b/compiler/rustc_trait_selection/src/traits/error_reporting/infer_ctxt_ext.rs index 90e2c1531b4..864580afe62 100644 --- a/compiler/rustc_trait_selection/src/traits/error_reporting/infer_ctxt_ext.rs +++ b/compiler/rustc_trait_selection/src/traits/error_reporting/infer_ctxt_ext.rs @@ -1,7 +1,7 @@ use crate::infer::type_variable::{TypeVariableOrigin, TypeVariableOriginKind}; use crate::infer::InferCtxt; use crate::traits::{Obligation, ObligationCause, ObligationCtxt}; -use rustc_errors::{pluralize, struct_span_err, Applicability, DiagnosticBuilder}; +use rustc_errors::{pluralize, struct_span_code_err, Applicability, DiagnosticBuilder}; use rustc_hir as hir; use rustc_hir::Node; use rustc_middle::ty::{self, Ty}; @@ -140,7 +140,7 @@ impl<'tcx> InferCtxtExt<'tcx> for InferCtxt<'tcx> { let expected_str = args_str(&expected_args, &found_args); let found_str = args_str(&found_args, &expected_args); - let mut err = struct_span_err!( + let mut err = struct_span_code_err!( self.dcx(), span, E0593, diff --git a/compiler/rustc_trait_selection/src/traits/error_reporting/on_unimplemented.rs b/compiler/rustc_trait_selection/src/traits/error_reporting/on_unimplemented.rs index c9e8b30c4c4..100c9a70aaa 100644 --- a/compiler/rustc_trait_selection/src/traits/error_reporting/on_unimplemented.rs +++ b/compiler/rustc_trait_selection/src/traits/error_reporting/on_unimplemented.rs @@ -6,7 +6,7 @@ use rustc_ast::AttrKind; use rustc_ast::{Attribute, MetaItem, NestedMetaItem}; use rustc_attr as attr; use rustc_data_structures::fx::FxHashMap; -use rustc_errors::{struct_span_err, ErrorGuaranteed}; +use rustc_errors::{struct_span_code_err, ErrorGuaranteed}; use rustc_hir as hir; use rustc_hir::def_id::{DefId, LocalDefId}; use rustc_middle::ty::GenericArgsRef; @@ -14,7 +14,7 @@ use rustc_middle::ty::{self, GenericParamDefKind, TyCtxt}; use rustc_parse_format::{ParseMode, Parser, Piece, Position}; use rustc_session::lint::builtin::UNKNOWN_OR_MALFORMED_DIAGNOSTIC_ATTRIBUTES; use rustc_span::symbol::{kw, sym, Symbol}; -use rustc_span::{Span, DUMMY_SP}; +use rustc_span::Span; use std::iter; use crate::errors::{ @@ -657,9 +657,7 @@ impl<'tcx> OnUnimplementedDirective { Ok(None) } else { - let reported = tcx - .dcx() - .span_delayed_bug(DUMMY_SP, "of_item: neither meta_item_list nor value_str"); + let reported = tcx.dcx().delayed_bug("of_item: neither meta_item_list nor value_str"); return Err(reported); }; debug!("of_item({:?}) = {:?}", item_def_id, result); @@ -797,7 +795,7 @@ impl<'tcx> OnUnimplementedFormatString { }, ); } else { - result = Err(struct_span_err!( + result = Err(struct_span_code_err!( tcx.dcx(), self.span, E0230, @@ -816,7 +814,7 @@ impl<'tcx> OnUnimplementedFormatString { } // `{:1}` and `{}` are not to be used Position::ArgumentIs(..) | Position::ArgumentImplicitlyIs(_) => { - let reported = struct_span_err!( + let reported = struct_span_code_err!( tcx.dcx(), self.span, E0231, diff --git a/compiler/rustc_trait_selection/src/traits/error_reporting/suggestions.rs b/compiler/rustc_trait_selection/src/traits/error_reporting/suggestions.rs index 4a6ef27e7ba..6c0909d2853 100644 --- a/compiler/rustc_trait_selection/src/traits/error_reporting/suggestions.rs +++ b/compiler/rustc_trait_selection/src/traits/error_reporting/suggestions.rs @@ -13,7 +13,7 @@ use hir::def::CtorOf; use rustc_data_structures::fx::FxHashSet; use rustc_data_structures::stack::ensure_sufficient_stack; use rustc_errors::{ - error_code, pluralize, struct_span_err, Applicability, Diagnostic, DiagnosticBuilder, + error_code, pluralize, struct_span_code_err, Applicability, Diagnostic, DiagnosticBuilder, MultiSpan, Style, SuggestionStyle, }; use rustc_hir as hir; @@ -2145,7 +2145,7 @@ impl<'tcx> TypeErrCtxtExt<'tcx> for TypeErrCtxt<'_, 'tcx> { ty::Coroutine(..) => "coroutine", _ => "function", }; - let mut err = struct_span_err!( + let mut err = struct_span_code_err!( self.dcx(), span, E0631, diff --git a/compiler/rustc_trait_selection/src/traits/error_reporting/type_err_ctxt_ext.rs b/compiler/rustc_trait_selection/src/traits/error_reporting/type_err_ctxt_ext.rs index b05895e4b9a..47a700805fa 100644 --- a/compiler/rustc_trait_selection/src/traits/error_reporting/type_err_ctxt_ext.rs +++ b/compiler/rustc_trait_selection/src/traits/error_reporting/type_err_ctxt_ext.rs @@ -19,7 +19,7 @@ use crate::traits::{ }; use rustc_data_structures::fx::{FxHashMap, FxIndexMap}; use rustc_errors::{ - pluralize, struct_span_err, Applicability, Diagnostic, DiagnosticBuilder, ErrorGuaranteed, + pluralize, struct_span_code_err, Applicability, Diagnostic, DiagnosticBuilder, ErrorGuaranteed, MultiSpan, StashKey, Style, }; use rustc_hir as hir; @@ -228,7 +228,7 @@ impl<'tcx> TypeErrCtxtExt<'tcx> for TypeErrCtxt<'_, 'tcx> { } } - self.dcx().span_delayed_bug(DUMMY_SP, "expected fulfillment errors") + self.dcx().delayed_bug("expected fulfillment errors") } /// Reports that an overflow has occurred and halts compilation. We @@ -280,7 +280,7 @@ impl<'tcx> TypeErrCtxtExt<'tcx> for TypeErrCtxt<'_, 'tcx> { predicate.print(&mut cx).unwrap(); pred_str = cx.into_buffer(); } - let mut err = struct_span_err!( + let mut err = struct_span_code_err!( self.dcx(), span, E0275, @@ -525,7 +525,7 @@ impl<'tcx> TypeErrCtxtExt<'tcx> for TypeErrCtxt<'_, 'tcx> { (err_msg, None) }; - let mut err = struct_span_err!(self.dcx(), span, E0277, "{}", err_msg); + let mut err = struct_span_code_err!(self.dcx(), span, E0277, "{}", err_msg); let mut suggested = false; if is_try_conversion { @@ -1236,7 +1236,7 @@ impl<'tcx> TypeErrCtxtExt<'tcx> for TypeErrCtxt<'_, 'tcx> { span_bug!(span, "const param tys cannot mention other generic parameters"); } ty::Float(_) => { - struct_span_err!( + struct_span_code_err!( self.dcx(), span, E0741, @@ -1244,7 +1244,7 @@ impl<'tcx> TypeErrCtxtExt<'tcx> for TypeErrCtxt<'_, 'tcx> { ) } ty::FnPtr(_) => { - struct_span_err!( + struct_span_code_err!( self.dcx(), span, E0741, @@ -1252,7 +1252,7 @@ impl<'tcx> TypeErrCtxtExt<'tcx> for TypeErrCtxt<'_, 'tcx> { ) } ty::RawPtr(_) => { - struct_span_err!( + struct_span_code_err!( self.dcx(), span, E0741, @@ -1261,7 +1261,7 @@ impl<'tcx> TypeErrCtxtExt<'tcx> for TypeErrCtxt<'_, 'tcx> { } ty::Adt(def, _) => { // We should probably see if we're *allowed* to derive `ConstParamTy` on the type... - let mut diag = struct_span_err!( + let mut diag = struct_span_code_err!( self.dcx(), span, E0741, @@ -1293,7 +1293,7 @@ impl<'tcx> TypeErrCtxtExt<'tcx> for TypeErrCtxt<'_, 'tcx> { diag } _ => { - struct_span_err!( + struct_span_code_err!( self.dcx(), span, E0741, @@ -1731,7 +1731,7 @@ impl<'tcx> InferCtxtPrivExt<'tcx> for TypeErrCtxt<'_, 'tcx> { cx.into_buffer() })) }); - let mut diag = struct_span_err!(self.dcx(), obligation.cause.span, E0271, "{msg}"); + let mut diag = struct_span_code_err!(self.dcx(), obligation.cause.span, E0271, "{msg}"); let secondary_span = (|| { let ty::PredicateKind::Clause(ty::ClauseKind::Projection(proj)) = @@ -2421,7 +2421,7 @@ impl<'tcx> InferCtxtPrivExt<'tcx> for TypeErrCtxt<'_, 'tcx> { true, ) } else { - struct_span_err!( + struct_span_code_err!( self.dcx(), span, E0283, @@ -2661,17 +2661,17 @@ impl<'tcx> InferCtxtPrivExt<'tcx> for TypeErrCtxt<'_, 'tcx> { ErrorCode::E0284, true, ) - .note_mv(format!("cannot satisfy `{predicate}`")) + .with_note(format!("cannot satisfy `{predicate}`")) } else { // If we can't find a substitution, just print a generic error - struct_span_err!( + struct_span_code_err!( self.dcx(), span, E0284, "type annotations needed: cannot satisfy `{}`", predicate, ) - .span_label_mv(span, format!("cannot satisfy `{predicate}`")) + .with_span_label(span, format!("cannot satisfy `{predicate}`")) } } @@ -2691,28 +2691,28 @@ impl<'tcx> InferCtxtPrivExt<'tcx> for TypeErrCtxt<'_, 'tcx> { err } else { // If we can't find a substitution, just print a generic error - struct_span_err!( + struct_span_code_err!( self.dcx(), span, E0284, "type annotations needed: cannot satisfy `{}`", predicate, ) - .span_label_mv(span, format!("cannot satisfy `{predicate}`")) + .with_span_label(span, format!("cannot satisfy `{predicate}`")) } } _ => { if self.dcx().has_errors().is_some() || self.tainted_by_errors().is_some() { return; } - struct_span_err!( + struct_span_code_err!( self.dcx(), span, E0284, "type annotations needed: cannot satisfy `{}`", predicate, ) - .span_label_mv(span, format!("cannot satisfy `{predicate}`")) + .with_span_label(span, format!("cannot satisfy `{predicate}`")) } }; self.note_obligation_cause(&mut err, obligation); @@ -3552,7 +3552,7 @@ impl<'tcx> InferCtxtPrivExt<'tcx> for TypeErrCtxt<'_, 'tcx> { // // Note that with `feature(generic_const_exprs)` this case should not // be reachable. - .note_mv("this may fail depending on what value the parameter takes") + .with_note("this may fail depending on what value the parameter takes") .emit(); return None; } diff --git a/compiler/rustc_trait_selection/src/traits/query/normalize.rs b/compiler/rustc_trait_selection/src/traits/query/normalize.rs index d5f98db2c93..0b73fefd2da 100644 --- a/compiler/rustc_trait_selection/src/traits/query/normalize.rs +++ b/compiler/rustc_trait_selection/src/traits/query/normalize.rs @@ -286,10 +286,8 @@ impl<'cx, 'tcx> FallibleTypeFolder<TyCtxt<'tcx>> for QueryNormalizer<'cx, 'tcx> // Rustdoc normalizes possibly not well-formed types, so only // treat this as a bug if we're not in rustdoc. if !tcx.sess.opts.actually_rustdoc { - tcx.dcx().span_delayed_bug( - DUMMY_SP, - format!("unexpected ambiguity: {c_data:?} {result:?}"), - ); + tcx.dcx() + .delayed_bug(format!("unexpected ambiguity: {c_data:?} {result:?}")); } return Err(NoSolution); } diff --git a/compiler/rustc_trait_selection/src/traits/query/type_op/custom.rs b/compiler/rustc_trait_selection/src/traits/query/type_op/custom.rs index f4baae2711f..d533e69a4fa 100644 --- a/compiler/rustc_trait_selection/src/traits/query/type_op/custom.rs +++ b/compiler/rustc_trait_selection/src/traits/query/type_op/custom.rs @@ -6,7 +6,7 @@ use rustc_errors::ErrorGuaranteed; use rustc_infer::infer::region_constraints::RegionConstraintData; use rustc_middle::traits::query::NoSolution; use rustc_middle::ty::{TyCtxt, TypeFoldable}; -use rustc_span::{Span, DUMMY_SP}; +use rustc_span::Span; use std::fmt; @@ -88,10 +88,9 @@ where if errors.is_empty() { Ok(value) } else { - Err(infcx.dcx().span_delayed_bug( - DUMMY_SP, - format!("errors selecting obligation during MIR typeck: {errors:?}"), - )) + Err(infcx + .dcx() + .delayed_bug(format!("errors selecting obligation during MIR typeck: {errors:?}"))) } })?; diff --git a/compiler/rustc_trait_selection/src/traits/select/candidate_assembly.rs b/compiler/rustc_trait_selection/src/traits/select/candidate_assembly.rs index c1145bc30c9..342b12ba498 100644 --- a/compiler/rustc_trait_selection/src/traits/select/candidate_assembly.rs +++ b/compiler/rustc_trait_selection/src/traits/select/candidate_assembly.rs @@ -969,7 +969,7 @@ impl<'cx, 'tcx> SelectionContext<'cx, 'tcx> { self.tcx().def_span(impl_def_id), "multiple drop impls found", ) - .span_note_mv( + .with_span_note( self.tcx().def_span(old_impl_def_id), "other impl here", ) |
