From a09b1d33a703d4ed412e70d3197e73ba7e0937f9 Mon Sep 17 00:00:00 2001 From: Nicholas Nethercote Date: Tue, 5 Mar 2024 16:53:24 +1100 Subject: [PATCH] Rename `IntoDiagnosticArg` as `IntoDiagArg`. Also rename `into_diagnostic_arg` as `into_diag_arg`, and `NotIntoDiagnosticArg` as `NotInotDiagArg`. --- .../src/diagnostics/region_name.rs | 6 +- .../src/assert_module_sources.rs | 6 +- compiler/rustc_codegen_ssa/src/errors.rs | 11 +- .../rustc_const_eval/src/const_eval/error.rs | 10 +- compiler/rustc_const_eval/src/errors.rs | 4 +- compiler/rustc_errors/src/diagnostic.rs | 16 +- compiler/rustc_errors/src/diagnostic_impls.rs | 144 +++++++++--------- compiler/rustc_errors/src/lib.rs | 2 +- compiler/rustc_hir/src/hir.rs | 2 +- compiler/rustc_hir_typeck/src/errors.rs | 8 +- compiler/rustc_infer/src/errors/mod.rs | 10 +- .../src/errors/note_and_explain.rs | 10 +- .../src/infer/error_reporting/mod.rs | 8 +- .../infer/error_reporting/need_type_info.rs | 6 +- .../nice_region_error/placeholder_error.rs | 6 +- compiler/rustc_metadata/src/locator.rs | 6 +- .../rustc_middle/src/mir/interpret/error.rs | 18 +-- .../rustc_middle/src/mir/interpret/mod.rs | 2 +- compiler/rustc_middle/src/mir/mod.rs | 2 +- compiler/rustc_middle/src/mir/terminator.rs | 2 +- compiler/rustc_middle/src/thir.rs | 8 +- compiler/rustc_middle/src/ty/consts/int.rs | 6 +- compiler/rustc_middle/src/ty/consts/kind.rs | 6 +- compiler/rustc_middle/src/ty/diagnostics.rs | 8 +- compiler/rustc_middle/src/ty/generic_args.rs | 8 +- compiler/rustc_middle/src/ty/layout.rs | 8 +- compiler/rustc_middle/src/ty/predicate.rs | 22 +-- compiler/rustc_middle/src/ty/print/pretty.rs | 12 +- compiler/rustc_middle/src/ty/sty.rs | 16 +- .../rustc_parse/src/parser/diagnostics.rs | 2 +- compiler/rustc_passes/src/check_attr.rs | 8 +- compiler/rustc_resolve/src/late.rs | 6 +- compiler/rustc_session/src/config.rs | 8 +- compiler/rustc_session/src/session.rs | 6 +- .../diagnostic-derive-doc-comment-field.rs | 12 +- ...diagnostic-derive-doc-comment-field.stderr | 12 +- .../session-diagnostic/diagnostic-derive.rs | 6 +- .../diagnostic-derive.stderr | 4 +- 38 files changed, 218 insertions(+), 219 deletions(-) diff --git a/compiler/rustc_borrowck/src/diagnostics/region_name.rs b/compiler/rustc_borrowck/src/diagnostics/region_name.rs index f6f33e10c20..08199068020 100644 --- a/compiler/rustc_borrowck/src/diagnostics/region_name.rs +++ b/compiler/rustc_borrowck/src/diagnostics/region_name.rs @@ -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() } } diff --git a/compiler/rustc_codegen_ssa/src/assert_module_sources.rs b/compiler/rustc_codegen_ssa/src/assert_module_sources.rs index 7ecc3864347..e441aea8400 100644 --- a/compiler/rustc_codegen_ssa/src/assert_module_sources.rs +++ b/compiler/rustc_codegen_ssa/src/assert_module_sources.rs @@ -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())) } } diff --git a/compiler/rustc_codegen_ssa/src/errors.rs b/compiler/rustc_codegen_ssa/src/errors.rs index 8fae80de064..04aed7086f8 100644 --- a/compiler/rustc_codegen_ssa/src/errors.rs +++ b/compiler/rustc_codegen_ssa/src/errors.rs @@ -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("*_")), diff --git a/compiler/rustc_const_eval/src/const_eval/error.rs b/compiler/rustc_const_eval/src/const_eval/error.rs index e5b4fc3a574..924f64160e5 100644 --- a/compiler/rustc_const_eval/src/const_eval/error.rs +++ b/compiler/rustc_const_eval/src/const_eval/error.rs @@ -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()); } } } diff --git a/compiler/rustc_const_eval/src/errors.rs b/compiler/rustc_const_eval/src/errors.rs index 32ec9118619..9753ac95ab1 100644 --- a/compiler/rustc_const_eval/src/errors.rs +++ b/compiler/rustc_const_eval/src/errors.rs @@ -887,8 +887,8 @@ impl ReportErrorExt for ResourceExhaustionInfo { fn add_args(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", diff --git a/compiler/rustc_errors/src/diagnostic.rs b/compiler/rustc_errors/src/diagnostic.rs index c186d5b284f..1f59352594c 100644 --- a/compiler/rustc_errors/src/diagnostic.rs +++ b/compiler/rustc_errors/src/diagnostic.rs @@ -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>), } @@ -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, arg: impl IntoDiagnosticArg) { - self.args.insert(name.into(), arg.into_diagnostic_arg()); + pub(crate) fn arg(&mut self, name: impl Into, 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, - arg: impl IntoDiagnosticArg, + arg: impl IntoDiagArg, ) -> &mut Self { self.deref_mut().arg(name, arg); self diff --git a/compiler/rustc_errors/src/diagnostic_impls.rs b/compiler/rustc_errors/src/diagnostic_impls.rs index 839bd65e4a6..a39e1b83f1e 100644 --- a/compiler/rustc_errors/src/diagnostic_impls.rs +++ b/compiler/rustc_errors/src/diagnostic_impls.rs @@ -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::::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, @@ -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 { - fn into_diagnostic_arg(self) -> DiagArgValue { +impl IntoDiagArg for Vec { + 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> 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 IntoDiagnosticArg for hir::def::Res { - fn into_diagnostic_arg(self) -> DiagArgValue { +impl IntoDiagArg for hir::def::Res { + 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()) } } diff --git a/compiler/rustc_errors/src/lib.rs b/compiler/rustc_errors/src/lib.rs index 76b44f73f47..a381c3784dc 100644 --- a/compiler/rustc_errors/src/lib.rs +++ b/compiler/rustc_errors/src/lib.rs @@ -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::{ diff --git a/compiler/rustc_hir/src/hir.rs b/compiler/rustc_hir/src/hir.rs index 7d5b4c0f06d..18dabe67dae 100644 --- a/compiler/rustc_hir/src/hir.rs +++ b/compiler/rustc_hir/src/hir.rs @@ -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. diff --git a/compiler/rustc_hir_typeck/src/errors.rs b/compiler/rustc_hir_typeck/src/errors.rs index 502b9ba6451..7e8a229f2a2 100644 --- a/compiler/rustc_hir_typeck/src/errors.rs +++ b/compiler/rustc_hir_typeck/src/errors.rs @@ -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", diff --git a/compiler/rustc_infer/src/errors/mod.rs b/compiler/rustc_infer/src/errors/mod.rs index af09ac2de96..a7d3bb240c8 100644 --- a/compiler/rustc_infer/src/errors/mod.rs +++ b/compiler/rustc_infer/src/errors/mod.rs @@ -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(), } } } diff --git a/compiler/rustc_infer/src/errors/note_and_explain.rs b/compiler/rustc_infer/src/errors/note_and_explain.rs index 7bb71d47031..c8141f67192 100644 --- a/compiler/rustc_infer/src/errors/note_and_explain.rs +++ b/compiler/rustc_infer/src/errors/note_and_explain.rs @@ -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", diff --git a/compiler/rustc_infer/src/infer/error_reporting/mod.rs b/compiler/rustc_infer/src/infer/error_reporting/mod.rs index ea5c6b8c057..222c0a39542 100644 --- a/compiler/rustc_infer/src/infer/error_reporting/mod.rs +++ b/compiler/rustc_infer/src/infer/error_reporting/mod.rs @@ -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", diff --git a/compiler/rustc_infer/src/infer/error_reporting/need_type_info.rs b/compiler/rustc_infer/src/infer/error_reporting/need_type_info.rs index 6c968c488fe..13e2152e45e 100644 --- a/compiler/rustc_infer/src/infer/error_reporting/need_type_info.rs +++ b/compiler/rustc_infer/src/infer/error_reporting/need_type_info.rs @@ -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", diff --git a/compiler/rustc_infer/src/infer/error_reporting/nice_region_error/placeholder_error.rs b/compiler/rustc_infer/src/infer/error_reporting/nice_region_error/placeholder_error.rs index d6595a0c114..98719e240bd 100644 --- a/compiler/rustc_infer/src/infer/error_reporting/nice_region_error/placeholder_error.rs +++ b/compiler/rustc_infer/src/infer/error_reporting/nice_region_error/placeholder_error.rs @@ -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()) } } diff --git a/compiler/rustc_metadata/src/locator.rs b/compiler/rustc_metadata/src/locator.rs index 10bbebb3871..7de03be6da6 100644 --- a/compiler/rustc_metadata/src/locator.rs +++ b/compiler/rustc_metadata/src/locator.rs @@ -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")), diff --git a/compiler/rustc_middle/src/mir/interpret/error.rs b/compiler/rustc_middle/src/mir/interpret/error.rs index aea88c4588b..751d6de83f9 100644 --- a/compiler/rustc_middle/src/mir/interpret/error.rs +++ b/compiler/rustc_middle/src/mir/interpret/error.rs @@ -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, 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", diff --git a/compiler/rustc_middle/src/mir/interpret/mod.rs b/compiler/rustc_middle/src/mir/interpret/mod.rs index 5be09b06d9e..94b9afa1dee 100644 --- a/compiler/rustc_middle/src/mir/interpret/mod.rs +++ b/compiler/rustc_middle/src/mir/interpret/mod.rs @@ -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)); )*)? }) } diff --git a/compiler/rustc_middle/src/mir/mod.rs b/compiler/rustc_middle/src/mir/mod.rs index 0221bc6c363..4b5a08d6af3 100644 --- a/compiler/rustc_middle/src/mir/mod.rs +++ b/compiler/rustc_middle/src/mir/mod.rs @@ -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}; diff --git a/compiler/rustc_middle/src/mir/terminator.rs b/compiler/rustc_middle/src/mir/terminator.rs index a4a4df55c48..94f8cba6fb5 100644 --- a/compiler/rustc_middle/src/mir/terminator.rs +++ b/compiler/rustc_middle/src/mir/terminator.rs @@ -311,7 +311,7 @@ impl AssertKind { macro_rules! add { ($name: expr, $value: expr) => { - adder($name.into(), $value.into_diagnostic_arg()); + adder($name.into(), $value.into_diag_arg()); }; } diff --git a/compiler/rustc_middle/src/thir.rs b/compiler/rustc_middle/src/thir.rs index 913d0072c29..74b47d8b04e 100644 --- a/compiler/rustc_middle/src/thir.rs +++ b/compiler/rustc_middle/src/thir.rs @@ -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() } } diff --git a/compiler/rustc_middle/src/ty/consts/int.rs b/compiler/rustc_middle/src/ty/consts/int.rs index 221a9ceee1a..a70e01645f4 100644 --- a/compiler/rustc_middle/src/ty/consts/int.rs +++ b/compiler/rustc_middle/src/ty/consts/int.rs @@ -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()) } } diff --git a/compiler/rustc_middle/src/ty/consts/kind.rs b/compiler/rustc_middle/src/ty/consts/kind.rs index b35682df2c8..705987d92fe 100644 --- a/compiler/rustc_middle/src/ty/consts/kind.rs +++ b/compiler/rustc_middle/src/ty/consts/kind.rs @@ -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() } } diff --git a/compiler/rustc_middle/src/ty/diagnostics.rs b/compiler/rustc_middle/src/ty/diagnostics.rs index 2506456f1fb..05463b8554f 100644 --- a/compiler/rustc_middle/src/ty/diagnostics.rs +++ b/compiler/rustc_middle/src/ty/diagnostics.rs @@ -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() } } diff --git a/compiler/rustc_middle/src/ty/generic_args.rs b/compiler/rustc_middle/src/ty/generic_args.rs index 8079ad121ad..02b58c035d4 100644 --- a/compiler/rustc_middle/src/ty/generic_args.rs +++ b/compiler/rustc_middle/src/ty/generic_args.rs @@ -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() } } diff --git a/compiler/rustc_middle/src/ty/layout.rs b/compiler/rustc_middle/src/ty/layout.rs index b1bfd2f1105..1dd0f733233 100644 --- a/compiler/rustc_middle/src/ty/layout.rs +++ b/compiler/rustc_middle/src/ty/layout.rs @@ -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() } } diff --git a/compiler/rustc_middle/src/ty/predicate.rs b/compiler/rustc_middle/src/ty/predicate.rs index 8dd95daed36..62822505fa5 100644 --- a/compiler/rustc_middle/src/ty/predicate.rs +++ b/compiler/rustc_middle/src/ty/predicate.rs @@ -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() } } diff --git a/compiler/rustc_middle/src/ty/print/pretty.rs b/compiler/rustc_middle/src/ty/print/pretty.rs index c8c9afa7f4d..33d63c2a505 100644 --- a/compiler/rustc_middle/src/ty/print/pretty.rs +++ b/compiler/rustc_middle/src/ty/print/pretty.rs @@ -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() } } diff --git a/compiler/rustc_middle/src/ty/sty.rs b/compiler/rustc_middle/src/ty/sty.rs index 39b5d3b6ea7..cac12e5ee0b 100644 --- a/compiler/rustc_middle/src/ty/sty.rs +++ b/compiler/rustc_middle/src/ty/sty.rs @@ -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() } } diff --git a/compiler/rustc_parse/src/parser/diagnostics.rs b/compiler/rustc_parse/src/parser/diagnostics.rs index de088b9364b..e56fc3e1129 100644 --- a/compiler/rustc_parse/src/parser/diagnostics.rs +++ b/compiler/rustc_parse/src/parser/diagnostics.rs @@ -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(); diff --git a/compiler/rustc_passes/src/check_attr.rs b/compiler/rustc_passes/src/check_attr.rs index a99db9cb8cc..91ab5b30dea 100644 --- a/compiler/rustc_passes/src/check_attr.rs +++ b/compiler/rustc_passes/src/check_attr.rs @@ -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() } } diff --git a/compiler/rustc_resolve/src/late.rs b/compiler/rustc_resolve/src/late.rs index d2aea0056b3..ea07ed9e654 100644 --- a/compiler/rustc_resolve/src/late.rs +++ b/compiler/rustc_resolve/src/late.rs @@ -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())) } } diff --git a/compiler/rustc_session/src/config.rs b/compiler/rustc_session/src/config.rs index 61a220428b0..1573920c8c0 100644 --- a/compiler/rustc_session/src/config.rs +++ b/compiler/rustc_session/src/config.rs @@ -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() } } diff --git a/compiler/rustc_session/src/session.rs b/compiler/rustc_session/src/session.rs index ae1dbd13204..6aabf64c6ff 100644 --- a/compiler/rustc_session/src/session.rs +++ b/compiler/rustc_session/src/session.rs @@ -111,9 +111,9 @@ impl Mul 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() } } diff --git a/tests/ui-fulldeps/session-diagnostic/diagnostic-derive-doc-comment-field.rs b/tests/ui-fulldeps/session-diagnostic/diagnostic-derive-doc-comment-field.rs index 40df9cc5dca..432ede89826 100644 --- a/tests/ui-fulldeps/session-diagnostic/diagnostic-derive-doc-comment-field.rs +++ b/tests/ui-fulldeps/session-diagnostic/diagnostic-derive-doc-comment-field.rs @@ -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 } diff --git a/tests/ui-fulldeps/session-diagnostic/diagnostic-derive-doc-comment-field.stderr b/tests/ui-fulldeps/session-diagnostic/diagnostic-derive-doc-comment-field.stderr index 98600d28229..7377b0dfd0a 100644 --- a/tests/ui-fulldeps/session-diagnostic/diagnostic-derive-doc-comment-field.stderr +++ b/tests/ui-fulldeps/session-diagnostic/diagnostic-derive-doc-comment-field.stderr @@ -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` diff --git a/tests/ui-fulldeps/session-diagnostic/diagnostic-derive.rs b/tests/ui-fulldeps/session-diagnostic/diagnostic-derive.rs index 11070972394..043c7c16654 100644 --- a/tests/ui-fulldeps/session-diagnostic/diagnostic-derive.rs +++ b/tests/ui-fulldeps/session-diagnostic/diagnostic-derive.rs @@ -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, diff --git a/tests/ui-fulldeps/session-diagnostic/diagnostic-derive.stderr b/tests/ui-fulldeps/session-diagnostic/diagnostic-derive.stderr index 058c88d315b..1266430e2f7 100644 --- a/tests/ui-fulldeps/session-diagnostic/diagnostic-derive.stderr +++ b/tests/ui-fulldeps/session-diagnostic/diagnostic-derive.stderr @@ -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`