Rename `IntoDiagnosticArg` as `IntoDiagArg`.

Also rename `into_diagnostic_arg` as `into_diag_arg`, and
`NotIntoDiagnosticArg` as `NotInotDiagArg`.
This commit is contained in:
Nicholas Nethercote 2024-03-05 16:53:24 +11:00
parent 256d802233
commit a09b1d33a7
38 changed files with 218 additions and 219 deletions

View File

@ -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()
}
}

View File

@ -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;
@ -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()))
}
}

View File

@ -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;
@ -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)))
}
}
@ -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("*_")),

View File

@ -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;
@ -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());
}
}
}

View File

@ -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",

View File

@ -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>>),
}
@ -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
}
}
@ -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.
@ -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

View File

@ -1,8 +1,8 @@
use crate::diagnostic::DiagLocation;
use crate::{fluent_generated as fluent, AddToDiagnostic};
use crate::{
Diag, DiagArgValue, DiagCtxt, EmissionGuarantee, ErrCode, IntoDiagnostic, IntoDiagnosticArg,
Level, SubdiagMessageOp,
Diag, DiagArgValue, DiagCtxt, EmissionGuarantee, ErrCode, IntoDiagArg, IntoDiagnostic, Level,
SubdiagMessageOp,
};
use rustc_ast as ast;
use rustc_ast_pretty::pprust;
@ -22,9 +22,9 @@ use std::process::ExitStatus;
pub struct DiagArgFromDisplay<'a>(pub &'a dyn fmt::Display);
impl IntoDiagnosticArg for DiagArgFromDisplay<'_> {
fn into_diagnostic_arg(self) -> DiagArgValue {
self.0.to_string().into_diagnostic_arg()
impl IntoDiagArg for DiagArgFromDisplay<'_> {
fn into_diag_arg(self) -> DiagArgValue {
self.0.to_string().into_diag_arg()
}
}
@ -40,34 +40,34 @@ impl<'a, T: fmt::Display> From<&'a T> for DiagArgFromDisplay<'a> {
}
}
impl<'a, T: Clone + IntoDiagnosticArg> IntoDiagnosticArg for &'a T {
fn into_diagnostic_arg(self) -> DiagArgValue {
self.clone().into_diagnostic_arg()
impl<'a, T: Clone + IntoDiagArg> IntoDiagArg for &'a T {
fn into_diag_arg(self) -> DiagArgValue {
self.clone().into_diag_arg()
}
}
macro_rules! into_diagnostic_arg_using_display {
macro_rules! into_diag_arg_using_display {
($( $ty:ty ),+ $(,)?) => {
$(
impl IntoDiagnosticArg for $ty {
fn into_diagnostic_arg(self) -> DiagArgValue {
self.to_string().into_diagnostic_arg()
impl IntoDiagArg for $ty {
fn into_diag_arg(self) -> DiagArgValue {
self.to_string().into_diag_arg()
}
}
)+
}
}
macro_rules! into_diagnostic_arg_for_number {
macro_rules! into_diag_arg_for_number {
($( $ty:ty ),+ $(,)?) => {
$(
impl IntoDiagnosticArg for $ty {
fn into_diagnostic_arg(self) -> DiagArgValue {
impl IntoDiagArg for $ty {
fn into_diag_arg(self) -> DiagArgValue {
// Convert to a string if it won't fit into `Number`.
if let Ok(n) = TryInto::<i32>::try_into(self) {
DiagArgValue::Number(n)
} else {
self.to_string().into_diagnostic_arg()
self.to_string().into_diag_arg()
}
}
}
@ -75,7 +75,7 @@ macro_rules! into_diagnostic_arg_for_number {
}
}
into_diagnostic_arg_using_display!(
into_diag_arg_using_display!(
ast::ParamKindOrd,
std::io::Error,
Box<dyn std::error::Error>,
@ -92,10 +92,10 @@ into_diagnostic_arg_using_display!(
ErrCode,
);
into_diagnostic_arg_for_number!(i8, u8, i16, u16, i32, u32, i64, u64, i128, u128, isize, usize);
into_diag_arg_for_number!(i8, u8, i16, u16, i32, u32, i64, u64, i128, u128, isize, usize);
impl IntoDiagnosticArg for bool {
fn into_diagnostic_arg(self) -> DiagArgValue {
impl IntoDiagArg for bool {
fn into_diag_arg(self) -> DiagArgValue {
if self {
DiagArgValue::Str(Cow::Borrowed("true"))
} else {
@ -104,64 +104,64 @@ impl IntoDiagnosticArg for bool {
}
}
impl IntoDiagnosticArg for char {
fn into_diagnostic_arg(self) -> DiagArgValue {
impl IntoDiagArg for char {
fn into_diag_arg(self) -> DiagArgValue {
DiagArgValue::Str(Cow::Owned(format!("{self:?}")))
}
}
impl IntoDiagnosticArg for Vec<char> {
fn into_diagnostic_arg(self) -> DiagArgValue {
impl IntoDiagArg for Vec<char> {
fn into_diag_arg(self) -> DiagArgValue {
DiagArgValue::StrListSepByAnd(
self.into_iter().map(|c| Cow::Owned(format!("{c:?}"))).collect(),
)
}
}
impl IntoDiagnosticArg for Symbol {
fn into_diagnostic_arg(self) -> DiagArgValue {
self.to_ident_string().into_diagnostic_arg()
impl IntoDiagArg for Symbol {
fn into_diag_arg(self) -> DiagArgValue {
self.to_ident_string().into_diag_arg()
}
}
impl<'a> IntoDiagnosticArg for &'a str {
fn into_diagnostic_arg(self) -> DiagArgValue {
self.to_string().into_diagnostic_arg()
impl<'a> IntoDiagArg for &'a str {
fn into_diag_arg(self) -> DiagArgValue {
self.to_string().into_diag_arg()
}
}
impl IntoDiagnosticArg for String {
fn into_diagnostic_arg(self) -> DiagArgValue {
impl IntoDiagArg for String {
fn into_diag_arg(self) -> DiagArgValue {
DiagArgValue::Str(Cow::Owned(self))
}
}
impl<'a> IntoDiagnosticArg for Cow<'a, str> {
fn into_diagnostic_arg(self) -> DiagArgValue {
impl<'a> IntoDiagArg for Cow<'a, str> {
fn into_diag_arg(self) -> DiagArgValue {
DiagArgValue::Str(Cow::Owned(self.into_owned()))
}
}
impl<'a> IntoDiagnosticArg for &'a Path {
fn into_diagnostic_arg(self) -> DiagArgValue {
impl<'a> IntoDiagArg for &'a Path {
fn into_diag_arg(self) -> DiagArgValue {
DiagArgValue::Str(Cow::Owned(self.display().to_string()))
}
}
impl IntoDiagnosticArg for PathBuf {
fn into_diagnostic_arg(self) -> DiagArgValue {
impl IntoDiagArg for PathBuf {
fn into_diag_arg(self) -> DiagArgValue {
DiagArgValue::Str(Cow::Owned(self.display().to_string()))
}
}
impl IntoDiagnosticArg for PanicStrategy {
fn into_diagnostic_arg(self) -> DiagArgValue {
impl IntoDiagArg for PanicStrategy {
fn into_diag_arg(self) -> DiagArgValue {
DiagArgValue::Str(Cow::Owned(self.desc().to_string()))
}
}
impl IntoDiagnosticArg for hir::ConstContext {
fn into_diagnostic_arg(self) -> DiagArgValue {
impl IntoDiagArg for hir::ConstContext {
fn into_diag_arg(self) -> DiagArgValue {
DiagArgValue::Str(Cow::Borrowed(match self {
hir::ConstContext::ConstFn => "const_fn",
hir::ConstContext::Static(_) => "static",
@ -170,58 +170,58 @@ impl IntoDiagnosticArg for hir::ConstContext {
}
}
impl IntoDiagnosticArg for ast::Expr {
fn into_diagnostic_arg(self) -> DiagArgValue {
impl IntoDiagArg for ast::Expr {
fn into_diag_arg(self) -> DiagArgValue {
DiagArgValue::Str(Cow::Owned(pprust::expr_to_string(&self)))
}
}
impl IntoDiagnosticArg for ast::Path {
fn into_diagnostic_arg(self) -> DiagArgValue {
impl IntoDiagArg for ast::Path {
fn into_diag_arg(self) -> DiagArgValue {
DiagArgValue::Str(Cow::Owned(pprust::path_to_string(&self)))
}
}
impl IntoDiagnosticArg for ast::token::Token {
fn into_diagnostic_arg(self) -> DiagArgValue {
impl IntoDiagArg for ast::token::Token {
fn into_diag_arg(self) -> DiagArgValue {
DiagArgValue::Str(pprust::token_to_string(&self))
}
}
impl IntoDiagnosticArg for ast::token::TokenKind {
fn into_diagnostic_arg(self) -> DiagArgValue {
impl IntoDiagArg for ast::token::TokenKind {
fn into_diag_arg(self) -> DiagArgValue {
DiagArgValue::Str(pprust::token_kind_to_string(&self))
}
}
impl IntoDiagnosticArg for type_ir::FloatTy {
fn into_diagnostic_arg(self) -> DiagArgValue {
impl IntoDiagArg for type_ir::FloatTy {
fn into_diag_arg(self) -> DiagArgValue {
DiagArgValue::Str(Cow::Borrowed(self.name_str()))
}
}
impl IntoDiagnosticArg for std::ffi::CString {
fn into_diagnostic_arg(self) -> DiagArgValue {
impl IntoDiagArg for std::ffi::CString {
fn into_diag_arg(self) -> DiagArgValue {
DiagArgValue::Str(Cow::Owned(self.to_string_lossy().into_owned()))
}
}
impl IntoDiagnosticArg for rustc_data_structures::small_c_str::SmallCStr {
fn into_diagnostic_arg(self) -> DiagArgValue {
impl IntoDiagArg for rustc_data_structures::small_c_str::SmallCStr {
fn into_diag_arg(self) -> DiagArgValue {
DiagArgValue::Str(Cow::Owned(self.to_string_lossy().into_owned()))
}
}
impl IntoDiagnosticArg for ast::Visibility {
fn into_diagnostic_arg(self) -> DiagArgValue {
impl IntoDiagArg for ast::Visibility {
fn into_diag_arg(self) -> DiagArgValue {
let s = pprust::vis_to_string(&self);
let s = s.trim_end().to_string();
DiagArgValue::Str(Cow::Owned(s))
}
}
impl IntoDiagnosticArg for rustc_lint_defs::Level {
fn into_diagnostic_arg(self) -> DiagArgValue {
impl IntoDiagArg for rustc_lint_defs::Level {
fn into_diag_arg(self) -> DiagArgValue {
DiagArgValue::Str(Cow::Borrowed(self.to_cmd_flag()))
}
}
@ -235,16 +235,16 @@ impl From<Vec<Symbol>> for DiagSymbolList {
}
}
impl IntoDiagnosticArg for DiagSymbolList {
fn into_diagnostic_arg(self) -> DiagArgValue {
impl IntoDiagArg for DiagSymbolList {
fn into_diag_arg(self) -> DiagArgValue {
DiagArgValue::StrListSepByAnd(
self.0.into_iter().map(|sym| Cow::Owned(format!("`{sym}`"))).collect(),
)
}
}
impl<Id> IntoDiagnosticArg for hir::def::Res<Id> {
fn into_diagnostic_arg(self) -> DiagArgValue {
impl<Id> IntoDiagArg for hir::def::Res<Id> {
fn into_diag_arg(self) -> DiagArgValue {
DiagArgValue::Str(Cow::Borrowed(self.descr()))
}
}
@ -315,20 +315,20 @@ pub struct ExpectedLifetimeParameter {
pub count: usize,
}
impl IntoDiagnosticArg for DiagLocation {
fn into_diagnostic_arg(self) -> DiagArgValue {
impl IntoDiagArg for DiagLocation {
fn into_diag_arg(self) -> DiagArgValue {
DiagArgValue::Str(Cow::from(self.to_string()))
}
}
impl IntoDiagnosticArg for Backtrace {
fn into_diagnostic_arg(self) -> DiagArgValue {
impl IntoDiagArg for Backtrace {
fn into_diag_arg(self) -> DiagArgValue {
DiagArgValue::Str(Cow::from(self.to_string()))
}
}
impl IntoDiagnosticArg for Level {
fn into_diagnostic_arg(self) -> DiagArgValue {
impl IntoDiagArg for Level {
fn into_diag_arg(self) -> DiagArgValue {
DiagArgValue::Str(Cow::from(self.to_string()))
}
}
@ -342,8 +342,8 @@ pub struct IndicateAnonymousLifetime {
pub suggestion: String,
}
impl IntoDiagnosticArg for type_ir::ClosureKind {
fn into_diagnostic_arg(self) -> DiagArgValue {
impl IntoDiagArg for type_ir::ClosureKind {
fn into_diag_arg(self) -> DiagArgValue {
DiagArgValue::Str(self.as_str().into())
}
}

View File

@ -38,7 +38,7 @@ extern crate self as rustc_errors;
pub use codes::*;
pub use diagnostic::{
AddToDiagnostic, BugAbort, DecorateLint, Diag, DiagArg, DiagArgMap, DiagArgName, DiagArgValue,
DiagInner, DiagStyledString, EmissionGuarantee, FatalAbort, IntoDiagnostic, IntoDiagnosticArg,
DiagInner, DiagStyledString, EmissionGuarantee, FatalAbort, IntoDiagArg, IntoDiagnostic,
StringPart, Subdiag, SubdiagMessageOp,
};
pub use diagnostic_impls::{

View File

@ -1510,7 +1510,7 @@ impl fmt::Display for ConstContext {
}
}
// NOTE: `IntoDiagnosticArg` impl for `ConstContext` lives in `rustc_errors`
// NOTE: `IntoDiagArg` impl for `ConstContext` lives in `rustc_errors`
// due to a cyclical dependency between hir that crate.
/// A literal.

View File

@ -3,8 +3,8 @@ use std::borrow::Cow;
use crate::fluent_generated as fluent;
use rustc_errors::{
codes::*, AddToDiagnostic, Applicability, Diag, DiagArgValue, EmissionGuarantee,
IntoDiagnosticArg, MultiSpan, SubdiagMessageOp,
codes::*, AddToDiagnostic, Applicability, Diag, DiagArgValue, EmissionGuarantee, IntoDiagArg,
MultiSpan, SubdiagMessageOp,
};
use rustc_macros::{Diagnostic, LintDiagnostic, Subdiagnostic};
use rustc_middle::ty::Ty;
@ -42,8 +42,8 @@ pub enum ReturnLikeStatementKind {
Become,
}
impl IntoDiagnosticArg for ReturnLikeStatementKind {
fn into_diagnostic_arg(self) -> DiagArgValue {
impl IntoDiagArg for ReturnLikeStatementKind {
fn into_diag_arg(self) -> DiagArgValue {
let kind = match self {
Self::Return => "return",
Self::Become => "become",

View File

@ -1,7 +1,7 @@
use hir::GenericParamKind;
use rustc_errors::{
codes::*, AddToDiagnostic, Applicability, Diag, DiagMessage, DiagStyledString,
EmissionGuarantee, IntoDiagnosticArg, MultiSpan, SubdiagMessageOp,
EmissionGuarantee, IntoDiagArg, MultiSpan, SubdiagMessageOp,
};
use rustc_hir as hir;
use rustc_hir::FnRetTy;
@ -537,11 +537,11 @@ pub enum TyOrSig<'tcx> {
ClosureSig(Highlighted<'tcx, Binder<'tcx, FnSig<'tcx>>>),
}
impl IntoDiagnosticArg for TyOrSig<'_> {
fn into_diagnostic_arg(self) -> rustc_errors::DiagArgValue {
impl IntoDiagArg for TyOrSig<'_> {
fn into_diag_arg(self) -> rustc_errors::DiagArgValue {
match self {
TyOrSig::Ty(ty) => ty.into_diagnostic_arg(),
TyOrSig::ClosureSig(sig) => sig.into_diagnostic_arg(),
TyOrSig::Ty(ty) => ty.into_diag_arg(),
TyOrSig::ClosureSig(sig) => sig.into_diag_arg(),
}
}
}

View File

@ -1,6 +1,6 @@
use crate::fluent_generated as fluent;
use crate::infer::error_reporting::nice_region_error::find_anon_type;
use rustc_errors::{AddToDiagnostic, Diag, EmissionGuarantee, IntoDiagnosticArg, SubdiagMessageOp};
use rustc_errors::{AddToDiagnostic, Diag, EmissionGuarantee, IntoDiagArg, SubdiagMessageOp};
use rustc_middle::ty::{self, TyCtxt};
use rustc_span::{symbol::kw, Span};
@ -107,8 +107,8 @@ pub enum SuffixKind {
ReqByBinding,
}
impl IntoDiagnosticArg for PrefixKind {
fn into_diagnostic_arg(self) -> rustc_errors::DiagArgValue {
impl IntoDiagArg for PrefixKind {
fn into_diag_arg(self) -> rustc_errors::DiagArgValue {
let kind = match self {
Self::Empty => "empty",
Self::RefValidFor => "ref_valid_for",
@ -129,8 +129,8 @@ impl IntoDiagnosticArg for PrefixKind {
}
}
impl IntoDiagnosticArg for SuffixKind {
fn into_diagnostic_arg(self) -> rustc_errors::DiagArgValue {
impl IntoDiagArg for SuffixKind {
fn into_diag_arg(self) -> rustc_errors::DiagArgValue {
let kind = match self {
Self::Empty => "empty",
Self::Continues => "continues",

View File

@ -61,7 +61,7 @@ use crate::traits::{
use rustc_data_structures::fx::{FxIndexMap, FxIndexSet};
use rustc_errors::{
codes::*, pluralize, struct_span_code_err, Applicability, Diag, DiagCtxt, DiagStyledString,
ErrorGuaranteed, IntoDiagnosticArg,
ErrorGuaranteed, IntoDiagArg,
};
use rustc_hir as hir;
use rustc_hir::def::DefKind;
@ -2895,11 +2895,11 @@ impl<'tcx> ObligationCause<'tcx> {
}
}
/// Newtype to allow implementing IntoDiagnosticArg
/// Newtype to allow implementing IntoDiagArg
pub struct ObligationCauseAsDiagArg<'tcx>(pub ObligationCause<'tcx>);
impl IntoDiagnosticArg for ObligationCauseAsDiagArg<'_> {
fn into_diagnostic_arg(self) -> rustc_errors::DiagArgValue {
impl IntoDiagArg for ObligationCauseAsDiagArg<'_> {
fn into_diag_arg(self) -> rustc_errors::DiagArgValue {
use crate::traits::ObligationCauseCode::*;
let kind = match self.0.code() {
CompareImplItemObligation { kind: ty::AssocKind::Fn, .. } => "method_compat",

View File

@ -5,7 +5,7 @@ use crate::errors::{
use crate::infer::error_reporting::TypeErrCtxt;
use crate::infer::type_variable::{TypeVariableOrigin, TypeVariableOriginKind};
use crate::infer::InferCtxt;
use rustc_errors::{codes::*, Diag, IntoDiagnosticArg};
use rustc_errors::{codes::*, Diag, IntoDiagArg};
use rustc_hir as hir;
use rustc_hir::def::Res;
use rustc_hir::def::{CtorOf, DefKind, Namespace};
@ -133,8 +133,8 @@ impl InferenceDiagnosticsParentData {
}
}
impl IntoDiagnosticArg for UnderspecifiedArgKind {
fn into_diagnostic_arg(self) -> rustc_errors::DiagArgValue {
impl IntoDiagArg for UnderspecifiedArgKind {
fn into_diag_arg(self) -> rustc_errors::DiagArgValue {
let kind = match self {
Self::Type { .. } => "type",
Self::Const { is_parameter: true } => "const_with_param",

View File

@ -8,7 +8,7 @@ use crate::infer::ValuePairs;
use crate::infer::{SubregionOrigin, TypeTrace};
use crate::traits::{ObligationCause, ObligationCauseCode};
use rustc_data_structures::intern::Interned;
use rustc_errors::{Diag, IntoDiagnosticArg};
use rustc_errors::{Diag, IntoDiagArg};
use rustc_hir::def::Namespace;
use rustc_hir::def_id::DefId;
use rustc_middle::ty::error::ExpectedFound;
@ -26,11 +26,11 @@ pub struct Highlighted<'tcx, T> {
value: T,
}
impl<'tcx, T> IntoDiagnosticArg for Highlighted<'tcx, T>
impl<'tcx, T> IntoDiagArg for Highlighted<'tcx, T>
where
T: for<'a> Print<'tcx, FmtPrinter<'a, 'tcx>>,
{
fn into_diagnostic_arg(self) -> rustc_errors::DiagArgValue {
fn into_diag_arg(self) -> rustc_errors::DiagArgValue {
rustc_errors::DiagArgValue::Str(self.to_string().into())
}
}

View File

@ -220,7 +220,7 @@ use rustc_data_structures::fx::{FxHashMap, FxHashSet};
use rustc_data_structures::memmap::Mmap;
use rustc_data_structures::owned_slice::slice_owned;
use rustc_data_structures::svh::Svh;
use rustc_errors::{DiagArgValue, IntoDiagnosticArg};
use rustc_errors::{DiagArgValue, IntoDiagArg};
use rustc_fs_util::try_canonicalize;
use rustc_session::config;
use rustc_session::cstore::CrateSource;
@ -290,8 +290,8 @@ impl fmt::Display for CrateFlavor {
}
}
impl IntoDiagnosticArg for CrateFlavor {
fn into_diagnostic_arg(self) -> rustc_errors::DiagArgValue {
impl IntoDiagArg for CrateFlavor {
fn into_diag_arg(self) -> rustc_errors::DiagArgValue {
match self {
CrateFlavor::Rlib => DiagArgValue::Str(Cow::Borrowed("rlib")),
CrateFlavor::Rmeta => DiagArgValue::Str(Cow::Borrowed("rmeta")),

View File

@ -6,7 +6,7 @@ use crate::ty::{layout, tls, Ty, TyCtxt, ValTree};
use rustc_ast_ir::Mutability;
use rustc_data_structures::sync::Lock;
use rustc_errors::{DiagArgName, DiagArgValue, DiagMessage, ErrorGuaranteed, IntoDiagnosticArg};
use rustc_errors::{DiagArgName, DiagArgValue, DiagMessage, ErrorGuaranteed, IntoDiagArg};
use rustc_macros::HashStable;
use rustc_session::CtfeBacktrace;
use rustc_span::{def_id::DefId, Span, DUMMY_SP};
@ -234,8 +234,8 @@ pub enum InvalidMetaKind {
TooBig,
}
impl IntoDiagnosticArg for InvalidMetaKind {
fn into_diagnostic_arg(self) -> DiagArgValue {
impl IntoDiagArg for InvalidMetaKind {
fn into_diag_arg(self) -> DiagArgValue {
DiagArgValue::Str(Cow::Borrowed(match self {
InvalidMetaKind::SliceTooBig => "slice_too_big",
InvalidMetaKind::TooBig => "too_big",
@ -266,10 +266,10 @@ pub struct Misalignment {
pub required: Align,
}
macro_rules! impl_into_diagnostic_arg_through_debug {
macro_rules! impl_into_diag_arg_through_debug {
($($ty:ty),*$(,)?) => {$(
impl IntoDiagnosticArg for $ty {
fn into_diagnostic_arg(self) -> DiagArgValue {
impl IntoDiagArg for $ty {
fn into_diag_arg(self) -> DiagArgValue {
DiagArgValue::Str(Cow::Owned(format!("{self:?}")))
}
}
@ -277,7 +277,7 @@ macro_rules! impl_into_diagnostic_arg_through_debug {
}
// These types have nice `Debug` output so we can just use them in diagnostics.
impl_into_diagnostic_arg_through_debug! {
impl_into_diag_arg_through_debug! {
AllocId,
Pointer<AllocId>,
AllocRange,
@ -370,8 +370,8 @@ pub enum PointerKind {
Box,
}
impl IntoDiagnosticArg for PointerKind {
fn into_diagnostic_arg(self) -> DiagArgValue {
impl IntoDiagArg for PointerKind {
fn into_diag_arg(self) -> DiagArgValue {
DiagArgValue::Str(
match self {
Self::Ref(_) => "ref",

View File

@ -100,7 +100,7 @@ macro_rules! err_ub_custom {
msg: || $msg,
add_args: Box::new(move |mut set_arg| {
$($(
set_arg(stringify!($name).into(), rustc_errors::IntoDiagnosticArg::into_diagnostic_arg($name));
set_arg(stringify!($name).into(), rustc_errors::IntoDiagArg::into_diag_arg($name));
)*)?
})
}

View File

@ -14,7 +14,7 @@ use crate::ty::{AdtDef, InstanceDef, UserTypeAnnotationIndex};
use crate::ty::{GenericArg, GenericArgsRef};
use rustc_data_structures::captures::Captures;
use rustc_errors::{DiagArgName, DiagArgValue, DiagMessage, ErrorGuaranteed, IntoDiagnosticArg};
use rustc_errors::{DiagArgName, DiagArgValue, DiagMessage, ErrorGuaranteed, IntoDiagArg};
use rustc_hir::def::{CtorKind, Namespace};
use rustc_hir::def_id::{DefId, CRATE_DEF_ID};
use rustc_hir::{self, CoroutineDesugaring, CoroutineKind, ImplicitSelfKind};

View File

@ -311,7 +311,7 @@ impl<O> AssertKind<O> {
macro_rules! add {
($name: expr, $value: expr) => {
adder($name.into(), $value.into_diagnostic_arg());
adder($name.into(), $value.into_diag_arg());
};
}

View File

@ -9,7 +9,7 @@
//! [rustc dev guide]: https://rustc-dev-guide.rust-lang.org/thir.html
use rustc_ast::{InlineAsmOptions, InlineAsmTemplatePiece};
use rustc_errors::{DiagArgValue, IntoDiagnosticArg};
use rustc_errors::{DiagArgValue, IntoDiagArg};
use rustc_hir as hir;
use rustc_hir::def_id::DefId;
use rustc_hir::RangeEnd;
@ -676,9 +676,9 @@ impl<'tcx> Pat<'tcx> {
}
}
impl<'tcx> IntoDiagnosticArg for Pat<'tcx> {
fn into_diagnostic_arg(self) -> DiagArgValue {
format!("{self}").into_diagnostic_arg()
impl<'tcx> IntoDiagArg for Pat<'tcx> {
fn into_diag_arg(self) -> DiagArgValue {
format!("{self}").into_diag_arg()
}
}

View File

@ -1,6 +1,6 @@
use rustc_apfloat::ieee::{Double, Single};
use rustc_apfloat::Float;
use rustc_errors::{DiagArgValue, IntoDiagnosticArg};
use rustc_errors::{DiagArgValue, IntoDiagArg};
use rustc_serialize::{Decodable, Decoder, Encodable, Encoder};
use rustc_target::abi::Size;
use std::fmt;
@ -114,10 +114,10 @@ impl std::fmt::Debug for ConstInt {
}
}
impl IntoDiagnosticArg for ConstInt {
impl IntoDiagArg 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) -> DiagArgValue {
fn into_diag_arg(self) -> DiagArgValue {
DiagArgValue::Str(format!("{self:?}").into())
}
}

View File

@ -14,9 +14,9 @@ pub struct UnevaluatedConst<'tcx> {
pub args: GenericArgsRef<'tcx>,
}
impl rustc_errors::IntoDiagnosticArg for UnevaluatedConst<'_> {
fn into_diagnostic_arg(self) -> rustc_errors::DiagArgValue {
format!("{self:?}").into_diagnostic_arg()
impl rustc_errors::IntoDiagArg for UnevaluatedConst<'_> {
fn into_diag_arg(self) -> rustc_errors::DiagArgValue {
format!("{self:?}").into_diag_arg()
}
}

View File

@ -11,7 +11,7 @@ use crate::ty::{
};
use rustc_data_structures::fx::FxHashMap;
use rustc_errors::{Applicability, Diag, DiagArgValue, IntoDiagnosticArg};
use rustc_errors::{Applicability, Diag, DiagArgValue, IntoDiagArg};
use rustc_hir as hir;
use rustc_hir::def::DefKind;
use rustc_hir::def_id::DefId;
@ -19,9 +19,9 @@ use rustc_hir::{PredicateOrigin, WherePredicate};
use rustc_span::{BytePos, Span};
use rustc_type_ir::TyKind::*;
impl<'tcx> IntoDiagnosticArg for Ty<'tcx> {
fn into_diagnostic_arg(self) -> DiagArgValue {
self.to_string().into_diagnostic_arg()
impl<'tcx> IntoDiagArg for Ty<'tcx> {
fn into_diag_arg(self) -> DiagArgValue {
self.to_string().into_diag_arg()
}
}

View File

@ -9,7 +9,7 @@ use crate::ty::{self, Lift, List, ParamConst, Ty, TyCtxt};
use rustc_ast_ir::visit::VisitorResult;
use rustc_ast_ir::walk_visitable_list;
use rustc_data_structures::intern::Interned;
use rustc_errors::{DiagArgValue, IntoDiagnosticArg};
use rustc_errors::{DiagArgValue, IntoDiagArg};
use rustc_hir::def_id::DefId;
use rustc_macros::HashStable;
use rustc_serialize::{Decodable, Encodable};
@ -57,9 +57,9 @@ unsafe impl<'tcx> Sync for GenericArg<'tcx> where
{
}
impl<'tcx> IntoDiagnosticArg for GenericArg<'tcx> {
fn into_diagnostic_arg(self) -> DiagArgValue {
self.to_string().into_diagnostic_arg()
impl<'tcx> IntoDiagArg for GenericArg<'tcx> {
fn into_diag_arg(self) -> DiagArgValue {
self.to_string().into_diag_arg()
}
}

View File

@ -5,7 +5,7 @@ use crate::ty::normalize_erasing_regions::NormalizationError;
use crate::ty::{self, ConstKind, Ty, TyCtxt, TypeVisitableExt};
use rustc_error_messages::DiagMessage;
use rustc_errors::{
Diag, DiagArgValue, DiagCtxt, EmissionGuarantee, IntoDiagnostic, IntoDiagnosticArg, Level,
Diag, DiagArgValue, DiagCtxt, EmissionGuarantee, IntoDiagArg, IntoDiagnostic, Level,
};
use rustc_hir as hir;
use rustc_hir::def_id::DefId;
@ -254,9 +254,9 @@ impl<'tcx> fmt::Display for LayoutError<'tcx> {
}
}
impl<'tcx> IntoDiagnosticArg for LayoutError<'tcx> {
fn into_diagnostic_arg(self) -> DiagArgValue {
self.to_string().into_diagnostic_arg()
impl<'tcx> IntoDiagArg for LayoutError<'tcx> {
fn into_diag_arg(self) -> DiagArgValue {
self.to_string().into_diag_arg()
}
}

View File

@ -1,6 +1,6 @@
use rustc_data_structures::captures::Captures;
use rustc_data_structures::intern::Interned;
use rustc_errors::{DiagArgValue, IntoDiagnosticArg};
use rustc_errors::{DiagArgValue, IntoDiagArg};
use rustc_hir::def_id::DefId;
use rustc_hir::LangItem;
use rustc_span::Span;
@ -120,14 +120,14 @@ impl<'tcx> Predicate<'tcx> {
}
}
impl rustc_errors::IntoDiagnosticArg for Predicate<'_> {
fn into_diagnostic_arg(self) -> rustc_errors::DiagArgValue {
impl rustc_errors::IntoDiagArg for Predicate<'_> {
fn into_diag_arg(self) -> rustc_errors::DiagArgValue {
rustc_errors::DiagArgValue::Str(std::borrow::Cow::Owned(self.to_string()))
}
}
impl rustc_errors::IntoDiagnosticArg for Clause<'_> {
fn into_diagnostic_arg(self) -> rustc_errors::DiagArgValue {
impl rustc_errors::IntoDiagArg for Clause<'_> {
fn into_diag_arg(self) -> rustc_errors::DiagArgValue {
rustc_errors::DiagArgValue::Str(std::borrow::Cow::Owned(self.to_string()))
}
}
@ -407,9 +407,9 @@ impl<'tcx> PolyTraitRef<'tcx> {
}
}
impl<'tcx> IntoDiagnosticArg for TraitRef<'tcx> {
fn into_diagnostic_arg(self) -> DiagArgValue {
self.to_string().into_diagnostic_arg()
impl<'tcx> IntoDiagArg for TraitRef<'tcx> {
fn into_diag_arg(self) -> DiagArgValue {
self.to_string().into_diag_arg()
}
}
@ -453,9 +453,9 @@ impl<'tcx> ExistentialTraitRef<'tcx> {
}
}
impl<'tcx> IntoDiagnosticArg for ExistentialTraitRef<'tcx> {
fn into_diagnostic_arg(self) -> DiagArgValue {
self.to_string().into_diagnostic_arg()
impl<'tcx> IntoDiagArg for ExistentialTraitRef<'tcx> {
fn into_diag_arg(self) -> DiagArgValue {
self.to_string().into_diag_arg()
}
}

View File

@ -2722,9 +2722,9 @@ where
#[derive(Copy, Clone, TypeFoldable, TypeVisitable, Lift)]
pub struct TraitRefPrintOnlyTraitPath<'tcx>(ty::TraitRef<'tcx>);
impl<'tcx> rustc_errors::IntoDiagnosticArg for TraitRefPrintOnlyTraitPath<'tcx> {
fn into_diagnostic_arg(self) -> rustc_errors::DiagArgValue {
self.to_string().into_diagnostic_arg()
impl<'tcx> rustc_errors::IntoDiagArg for TraitRefPrintOnlyTraitPath<'tcx> {
fn into_diag_arg(self) -> rustc_errors::DiagArgValue {
self.to_string().into_diag_arg()
}
}
@ -2739,9 +2739,9 @@ impl<'tcx> fmt::Debug for TraitRefPrintOnlyTraitPath<'tcx> {
#[derive(Copy, Clone, TypeFoldable, TypeVisitable, Lift)]
pub struct TraitRefPrintSugared<'tcx>(ty::TraitRef<'tcx>);
impl<'tcx> rustc_errors::IntoDiagnosticArg for TraitRefPrintSugared<'tcx> {
fn into_diagnostic_arg(self) -> rustc_errors::DiagArgValue {
self.to_string().into_diagnostic_arg()
impl<'tcx> rustc_errors::IntoDiagArg for TraitRefPrintSugared<'tcx> {
fn into_diag_arg(self) -> rustc_errors::DiagArgValue {
self.to_string().into_diag_arg()
}
}

View File

@ -13,7 +13,7 @@ use crate::ty::{GenericArg, GenericArgs, GenericArgsRef};
use crate::ty::{List, ParamEnv};
use hir::def::DefKind;
use rustc_data_structures::captures::Captures;
use rustc_errors::{DiagArgValue, ErrorGuaranteed, IntoDiagnosticArg, MultiSpan};
use rustc_errors::{DiagArgValue, ErrorGuaranteed, IntoDiagArg, MultiSpan};
use rustc_hir as hir;
use rustc_hir::def_id::DefId;
use rustc_hir::LangItem;
@ -1094,12 +1094,12 @@ impl<'tcx, T: IntoIterator> Binder<'tcx, T> {
}
}
impl<'tcx, T> IntoDiagnosticArg for Binder<'tcx, T>
impl<'tcx, T> IntoDiagArg for Binder<'tcx, T>
where
T: IntoDiagnosticArg,
T: IntoDiagArg,
{
fn into_diagnostic_arg(self) -> DiagArgValue {
self.value.into_diagnostic_arg()
fn into_diag_arg(self) -> DiagArgValue {
self.value.into_diag_arg()
}
}
@ -1307,9 +1307,9 @@ impl<'tcx> FnSig<'tcx> {
}
}
impl<'tcx> IntoDiagnosticArg for FnSig<'tcx> {
fn into_diagnostic_arg(self) -> DiagArgValue {
self.to_string().into_diagnostic_arg()
impl<'tcx> IntoDiagArg for FnSig<'tcx> {
fn into_diag_arg(self) -> DiagArgValue {
self.to_string().into_diag_arg()
}
}

View File

@ -298,7 +298,7 @@ impl<'a> Parser<'a> {
{
recovered_ident = Some((ident, IdentIsRaw::Yes));
// `Symbol::to_string()` is different from `Symbol::into_diagnostic_arg()`,
// `Symbol::to_string()` is different from `Symbol::into_diag_arg()`,
// which uses `Symbol::to_ident_string()` and "helpfully" adds an implicit `r#`
let ident_name = ident.name.to_string();

View File

@ -9,7 +9,7 @@ use rustc_ast::{ast, AttrKind, AttrStyle, Attribute, LitKind};
use rustc_ast::{MetaItemKind, MetaItemLit, NestedMetaItem};
use rustc_data_structures::fx::FxHashMap;
use rustc_errors::StashKey;
use rustc_errors::{Applicability, DiagCtxt, IntoDiagnosticArg, MultiSpan};
use rustc_errors::{Applicability, DiagCtxt, IntoDiagArg, MultiSpan};
use rustc_feature::{AttributeDuplicates, AttributeType, BuiltinAttribute, BUILTIN_ATTRIBUTE_MAP};
use rustc_hir as hir;
use rustc_hir::def_id::LocalModDefId;
@ -79,14 +79,14 @@ pub(crate) enum ProcMacroKind {
Attribute,
}
impl IntoDiagnosticArg for ProcMacroKind {
fn into_diagnostic_arg(self) -> rustc_errors::DiagArgValue {
impl IntoDiagArg for ProcMacroKind {
fn into_diag_arg(self) -> rustc_errors::DiagArgValue {
match self {
ProcMacroKind::Attribute => "attribute proc macro",
ProcMacroKind::Derive => "derive proc macro",
ProcMacroKind::FunctionLike => "function-like proc macro",
}
.into_diagnostic_arg()
.into_diag_arg()
}
}

View File

@ -17,7 +17,7 @@ use rustc_ast::visit::{walk_list, AssocCtxt, BoundKind, FnCtxt, FnKind, Visitor}
use rustc_ast::*;
use rustc_data_structures::fx::{FxHashMap, FxHashSet, FxIndexMap};
use rustc_errors::{
codes::*, struct_span_code_err, Applicability, DiagArgValue, IntoDiagnosticArg, StashKey,
codes::*, struct_span_code_err, Applicability, DiagArgValue, IntoDiagArg, StashKey,
};
use rustc_hir::def::Namespace::{self, *};
use rustc_hir::def::{self, CtorKind, DefKind, LifetimeRes, NonMacroAttrKind, PartialRes, PerNS};
@ -89,8 +89,8 @@ impl PatternSource {
}
}
impl IntoDiagnosticArg for PatternSource {
fn into_diagnostic_arg(self) -> DiagArgValue {
impl IntoDiagArg for PatternSource {
fn into_diag_arg(self) -> DiagArgValue {
DiagArgValue::Str(Cow::Borrowed(self.descr()))
}
}

View File

@ -13,7 +13,7 @@ use crate::{EarlyDiagCtxt, Session};
use rustc_data_structures::fx::{FxHashMap, FxHashSet, FxIndexMap, FxIndexSet};
use rustc_data_structures::stable_hasher::{StableOrd, ToStableHashKey};
use rustc_errors::emitter::HumanReadableErrorType;
use rustc_errors::{ColorConfig, DiagArgValue, DiagCtxtFlags, IntoDiagnosticArg};
use rustc_errors::{ColorConfig, DiagArgValue, DiagCtxtFlags, IntoDiagArg};
use rustc_feature::UnstableFeatures;
use rustc_span::edition::{Edition, DEFAULT_EDITION, EDITION_NAME_LIST, LATEST_STABLE_EDITION};
use rustc_span::source_map::FilePathMapping;
@ -3098,9 +3098,9 @@ impl fmt::Display for CrateType {
}
}
impl IntoDiagnosticArg for CrateType {
fn into_diagnostic_arg(self) -> DiagArgValue {
self.to_string().into_diagnostic_arg()
impl IntoDiagArg for CrateType {
fn into_diag_arg(self) -> DiagArgValue {
self.to_string().into_diag_arg()
}
}

View File

@ -111,9 +111,9 @@ impl Mul<usize> for Limit {
}
}
impl rustc_errors::IntoDiagnosticArg for Limit {
fn into_diagnostic_arg(self) -> rustc_errors::DiagArgValue {
self.to_string().into_diagnostic_arg()
impl rustc_errors::IntoDiagArg for Limit {
fn into_diag_arg(self) -> rustc_errors::DiagArgValue {
self.to_string().into_diag_arg()
}
}

View File

@ -1,6 +1,6 @@
//@ check-fail
// Tests that a doc comment will not preclude a field from being considered a diagnostic argument
//@ normalize-stderr-test "the following other types implement trait `IntoDiagnosticArg`:(?:.*\n){0,9}\s+and \d+ others" -> "normalized in stderr"
//@ normalize-stderr-test "the following other types implement trait `IntoDiagArg`:(?:.*\n){0,9}\s+and \d+ others" -> "normalized in stderr"
//@ normalize-stderr-test "(COMPILER_DIR/.*\.rs):[0-9]+:[0-9]+" -> "$1:LL:CC"
// The proc_macro2 crate handles spans differently when on beta/stable release rather than nightly,
@ -25,7 +25,7 @@ use rustc_span::Span;
rustc_fluent_macro::fluent_messages! { "./example.ftl" }
struct NotIntoDiagnosticArg;
struct NotIntoDiagArg;
#[derive(Diagnostic)]
#[diag(no_crate_example)]
@ -33,8 +33,8 @@ struct Test {
#[primary_span]
span: Span,
/// A doc comment
arg: NotIntoDiagnosticArg,
//~^ ERROR the trait bound `NotIntoDiagnosticArg: IntoDiagnosticArg` is not satisfied
arg: NotIntoDiagArg,
//~^ ERROR the trait bound `NotIntoDiagArg: IntoDiagArg` is not satisfied
}
#[derive(Subdiagnostic)]
@ -43,6 +43,6 @@ struct SubTest {
#[primary_span]
span: Span,
/// A doc comment
arg: NotIntoDiagnosticArg,
//~^ ERROR the trait bound `NotIntoDiagnosticArg: IntoDiagnosticArg` is not satisfied
arg: NotIntoDiagArg,
//~^ ERROR the trait bound `NotIntoDiagArg: IntoDiagArg` is not satisfied
}

View File

@ -1,25 +1,25 @@
error[E0277]: the trait bound `NotIntoDiagnosticArg: IntoDiagnosticArg` is not satisfied
error[E0277]: the trait bound `NotIntoDiagArg: IntoDiagArg` is not satisfied
--> $DIR/diagnostic-derive-doc-comment-field.rs:36:10
|
LL | #[derive(Diagnostic)]
| ---------- required by a bound introduced by this call
...
LL | arg: NotIntoDiagnosticArg,
| ^^^^^^^^^^^^^^^^^^^^ the trait `IntoDiagnosticArg` is not implemented for `NotIntoDiagnosticArg`
LL | arg: NotIntoDiagArg,
| ^^^^^^^^^^^^^^ the trait `IntoDiagArg` is not implemented for `NotIntoDiagArg`
|
= help: normalized in stderr
note: required by a bound in `Diag::<'a, G>::arg`
--> $COMPILER_DIR/rustc_errors/src/diagnostic.rs:LL:CC
= note: this error originates in the macro `with_fn` (in Nightly builds, run with -Z macro-backtrace for more info)
error[E0277]: the trait bound `NotIntoDiagnosticArg: IntoDiagnosticArg` is not satisfied
error[E0277]: the trait bound `NotIntoDiagArg: IntoDiagArg` is not satisfied
--> $DIR/diagnostic-derive-doc-comment-field.rs:46:10
|
LL | #[derive(Subdiagnostic)]
| ------------- required by a bound introduced by this call
...
LL | arg: NotIntoDiagnosticArg,
| ^^^^^^^^^^^^^^^^^^^^ the trait `IntoDiagnosticArg` is not implemented for `NotIntoDiagnosticArg`
LL | arg: NotIntoDiagArg,
| ^^^^^^^^^^^^^^ the trait `IntoDiagArg` is not implemented for `NotIntoDiagArg`
|
= help: normalized in stderr
note: required by a bound in `Diag::<'a, G>::arg`

View File

@ -1,6 +1,6 @@
//@ check-fail
// Tests error conditions for specifying diagnostics using #[derive(Diagnostic)]
//@ normalize-stderr-test "the following other types implement trait `IntoDiagnosticArg`:(?:.*\n){0,9}\s+and \d+ others" -> "normalized in stderr"
//@ normalize-stderr-test "the following other types implement trait `IntoDiagArg`:(?:.*\n){0,9}\s+and \d+ others" -> "normalized in stderr"
//@ normalize-stderr-test "(COMPILER_DIR/.*\.rs):[0-9]+:[0-9]+" -> "$1:LL:CC"
// The proc_macro2 crate handles spans differently when on beta/stable release rather than nightly,
@ -347,7 +347,7 @@ struct ArgFieldWithoutSkip {
#[primary_span]
span: Span,
other: Hello,
//~^ ERROR the trait bound `Hello: IntoDiagnosticArg` is not satisfied
//~^ ERROR the trait bound `Hello: IntoDiagArg` is not satisfied
}
#[derive(Diagnostic)]
@ -355,7 +355,7 @@ struct ArgFieldWithoutSkip {
struct ArgFieldWithSkip {
#[primary_span]
span: Span,
// `Hello` does not implement `IntoDiagnosticArg` so this would result in an error if
// `Hello` does not implement `IntoDiagArg` so this would result in an error if
// not for `#[skip_arg]`.
#[skip_arg]
other: Hello,

View File

@ -618,14 +618,14 @@ LL | #[derive(Diagnostic)]
|
= note: this error originates in the derive macro `Diagnostic` (in Nightly builds, run with -Z macro-backtrace for more info)
error[E0277]: the trait bound `Hello: IntoDiagnosticArg` is not satisfied
error[E0277]: the trait bound `Hello: IntoDiagArg` is not satisfied
--> $DIR/diagnostic-derive.rs:349:12
|
LL | #[derive(Diagnostic)]
| ---------- required by a bound introduced by this call
...
LL | other: Hello,
| ^^^^^ the trait `IntoDiagnosticArg` is not implemented for `Hello`
| ^^^^^ the trait `IntoDiagArg` is not implemented for `Hello`
|
= help: normalized in stderr
note: required by a bound in `Diag::<'a, G>::arg`