mirror of https://github.com/rust-lang/rust.git
Rollup merge of #120488 - nnethercote:diag-lifetimes, r=oli-obk
Diagnostic lifetimes cleanups Some diagnostic simplifications. r? `@oli-obk`
This commit is contained in:
commit
f99b510429
|
@ -188,7 +188,7 @@ impl Display for RegionName {
|
|||
}
|
||||
|
||||
impl rustc_errors::IntoDiagnosticArg for RegionName {
|
||||
fn into_diagnostic_arg(self) -> rustc_errors::DiagnosticArgValue<'static> {
|
||||
fn into_diagnostic_arg(self) -> rustc_errors::DiagnosticArgValue {
|
||||
self.to_string().into_diagnostic_arg()
|
||||
}
|
||||
}
|
||||
|
|
|
@ -35,7 +35,7 @@ pub(crate) enum PossibleFeature<'a> {
|
|||
struct ExitCode(Option<i32>);
|
||||
|
||||
impl IntoDiagnosticArg for ExitCode {
|
||||
fn into_diagnostic_arg(self) -> DiagnosticArgValue<'static> {
|
||||
fn into_diagnostic_arg(self) -> DiagnosticArgValue {
|
||||
let ExitCode(exit_code) = self;
|
||||
match exit_code {
|
||||
Some(t) => t.into_diagnostic_arg(),
|
||||
|
|
|
@ -206,7 +206,7 @@ impl fmt::Display for CguReuse {
|
|||
}
|
||||
|
||||
impl IntoDiagnosticArg for CguReuse {
|
||||
fn into_diagnostic_arg(self) -> DiagnosticArgValue<'static> {
|
||||
fn into_diagnostic_arg(self) -> DiagnosticArgValue {
|
||||
DiagnosticArgValue::Str(Cow::Owned(self.to_string()))
|
||||
}
|
||||
}
|
||||
|
|
|
@ -14,8 +14,11 @@ use rustc_data_structures::memmap::Mmap;
|
|||
use rustc_data_structures::profiling::{SelfProfilerRef, VerboseTimingGuard};
|
||||
use rustc_data_structures::sync::Lrc;
|
||||
use rustc_errors::emitter::Emitter;
|
||||
use rustc_errors::{translation::Translate, DiagCtxt, FatalError, Level};
|
||||
use rustc_errors::{DiagnosticBuilder, DiagnosticMessage, ErrCode, Style};
|
||||
use rustc_errors::translation::Translate;
|
||||
use rustc_errors::{
|
||||
DiagCtxt, DiagnosticArgName, DiagnosticArgValue, DiagnosticBuilder, DiagnosticMessage, ErrCode,
|
||||
FatalError, FluentBundle, Level, Style,
|
||||
};
|
||||
use rustc_fs_util::link_or_copy;
|
||||
use rustc_hir::def_id::{CrateNum, LOCAL_CRATE};
|
||||
use rustc_incremental::{
|
||||
|
@ -995,11 +998,9 @@ pub(crate) enum Message<B: WriteBackendMethods> {
|
|||
/// process another codegen unit.
|
||||
pub struct CguMessage;
|
||||
|
||||
type DiagnosticArgName<'source> = Cow<'source, str>;
|
||||
|
||||
struct Diagnostic {
|
||||
msgs: Vec<(DiagnosticMessage, Style)>,
|
||||
args: FxHashMap<DiagnosticArgName<'static>, rustc_errors::DiagnosticArgValue<'static>>,
|
||||
args: FxHashMap<DiagnosticArgName, DiagnosticArgValue>,
|
||||
code: Option<ErrCode>,
|
||||
lvl: Level,
|
||||
}
|
||||
|
@ -1800,18 +1801,18 @@ impl SharedEmitter {
|
|||
}
|
||||
|
||||
impl Translate for SharedEmitter {
|
||||
fn fluent_bundle(&self) -> Option<&Lrc<rustc_errors::FluentBundle>> {
|
||||
fn fluent_bundle(&self) -> Option<&Lrc<FluentBundle>> {
|
||||
None
|
||||
}
|
||||
|
||||
fn fallback_fluent_bundle(&self) -> &rustc_errors::FluentBundle {
|
||||
fn fallback_fluent_bundle(&self) -> &FluentBundle {
|
||||
panic!("shared emitter attempted to translate a diagnostic");
|
||||
}
|
||||
}
|
||||
|
||||
impl Emitter for SharedEmitter {
|
||||
fn emit_diagnostic(&mut self, diag: &rustc_errors::Diagnostic) {
|
||||
let args: FxHashMap<Cow<'_, str>, rustc_errors::DiagnosticArgValue<'_>> =
|
||||
let args: FxHashMap<Cow<'_, str>, DiagnosticArgValue> =
|
||||
diag.args().map(|(name, arg)| (name.clone(), arg.clone())).collect();
|
||||
drop(self.sender.send(SharedEmitterMessage::Diagnostic(Diagnostic {
|
||||
msgs: diag.messages.clone(),
|
||||
|
|
|
@ -147,7 +147,7 @@ impl<'a> CopyPath<'a> {
|
|||
struct DebugArgPath<'a>(pub &'a Path);
|
||||
|
||||
impl IntoDiagnosticArg for DebugArgPath<'_> {
|
||||
fn into_diagnostic_arg(self) -> rustc_errors::DiagnosticArgValue<'static> {
|
||||
fn into_diagnostic_arg(self) -> rustc_errors::DiagnosticArgValue {
|
||||
DiagnosticArgValue::Str(Cow::Owned(format!("{:?}", self.0)))
|
||||
}
|
||||
}
|
||||
|
@ -974,7 +974,7 @@ pub enum ExpectedPointerMutability {
|
|||
}
|
||||
|
||||
impl IntoDiagnosticArg for ExpectedPointerMutability {
|
||||
fn into_diagnostic_arg(self) -> DiagnosticArgValue<'static> {
|
||||
fn into_diagnostic_arg(self) -> DiagnosticArgValue {
|
||||
match self {
|
||||
ExpectedPointerMutability::Mut => DiagnosticArgValue::Str(Cow::Borrowed("*mut")),
|
||||
ExpectedPointerMutability::Not => DiagnosticArgValue::Str(Cow::Borrowed("*_")),
|
||||
|
|
|
@ -34,7 +34,7 @@ impl MachineStopType for ConstEvalErrKind {
|
|||
}
|
||||
fn add_args(
|
||||
self: Box<Self>,
|
||||
adder: &mut dyn FnMut(std::borrow::Cow<'static, str>, DiagnosticArgValue<'static>),
|
||||
adder: &mut dyn FnMut(std::borrow::Cow<'static, str>, DiagnosticArgValue),
|
||||
) {
|
||||
use ConstEvalErrKind::*;
|
||||
match *self {
|
||||
|
|
|
@ -906,7 +906,7 @@ impl ReportErrorExt for ResourceExhaustionInfo {
|
|||
}
|
||||
|
||||
impl rustc_errors::IntoDiagnosticArg for InternKind {
|
||||
fn into_diagnostic_arg(self) -> DiagnosticArgValue<'static> {
|
||||
fn into_diagnostic_arg(self) -> DiagnosticArgValue {
|
||||
DiagnosticArgValue::Str(Cow::Borrowed(match self {
|
||||
InternKind::Static(Mutability::Not) => "static",
|
||||
InternKind::Static(Mutability::Mut) => "static_mut",
|
||||
|
|
|
@ -23,19 +23,18 @@ pub struct SuggestionsDisabled;
|
|||
/// Simplified version of `FluentArg` that can implement `Encodable` and `Decodable`. Collection of
|
||||
/// `DiagnosticArg` are converted to `FluentArgs` (consuming the collection) at the start of
|
||||
/// diagnostic emission.
|
||||
pub type DiagnosticArg<'iter, 'source> =
|
||||
(&'iter DiagnosticArgName<'source>, &'iter DiagnosticArgValue<'source>);
|
||||
pub type DiagnosticArg<'iter> = (&'iter DiagnosticArgName, &'iter DiagnosticArgValue);
|
||||
|
||||
/// Name of a diagnostic argument.
|
||||
pub type DiagnosticArgName<'source> = Cow<'source, str>;
|
||||
pub type DiagnosticArgName = Cow<'static, str>;
|
||||
|
||||
/// Simplified version of `FluentValue` that can implement `Encodable` and `Decodable`. Converted
|
||||
/// to a `FluentValue` by the emitter to be used in diagnostic translation.
|
||||
#[derive(Clone, Debug, PartialEq, Eq, Hash, Encodable, Decodable)]
|
||||
pub enum DiagnosticArgValue<'source> {
|
||||
Str(Cow<'source, str>),
|
||||
pub enum DiagnosticArgValue {
|
||||
Str(Cow<'static, str>),
|
||||
Number(i128),
|
||||
StrListSepByAnd(Vec<Cow<'source, str>>),
|
||||
StrListSepByAnd(Vec<Cow<'static, str>>),
|
||||
}
|
||||
|
||||
/// Converts a value of a type into a `DiagnosticArg` (typically a field of an `IntoDiagnostic`
|
||||
|
@ -43,23 +42,17 @@ pub enum DiagnosticArgValue<'source> {
|
|||
/// being converted rather than on `DiagnosticArgValue`, which enables types from other `rustc_*`
|
||||
/// crates to implement this.
|
||||
pub trait IntoDiagnosticArg {
|
||||
fn into_diagnostic_arg(self) -> DiagnosticArgValue<'static>;
|
||||
fn into_diagnostic_arg(self) -> DiagnosticArgValue;
|
||||
}
|
||||
|
||||
impl<'source> IntoDiagnosticArg for DiagnosticArgValue<'source> {
|
||||
fn into_diagnostic_arg(self) -> DiagnosticArgValue<'static> {
|
||||
match self {
|
||||
DiagnosticArgValue::Str(s) => DiagnosticArgValue::Str(Cow::Owned(s.into_owned())),
|
||||
DiagnosticArgValue::Number(n) => DiagnosticArgValue::Number(n),
|
||||
DiagnosticArgValue::StrListSepByAnd(l) => DiagnosticArgValue::StrListSepByAnd(
|
||||
l.into_iter().map(|s| Cow::Owned(s.into_owned())).collect(),
|
||||
),
|
||||
}
|
||||
impl IntoDiagnosticArg for DiagnosticArgValue {
|
||||
fn into_diagnostic_arg(self) -> DiagnosticArgValue {
|
||||
self
|
||||
}
|
||||
}
|
||||
|
||||
impl<'source> Into<FluentValue<'source>> for DiagnosticArgValue<'source> {
|
||||
fn into(self) -> FluentValue<'source> {
|
||||
impl Into<FluentValue<'static>> for DiagnosticArgValue {
|
||||
fn into(self) -> FluentValue<'static> {
|
||||
match self {
|
||||
DiagnosticArgValue::Str(s) => From::from(s),
|
||||
DiagnosticArgValue::Number(n) => From::from(n),
|
||||
|
@ -109,7 +102,7 @@ pub struct Diagnostic {
|
|||
pub span: MultiSpan,
|
||||
pub children: Vec<SubDiagnostic>,
|
||||
pub suggestions: Result<Vec<CodeSuggestion>, SuggestionsDisabled>,
|
||||
args: FxHashMap<DiagnosticArgName<'static>, DiagnosticArgValue<'static>>,
|
||||
args: FxHashMap<DiagnosticArgName, DiagnosticArgValue>,
|
||||
|
||||
/// This is not used for highlighting or rendering any error message. Rather, it can be used
|
||||
/// as a sort key to sort a buffer of diagnostics. By default, it is the primary span of
|
||||
|
@ -916,7 +909,7 @@ impl Diagnostic {
|
|||
// Exact iteration order of diagnostic arguments shouldn't make a difference to output because
|
||||
// they're only used in interpolation.
|
||||
#[allow(rustc::potential_query_instability)]
|
||||
pub fn args(&self) -> impl Iterator<Item = DiagnosticArg<'_, 'static>> {
|
||||
pub fn args(&self) -> impl Iterator<Item = DiagnosticArg<'_>> {
|
||||
self.args.iter()
|
||||
}
|
||||
|
||||
|
@ -929,10 +922,7 @@ impl Diagnostic {
|
|||
self
|
||||
}
|
||||
|
||||
pub fn replace_args(
|
||||
&mut self,
|
||||
args: FxHashMap<DiagnosticArgName<'static>, DiagnosticArgValue<'static>>,
|
||||
) {
|
||||
pub fn replace_args(&mut self, args: FxHashMap<DiagnosticArgName, DiagnosticArgValue>) {
|
||||
self.args = args;
|
||||
}
|
||||
|
||||
|
@ -990,7 +980,7 @@ impl Diagnostic {
|
|||
) -> (
|
||||
&Level,
|
||||
&[(DiagnosticMessage, Style)],
|
||||
Vec<(&Cow<'static, str>, &DiagnosticArgValue<'static>)>,
|
||||
Vec<(&Cow<'static, str>, &DiagnosticArgValue)>,
|
||||
&Option<ErrCode>,
|
||||
&Option<IsLint>,
|
||||
&MultiSpan,
|
||||
|
|
|
@ -23,7 +23,7 @@ use std::process::ExitStatus;
|
|||
pub struct DiagnosticArgFromDisplay<'a>(pub &'a dyn fmt::Display);
|
||||
|
||||
impl IntoDiagnosticArg for DiagnosticArgFromDisplay<'_> {
|
||||
fn into_diagnostic_arg(self) -> DiagnosticArgValue<'static> {
|
||||
fn into_diagnostic_arg(self) -> DiagnosticArgValue {
|
||||
self.0.to_string().into_diagnostic_arg()
|
||||
}
|
||||
}
|
||||
|
@ -41,7 +41,7 @@ impl<'a, T: fmt::Display> From<&'a T> for DiagnosticArgFromDisplay<'a> {
|
|||
}
|
||||
|
||||
impl<'a, T: Clone + IntoDiagnosticArg> IntoDiagnosticArg for &'a T {
|
||||
fn into_diagnostic_arg(self) -> DiagnosticArgValue<'static> {
|
||||
fn into_diagnostic_arg(self) -> DiagnosticArgValue {
|
||||
self.clone().into_diagnostic_arg()
|
||||
}
|
||||
}
|
||||
|
@ -50,7 +50,7 @@ macro_rules! into_diagnostic_arg_using_display {
|
|||
($( $ty:ty ),+ $(,)?) => {
|
||||
$(
|
||||
impl IntoDiagnosticArg for $ty {
|
||||
fn into_diagnostic_arg(self) -> DiagnosticArgValue<'static> {
|
||||
fn into_diagnostic_arg(self) -> DiagnosticArgValue {
|
||||
self.to_string().into_diagnostic_arg()
|
||||
}
|
||||
}
|
||||
|
@ -62,7 +62,7 @@ macro_rules! into_diagnostic_arg_for_number {
|
|||
($( $ty:ty ),+ $(,)?) => {
|
||||
$(
|
||||
impl IntoDiagnosticArg for $ty {
|
||||
fn into_diagnostic_arg(self) -> DiagnosticArgValue<'static> {
|
||||
fn into_diagnostic_arg(self) -> DiagnosticArgValue {
|
||||
// HACK: `FluentNumber` the underline backing struct represent
|
||||
// numbers using a f64 which can't represent all the i128 numbers
|
||||
// So in order to be able to use fluent selectors and still
|
||||
|
@ -99,7 +99,7 @@ into_diagnostic_arg_using_display!(
|
|||
into_diagnostic_arg_for_number!(i8, u8, i16, u16, i32, u32, i64, u64, i128, u128, isize, usize);
|
||||
|
||||
impl IntoDiagnosticArg for bool {
|
||||
fn into_diagnostic_arg(self) -> DiagnosticArgValue<'static> {
|
||||
fn into_diagnostic_arg(self) -> DiagnosticArgValue {
|
||||
if self {
|
||||
DiagnosticArgValue::Str(Cow::Borrowed("true"))
|
||||
} else {
|
||||
|
@ -109,13 +109,13 @@ impl IntoDiagnosticArg for bool {
|
|||
}
|
||||
|
||||
impl IntoDiagnosticArg for char {
|
||||
fn into_diagnostic_arg(self) -> DiagnosticArgValue<'static> {
|
||||
fn into_diagnostic_arg(self) -> DiagnosticArgValue {
|
||||
DiagnosticArgValue::Str(Cow::Owned(format!("{self:?}")))
|
||||
}
|
||||
}
|
||||
|
||||
impl IntoDiagnosticArg for Vec<char> {
|
||||
fn into_diagnostic_arg(self) -> DiagnosticArgValue<'static> {
|
||||
fn into_diagnostic_arg(self) -> DiagnosticArgValue {
|
||||
DiagnosticArgValue::StrListSepByAnd(
|
||||
self.into_iter().map(|c| Cow::Owned(format!("{c:?}"))).collect(),
|
||||
)
|
||||
|
@ -123,49 +123,49 @@ impl IntoDiagnosticArg for Vec<char> {
|
|||
}
|
||||
|
||||
impl IntoDiagnosticArg for Symbol {
|
||||
fn into_diagnostic_arg(self) -> DiagnosticArgValue<'static> {
|
||||
fn into_diagnostic_arg(self) -> DiagnosticArgValue {
|
||||
self.to_ident_string().into_diagnostic_arg()
|
||||
}
|
||||
}
|
||||
|
||||
impl<'a> IntoDiagnosticArg for &'a str {
|
||||
fn into_diagnostic_arg(self) -> DiagnosticArgValue<'static> {
|
||||
fn into_diagnostic_arg(self) -> DiagnosticArgValue {
|
||||
self.to_string().into_diagnostic_arg()
|
||||
}
|
||||
}
|
||||
|
||||
impl IntoDiagnosticArg for String {
|
||||
fn into_diagnostic_arg(self) -> DiagnosticArgValue<'static> {
|
||||
fn into_diagnostic_arg(self) -> DiagnosticArgValue {
|
||||
DiagnosticArgValue::Str(Cow::Owned(self))
|
||||
}
|
||||
}
|
||||
|
||||
impl<'a> IntoDiagnosticArg for Cow<'a, str> {
|
||||
fn into_diagnostic_arg(self) -> DiagnosticArgValue<'static> {
|
||||
fn into_diagnostic_arg(self) -> DiagnosticArgValue {
|
||||
DiagnosticArgValue::Str(Cow::Owned(self.into_owned()))
|
||||
}
|
||||
}
|
||||
|
||||
impl<'a> IntoDiagnosticArg for &'a Path {
|
||||
fn into_diagnostic_arg(self) -> DiagnosticArgValue<'static> {
|
||||
fn into_diagnostic_arg(self) -> DiagnosticArgValue {
|
||||
DiagnosticArgValue::Str(Cow::Owned(self.display().to_string()))
|
||||
}
|
||||
}
|
||||
|
||||
impl IntoDiagnosticArg for PathBuf {
|
||||
fn into_diagnostic_arg(self) -> DiagnosticArgValue<'static> {
|
||||
fn into_diagnostic_arg(self) -> DiagnosticArgValue {
|
||||
DiagnosticArgValue::Str(Cow::Owned(self.display().to_string()))
|
||||
}
|
||||
}
|
||||
|
||||
impl IntoDiagnosticArg for PanicStrategy {
|
||||
fn into_diagnostic_arg(self) -> DiagnosticArgValue<'static> {
|
||||
fn into_diagnostic_arg(self) -> DiagnosticArgValue {
|
||||
DiagnosticArgValue::Str(Cow::Owned(self.desc().to_string()))
|
||||
}
|
||||
}
|
||||
|
||||
impl IntoDiagnosticArg for hir::ConstContext {
|
||||
fn into_diagnostic_arg(self) -> DiagnosticArgValue<'static> {
|
||||
fn into_diagnostic_arg(self) -> DiagnosticArgValue {
|
||||
DiagnosticArgValue::Str(Cow::Borrowed(match self {
|
||||
hir::ConstContext::ConstFn => "const_fn",
|
||||
hir::ConstContext::Static(_) => "static",
|
||||
|
@ -175,49 +175,49 @@ impl IntoDiagnosticArg for hir::ConstContext {
|
|||
}
|
||||
|
||||
impl IntoDiagnosticArg for ast::Expr {
|
||||
fn into_diagnostic_arg(self) -> DiagnosticArgValue<'static> {
|
||||
fn into_diagnostic_arg(self) -> DiagnosticArgValue {
|
||||
DiagnosticArgValue::Str(Cow::Owned(pprust::expr_to_string(&self)))
|
||||
}
|
||||
}
|
||||
|
||||
impl IntoDiagnosticArg for ast::Path {
|
||||
fn into_diagnostic_arg(self) -> DiagnosticArgValue<'static> {
|
||||
fn into_diagnostic_arg(self) -> DiagnosticArgValue {
|
||||
DiagnosticArgValue::Str(Cow::Owned(pprust::path_to_string(&self)))
|
||||
}
|
||||
}
|
||||
|
||||
impl IntoDiagnosticArg for ast::token::Token {
|
||||
fn into_diagnostic_arg(self) -> DiagnosticArgValue<'static> {
|
||||
fn into_diagnostic_arg(self) -> DiagnosticArgValue {
|
||||
DiagnosticArgValue::Str(pprust::token_to_string(&self))
|
||||
}
|
||||
}
|
||||
|
||||
impl IntoDiagnosticArg for ast::token::TokenKind {
|
||||
fn into_diagnostic_arg(self) -> DiagnosticArgValue<'static> {
|
||||
fn into_diagnostic_arg(self) -> DiagnosticArgValue {
|
||||
DiagnosticArgValue::Str(pprust::token_kind_to_string(&self))
|
||||
}
|
||||
}
|
||||
|
||||
impl IntoDiagnosticArg for type_ir::FloatTy {
|
||||
fn into_diagnostic_arg(self) -> DiagnosticArgValue<'static> {
|
||||
fn into_diagnostic_arg(self) -> DiagnosticArgValue {
|
||||
DiagnosticArgValue::Str(Cow::Borrowed(self.name_str()))
|
||||
}
|
||||
}
|
||||
|
||||
impl IntoDiagnosticArg for std::ffi::CString {
|
||||
fn into_diagnostic_arg(self) -> DiagnosticArgValue<'static> {
|
||||
fn into_diagnostic_arg(self) -> DiagnosticArgValue {
|
||||
DiagnosticArgValue::Str(Cow::Owned(self.to_string_lossy().into_owned()))
|
||||
}
|
||||
}
|
||||
|
||||
impl IntoDiagnosticArg for rustc_data_structures::small_c_str::SmallCStr {
|
||||
fn into_diagnostic_arg(self) -> DiagnosticArgValue<'static> {
|
||||
fn into_diagnostic_arg(self) -> DiagnosticArgValue {
|
||||
DiagnosticArgValue::Str(Cow::Owned(self.to_string_lossy().into_owned()))
|
||||
}
|
||||
}
|
||||
|
||||
impl IntoDiagnosticArg for ast::Visibility {
|
||||
fn into_diagnostic_arg(self) -> DiagnosticArgValue<'static> {
|
||||
fn into_diagnostic_arg(self) -> DiagnosticArgValue {
|
||||
let s = pprust::vis_to_string(&self);
|
||||
let s = s.trim_end().to_string();
|
||||
DiagnosticArgValue::Str(Cow::Owned(s))
|
||||
|
@ -225,7 +225,7 @@ impl IntoDiagnosticArg for ast::Visibility {
|
|||
}
|
||||
|
||||
impl IntoDiagnosticArg for rustc_lint_defs::Level {
|
||||
fn into_diagnostic_arg(self) -> DiagnosticArgValue<'static> {
|
||||
fn into_diagnostic_arg(self) -> DiagnosticArgValue {
|
||||
DiagnosticArgValue::Str(Cow::Borrowed(self.to_cmd_flag()))
|
||||
}
|
||||
}
|
||||
|
@ -240,7 +240,7 @@ impl From<Vec<Symbol>> for DiagnosticSymbolList {
|
|||
}
|
||||
|
||||
impl IntoDiagnosticArg for DiagnosticSymbolList {
|
||||
fn into_diagnostic_arg(self) -> DiagnosticArgValue<'static> {
|
||||
fn into_diagnostic_arg(self) -> DiagnosticArgValue {
|
||||
DiagnosticArgValue::StrListSepByAnd(
|
||||
self.0.into_iter().map(|sym| Cow::Owned(format!("`{sym}`"))).collect(),
|
||||
)
|
||||
|
@ -248,7 +248,7 @@ impl IntoDiagnosticArg for DiagnosticSymbolList {
|
|||
}
|
||||
|
||||
impl<Id> IntoDiagnosticArg for hir::def::Res<Id> {
|
||||
fn into_diagnostic_arg(self) -> DiagnosticArgValue<'static> {
|
||||
fn into_diagnostic_arg(self) -> DiagnosticArgValue {
|
||||
DiagnosticArgValue::Str(Cow::Borrowed(self.descr()))
|
||||
}
|
||||
}
|
||||
|
@ -334,13 +334,13 @@ pub struct DelayedAtWithoutNewline {
|
|||
}
|
||||
|
||||
impl IntoDiagnosticArg for DiagnosticLocation {
|
||||
fn into_diagnostic_arg(self) -> DiagnosticArgValue<'static> {
|
||||
fn into_diagnostic_arg(self) -> DiagnosticArgValue {
|
||||
DiagnosticArgValue::Str(Cow::from(self.to_string()))
|
||||
}
|
||||
}
|
||||
|
||||
impl IntoDiagnosticArg for Backtrace {
|
||||
fn into_diagnostic_arg(self) -> DiagnosticArgValue<'static> {
|
||||
fn into_diagnostic_arg(self) -> DiagnosticArgValue {
|
||||
DiagnosticArgValue::Str(Cow::from(self.to_string()))
|
||||
}
|
||||
}
|
||||
|
@ -353,7 +353,7 @@ pub struct InvalidFlushedDelayedDiagnosticLevel {
|
|||
pub level: Level,
|
||||
}
|
||||
impl IntoDiagnosticArg for Level {
|
||||
fn into_diagnostic_arg(self) -> DiagnosticArgValue<'static> {
|
||||
fn into_diagnostic_arg(self) -> DiagnosticArgValue {
|
||||
DiagnosticArgValue::Str(Cow::from(self.to_string()))
|
||||
}
|
||||
}
|
||||
|
@ -368,7 +368,7 @@ pub struct IndicateAnonymousLifetime {
|
|||
}
|
||||
|
||||
impl IntoDiagnosticArg for type_ir::ClosureKind {
|
||||
fn into_diagnostic_arg(self) -> DiagnosticArgValue<'static> {
|
||||
fn into_diagnostic_arg(self) -> DiagnosticArgValue {
|
||||
DiagnosticArgValue::Str(self.as_str().into())
|
||||
}
|
||||
}
|
||||
|
|
|
@ -33,8 +33,8 @@ extern crate self as rustc_errors;
|
|||
|
||||
pub use codes::*;
|
||||
pub use diagnostic::{
|
||||
AddToDiagnostic, DecorateLint, Diagnostic, DiagnosticArg, DiagnosticArgValue,
|
||||
DiagnosticStyledString, IntoDiagnosticArg, SubDiagnostic,
|
||||
AddToDiagnostic, DecorateLint, Diagnostic, DiagnosticArg, DiagnosticArgName,
|
||||
DiagnosticArgValue, DiagnosticStyledString, IntoDiagnosticArg, SubDiagnostic,
|
||||
};
|
||||
pub use diagnostic_builder::{
|
||||
BugAbort, DiagnosticBuilder, EmissionGuarantee, FatalAbort, IntoDiagnostic,
|
||||
|
@ -628,7 +628,7 @@ impl DiagCtxt {
|
|||
pub fn eagerly_translate<'a>(
|
||||
&self,
|
||||
message: DiagnosticMessage,
|
||||
args: impl Iterator<Item = DiagnosticArg<'a, 'static>>,
|
||||
args: impl Iterator<Item = DiagnosticArg<'a>>,
|
||||
) -> SubdiagnosticMessage {
|
||||
SubdiagnosticMessage::Eager(Cow::from(self.eagerly_translate_to_string(message, args)))
|
||||
}
|
||||
|
@ -637,7 +637,7 @@ impl DiagCtxt {
|
|||
pub fn eagerly_translate_to_string<'a>(
|
||||
&self,
|
||||
message: DiagnosticMessage,
|
||||
args: impl Iterator<Item = DiagnosticArg<'a, 'static>>,
|
||||
args: impl Iterator<Item = DiagnosticArg<'a>>,
|
||||
) -> String {
|
||||
let inner = self.inner.borrow();
|
||||
let args = crate::translation::to_fluent_args(args);
|
||||
|
|
|
@ -12,9 +12,9 @@ use std::error::Report;
|
|||
///
|
||||
/// Typically performed once for each diagnostic at the start of `emit_diagnostic` and then
|
||||
/// passed around as a reference thereafter.
|
||||
pub fn to_fluent_args<'iter, 'arg: 'iter>(
|
||||
iter: impl Iterator<Item = DiagnosticArg<'iter, 'arg>>,
|
||||
) -> FluentArgs<'arg> {
|
||||
pub fn to_fluent_args<'iter>(
|
||||
iter: impl Iterator<Item = DiagnosticArg<'iter>>,
|
||||
) -> FluentArgs<'static> {
|
||||
let mut args = if let Some(size) = iter.size_hint().1 {
|
||||
FluentArgs::with_capacity(size)
|
||||
} else {
|
||||
|
|
|
@ -43,7 +43,7 @@ pub enum ReturnLikeStatementKind {
|
|||
}
|
||||
|
||||
impl IntoDiagnosticArg for ReturnLikeStatementKind {
|
||||
fn into_diagnostic_arg(self) -> DiagnosticArgValue<'static> {
|
||||
fn into_diagnostic_arg(self) -> DiagnosticArgValue {
|
||||
let kind = match self {
|
||||
Self::Return => "return",
|
||||
Self::Become => "become",
|
||||
|
|
|
@ -534,7 +534,7 @@ pub enum TyOrSig<'tcx> {
|
|||
}
|
||||
|
||||
impl IntoDiagnosticArg for TyOrSig<'_> {
|
||||
fn into_diagnostic_arg(self) -> rustc_errors::DiagnosticArgValue<'static> {
|
||||
fn into_diagnostic_arg(self) -> rustc_errors::DiagnosticArgValue {
|
||||
match self {
|
||||
TyOrSig::Ty(ty) => ty.into_diagnostic_arg(),
|
||||
TyOrSig::ClosureSig(sig) => sig.into_diagnostic_arg(),
|
||||
|
|
|
@ -108,7 +108,7 @@ pub enum SuffixKind {
|
|||
}
|
||||
|
||||
impl IntoDiagnosticArg for PrefixKind {
|
||||
fn into_diagnostic_arg(self) -> rustc_errors::DiagnosticArgValue<'static> {
|
||||
fn into_diagnostic_arg(self) -> rustc_errors::DiagnosticArgValue {
|
||||
let kind = match self {
|
||||
Self::Empty => "empty",
|
||||
Self::RefValidFor => "ref_valid_for",
|
||||
|
@ -130,7 +130,7 @@ impl IntoDiagnosticArg for PrefixKind {
|
|||
}
|
||||
|
||||
impl IntoDiagnosticArg for SuffixKind {
|
||||
fn into_diagnostic_arg(self) -> rustc_errors::DiagnosticArgValue<'static> {
|
||||
fn into_diagnostic_arg(self) -> rustc_errors::DiagnosticArgValue {
|
||||
let kind = match self {
|
||||
Self::Empty => "empty",
|
||||
Self::Continues => "continues",
|
||||
|
|
|
@ -2914,7 +2914,7 @@ impl<'tcx> ObligationCauseExt<'tcx> for ObligationCause<'tcx> {
|
|||
pub struct ObligationCauseAsDiagArg<'tcx>(pub ObligationCause<'tcx>);
|
||||
|
||||
impl IntoDiagnosticArg for ObligationCauseAsDiagArg<'_> {
|
||||
fn into_diagnostic_arg(self) -> rustc_errors::DiagnosticArgValue<'static> {
|
||||
fn into_diagnostic_arg(self) -> rustc_errors::DiagnosticArgValue {
|
||||
use crate::traits::ObligationCauseCode::*;
|
||||
let kind = match self.0.code() {
|
||||
CompareImplItemObligation { kind: ty::AssocKind::Fn, .. } => "method_compat",
|
||||
|
|
|
@ -134,7 +134,7 @@ impl InferenceDiagnosticsParentData {
|
|||
}
|
||||
|
||||
impl IntoDiagnosticArg for UnderspecifiedArgKind {
|
||||
fn into_diagnostic_arg(self) -> rustc_errors::DiagnosticArgValue<'static> {
|
||||
fn into_diagnostic_arg(self) -> rustc_errors::DiagnosticArgValue {
|
||||
let kind = match self {
|
||||
Self::Type { .. } => "type",
|
||||
Self::Const { is_parameter: true } => "const_with_param",
|
||||
|
|
|
@ -30,7 +30,7 @@ impl<'tcx, T> IntoDiagnosticArg for Highlighted<'tcx, T>
|
|||
where
|
||||
T: for<'a> Print<'tcx, FmtPrinter<'a, 'tcx>>,
|
||||
{
|
||||
fn into_diagnostic_arg(self) -> rustc_errors::DiagnosticArgValue<'static> {
|
||||
fn into_diagnostic_arg(self) -> rustc_errors::DiagnosticArgValue {
|
||||
rustc_errors::DiagnosticArgValue::Str(self.to_string().into())
|
||||
}
|
||||
}
|
||||
|
|
|
@ -291,7 +291,7 @@ impl fmt::Display for CrateFlavor {
|
|||
}
|
||||
|
||||
impl IntoDiagnosticArg for CrateFlavor {
|
||||
fn into_diagnostic_arg(self) -> rustc_errors::DiagnosticArgValue<'static> {
|
||||
fn into_diagnostic_arg(self) -> rustc_errors::DiagnosticArgValue {
|
||||
match self {
|
||||
CrateFlavor::Rlib => DiagnosticArgValue::Str(Cow::Borrowed("rlib")),
|
||||
CrateFlavor::Rmeta => DiagnosticArgValue::Str(Cow::Borrowed("rmeta")),
|
||||
|
|
|
@ -95,17 +95,14 @@ pub(super) struct ConstNotUsedTraitAlias {
|
|||
|
||||
pub struct CustomSubdiagnostic<'a> {
|
||||
pub msg: fn() -> DiagnosticMessage,
|
||||
pub add_args:
|
||||
Box<dyn FnOnce(&mut dyn FnMut(Cow<'static, str>, DiagnosticArgValue<'static>)) + 'a>,
|
||||
pub add_args: Box<dyn FnOnce(&mut dyn FnMut(Cow<'static, str>, DiagnosticArgValue)) + 'a>,
|
||||
}
|
||||
|
||||
impl<'a> CustomSubdiagnostic<'a> {
|
||||
pub fn label(x: fn() -> DiagnosticMessage) -> Self {
|
||||
Self::label_and_then(x, |_| {})
|
||||
}
|
||||
pub fn label_and_then<
|
||||
F: FnOnce(&mut dyn FnMut(Cow<'static, str>, DiagnosticArgValue<'static>)) + 'a,
|
||||
>(
|
||||
pub fn label_and_then<F: FnOnce(&mut dyn FnMut(Cow<'static, str>, DiagnosticArgValue)) + 'a>(
|
||||
msg: fn() -> DiagnosticMessage,
|
||||
f: F,
|
||||
) -> Self {
|
||||
|
|
|
@ -233,7 +233,7 @@ pub enum InvalidMetaKind {
|
|||
}
|
||||
|
||||
impl IntoDiagnosticArg for InvalidMetaKind {
|
||||
fn into_diagnostic_arg(self) -> DiagnosticArgValue<'static> {
|
||||
fn into_diagnostic_arg(self) -> DiagnosticArgValue {
|
||||
DiagnosticArgValue::Str(Cow::Borrowed(match self {
|
||||
InvalidMetaKind::SliceTooBig => "slice_too_big",
|
||||
InvalidMetaKind::TooBig => "too_big",
|
||||
|
@ -267,7 +267,7 @@ pub struct Misalignment {
|
|||
macro_rules! impl_into_diagnostic_arg_through_debug {
|
||||
($($ty:ty),*$(,)?) => {$(
|
||||
impl IntoDiagnosticArg for $ty {
|
||||
fn into_diagnostic_arg(self) -> DiagnosticArgValue<'static> {
|
||||
fn into_diagnostic_arg(self) -> DiagnosticArgValue {
|
||||
DiagnosticArgValue::Str(Cow::Owned(format!("{self:?}")))
|
||||
}
|
||||
}
|
||||
|
@ -367,7 +367,7 @@ pub enum PointerKind {
|
|||
}
|
||||
|
||||
impl IntoDiagnosticArg for PointerKind {
|
||||
fn into_diagnostic_arg(self) -> DiagnosticArgValue<'static> {
|
||||
fn into_diagnostic_arg(self) -> DiagnosticArgValue {
|
||||
DiagnosticArgValue::Str(
|
||||
match self {
|
||||
Self::Ref => "ref",
|
||||
|
@ -485,10 +485,7 @@ pub trait MachineStopType: Any + fmt::Debug + Send {
|
|||
fn diagnostic_message(&self) -> DiagnosticMessage;
|
||||
/// Add diagnostic arguments by passing name and value pairs to `adder`, which are passed to
|
||||
/// fluent for formatting the translated diagnostic message.
|
||||
fn add_args(
|
||||
self: Box<Self>,
|
||||
adder: &mut dyn FnMut(Cow<'static, str>, DiagnosticArgValue<'static>),
|
||||
);
|
||||
fn add_args(self: Box<Self>, adder: &mut dyn FnMut(Cow<'static, str>, DiagnosticArgValue));
|
||||
}
|
||||
|
||||
impl dyn MachineStopType {
|
||||
|
|
|
@ -292,7 +292,7 @@ impl<O> AssertKind<O> {
|
|||
}
|
||||
}
|
||||
|
||||
pub fn add_args(self, adder: &mut dyn FnMut(Cow<'static, str>, DiagnosticArgValue<'static>))
|
||||
pub fn add_args(self, adder: &mut dyn FnMut(Cow<'static, str>, DiagnosticArgValue))
|
||||
where
|
||||
O: fmt::Debug,
|
||||
{
|
||||
|
|
|
@ -674,7 +674,7 @@ impl<'tcx> Pat<'tcx> {
|
|||
}
|
||||
|
||||
impl<'tcx> IntoDiagnosticArg for Pat<'tcx> {
|
||||
fn into_diagnostic_arg(self) -> DiagnosticArgValue<'static> {
|
||||
fn into_diagnostic_arg(self) -> DiagnosticArgValue {
|
||||
format!("{self}").into_diagnostic_arg()
|
||||
}
|
||||
}
|
||||
|
|
|
@ -117,7 +117,7 @@ impl std::fmt::Debug for ConstInt {
|
|||
impl IntoDiagnosticArg 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) -> DiagnosticArgValue<'static> {
|
||||
fn into_diagnostic_arg(self) -> DiagnosticArgValue {
|
||||
DiagnosticArgValue::Str(format!("{self:?}").into())
|
||||
}
|
||||
}
|
||||
|
|
|
@ -15,7 +15,7 @@ pub struct UnevaluatedConst<'tcx> {
|
|||
}
|
||||
|
||||
impl rustc_errors::IntoDiagnosticArg for UnevaluatedConst<'_> {
|
||||
fn into_diagnostic_arg(self) -> rustc_errors::DiagnosticArgValue<'static> {
|
||||
fn into_diagnostic_arg(self) -> rustc_errors::DiagnosticArgValue {
|
||||
format!("{self:?}").into_diagnostic_arg()
|
||||
}
|
||||
}
|
||||
|
|
|
@ -20,7 +20,7 @@ use rustc_span::{BytePos, Span};
|
|||
use rustc_type_ir::TyKind::*;
|
||||
|
||||
impl<'tcx> IntoDiagnosticArg for Ty<'tcx> {
|
||||
fn into_diagnostic_arg(self) -> DiagnosticArgValue<'static> {
|
||||
fn into_diagnostic_arg(self) -> DiagnosticArgValue {
|
||||
self.to_string().into_diagnostic_arg()
|
||||
}
|
||||
}
|
||||
|
|
|
@ -56,7 +56,7 @@ unsafe impl<'tcx> Sync for GenericArg<'tcx> where
|
|||
}
|
||||
|
||||
impl<'tcx> IntoDiagnosticArg for GenericArg<'tcx> {
|
||||
fn into_diagnostic_arg(self) -> DiagnosticArgValue<'static> {
|
||||
fn into_diagnostic_arg(self) -> DiagnosticArgValue {
|
||||
self.to_string().into_diagnostic_arg()
|
||||
}
|
||||
}
|
||||
|
|
|
@ -269,7 +269,7 @@ impl<'tcx> fmt::Display for LayoutError<'tcx> {
|
|||
}
|
||||
|
||||
impl<'tcx> IntoDiagnosticArg for LayoutError<'tcx> {
|
||||
fn into_diagnostic_arg(self) -> DiagnosticArgValue<'static> {
|
||||
fn into_diagnostic_arg(self) -> DiagnosticArgValue {
|
||||
self.to_string().into_diagnostic_arg()
|
||||
}
|
||||
}
|
||||
|
|
|
@ -583,13 +583,13 @@ impl<'tcx> Predicate<'tcx> {
|
|||
}
|
||||
|
||||
impl rustc_errors::IntoDiagnosticArg for Predicate<'_> {
|
||||
fn into_diagnostic_arg(self) -> rustc_errors::DiagnosticArgValue<'static> {
|
||||
fn into_diagnostic_arg(self) -> rustc_errors::DiagnosticArgValue {
|
||||
rustc_errors::DiagnosticArgValue::Str(std::borrow::Cow::Owned(self.to_string()))
|
||||
}
|
||||
}
|
||||
|
||||
impl rustc_errors::IntoDiagnosticArg for Clause<'_> {
|
||||
fn into_diagnostic_arg(self) -> rustc_errors::DiagnosticArgValue<'static> {
|
||||
fn into_diagnostic_arg(self) -> rustc_errors::DiagnosticArgValue {
|
||||
rustc_errors::DiagnosticArgValue::Str(std::borrow::Cow::Owned(self.to_string()))
|
||||
}
|
||||
}
|
||||
|
|
|
@ -2632,7 +2632,7 @@ where
|
|||
pub struct TraitRefPrintOnlyTraitPath<'tcx>(ty::TraitRef<'tcx>);
|
||||
|
||||
impl<'tcx> rustc_errors::IntoDiagnosticArg for TraitRefPrintOnlyTraitPath<'tcx> {
|
||||
fn into_diagnostic_arg(self) -> rustc_errors::DiagnosticArgValue<'static> {
|
||||
fn into_diagnostic_arg(self) -> rustc_errors::DiagnosticArgValue {
|
||||
self.to_string().into_diagnostic_arg()
|
||||
}
|
||||
}
|
||||
|
@ -2649,7 +2649,7 @@ impl<'tcx> fmt::Debug for TraitRefPrintOnlyTraitPath<'tcx> {
|
|||
pub struct TraitRefPrintSugared<'tcx>(ty::TraitRef<'tcx>);
|
||||
|
||||
impl<'tcx> rustc_errors::IntoDiagnosticArg for TraitRefPrintSugared<'tcx> {
|
||||
fn into_diagnostic_arg(self) -> rustc_errors::DiagnosticArgValue<'static> {
|
||||
fn into_diagnostic_arg(self) -> rustc_errors::DiagnosticArgValue {
|
||||
self.to_string().into_diagnostic_arg()
|
||||
}
|
||||
}
|
||||
|
|
|
@ -862,7 +862,7 @@ impl<'tcx> PolyTraitRef<'tcx> {
|
|||
}
|
||||
|
||||
impl<'tcx> IntoDiagnosticArg for TraitRef<'tcx> {
|
||||
fn into_diagnostic_arg(self) -> DiagnosticArgValue<'static> {
|
||||
fn into_diagnostic_arg(self) -> DiagnosticArgValue {
|
||||
self.to_string().into_diagnostic_arg()
|
||||
}
|
||||
}
|
||||
|
@ -908,7 +908,7 @@ impl<'tcx> ExistentialTraitRef<'tcx> {
|
|||
}
|
||||
|
||||
impl<'tcx> IntoDiagnosticArg for ExistentialTraitRef<'tcx> {
|
||||
fn into_diagnostic_arg(self) -> DiagnosticArgValue<'static> {
|
||||
fn into_diagnostic_arg(self) -> DiagnosticArgValue {
|
||||
self.to_string().into_diagnostic_arg()
|
||||
}
|
||||
}
|
||||
|
@ -1149,7 +1149,7 @@ impl<'tcx, T> IntoDiagnosticArg for Binder<'tcx, T>
|
|||
where
|
||||
T: IntoDiagnosticArg,
|
||||
{
|
||||
fn into_diagnostic_arg(self) -> DiagnosticArgValue<'static> {
|
||||
fn into_diagnostic_arg(self) -> DiagnosticArgValue {
|
||||
self.value.into_diagnostic_arg()
|
||||
}
|
||||
}
|
||||
|
@ -1359,7 +1359,7 @@ impl<'tcx> FnSig<'tcx> {
|
|||
}
|
||||
|
||||
impl<'tcx> IntoDiagnosticArg for FnSig<'tcx> {
|
||||
fn into_diagnostic_arg(self) -> DiagnosticArgValue<'static> {
|
||||
fn into_diagnostic_arg(self) -> DiagnosticArgValue {
|
||||
self.to_string().into_diagnostic_arg()
|
||||
}
|
||||
}
|
||||
|
|
|
@ -605,7 +605,7 @@ impl UnsafeOpKind {
|
|||
span,
|
||||
UnsafeOpInUnsafeFnCallToUnsafeFunctionRequiresUnsafe {
|
||||
span,
|
||||
function: &with_no_trimmed_paths!(tcx.def_path_str(*did)),
|
||||
function: with_no_trimmed_paths!(tcx.def_path_str(*did)),
|
||||
unsafe_not_inherited_note,
|
||||
},
|
||||
),
|
||||
|
@ -696,14 +696,17 @@ impl UnsafeOpKind {
|
|||
span,
|
||||
UnsafeOpInUnsafeFnCallToFunctionWithRequiresUnsafe {
|
||||
span,
|
||||
function: &with_no_trimmed_paths!(tcx.def_path_str(*function)),
|
||||
function: with_no_trimmed_paths!(tcx.def_path_str(*function)),
|
||||
missing_target_features: DiagnosticArgValue::StrListSepByAnd(
|
||||
missing.iter().map(|feature| Cow::from(feature.as_str())).collect(),
|
||||
missing.iter().map(|feature| Cow::from(feature.to_string())).collect(),
|
||||
),
|
||||
missing_target_features_count: missing.len(),
|
||||
note: if build_enabled.is_empty() { None } else { Some(()) },
|
||||
build_target_features: DiagnosticArgValue::StrListSepByAnd(
|
||||
build_enabled.iter().map(|feature| Cow::from(feature.as_str())).collect(),
|
||||
build_enabled
|
||||
.iter()
|
||||
.map(|feature| Cow::from(feature.to_string()))
|
||||
.collect(),
|
||||
),
|
||||
build_target_features_count: build_enabled.len(),
|
||||
unsafe_not_inherited_note,
|
||||
|
@ -747,14 +750,14 @@ impl UnsafeOpKind {
|
|||
dcx.emit_err(CallToUnsafeFunctionRequiresUnsafeUnsafeOpInUnsafeFnAllowed {
|
||||
span,
|
||||
unsafe_not_inherited_note,
|
||||
function: &tcx.def_path_str(*did),
|
||||
function: tcx.def_path_str(*did),
|
||||
});
|
||||
}
|
||||
CallToUnsafeFunction(Some(did)) => {
|
||||
dcx.emit_err(CallToUnsafeFunctionRequiresUnsafe {
|
||||
span,
|
||||
unsafe_not_inherited_note,
|
||||
function: &tcx.def_path_str(*did),
|
||||
function: tcx.def_path_str(*did),
|
||||
});
|
||||
}
|
||||
CallToUnsafeFunction(None) if unsafe_op_in_unsafe_fn_allowed => {
|
||||
|
@ -860,32 +863,38 @@ impl UnsafeOpKind {
|
|||
dcx.emit_err(CallToFunctionWithRequiresUnsafeUnsafeOpInUnsafeFnAllowed {
|
||||
span,
|
||||
missing_target_features: DiagnosticArgValue::StrListSepByAnd(
|
||||
missing.iter().map(|feature| Cow::from(feature.as_str())).collect(),
|
||||
missing.iter().map(|feature| Cow::from(feature.to_string())).collect(),
|
||||
),
|
||||
missing_target_features_count: missing.len(),
|
||||
note: if build_enabled.is_empty() { None } else { Some(()) },
|
||||
build_target_features: DiagnosticArgValue::StrListSepByAnd(
|
||||
build_enabled.iter().map(|feature| Cow::from(feature.as_str())).collect(),
|
||||
build_enabled
|
||||
.iter()
|
||||
.map(|feature| Cow::from(feature.to_string()))
|
||||
.collect(),
|
||||
),
|
||||
build_target_features_count: build_enabled.len(),
|
||||
unsafe_not_inherited_note,
|
||||
function: &tcx.def_path_str(*function),
|
||||
function: tcx.def_path_str(*function),
|
||||
});
|
||||
}
|
||||
CallToFunctionWith { function, missing, build_enabled } => {
|
||||
dcx.emit_err(CallToFunctionWithRequiresUnsafe {
|
||||
span,
|
||||
missing_target_features: DiagnosticArgValue::StrListSepByAnd(
|
||||
missing.iter().map(|feature| Cow::from(feature.as_str())).collect(),
|
||||
missing.iter().map(|feature| Cow::from(feature.to_string())).collect(),
|
||||
),
|
||||
missing_target_features_count: missing.len(),
|
||||
note: if build_enabled.is_empty() { None } else { Some(()) },
|
||||
build_target_features: DiagnosticArgValue::StrListSepByAnd(
|
||||
build_enabled.iter().map(|feature| Cow::from(feature.as_str())).collect(),
|
||||
build_enabled
|
||||
.iter()
|
||||
.map(|feature| Cow::from(feature.to_string()))
|
||||
.collect(),
|
||||
),
|
||||
build_target_features_count: build_enabled.len(),
|
||||
unsafe_not_inherited_note,
|
||||
function: &tcx.def_path_str(*function),
|
||||
function: tcx.def_path_str(*function),
|
||||
});
|
||||
}
|
||||
}
|
||||
|
|
|
@ -23,10 +23,10 @@ pub struct UnconditionalRecursion {
|
|||
#[derive(LintDiagnostic)]
|
||||
#[diag(mir_build_unsafe_op_in_unsafe_fn_call_to_unsafe_fn_requires_unsafe)]
|
||||
#[note]
|
||||
pub struct UnsafeOpInUnsafeFnCallToUnsafeFunctionRequiresUnsafe<'a> {
|
||||
pub struct UnsafeOpInUnsafeFnCallToUnsafeFunctionRequiresUnsafe {
|
||||
#[label]
|
||||
pub span: Span,
|
||||
pub function: &'a str,
|
||||
pub function: String,
|
||||
#[subdiagnostic]
|
||||
pub unsafe_not_inherited_note: Option<UnsafeNotInheritedLintNote>,
|
||||
}
|
||||
|
@ -123,15 +123,15 @@ pub struct UnsafeOpInUnsafeFnBorrowOfLayoutConstrainedFieldRequiresUnsafe {
|
|||
#[derive(LintDiagnostic)]
|
||||
#[diag(mir_build_unsafe_op_in_unsafe_fn_call_to_fn_with_requires_unsafe)]
|
||||
#[help]
|
||||
pub struct UnsafeOpInUnsafeFnCallToFunctionWithRequiresUnsafe<'a> {
|
||||
pub struct UnsafeOpInUnsafeFnCallToFunctionWithRequiresUnsafe {
|
||||
#[label]
|
||||
pub span: Span,
|
||||
pub function: &'a str,
|
||||
pub missing_target_features: DiagnosticArgValue<'a>,
|
||||
pub function: String,
|
||||
pub missing_target_features: DiagnosticArgValue,
|
||||
pub missing_target_features_count: usize,
|
||||
#[note]
|
||||
pub note: Option<()>,
|
||||
pub build_target_features: DiagnosticArgValue<'a>,
|
||||
pub build_target_features: DiagnosticArgValue,
|
||||
pub build_target_features_count: usize,
|
||||
#[subdiagnostic]
|
||||
pub unsafe_not_inherited_note: Option<UnsafeNotInheritedLintNote>,
|
||||
|
@ -140,11 +140,11 @@ pub struct UnsafeOpInUnsafeFnCallToFunctionWithRequiresUnsafe<'a> {
|
|||
#[derive(Diagnostic)]
|
||||
#[diag(mir_build_call_to_unsafe_fn_requires_unsafe, code = E0133)]
|
||||
#[note]
|
||||
pub struct CallToUnsafeFunctionRequiresUnsafe<'a> {
|
||||
pub struct CallToUnsafeFunctionRequiresUnsafe {
|
||||
#[primary_span]
|
||||
#[label]
|
||||
pub span: Span,
|
||||
pub function: &'a str,
|
||||
pub function: String,
|
||||
#[subdiagnostic]
|
||||
pub unsafe_not_inherited_note: Option<UnsafeNotInheritedNote>,
|
||||
}
|
||||
|
@ -163,11 +163,11 @@ pub struct CallToUnsafeFunctionRequiresUnsafeNameless {
|
|||
#[derive(Diagnostic)]
|
||||
#[diag(mir_build_call_to_unsafe_fn_requires_unsafe_unsafe_op_in_unsafe_fn_allowed, code = E0133)]
|
||||
#[note]
|
||||
pub struct CallToUnsafeFunctionRequiresUnsafeUnsafeOpInUnsafeFnAllowed<'a> {
|
||||
pub struct CallToUnsafeFunctionRequiresUnsafeUnsafeOpInUnsafeFnAllowed {
|
||||
#[primary_span]
|
||||
#[label]
|
||||
pub span: Span,
|
||||
pub function: &'a str,
|
||||
pub function: String,
|
||||
#[subdiagnostic]
|
||||
pub unsafe_not_inherited_note: Option<UnsafeNotInheritedNote>,
|
||||
}
|
||||
|
@ -374,16 +374,16 @@ pub struct BorrowOfLayoutConstrainedFieldRequiresUnsafeUnsafeOpInUnsafeFnAllowed
|
|||
#[derive(Diagnostic)]
|
||||
#[diag(mir_build_call_to_fn_with_requires_unsafe, code = E0133)]
|
||||
#[help]
|
||||
pub struct CallToFunctionWithRequiresUnsafe<'a> {
|
||||
pub struct CallToFunctionWithRequiresUnsafe {
|
||||
#[primary_span]
|
||||
#[label]
|
||||
pub span: Span,
|
||||
pub function: &'a str,
|
||||
pub missing_target_features: DiagnosticArgValue<'a>,
|
||||
pub function: String,
|
||||
pub missing_target_features: DiagnosticArgValue,
|
||||
pub missing_target_features_count: usize,
|
||||
#[note]
|
||||
pub note: Option<()>,
|
||||
pub build_target_features: DiagnosticArgValue<'a>,
|
||||
pub build_target_features: DiagnosticArgValue,
|
||||
pub build_target_features_count: usize,
|
||||
#[subdiagnostic]
|
||||
pub unsafe_not_inherited_note: Option<UnsafeNotInheritedNote>,
|
||||
|
@ -392,16 +392,16 @@ pub struct CallToFunctionWithRequiresUnsafe<'a> {
|
|||
#[derive(Diagnostic)]
|
||||
#[diag(mir_build_call_to_fn_with_requires_unsafe_unsafe_op_in_unsafe_fn_allowed, code = E0133)]
|
||||
#[help]
|
||||
pub struct CallToFunctionWithRequiresUnsafeUnsafeOpInUnsafeFnAllowed<'a> {
|
||||
pub struct CallToFunctionWithRequiresUnsafeUnsafeOpInUnsafeFnAllowed {
|
||||
#[primary_span]
|
||||
#[label]
|
||||
pub span: Span,
|
||||
pub function: &'a str,
|
||||
pub missing_target_features: DiagnosticArgValue<'a>,
|
||||
pub function: String,
|
||||
pub missing_target_features: DiagnosticArgValue,
|
||||
pub missing_target_features_count: usize,
|
||||
#[note]
|
||||
pub note: Option<()>,
|
||||
pub build_target_features: DiagnosticArgValue<'a>,
|
||||
pub build_target_features: DiagnosticArgValue,
|
||||
pub build_target_features_count: usize,
|
||||
#[subdiagnostic]
|
||||
pub unsafe_not_inherited_note: Option<UnsafeNotInheritedNote>,
|
||||
|
|
|
@ -34,7 +34,7 @@ pub(crate) macro throw_machine_stop_str($($tt:tt)*) {{
|
|||
|
||||
fn add_args(
|
||||
self: Box<Self>,
|
||||
_: &mut dyn FnMut(std::borrow::Cow<'static, str>, rustc_errors::DiagnosticArgValue<'static>),
|
||||
_: &mut dyn FnMut(std::borrow::Cow<'static, str>, rustc_errors::DiagnosticArgValue),
|
||||
) {}
|
||||
}
|
||||
throw_machine_stop!(Zst)
|
||||
|
|
|
@ -125,7 +125,7 @@ impl RequiresUnsafeDetail {
|
|||
diag.arg(
|
||||
"missing_target_features",
|
||||
DiagnosticArgValue::StrListSepByAnd(
|
||||
missing.iter().map(|feature| Cow::from(feature.as_str())).collect(),
|
||||
missing.iter().map(|feature| Cow::from(feature.to_string())).collect(),
|
||||
),
|
||||
);
|
||||
diag.arg("missing_target_features_count", missing.len());
|
||||
|
@ -136,7 +136,7 @@ impl RequiresUnsafeDetail {
|
|||
DiagnosticArgValue::StrListSepByAnd(
|
||||
build_enabled
|
||||
.iter()
|
||||
.map(|feature| Cow::from(feature.as_str()))
|
||||
.map(|feature| Cow::from(feature.to_string()))
|
||||
.collect(),
|
||||
),
|
||||
);
|
||||
|
|
|
@ -78,7 +78,7 @@ pub(crate) enum ProcMacroKind {
|
|||
}
|
||||
|
||||
impl IntoDiagnosticArg for ProcMacroKind {
|
||||
fn into_diagnostic_arg(self) -> rustc_errors::DiagnosticArgValue<'static> {
|
||||
fn into_diagnostic_arg(self) -> rustc_errors::DiagnosticArgValue {
|
||||
match self {
|
||||
ProcMacroKind::Attribute => "attribute proc macro",
|
||||
ProcMacroKind::Derive => "derive proc macro",
|
||||
|
|
|
@ -90,7 +90,7 @@ impl PatternSource {
|
|||
}
|
||||
|
||||
impl IntoDiagnosticArg for PatternSource {
|
||||
fn into_diagnostic_arg(self) -> DiagnosticArgValue<'static> {
|
||||
fn into_diagnostic_arg(self) -> DiagnosticArgValue {
|
||||
DiagnosticArgValue::Str(Cow::Borrowed(self.descr()))
|
||||
}
|
||||
}
|
||||
|
|
|
@ -3092,7 +3092,7 @@ impl fmt::Display for CrateType {
|
|||
}
|
||||
|
||||
impl IntoDiagnosticArg for CrateType {
|
||||
fn into_diagnostic_arg(self) -> DiagnosticArgValue<'static> {
|
||||
fn into_diagnostic_arg(self) -> DiagnosticArgValue {
|
||||
self.to_string().into_diagnostic_arg()
|
||||
}
|
||||
}
|
||||
|
|
|
@ -111,7 +111,7 @@ impl Mul<usize> for Limit {
|
|||
}
|
||||
|
||||
impl rustc_errors::IntoDiagnosticArg for Limit {
|
||||
fn into_diagnostic_arg(self) -> rustc_errors::DiagnosticArgValue<'static> {
|
||||
fn into_diagnostic_arg(self) -> rustc_errors::DiagnosticArgValue {
|
||||
self.to_string().into_diagnostic_arg()
|
||||
}
|
||||
}
|
||||
|
|
|
@ -104,7 +104,7 @@ impl MachineStopType for TerminationInfo {
|
|||
self: Box<Self>,
|
||||
_: &mut dyn FnMut(
|
||||
std::borrow::Cow<'static, str>,
|
||||
rustc_errors::DiagnosticArgValue<'static>,
|
||||
rustc_errors::DiagnosticArgValue,
|
||||
),
|
||||
) {
|
||||
}
|
||||
|
|
Loading…
Reference in New Issue