diff options
| author | Yuki Okushi <jtitor@2k36.org> | 2022-08-25 08:50:57 +0900 |
|---|---|---|
| committer | GitHub <noreply@github.com> | 2022-08-25 08:50:57 +0900 |
| commit | 2e4760c7e74104a2f336e21a432a3e613ef8904f (patch) | |
| tree | 0ad937d15a03e594f65eb9b00d5ba554968680f2 /compiler/rustc_errors/src | |
| parent | ed8cfc86a2a6541f8f998ab45e889fd3f2371cbe (diff) | |
| parent | c18503f3ff9f81ed3b368246ade73e79dbd53282 (diff) | |
| download | rust-2e4760c7e74104a2f336e21a432a3e613ef8904f.tar.gz rust-2e4760c7e74104a2f336e21a432a3e613ef8904f.zip | |
Rollup merge of #100780 - wonchulee:translation_save_analysis, r=davidtwco
save_analysis: Migrate diagnostic * Migrate the `rustc_save_analysis` crate's diagnostic to translatable diagnostic structs. Depends on https://github.com/rust-lang/rust/pull/100694 and https://github.com/rust-lang/rust/pull/100754 for #[fatal(..)] support, then https://github.com/rust-lang/rust/commit/aa68eb4179881ed25106e675a6a224746f8fad5f, https://github.com/rust-lang/rust/commit/f5219a396083b764f3741e9e105685323a745ce8, https://github.com/rust-lang/rust/commit/7da52f694a4ff7c4b9870415584f2c86cec5ce62 can be removed. (I copied commits from https://github.com/rust-lang/rust/pull/100754)
Diffstat (limited to 'compiler/rustc_errors/src')
| -rw-r--r-- | compiler/rustc_errors/src/diagnostic.rs | 14 |
1 files changed, 14 insertions, 0 deletions
diff --git a/compiler/rustc_errors/src/diagnostic.rs b/compiler/rustc_errors/src/diagnostic.rs index 356f9dfdb3b..506198df4d8 100644 --- a/compiler/rustc_errors/src/diagnostic.rs +++ b/compiler/rustc_errors/src/diagnostic.rs @@ -13,6 +13,7 @@ use rustc_span::{edition::Edition, Span, DUMMY_SP}; use std::borrow::Cow; use std::fmt; use std::hash::{Hash, Hasher}; +use std::path::{Path, PathBuf}; /// Error type for `Diagnostic`'s `suggestions` field, indicating that /// `.disable_suggestions()` was called on the `Diagnostic`. @@ -83,6 +84,7 @@ into_diagnostic_arg_using_display!( u64, i128, u128, + std::io::Error, std::num::NonZeroU32, hir::Target, Edition, @@ -124,6 +126,18 @@ impl IntoDiagnosticArg for String { } } +impl<'a> IntoDiagnosticArg for &'a Path { + fn into_diagnostic_arg(self) -> DiagnosticArgValue<'static> { + DiagnosticArgValue::Str(Cow::Owned(self.display().to_string())) + } +} + +impl IntoDiagnosticArg for PathBuf { + fn into_diagnostic_arg(self) -> DiagnosticArgValue<'static> { + DiagnosticArgValue::Str(Cow::Owned(self.display().to_string())) + } +} + impl IntoDiagnosticArg for usize { fn into_diagnostic_arg(self) -> DiagnosticArgValue<'static> { DiagnosticArgValue::Number(self) |
