Skip to content

Commit 6fdaf3e

Browse files
committed
Use DiagnosticArgName in a few more places.
1 parent df322fc commit 6fdaf3e

File tree

8 files changed

+18
-17
lines changed

8 files changed

+18
-17
lines changed

compiler/rustc_codegen_ssa/src/back/write.rs

Lines changed: 1 addition & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -39,7 +39,6 @@ use rustc_target::spec::{MergeFunctions, SanitizerSet};
3939

4040
use crate::errors::ErrorCreatingRemarkDir;
4141
use std::any::Any;
42-
use std::borrow::Cow;
4342
use std::fs;
4443
use std::io;
4544
use std::marker::PhantomData;
@@ -1812,7 +1811,7 @@ impl Translate for SharedEmitter {
18121811

18131812
impl Emitter for SharedEmitter {
18141813
fn emit_diagnostic(&mut self, diag: &rustc_errors::Diagnostic) {
1815-
let args: FxHashMap<Cow<'_, str>, DiagnosticArgValue> =
1814+
let args: FxHashMap<DiagnosticArgName, DiagnosticArgValue> =
18161815
diag.args().map(|(name, arg)| (name.clone(), arg.clone())).collect();
18171816
drop(self.sender.send(SharedEmitterMessage::Diagnostic(Diagnostic {
18181817
msgs: diag.messages.clone(),

compiler/rustc_const_eval/src/const_eval/error.rs

Lines changed: 4 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,8 @@
11
use std::mem;
22

3-
use rustc_errors::{DiagnosticArgValue, DiagnosticMessage, IntoDiagnostic, IntoDiagnosticArg};
3+
use rustc_errors::{
4+
DiagnosticArgName, DiagnosticArgValue, DiagnosticMessage, IntoDiagnostic, IntoDiagnosticArg,
5+
};
46
use rustc_hir::CRATE_HIR_ID;
57
use rustc_middle::mir::AssertKind;
68
use rustc_middle::query::TyCtxtAt;
@@ -32,10 +34,7 @@ impl MachineStopType for ConstEvalErrKind {
3234
AssertFailure(x) => x.diagnostic_message(),
3335
}
3436
}
35-
fn add_args(
36-
self: Box<Self>,
37-
adder: &mut dyn FnMut(std::borrow::Cow<'static, str>, DiagnosticArgValue),
38-
) {
37+
fn add_args(self: Box<Self>, adder: &mut dyn FnMut(DiagnosticArgName, DiagnosticArgValue)) {
3938
use ConstEvalErrKind::*;
4039
match *self {
4140
ConstAccessesStatic | ModifiedGlobal => {}

compiler/rustc_errors/src/diagnostic.rs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -900,7 +900,7 @@ impl Diagnostic {
900900

901901
pub fn arg(
902902
&mut self,
903-
name: impl Into<Cow<'static, str>>,
903+
name: impl Into<DiagnosticArgName>,
904904
arg: impl IntoDiagnosticArg,
905905
) -> &mut Self {
906906
self.args.insert(name.into(), arg.into_diagnostic_arg());

compiler/rustc_middle/src/error.rs

Lines changed: 3 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,6 @@
1-
use std::borrow::Cow;
21
use std::fmt;
32

4-
use rustc_errors::{codes::*, DiagnosticArgValue, DiagnosticMessage};
3+
use rustc_errors::{codes::*, DiagnosticArgName, DiagnosticArgValue, DiagnosticMessage};
54
use rustc_macros::Diagnostic;
65
use rustc_span::{Span, Symbol};
76

@@ -95,14 +94,14 @@ pub(super) struct ConstNotUsedTraitAlias {
9594

9695
pub struct CustomSubdiagnostic<'a> {
9796
pub msg: fn() -> DiagnosticMessage,
98-
pub add_args: Box<dyn FnOnce(&mut dyn FnMut(Cow<'static, str>, DiagnosticArgValue)) + 'a>,
97+
pub add_args: Box<dyn FnOnce(&mut dyn FnMut(DiagnosticArgName, DiagnosticArgValue)) + 'a>,
9998
}
10099

101100
impl<'a> CustomSubdiagnostic<'a> {
102101
pub fn label(x: fn() -> DiagnosticMessage) -> Self {
103102
Self::label_and_then(x, |_| {})
104103
}
105-
pub fn label_and_then<F: FnOnce(&mut dyn FnMut(Cow<'static, str>, DiagnosticArgValue)) + 'a>(
104+
pub fn label_and_then<F: FnOnce(&mut dyn FnMut(DiagnosticArgName, DiagnosticArgValue)) + 'a>(
106105
msg: fn() -> DiagnosticMessage,
107106
f: F,
108107
) -> Self {

compiler/rustc_middle/src/mir/interpret/error.rs

Lines changed: 4 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -5,7 +5,9 @@ use crate::mir::{ConstAlloc, ConstValue};
55
use crate::ty::{layout, tls, Ty, TyCtxt, ValTree};
66

77
use rustc_data_structures::sync::Lock;
8-
use rustc_errors::{DiagnosticArgValue, DiagnosticMessage, ErrorGuaranteed, IntoDiagnosticArg};
8+
use rustc_errors::{
9+
DiagnosticArgName, DiagnosticArgValue, DiagnosticMessage, ErrorGuaranteed, IntoDiagnosticArg,
10+
};
911
use rustc_macros::HashStable;
1012
use rustc_session::CtfeBacktrace;
1113
use rustc_span::{def_id::DefId, Span, DUMMY_SP};
@@ -485,7 +487,7 @@ pub trait MachineStopType: Any + fmt::Debug + Send {
485487
fn diagnostic_message(&self) -> DiagnosticMessage;
486488
/// Add diagnostic arguments by passing name and value pairs to `adder`, which are passed to
487489
/// fluent for formatting the translated diagnostic message.
488-
fn add_args(self: Box<Self>, adder: &mut dyn FnMut(Cow<'static, str>, DiagnosticArgValue));
490+
fn add_args(self: Box<Self>, adder: &mut dyn FnMut(DiagnosticArgName, DiagnosticArgValue));
489491
}
490492

491493
impl dyn MachineStopType {

compiler/rustc_middle/src/mir/mod.rs

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -14,7 +14,9 @@ use crate::ty::{AdtDef, InstanceDef, UserTypeAnnotationIndex};
1414
use crate::ty::{GenericArg, GenericArgsRef};
1515

1616
use rustc_data_structures::captures::Captures;
17-
use rustc_errors::{DiagnosticArgValue, DiagnosticMessage, ErrorGuaranteed, IntoDiagnosticArg};
17+
use rustc_errors::{
18+
DiagnosticArgName, DiagnosticArgValue, DiagnosticMessage, ErrorGuaranteed, IntoDiagnosticArg,
19+
};
1820
use rustc_hir::def::{CtorKind, Namespace};
1921
use rustc_hir::def_id::{DefId, CRATE_DEF_ID};
2022
use rustc_hir::{self, CoroutineDesugaring, CoroutineKind, ImplicitSelfKind};

compiler/rustc_middle/src/mir/terminator.rs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -292,7 +292,7 @@ impl<O> AssertKind<O> {
292292
}
293293
}
294294

295-
pub fn add_args(self, adder: &mut dyn FnMut(Cow<'static, str>, DiagnosticArgValue))
295+
pub fn add_args(self, adder: &mut dyn FnMut(DiagnosticArgName, DiagnosticArgValue))
296296
where
297297
O: fmt::Debug,
298298
{

compiler/rustc_mir_transform/src/const_prop.rs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -34,7 +34,7 @@ pub(crate) macro throw_machine_stop_str($($tt:tt)*) {{
3434

3535
fn add_args(
3636
self: Box<Self>,
37-
_: &mut dyn FnMut(std::borrow::Cow<'static, str>, rustc_errors::DiagnosticArgValue),
37+
_: &mut dyn FnMut(rustc_errors::DiagnosticArgName, rustc_errors::DiagnosticArgValue),
3838
) {}
3939
}
4040
throw_machine_stop!(Zst)

0 commit comments

Comments
 (0)