Skip to content

Commit

Permalink
Rename IntoDiagnosticArg as IntoDiagArg.
Browse files Browse the repository at this point in the history
Also rename `into_diagnostic_arg` as `into_diag_arg`, and
`NotIntoDiagnosticArg` as `NotInotDiagArg`.
  • Loading branch information
nnethercote committed Mar 10, 2024
1 parent 256d802 commit a09b1d3
Show file tree
Hide file tree
Showing 38 changed files with 218 additions and 219 deletions.
6 changes: 3 additions & 3 deletions compiler/rustc_borrowck/src/diagnostics/region_name.rs
Original file line number Diff line number Diff line change
Expand Up @@ -191,9 +191,9 @@ impl Display for RegionName {
}
}

impl rustc_errors::IntoDiagnosticArg for RegionName {
fn into_diagnostic_arg(self) -> rustc_errors::DiagArgValue {
self.to_string().into_diagnostic_arg()
impl rustc_errors::IntoDiagArg for RegionName {
fn into_diag_arg(self) -> rustc_errors::DiagArgValue {
self.to_string().into_diag_arg()
}
}

Expand Down
6 changes: 3 additions & 3 deletions compiler/rustc_codegen_ssa/src/assert_module_sources.rs
Original file line number Diff line number Diff line change
Expand Up @@ -27,7 +27,7 @@ use crate::errors;
use rustc_ast as ast;
use rustc_data_structures::unord::UnordMap;
use rustc_data_structures::unord::UnordSet;
use rustc_errors::{DiagArgValue, IntoDiagnosticArg};
use rustc_errors::{DiagArgValue, IntoDiagArg};
use rustc_hir::def_id::LOCAL_CRATE;
use rustc_middle::mir::mono::CodegenUnitNameBuilder;
use rustc_middle::ty::TyCtxt;
Expand Down Expand Up @@ -205,8 +205,8 @@ impl fmt::Display for CguReuse {
}
}

impl IntoDiagnosticArg for CguReuse {
fn into_diagnostic_arg(self) -> DiagArgValue {
impl IntoDiagArg for CguReuse {
fn into_diag_arg(self) -> DiagArgValue {
DiagArgValue::Str(Cow::Owned(self.to_string()))
}
}
Expand Down
11 changes: 5 additions & 6 deletions compiler/rustc_codegen_ssa/src/errors.rs
Original file line number Diff line number Diff line change
Expand Up @@ -4,8 +4,7 @@ use crate::assert_module_sources::CguReuse;
use crate::back::command::Command;
use crate::fluent_generated as fluent;
use rustc_errors::{
codes::*, Diag, DiagArgValue, DiagCtxt, EmissionGuarantee, IntoDiagnostic, IntoDiagnosticArg,
Level,
codes::*, Diag, DiagArgValue, DiagCtxt, EmissionGuarantee, IntoDiagArg, IntoDiagnostic, Level,
};
use rustc_macros::Diagnostic;
use rustc_middle::ty::layout::LayoutError;
Expand Down Expand Up @@ -152,8 +151,8 @@ impl<'a> CopyPath<'a> {

struct DebugArgPath<'a>(pub &'a Path);

impl IntoDiagnosticArg for DebugArgPath<'_> {
fn into_diagnostic_arg(self) -> rustc_errors::DiagArgValue {
impl IntoDiagArg for DebugArgPath<'_> {
fn into_diag_arg(self) -> rustc_errors::DiagArgValue {
DiagArgValue::Str(Cow::Owned(format!("{:?}", self.0)))
}
}
Expand Down Expand Up @@ -974,8 +973,8 @@ pub enum ExpectedPointerMutability {
Not,
}

impl IntoDiagnosticArg for ExpectedPointerMutability {
fn into_diagnostic_arg(self) -> DiagArgValue {
impl IntoDiagArg for ExpectedPointerMutability {
fn into_diag_arg(self) -> DiagArgValue {
match self {
ExpectedPointerMutability::Mut => DiagArgValue::Str(Cow::Borrowed("*mut")),
ExpectedPointerMutability::Not => DiagArgValue::Str(Cow::Borrowed("*_")),
Expand Down
10 changes: 5 additions & 5 deletions compiler/rustc_const_eval/src/const_eval/error.rs
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
use std::mem;

use rustc_errors::{DiagArgName, DiagArgValue, DiagMessage, IntoDiagnostic, IntoDiagnosticArg};
use rustc_errors::{DiagArgName, DiagArgValue, DiagMessage, IntoDiagArg, IntoDiagnostic};
use rustc_hir::CRATE_HIR_ID;
use rustc_middle::mir::AssertKind;
use rustc_middle::query::TyCtxtAt;
Expand Down Expand Up @@ -40,10 +40,10 @@ impl MachineStopType for ConstEvalErrKind {
RecursiveStatic | ConstAccessesMutGlobal | ModifiedGlobal => {}
AssertFailure(kind) => kind.add_args(adder),
Panic { msg, line, col, file } => {
adder("msg".into(), msg.into_diagnostic_arg());
adder("file".into(), file.into_diagnostic_arg());
adder("line".into(), line.into_diagnostic_arg());
adder("col".into(), col.into_diagnostic_arg());
adder("msg".into(), msg.into_diag_arg());
adder("file".into(), file.into_diag_arg());
adder("line".into(), line.into_diag_arg());
adder("col".into(), col.into_diag_arg());
}
}
}
Expand Down
4 changes: 2 additions & 2 deletions compiler/rustc_const_eval/src/errors.rs
Original file line number Diff line number Diff line change
Expand Up @@ -887,8 +887,8 @@ impl ReportErrorExt for ResourceExhaustionInfo {
fn add_args<G: EmissionGuarantee>(self, _: &mut Diag<'_, G>) {}
}

impl rustc_errors::IntoDiagnosticArg for InternKind {
fn into_diagnostic_arg(self) -> DiagArgValue {
impl rustc_errors::IntoDiagArg for InternKind {
fn into_diag_arg(self) -> DiagArgValue {
DiagArgValue::Str(Cow::Borrowed(match self {
InternKind::Static(Mutability::Not) => "static",
InternKind::Static(Mutability::Mut) => "static_mut",
Expand Down
16 changes: 8 additions & 8 deletions compiler/rustc_errors/src/diagnostic.rs
Original file line number Diff line number Diff line change
Expand Up @@ -38,7 +38,7 @@ pub enum DiagArgValue {
Str(Cow<'static, str>),
// This gets converted to a `FluentNumber`, which is an `f64`. An `i32`
// safely fits in an `f64`. Any integers bigger than that will be converted
// to strings in `into_diagnostic_arg` and stored using the `Str` variant.
// to strings in `into_diag_arg` and stored using the `Str` variant.
Number(i32),
StrListSepByAnd(Vec<Cow<'static, str>>),
}
Expand Down Expand Up @@ -148,12 +148,12 @@ where
/// Implemented as a custom trait rather than `From` so that it is implemented on the type being
/// converted rather than on `DiagArgValue`, which enables types from other `rustc_*` crates to
/// implement this.
pub trait IntoDiagnosticArg {
fn into_diagnostic_arg(self) -> DiagArgValue;
pub trait IntoDiagArg {
fn into_diag_arg(self) -> DiagArgValue;
}

impl IntoDiagnosticArg for DiagArgValue {
fn into_diagnostic_arg(self) -> DiagArgValue {
impl IntoDiagArg for DiagArgValue {
fn into_diag_arg(self) -> DiagArgValue {
self
}
}
Expand Down Expand Up @@ -419,8 +419,8 @@ impl DiagInner {
self.children.push(sub);
}

pub(crate) fn arg(&mut self, name: impl Into<DiagArgName>, arg: impl IntoDiagnosticArg) {
self.args.insert(name.into(), arg.into_diagnostic_arg());
pub(crate) fn arg(&mut self, name: impl Into<DiagArgName>, arg: impl IntoDiagArg) {
self.args.insert(name.into(), arg.into_diag_arg());
}

/// Fields used for Hash, and PartialEq trait.
Expand Down Expand Up @@ -1243,7 +1243,7 @@ impl<'a, G: EmissionGuarantee> Diag<'a, G> {
pub fn arg(
&mut self,
name: impl Into<DiagArgName>,
arg: impl IntoDiagnosticArg,
arg: impl IntoDiagArg,
) -> &mut Self {
self.deref_mut().arg(name, arg);
self
Expand Down
Loading

0 comments on commit a09b1d3

Please sign in to comment.