summaryrefslogtreecommitdiffstats
path: root/compiler/rustc_errors/src/diagnostic_impls.rs
diff options
context:
space:
mode:
authorDaniel Baumann <daniel.baumann@progress-linux.org>2024-04-17 12:18:25 +0000
committerDaniel Baumann <daniel.baumann@progress-linux.org>2024-04-17 12:18:25 +0000
commit5363f350887b1e5b5dd21a86f88c8af9d7fea6da (patch)
tree35ca005eb6e0e9a1ba3bb5dbc033209ad445dc17 /compiler/rustc_errors/src/diagnostic_impls.rs
parentAdding debian version 1.66.0+dfsg1-1. (diff)
downloadrustc-5363f350887b1e5b5dd21a86f88c8af9d7fea6da.tar.xz
rustc-5363f350887b1e5b5dd21a86f88c8af9d7fea6da.zip
Merging upstream version 1.67.1+dfsg1.
Signed-off-by: Daniel Baumann <daniel.baumann@progress-linux.org>
Diffstat (limited to 'compiler/rustc_errors/src/diagnostic_impls.rs')
-rw-r--r--compiler/rustc_errors/src/diagnostic_impls.rs34
1 files changed, 33 insertions, 1 deletions
diff --git a/compiler/rustc_errors/src/diagnostic_impls.rs b/compiler/rustc_errors/src/diagnostic_impls.rs
index 7640b2919..7155db32e 100644
--- a/compiler/rustc_errors/src/diagnostic_impls.rs
+++ b/compiler/rustc_errors/src/diagnostic_impls.rs
@@ -13,6 +13,7 @@ use std::borrow::Cow;
use std::fmt;
use std::num::ParseIntError;
use std::path::{Path, PathBuf};
+use std::process::ExitStatus;
pub struct DiagnosticArgFromDisplay<'a>(pub &'a dyn fmt::Display);
@@ -58,6 +59,7 @@ into_diagnostic_arg_using_display!(
i128,
u128,
std::io::Error,
+ std::boxed::Box<dyn std::error::Error>,
std::num::NonZeroU32,
hir::Target,
Edition,
@@ -66,7 +68,8 @@ into_diagnostic_arg_using_display!(
ParseIntError,
StackProtector,
&TargetTriple,
- SplitDebuginfo
+ SplitDebuginfo,
+ ExitStatus,
);
impl IntoDiagnosticArg for bool {
@@ -103,6 +106,12 @@ impl IntoDiagnosticArg for String {
}
}
+impl<'a> IntoDiagnosticArg for Cow<'a, str> {
+ fn into_diagnostic_arg(self) -> DiagnosticArgValue<'static> {
+ DiagnosticArgValue::Str(Cow::Owned(self.into_owned()))
+ }
+}
+
impl<'a> IntoDiagnosticArg for &'a Path {
fn into_diagnostic_arg(self) -> DiagnosticArgValue<'static> {
DiagnosticArgValue::Str(Cow::Owned(self.display().to_string()))
@@ -170,6 +179,29 @@ impl IntoDiagnosticArg for Level {
}
}
+#[derive(Clone)]
+pub struct DiagnosticSymbolList(Vec<Symbol>);
+
+impl From<Vec<Symbol>> for DiagnosticSymbolList {
+ fn from(v: Vec<Symbol>) -> Self {
+ DiagnosticSymbolList(v)
+ }
+}
+
+impl IntoDiagnosticArg for DiagnosticSymbolList {
+ fn into_diagnostic_arg(self) -> DiagnosticArgValue<'static> {
+ DiagnosticArgValue::StrListSepByAnd(
+ self.0.into_iter().map(|sym| Cow::Owned(format!("`{sym}`"))).collect(),
+ )
+ }
+}
+
+impl<Id> IntoDiagnosticArg for hir::def::Res<Id> {
+ fn into_diagnostic_arg(self) -> DiagnosticArgValue<'static> {
+ DiagnosticArgValue::Str(Cow::Borrowed(self.descr()))
+ }
+}
+
impl IntoDiagnostic<'_, !> for TargetDataLayoutErrors<'_> {
fn into_diagnostic(self, handler: &Handler) -> DiagnosticBuilder<'_, !> {
let mut diag;