about summary refs log tree commit diff
path: root/compiler/rustc_session/src/errors.rs
diff options
context:
space:
mode:
authorLuis Cardoso <61982523+LuisCardosoOliveira@users.noreply.github.com>2022-09-01 08:03:47 +0200
committerLuis Cardoso <61982523+LuisCardosoOliveira@users.noreply.github.com>2022-09-10 08:19:17 +0200
commit329d5014b6a773d819e6cd56d5930a204bed7983 (patch)
tree1276ba3a311bd74d995b6ab5f702713328c2580f /compiler/rustc_session/src/errors.rs
parentb0cfeec2931cfb3bc9f8b11510684fb2fedee731 (diff)
downloadrust-329d5014b6a773d819e6cd56d5930a204bed7983.tar.gz
rust-329d5014b6a773d819e6cd56d5930a204bed7983.zip
translations(rustc_session): migrate output.rs
Diffstat (limited to 'compiler/rustc_session/src/errors.rs')
-rw-r--r--compiler/rustc_session/src/errors.rs51
1 files changed, 50 insertions, 1 deletions
diff --git a/compiler/rustc_session/src/errors.rs b/compiler/rustc_session/src/errors.rs
index 3c93cfab183..c6596ff2498 100644
--- a/compiler/rustc_session/src/errors.rs
+++ b/compiler/rustc_session/src/errors.rs
@@ -2,7 +2,7 @@ use std::num::NonZeroU32;
 
 use crate::cgu_reuse_tracker::CguReuse;
 use crate::{self as rustc_session, SessionDiagnostic};
-use rustc_errors::{fluent, DiagnosticBuilder, Handler, MultiSpan};
+use rustc_errors::{fluent, DiagnosticBuilder, ErrorGuaranteed, Handler, MultiSpan};
 use rustc_macros::SessionDiagnostic;
 use rustc_span::{Span, Symbol};
 use rustc_target::abi::TargetDataLayoutErrors;
@@ -170,3 +170,52 @@ pub struct StackProtectorNotSupportedForTarget<'a> {
 pub struct SplitDebugInfoUnstablePlatform {
     pub debuginfo: SplitDebuginfo,
 }
+
+#[derive(SessionDiagnostic)]
+#[diag(session::file_is_not_writeable)]
+pub struct FileIsNotWriteable<'a> {
+    pub file: &'a std::path::Path,
+}
+
+#[derive(SessionDiagnostic)]
+#[diag(session::crate_name_does_not_match)]
+pub struct CrateNameDoesNotMatch<'a> {
+    #[primary_span]
+    pub span: Span,
+    pub s: &'a str,
+    pub name: Symbol,
+}
+
+#[derive(SessionDiagnostic)]
+#[diag(session::crate_name_invalid)]
+pub struct CrateNameInvalid<'a> {
+    pub s: &'a str,
+}
+
+#[derive(SessionDiagnostic)]
+#[diag(session::crate_name_empty)]
+pub struct CrateNameEmpty {
+    #[primary_span]
+    pub span: Option<Span>,
+}
+
+pub struct InvalidCharacterInCrateName<'a> {
+    pub span: Option<Span>,
+    pub character: char,
+    pub crate_name: &'a str,
+}
+
+impl crate::SessionDiagnostic<'_> for InvalidCharacterInCrateName<'_> {
+    fn into_diagnostic(
+        self,
+        sess: &Handler,
+    ) -> rustc_errors::DiagnosticBuilder<'_, ErrorGuaranteed> {
+        let mut diag = sess.struct_err(fluent::session::invalid_character_in_create_name);
+        if let Some(sp) = self.span {
+            diag.set_span(sp);
+        }
+        diag.set_arg("character", self.character);
+        diag.set_arg("crate_name", self.crate_name);
+        diag
+    }
+}