Skip to content

Commit 8199632

Browse files
committed
Rename DiagnosticArg{,Map,Name,Value} as DiagArg{,Map,Name,Value}.
1 parent 899cb40 commit 8199632

File tree

40 files changed

+196
-198
lines changed

40 files changed

+196
-198
lines changed

compiler/rustc_borrowck/src/diagnostics/region_name.rs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -192,7 +192,7 @@ impl Display for RegionName {
192192
}
193193

194194
impl rustc_errors::IntoDiagnosticArg for RegionName {
195-
fn into_diagnostic_arg(self) -> rustc_errors::DiagnosticArgValue {
195+
fn into_diagnostic_arg(self) -> rustc_errors::DiagArgValue {
196196
self.to_string().into_diagnostic_arg()
197197
}
198198
}

compiler/rustc_codegen_gcc/src/errors.rs

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,5 @@
11
use rustc_errors::{
2-
DiagCtxt, DiagnosticArgValue, Diag, EmissionGuarantee, IntoDiagnostic, IntoDiagnosticArg, Level,
2+
DiagCtxt, DiagArgValue, Diag, EmissionGuarantee, IntoDiagnostic, IntoDiagnosticArg, Level,
33
};
44
use rustc_macros::{Diagnostic, Subdiagnostic};
55
use rustc_span::Span;
@@ -34,11 +34,11 @@ pub(crate) enum PossibleFeature<'a> {
3434
struct ExitCode(Option<i32>);
3535

3636
impl IntoDiagnosticArg for ExitCode {
37-
fn into_diagnostic_arg(self) -> DiagnosticArgValue {
37+
fn into_diagnostic_arg(self) -> DiagArgValue {
3838
let ExitCode(exit_code) = self;
3939
match exit_code {
4040
Some(t) => t.into_diagnostic_arg(),
41-
None => DiagnosticArgValue::Str(Cow::Borrowed("<signal>")),
41+
None => DiagArgValue::Str(Cow::Borrowed("<signal>")),
4242
}
4343
}
4444
}

compiler/rustc_codegen_ssa/src/assert_module_sources.rs

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -27,7 +27,7 @@ use crate::errors;
2727
use rustc_ast as ast;
2828
use rustc_data_structures::unord::UnordMap;
2929
use rustc_data_structures::unord::UnordSet;
30-
use rustc_errors::{DiagnosticArgValue, IntoDiagnosticArg};
30+
use rustc_errors::{DiagArgValue, IntoDiagnosticArg};
3131
use rustc_hir::def_id::LOCAL_CRATE;
3232
use rustc_middle::mir::mono::CodegenUnitNameBuilder;
3333
use rustc_middle::ty::TyCtxt;
@@ -206,8 +206,8 @@ impl fmt::Display for CguReuse {
206206
}
207207

208208
impl IntoDiagnosticArg for CguReuse {
209-
fn into_diagnostic_arg(self) -> DiagnosticArgValue {
210-
DiagnosticArgValue::Str(Cow::Owned(self.to_string()))
209+
fn into_diagnostic_arg(self) -> DiagArgValue {
210+
DiagArgValue::Str(Cow::Owned(self.to_string()))
211211
}
212212
}
213213

compiler/rustc_codegen_ssa/src/back/write.rs

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -16,7 +16,7 @@ use rustc_data_structures::sync::Lrc;
1616
use rustc_errors::emitter::Emitter;
1717
use rustc_errors::translation::Translate;
1818
use rustc_errors::{
19-
Diag, DiagCtxt, DiagnosticArgMap, DiagnosticMessage, ErrCode, FatalError, FluentBundle, Level,
19+
Diag, DiagArgMap, DiagCtxt, DiagnosticMessage, ErrCode, FatalError, FluentBundle, Level,
2020
MultiSpan, Style,
2121
};
2222
use rustc_fs_util::link_or_copy;
@@ -1013,7 +1013,7 @@ struct Diagnostic {
10131013
messages: Vec<(DiagnosticMessage, Style)>,
10141014
code: Option<ErrCode>,
10151015
children: Vec<Subdiagnostic>,
1016-
args: DiagnosticArgMap,
1016+
args: DiagArgMap,
10171017
}
10181018

10191019
// A cut-down version of `rustc_errors::SubDiagnostic` that impls `Send`. It's
@@ -1838,7 +1838,7 @@ impl Emitter for SharedEmitter {
18381838
assert_eq!(diag.is_lint, None);
18391839
// No sensible check for `diag.emitted_at`.
18401840

1841-
let args = mem::replace(&mut diag.args, DiagnosticArgMap::default());
1841+
let args = mem::replace(&mut diag.args, DiagArgMap::default());
18421842
drop(
18431843
self.sender.send(SharedEmitterMessage::Diagnostic(Diagnostic {
18441844
level: diag.level(),

compiler/rustc_codegen_ssa/src/errors.rs

Lines changed: 7 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -4,8 +4,8 @@ use crate::assert_module_sources::CguReuse;
44
use crate::back::command::Command;
55
use crate::fluent_generated as fluent;
66
use rustc_errors::{
7-
codes::*, Diag, DiagCtxt, DiagnosticArgValue, EmissionGuarantee, IntoDiagnostic,
8-
IntoDiagnosticArg, Level,
7+
codes::*, Diag, DiagArgValue, DiagCtxt, EmissionGuarantee, IntoDiagnostic, IntoDiagnosticArg,
8+
Level,
99
};
1010
use rustc_macros::Diagnostic;
1111
use rustc_middle::ty::layout::LayoutError;
@@ -153,8 +153,8 @@ impl<'a> CopyPath<'a> {
153153
struct DebugArgPath<'a>(pub &'a Path);
154154

155155
impl IntoDiagnosticArg for DebugArgPath<'_> {
156-
fn into_diagnostic_arg(self) -> rustc_errors::DiagnosticArgValue {
157-
DiagnosticArgValue::Str(Cow::Owned(format!("{:?}", self.0)))
156+
fn into_diagnostic_arg(self) -> rustc_errors::DiagArgValue {
157+
DiagArgValue::Str(Cow::Owned(format!("{:?}", self.0)))
158158
}
159159
}
160160

@@ -975,10 +975,10 @@ pub enum ExpectedPointerMutability {
975975
}
976976

977977
impl IntoDiagnosticArg for ExpectedPointerMutability {
978-
fn into_diagnostic_arg(self) -> DiagnosticArgValue {
978+
fn into_diagnostic_arg(self) -> DiagArgValue {
979979
match self {
980-
ExpectedPointerMutability::Mut => DiagnosticArgValue::Str(Cow::Borrowed("*mut")),
981-
ExpectedPointerMutability::Not => DiagnosticArgValue::Str(Cow::Borrowed("*_")),
980+
ExpectedPointerMutability::Mut => DiagArgValue::Str(Cow::Borrowed("*mut")),
981+
ExpectedPointerMutability::Not => DiagArgValue::Str(Cow::Borrowed("*_")),
982982
}
983983
}
984984
}

compiler/rustc_const_eval/src/const_eval/error.rs

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,7 @@
11
use std::mem;
22

33
use rustc_errors::{
4-
DiagnosticArgName, DiagnosticArgValue, DiagnosticMessage, IntoDiagnostic, IntoDiagnosticArg,
4+
DiagArgName, DiagArgValue, DiagnosticMessage, IntoDiagnostic, IntoDiagnosticArg,
55
};
66
use rustc_hir::CRATE_HIR_ID;
77
use rustc_middle::mir::AssertKind;
@@ -36,7 +36,7 @@ impl MachineStopType for ConstEvalErrKind {
3636
AssertFailure(x) => x.diagnostic_message(),
3737
}
3838
}
39-
fn add_args(self: Box<Self>, adder: &mut dyn FnMut(DiagnosticArgName, DiagnosticArgValue)) {
39+
fn add_args(self: Box<Self>, adder: &mut dyn FnMut(DiagArgName, DiagArgValue)) {
4040
use ConstEvalErrKind::*;
4141
match *self {
4242
RecursiveStatic | ConstAccessesMutGlobal | ModifiedGlobal => {}

compiler/rustc_const_eval/src/errors.rs

Lines changed: 7 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -1,8 +1,8 @@
11
use std::borrow::Cow;
22

33
use rustc_errors::{
4-
codes::*, Diag, DiagCtxt, DiagnosticArgValue, DiagnosticMessage, EmissionGuarantee,
5-
IntoDiagnostic, Level,
4+
codes::*, Diag, DiagArgValue, DiagCtxt, DiagnosticMessage, EmissionGuarantee, IntoDiagnostic,
5+
Level,
66
};
77
use rustc_hir::ConstContext;
88
use rustc_macros::{Diagnostic, LintDiagnostic, Subdiagnostic};
@@ -683,7 +683,7 @@ impl<'tcx> ReportErrorExt for ValidationErrorInfo<'tcx> {
683683
let message = if let Some(path) = self.path {
684684
err.dcx.eagerly_translate_to_string(
685685
fluent::const_eval_validation_front_matter_invalid_value_with_path,
686-
[("path".into(), DiagnosticArgValue::Str(path.into()))].iter().map(|(a, b)| (a, b)),
686+
[("path".into(), DiagArgValue::Str(path.into()))].iter().map(|(a, b)| (a, b)),
687687
)
688688
} else {
689689
err.dcx.eagerly_translate_to_string(
@@ -716,8 +716,8 @@ impl<'tcx> ReportErrorExt for ValidationErrorInfo<'tcx> {
716716
};
717717

718718
let args = [
719-
("lo".into(), DiagnosticArgValue::Str(lo.to_string().into())),
720-
("hi".into(), DiagnosticArgValue::Str(hi.to_string().into())),
719+
("lo".into(), DiagArgValue::Str(lo.to_string().into())),
720+
("hi".into(), DiagArgValue::Str(hi.to_string().into())),
721721
];
722722
let args = args.iter().map(|(a, b)| (a, b));
723723
let message = err.dcx.eagerly_translate_to_string(msg, args);
@@ -892,8 +892,8 @@ impl ReportErrorExt for ResourceExhaustionInfo {
892892
}
893893

894894
impl rustc_errors::IntoDiagnosticArg for InternKind {
895-
fn into_diagnostic_arg(self) -> DiagnosticArgValue {
896-
DiagnosticArgValue::Str(Cow::Borrowed(match self {
895+
fn into_diagnostic_arg(self) -> DiagArgValue {
896+
DiagArgValue::Str(Cow::Borrowed(match self {
897897
InternKind::Static(Mutability::Not) => "static",
898898
InternKind::Static(Mutability::Mut) => "static_mut",
899899
InternKind::Constant => "const",

compiler/rustc_errors/src/diagnostic.rs

Lines changed: 21 additions & 21 deletions
Original file line numberDiff line numberDiff line change
@@ -24,17 +24,17 @@ use std::thread::panicking;
2424
pub struct SuggestionsDisabled;
2525

2626
/// Simplified version of `FluentArg` that can implement `Encodable` and `Decodable`. Collection of
27-
/// `DiagnosticArg` are converted to `FluentArgs` (consuming the collection) at the start of
28-
/// diagnostic emission.
29-
pub type DiagnosticArg<'iter> = (&'iter DiagnosticArgName, &'iter DiagnosticArgValue);
27+
/// `DiagArg` are converted to `FluentArgs` (consuming the collection) at the start of diagnostic
28+
/// emission.
29+
pub type DiagArg<'iter> = (&'iter DiagArgName, &'iter DiagArgValue);
3030

3131
/// Name of a diagnostic argument.
32-
pub type DiagnosticArgName = Cow<'static, str>;
32+
pub type DiagArgName = Cow<'static, str>;
3333

3434
/// Simplified version of `FluentValue` that can implement `Encodable` and `Decodable`. Converted
3535
/// to a `FluentValue` by the emitter to be used in diagnostic translation.
3636
#[derive(Clone, Debug, PartialEq, Eq, Hash, Encodable, Decodable)]
37-
pub enum DiagnosticArgValue {
37+
pub enum DiagArgValue {
3838
Str(Cow<'static, str>),
3939
// This gets converted to a `FluentNumber`, which is an `f64`. An `i32`
4040
// safely fits in an `f64`. Any integers bigger than that will be converted
@@ -43,7 +43,7 @@ pub enum DiagnosticArgValue {
4343
StrListSepByAnd(Vec<Cow<'static, str>>),
4444
}
4545

46-
pub type DiagnosticArgMap = FxIndexMap<DiagnosticArgName, DiagnosticArgValue>;
46+
pub type DiagArgMap = FxIndexMap<DiagArgName, DiagArgValue>;
4747

4848
/// Trait for types that `Diag::emit` can return as a "guarantee" (or "proof")
4949
/// token that the emission happened.
@@ -125,26 +125,26 @@ where
125125
}
126126
}
127127

128-
/// Converts a value of a type into a `DiagnosticArg` (typically a field of an `IntoDiagnostic`
129-
/// struct). Implemented as a custom trait rather than `From` so that it is implemented on the type
130-
/// being converted rather than on `DiagnosticArgValue`, which enables types from other `rustc_*`
131-
/// crates to implement this.
128+
/// Converts a value of a type into a `DiagArg` (typically a field of an `IntoDiagnostic` struct).
129+
/// Implemented as a custom trait rather than `From` so that it is implemented on the type being
130+
/// converted rather than on `DiagArgValue`, which enables types from other `rustc_*` crates to
131+
/// implement this.
132132
pub trait IntoDiagnosticArg {
133-
fn into_diagnostic_arg(self) -> DiagnosticArgValue;
133+
fn into_diagnostic_arg(self) -> DiagArgValue;
134134
}
135135

136-
impl IntoDiagnosticArg for DiagnosticArgValue {
137-
fn into_diagnostic_arg(self) -> DiagnosticArgValue {
136+
impl IntoDiagnosticArg for DiagArgValue {
137+
fn into_diagnostic_arg(self) -> DiagArgValue {
138138
self
139139
}
140140
}
141141

142-
impl Into<FluentValue<'static>> for DiagnosticArgValue {
142+
impl Into<FluentValue<'static>> for DiagArgValue {
143143
fn into(self) -> FluentValue<'static> {
144144
match self {
145-
DiagnosticArgValue::Str(s) => From::from(s),
146-
DiagnosticArgValue::Number(n) => From::from(n),
147-
DiagnosticArgValue::StrListSepByAnd(l) => fluent_value_from_str_list_sep_by_and(l),
145+
DiagArgValue::Str(s) => From::from(s),
146+
DiagArgValue::Number(n) => From::from(n),
147+
DiagArgValue::StrListSepByAnd(l) => fluent_value_from_str_list_sep_by_and(l),
148148
}
149149
}
150150
}
@@ -277,7 +277,7 @@ pub struct DiagInner {
277277
pub span: MultiSpan,
278278
pub children: Vec<Subdiag>,
279279
pub suggestions: Result<Vec<CodeSuggestion>, SuggestionsDisabled>,
280-
pub args: DiagnosticArgMap,
280+
pub args: DiagArgMap,
281281

282282
/// This is not used for highlighting or rendering any error message. Rather, it can be used
283283
/// as a sort key to sort a buffer of diagnostics. By default, it is the primary span of
@@ -401,7 +401,7 @@ impl DiagInner {
401401
self.children.push(sub);
402402
}
403403

404-
pub(crate) fn arg(&mut self, name: impl Into<DiagnosticArgName>, arg: impl IntoDiagnosticArg) {
404+
pub(crate) fn arg(&mut self, name: impl Into<DiagArgName>, arg: impl IntoDiagnosticArg) {
405405
self.args.insert(name.into(), arg.into_diagnostic_arg());
406406
}
407407

@@ -415,7 +415,7 @@ impl DiagInner {
415415
&MultiSpan,
416416
&[Subdiag],
417417
&Result<Vec<CodeSuggestion>, SuggestionsDisabled>,
418-
Vec<(&DiagnosticArgName, &DiagnosticArgValue)>,
418+
Vec<(&DiagArgName, &DiagArgValue)>,
419419
&Option<IsLint>,
420420
) {
421421
(
@@ -1193,7 +1193,7 @@ impl<'a, G: EmissionGuarantee> Diag<'a, G> {
11931193
/// Add an argument.
11941194
pub fn arg(
11951195
&mut self,
1196-
name: impl Into<DiagnosticArgName>,
1196+
name: impl Into<DiagArgName>,
11971197
arg: impl IntoDiagnosticArg,
11981198
) -> &mut Self {
11991199
self.deref_mut().arg(name, arg);

0 commit comments

Comments
 (0)