Rename DiagnosticArgFromDisplay as DiagArgFromDisplay.

This commit is contained in:
Nicholas Nethercote 2024-02-23 15:34:39 +11:00
parent 8199632aa8
commit d0ef108ce9
5 changed files with 20 additions and 21 deletions

View File

@ -1,6 +1,5 @@
use rustc_errors::{
codes::*, AddToDiagnostic, Diag, DiagnosticArgFromDisplay, EmissionGuarantee,
SubdiagnosticMessageOp,
codes::*, AddToDiagnostic, Diag, DiagArgFromDisplay, EmissionGuarantee, SubdiagnosticMessageOp,
};
use rustc_macros::{Diagnostic, Subdiagnostic};
use rustc_span::{symbol::Ident, Span, Symbol};
@ -95,7 +94,7 @@ pub enum AssocTyParenthesesSub {
pub struct MisplacedImplTrait<'a> {
#[primary_span]
pub span: Span,
pub position: DiagnosticArgFromDisplay<'a>,
pub position: DiagArgFromDisplay<'a>,
}
#[derive(Diagnostic)]

View File

@ -51,7 +51,7 @@ use rustc_data_structures::fingerprint::Fingerprint;
use rustc_data_structures::sorted_map::SortedMap;
use rustc_data_structures::stable_hasher::{HashStable, StableHasher};
use rustc_data_structures::sync::Lrc;
use rustc_errors::{DiagCtxt, DiagnosticArgFromDisplay, StashKey};
use rustc_errors::{DiagArgFromDisplay, DiagCtxt, StashKey};
use rustc_hir as hir;
use rustc_hir::def::{DefKind, LifetimeRes, Namespace, PartialRes, PerNS, Res};
use rustc_hir::def_id::{LocalDefId, LocalDefIdMap, CRATE_DEF_ID, LOCAL_CRATE};
@ -1473,7 +1473,7 @@ impl<'a, 'hir> LoweringContext<'a, 'hir> {
.create_feature_err(
MisplacedImplTrait {
span: t.span,
position: DiagnosticArgFromDisplay(&position),
position: DiagArgFromDisplay(&position),
},
feature,
)
@ -1483,7 +1483,7 @@ impl<'a, 'hir> LoweringContext<'a, 'hir> {
ImplTraitContext::Disallowed(position) => {
let guar = self.dcx().emit_err(MisplacedImplTrait {
span: t.span,
position: DiagnosticArgFromDisplay(&position),
position: DiagArgFromDisplay(&position),
});
hir::TyKind::Err(guar)
}

View File

@ -20,23 +20,23 @@ use std::num::ParseIntError;
use std::path::{Path, PathBuf};
use std::process::ExitStatus;
pub struct DiagnosticArgFromDisplay<'a>(pub &'a dyn fmt::Display);
pub struct DiagArgFromDisplay<'a>(pub &'a dyn fmt::Display);
impl IntoDiagnosticArg for DiagnosticArgFromDisplay<'_> {
impl IntoDiagnosticArg for DiagArgFromDisplay<'_> {
fn into_diagnostic_arg(self) -> DiagArgValue {
self.0.to_string().into_diagnostic_arg()
}
}
impl<'a> From<&'a dyn fmt::Display> for DiagnosticArgFromDisplay<'a> {
impl<'a> From<&'a dyn fmt::Display> for DiagArgFromDisplay<'a> {
fn from(t: &'a dyn fmt::Display) -> Self {
DiagnosticArgFromDisplay(t)
DiagArgFromDisplay(t)
}
}
impl<'a, T: fmt::Display> From<&'a T> for DiagnosticArgFromDisplay<'a> {
impl<'a, T: fmt::Display> From<&'a T> for DiagArgFromDisplay<'a> {
fn from(t: &'a T) -> Self {
DiagnosticArgFromDisplay(t)
DiagArgFromDisplay(t)
}
}

View File

@ -42,8 +42,8 @@ pub use diagnostic::{
IntoDiagnosticArg, StringPart, Subdiag, SubdiagnosticMessageOp,
};
pub use diagnostic_impls::{
DiagnosticArgFromDisplay, DiagnosticSymbolList, ExpectedLifetimeParameter,
IndicateAnonymousLifetime, SingleLabelManySpans,
DiagArgFromDisplay, DiagnosticSymbolList, ExpectedLifetimeParameter, IndicateAnonymousLifetime,
SingleLabelManySpans,
};
pub use emitter::ColorConfig;
pub use rustc_error_messages::{

View File

@ -1,4 +1,4 @@
use rustc_errors::{codes::*, DiagnosticArgFromDisplay};
use rustc_errors::{codes::*, DiagArgFromDisplay};
use rustc_macros::{Diagnostic, LintDiagnostic, Subdiagnostic};
use rustc_span::{Span, Symbol};
@ -36,7 +36,7 @@ pub struct ItemIsPrivate<'a> {
#[label]
pub span: Span,
pub kind: &'a str,
pub descr: DiagnosticArgFromDisplay<'a>,
pub descr: DiagArgFromDisplay<'a>,
}
#[derive(Diagnostic)]
@ -55,7 +55,7 @@ pub struct InPublicInterface<'a> {
pub span: Span,
pub vis_descr: &'static str,
pub kind: &'a str,
pub descr: DiagnosticArgFromDisplay<'a>,
pub descr: DiagArgFromDisplay<'a>,
#[label(privacy_visibility_label)]
pub vis_span: Span,
}
@ -72,7 +72,7 @@ pub struct ReportEffectiveVisibility {
#[diag(privacy_from_private_dep_in_public_interface)]
pub struct FromPrivateDependencyInPublicInterface<'a> {
pub kind: &'a str,
pub descr: DiagnosticArgFromDisplay<'a>,
pub descr: DiagArgFromDisplay<'a>,
pub krate: Symbol,
}
@ -82,7 +82,7 @@ pub struct UnnameableTypesLint<'a> {
#[label]
pub span: Span,
pub kind: &'a str,
pub descr: DiagnosticArgFromDisplay<'a>,
pub descr: DiagArgFromDisplay<'a>,
pub reachable_vis: &'a str,
pub reexported_vis: &'a str,
}
@ -96,11 +96,11 @@ pub struct PrivateInterfacesOrBoundsLint<'a> {
#[label(privacy_item_label)]
pub item_span: Span,
pub item_kind: &'a str,
pub item_descr: DiagnosticArgFromDisplay<'a>,
pub item_descr: DiagArgFromDisplay<'a>,
pub item_vis_descr: &'a str,
#[note(privacy_ty_note)]
pub ty_span: Span,
pub ty_kind: &'a str,
pub ty_descr: DiagnosticArgFromDisplay<'a>,
pub ty_descr: DiagArgFromDisplay<'a>,
pub ty_vis_descr: &'a str,
}