Rollup merge of #120488 - nnethercote:diag-lifetimes, r=oli-obk
Diagnostic lifetimes cleanups Some diagnostic simplifications. r? `@oli-obk`
This commit is contained in:
commit
f99b510429
39 changed files with 144 additions and 150 deletions
|
@ -95,17 +95,14 @@ pub(super) struct ConstNotUsedTraitAlias {
|
|||
|
||||
pub struct CustomSubdiagnostic<'a> {
|
||||
pub msg: fn() -> DiagnosticMessage,
|
||||
pub add_args:
|
||||
Box<dyn FnOnce(&mut dyn FnMut(Cow<'static, str>, DiagnosticArgValue<'static>)) + 'a>,
|
||||
pub add_args: Box<dyn FnOnce(&mut dyn FnMut(Cow<'static, str>, DiagnosticArgValue)) + 'a>,
|
||||
}
|
||||
|
||||
impl<'a> CustomSubdiagnostic<'a> {
|
||||
pub fn label(x: fn() -> DiagnosticMessage) -> Self {
|
||||
Self::label_and_then(x, |_| {})
|
||||
}
|
||||
pub fn label_and_then<
|
||||
F: FnOnce(&mut dyn FnMut(Cow<'static, str>, DiagnosticArgValue<'static>)) + 'a,
|
||||
>(
|
||||
pub fn label_and_then<F: FnOnce(&mut dyn FnMut(Cow<'static, str>, DiagnosticArgValue)) + 'a>(
|
||||
msg: fn() -> DiagnosticMessage,
|
||||
f: F,
|
||||
) -> Self {
|
||||
|
|
|
@ -233,7 +233,7 @@ pub enum InvalidMetaKind {
|
|||
}
|
||||
|
||||
impl IntoDiagnosticArg for InvalidMetaKind {
|
||||
fn into_diagnostic_arg(self) -> DiagnosticArgValue<'static> {
|
||||
fn into_diagnostic_arg(self) -> DiagnosticArgValue {
|
||||
DiagnosticArgValue::Str(Cow::Borrowed(match self {
|
||||
InvalidMetaKind::SliceTooBig => "slice_too_big",
|
||||
InvalidMetaKind::TooBig => "too_big",
|
||||
|
@ -267,7 +267,7 @@ pub struct Misalignment {
|
|||
macro_rules! impl_into_diagnostic_arg_through_debug {
|
||||
($($ty:ty),*$(,)?) => {$(
|
||||
impl IntoDiagnosticArg for $ty {
|
||||
fn into_diagnostic_arg(self) -> DiagnosticArgValue<'static> {
|
||||
fn into_diagnostic_arg(self) -> DiagnosticArgValue {
|
||||
DiagnosticArgValue::Str(Cow::Owned(format!("{self:?}")))
|
||||
}
|
||||
}
|
||||
|
@ -367,7 +367,7 @@ pub enum PointerKind {
|
|||
}
|
||||
|
||||
impl IntoDiagnosticArg for PointerKind {
|
||||
fn into_diagnostic_arg(self) -> DiagnosticArgValue<'static> {
|
||||
fn into_diagnostic_arg(self) -> DiagnosticArgValue {
|
||||
DiagnosticArgValue::Str(
|
||||
match self {
|
||||
Self::Ref => "ref",
|
||||
|
@ -485,10 +485,7 @@ pub trait MachineStopType: Any + fmt::Debug + Send {
|
|||
fn diagnostic_message(&self) -> DiagnosticMessage;
|
||||
/// Add diagnostic arguments by passing name and value pairs to `adder`, which are passed to
|
||||
/// fluent for formatting the translated diagnostic message.
|
||||
fn add_args(
|
||||
self: Box<Self>,
|
||||
adder: &mut dyn FnMut(Cow<'static, str>, DiagnosticArgValue<'static>),
|
||||
);
|
||||
fn add_args(self: Box<Self>, adder: &mut dyn FnMut(Cow<'static, str>, DiagnosticArgValue));
|
||||
}
|
||||
|
||||
impl dyn MachineStopType {
|
||||
|
|
|
@ -292,7 +292,7 @@ impl<O> AssertKind<O> {
|
|||
}
|
||||
}
|
||||
|
||||
pub fn add_args(self, adder: &mut dyn FnMut(Cow<'static, str>, DiagnosticArgValue<'static>))
|
||||
pub fn add_args(self, adder: &mut dyn FnMut(Cow<'static, str>, DiagnosticArgValue))
|
||||
where
|
||||
O: fmt::Debug,
|
||||
{
|
||||
|
|
|
@ -674,7 +674,7 @@ impl<'tcx> Pat<'tcx> {
|
|||
}
|
||||
|
||||
impl<'tcx> IntoDiagnosticArg for Pat<'tcx> {
|
||||
fn into_diagnostic_arg(self) -> DiagnosticArgValue<'static> {
|
||||
fn into_diagnostic_arg(self) -> DiagnosticArgValue {
|
||||
format!("{self}").into_diagnostic_arg()
|
||||
}
|
||||
}
|
||||
|
|
|
@ -117,7 +117,7 @@ impl std::fmt::Debug for ConstInt {
|
|||
impl IntoDiagnosticArg for ConstInt {
|
||||
// FIXME this simply uses the Debug impl, but we could probably do better by converting both
|
||||
// to an inherent method that returns `Cow`.
|
||||
fn into_diagnostic_arg(self) -> DiagnosticArgValue<'static> {
|
||||
fn into_diagnostic_arg(self) -> DiagnosticArgValue {
|
||||
DiagnosticArgValue::Str(format!("{self:?}").into())
|
||||
}
|
||||
}
|
||||
|
|
|
@ -15,7 +15,7 @@ pub struct UnevaluatedConst<'tcx> {
|
|||
}
|
||||
|
||||
impl rustc_errors::IntoDiagnosticArg for UnevaluatedConst<'_> {
|
||||
fn into_diagnostic_arg(self) -> rustc_errors::DiagnosticArgValue<'static> {
|
||||
fn into_diagnostic_arg(self) -> rustc_errors::DiagnosticArgValue {
|
||||
format!("{self:?}").into_diagnostic_arg()
|
||||
}
|
||||
}
|
||||
|
|
|
@ -20,7 +20,7 @@ use rustc_span::{BytePos, Span};
|
|||
use rustc_type_ir::TyKind::*;
|
||||
|
||||
impl<'tcx> IntoDiagnosticArg for Ty<'tcx> {
|
||||
fn into_diagnostic_arg(self) -> DiagnosticArgValue<'static> {
|
||||
fn into_diagnostic_arg(self) -> DiagnosticArgValue {
|
||||
self.to_string().into_diagnostic_arg()
|
||||
}
|
||||
}
|
||||
|
|
|
@ -56,7 +56,7 @@ unsafe impl<'tcx> Sync for GenericArg<'tcx> where
|
|||
}
|
||||
|
||||
impl<'tcx> IntoDiagnosticArg for GenericArg<'tcx> {
|
||||
fn into_diagnostic_arg(self) -> DiagnosticArgValue<'static> {
|
||||
fn into_diagnostic_arg(self) -> DiagnosticArgValue {
|
||||
self.to_string().into_diagnostic_arg()
|
||||
}
|
||||
}
|
||||
|
|
|
@ -269,7 +269,7 @@ impl<'tcx> fmt::Display for LayoutError<'tcx> {
|
|||
}
|
||||
|
||||
impl<'tcx> IntoDiagnosticArg for LayoutError<'tcx> {
|
||||
fn into_diagnostic_arg(self) -> DiagnosticArgValue<'static> {
|
||||
fn into_diagnostic_arg(self) -> DiagnosticArgValue {
|
||||
self.to_string().into_diagnostic_arg()
|
||||
}
|
||||
}
|
||||
|
|
|
@ -583,13 +583,13 @@ impl<'tcx> Predicate<'tcx> {
|
|||
}
|
||||
|
||||
impl rustc_errors::IntoDiagnosticArg for Predicate<'_> {
|
||||
fn into_diagnostic_arg(self) -> rustc_errors::DiagnosticArgValue<'static> {
|
||||
fn into_diagnostic_arg(self) -> rustc_errors::DiagnosticArgValue {
|
||||
rustc_errors::DiagnosticArgValue::Str(std::borrow::Cow::Owned(self.to_string()))
|
||||
}
|
||||
}
|
||||
|
||||
impl rustc_errors::IntoDiagnosticArg for Clause<'_> {
|
||||
fn into_diagnostic_arg(self) -> rustc_errors::DiagnosticArgValue<'static> {
|
||||
fn into_diagnostic_arg(self) -> rustc_errors::DiagnosticArgValue {
|
||||
rustc_errors::DiagnosticArgValue::Str(std::borrow::Cow::Owned(self.to_string()))
|
||||
}
|
||||
}
|
||||
|
|
|
@ -2632,7 +2632,7 @@ where
|
|||
pub struct TraitRefPrintOnlyTraitPath<'tcx>(ty::TraitRef<'tcx>);
|
||||
|
||||
impl<'tcx> rustc_errors::IntoDiagnosticArg for TraitRefPrintOnlyTraitPath<'tcx> {
|
||||
fn into_diagnostic_arg(self) -> rustc_errors::DiagnosticArgValue<'static> {
|
||||
fn into_diagnostic_arg(self) -> rustc_errors::DiagnosticArgValue {
|
||||
self.to_string().into_diagnostic_arg()
|
||||
}
|
||||
}
|
||||
|
@ -2649,7 +2649,7 @@ impl<'tcx> fmt::Debug for TraitRefPrintOnlyTraitPath<'tcx> {
|
|||
pub struct TraitRefPrintSugared<'tcx>(ty::TraitRef<'tcx>);
|
||||
|
||||
impl<'tcx> rustc_errors::IntoDiagnosticArg for TraitRefPrintSugared<'tcx> {
|
||||
fn into_diagnostic_arg(self) -> rustc_errors::DiagnosticArgValue<'static> {
|
||||
fn into_diagnostic_arg(self) -> rustc_errors::DiagnosticArgValue {
|
||||
self.to_string().into_diagnostic_arg()
|
||||
}
|
||||
}
|
||||
|
|
|
@ -862,7 +862,7 @@ impl<'tcx> PolyTraitRef<'tcx> {
|
|||
}
|
||||
|
||||
impl<'tcx> IntoDiagnosticArg for TraitRef<'tcx> {
|
||||
fn into_diagnostic_arg(self) -> DiagnosticArgValue<'static> {
|
||||
fn into_diagnostic_arg(self) -> DiagnosticArgValue {
|
||||
self.to_string().into_diagnostic_arg()
|
||||
}
|
||||
}
|
||||
|
@ -908,7 +908,7 @@ impl<'tcx> ExistentialTraitRef<'tcx> {
|
|||
}
|
||||
|
||||
impl<'tcx> IntoDiagnosticArg for ExistentialTraitRef<'tcx> {
|
||||
fn into_diagnostic_arg(self) -> DiagnosticArgValue<'static> {
|
||||
fn into_diagnostic_arg(self) -> DiagnosticArgValue {
|
||||
self.to_string().into_diagnostic_arg()
|
||||
}
|
||||
}
|
||||
|
@ -1149,7 +1149,7 @@ impl<'tcx, T> IntoDiagnosticArg for Binder<'tcx, T>
|
|||
where
|
||||
T: IntoDiagnosticArg,
|
||||
{
|
||||
fn into_diagnostic_arg(self) -> DiagnosticArgValue<'static> {
|
||||
fn into_diagnostic_arg(self) -> DiagnosticArgValue {
|
||||
self.value.into_diagnostic_arg()
|
||||
}
|
||||
}
|
||||
|
@ -1359,7 +1359,7 @@ impl<'tcx> FnSig<'tcx> {
|
|||
}
|
||||
|
||||
impl<'tcx> IntoDiagnosticArg for FnSig<'tcx> {
|
||||
fn into_diagnostic_arg(self) -> DiagnosticArgValue<'static> {
|
||||
fn into_diagnostic_arg(self) -> DiagnosticArgValue {
|
||||
self.to_string().into_diagnostic_arg()
|
||||
}
|
||||
}
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue