about summary refs log tree commit diff
path: root/compiler/rustc_session/src/errors.rs
diff options
context:
space:
mode:
authorJhonny Bill Mena <jhonnybillm@gmail.com>2022-09-15 00:01:44 -0400
committerJhonny Bill Mena <jhonnybillm@gmail.com>2022-09-21 11:43:22 -0400
commite52e2344dc574922ce4f8ddfd508f8bfdec3f404 (patch)
treeeeb9ec3b3c8ff3aa0bc879378a1519a861e2c855 /compiler/rustc_session/src/errors.rs
parent5f91719f75a1012f4b59391fd89a20bb989b2801 (diff)
downloadrust-e52e2344dc574922ce4f8ddfd508f8bfdec3f404.tar.gz
rust-e52e2344dc574922ce4f8ddfd508f8bfdec3f404.zip
FIX - adopt new Diagnostic naming in newly migrated modules
FIX - ambiguous Diagnostic link in docs

UPDATE - rename diagnostic_items to IntoDiagnostic and AddToDiagnostic

[Gardening] FIX - formatting via `x fmt`

FIX - rebase conflicts. NOTE: Confirm wheather or not we want to handle TargetDataLayoutErrorsWrapper this way

DELETE - unneeded allow attributes in Handler method

FIX - broken test

FIX - Rebase conflict

UPDATE - rename residual _SessionDiagnostic and fix LintDiag link
Diffstat (limited to 'compiler/rustc_session/src/errors.rs')
-rw-r--r--compiler/rustc_session/src/errors.rs56
1 files changed, 28 insertions, 28 deletions
diff --git a/compiler/rustc_session/src/errors.rs b/compiler/rustc_session/src/errors.rs
index 997a45272bc..e01dafe2102 100644
--- a/compiler/rustc_session/src/errors.rs
+++ b/compiler/rustc_session/src/errors.rs
@@ -1,9 +1,10 @@
 use std::num::NonZeroU32;
 
 use crate::cgu_reuse_tracker::CguReuse;
-use crate::{self as rustc_session, SessionDiagnostic};
-use rustc_errors::{fluent, DiagnosticBuilder, ErrorGuaranteed, Handler, MultiSpan};
-use rustc_macros::SessionDiagnostic;
+use rustc_errors::{
+    fluent, DiagnosticBuilder, ErrorGuaranteed, Handler, IntoDiagnostic, MultiSpan,
+};
+use rustc_macros::Diagnostic;
 use rustc_span::{Span, Symbol};
 use rustc_target::abi::TargetDataLayoutErrors;
 use rustc_target::spec::{SplitDebuginfo, StackProtector, TargetTriple};
@@ -46,10 +47,12 @@ pub struct FeatureDiagnosticHelp {
     pub feature: Symbol,
 }
 
-impl IntoDiagnostic<'_, !> for TargetDataLayoutErrors<'_> {
+pub struct TargetDataLayoutErrorsWrapper<'a>(pub TargetDataLayoutErrors<'a>);
+
+impl IntoDiagnostic<'_, !> for TargetDataLayoutErrorsWrapper<'_> {
     fn into_diagnostic(self, handler: &Handler) -> DiagnosticBuilder<'_, !> {
         let mut diag;
-        match self {
+        match self.0 {
             TargetDataLayoutErrors::InvalidAddressSpace { addr_space, err, cause } => {
                 diag = handler.struct_fatal(fluent::session::target_invalid_address_space);
                 diag.set_arg("addr_space", addr_space);
@@ -97,87 +100,87 @@ impl IntoDiagnostic<'_, !> for TargetDataLayoutErrors<'_> {
     }
 }
 
-#[derive(SessionDiagnostic)]
+#[derive(Diagnostic)]
 #[diag(session::not_circumvent_feature)]
 pub struct NotCircumventFeature;
 
-#[derive(SessionDiagnostic)]
+#[derive(Diagnostic)]
 #[diag(session::linker_plugin_lto_windows_not_supported)]
 pub struct LinkerPluginToWindowsNotSupported;
 
-#[derive(SessionDiagnostic)]
+#[derive(Diagnostic)]
 #[diag(session::profile_use_file_does_not_exist)]
 pub struct ProfileUseFileDoesNotExist<'a> {
     pub path: &'a std::path::Path,
 }
 
-#[derive(SessionDiagnostic)]
+#[derive(Diagnostic)]
 #[diag(session::profile_sample_use_file_does_not_exist)]
 pub struct ProfileSampleUseFileDoesNotExist<'a> {
     pub path: &'a std::path::Path,
 }
 
-#[derive(SessionDiagnostic)]
+#[derive(Diagnostic)]
 #[diag(session::target_requires_unwind_tables)]
 pub struct TargetRequiresUnwindTables;
 
-#[derive(SessionDiagnostic)]
+#[derive(Diagnostic)]
 #[diag(session::sanitizer_not_supported)]
 pub struct SanitizerNotSupported {
     pub us: String,
 }
 
-#[derive(SessionDiagnostic)]
+#[derive(Diagnostic)]
 #[diag(session::sanitizers_not_supported)]
 pub struct SanitizersNotSupported {
     pub us: String,
 }
 
-#[derive(SessionDiagnostic)]
+#[derive(Diagnostic)]
 #[diag(session::cannot_mix_and_match_sanitizers)]
 pub struct CannotMixAndMatchSanitizers {
     pub first: String,
     pub second: String,
 }
 
-#[derive(SessionDiagnostic)]
+#[derive(Diagnostic)]
 #[diag(session::cannot_enable_crt_static_linux)]
 pub struct CannotEnableCrtStaticLinux;
 
-#[derive(SessionDiagnostic)]
+#[derive(Diagnostic)]
 #[diag(session::sanitizer_cfi_enabled)]
 pub struct SanitizerCfiEnabled;
 
-#[derive(SessionDiagnostic)]
+#[derive(Diagnostic)]
 #[diag(session::unstable_virtual_function_elimination)]
 pub struct UnstableVirtualFunctionElimination;
 
-#[derive(SessionDiagnostic)]
+#[derive(Diagnostic)]
 #[diag(session::unsupported_dwarf_version)]
 pub struct UnsupportedDwarfVersion {
     pub dwarf_version: u32,
 }
 
-#[derive(SessionDiagnostic)]
+#[derive(Diagnostic)]
 #[diag(session::target_stack_protector_not_supported)]
 pub struct StackProtectorNotSupportedForTarget<'a> {
     pub stack_protector: StackProtector,
     pub target_triple: &'a TargetTriple,
 }
 
-#[derive(SessionDiagnostic)]
+#[derive(Diagnostic)]
 #[diag(session::split_debuginfo_unstable_platform)]
 pub struct SplitDebugInfoUnstablePlatform {
     pub debuginfo: SplitDebuginfo,
 }
 
-#[derive(SessionDiagnostic)]
+#[derive(Diagnostic)]
 #[diag(session::file_is_not_writeable)]
 pub struct FileIsNotWriteable<'a> {
     pub file: &'a std::path::Path,
 }
 
-#[derive(SessionDiagnostic)]
+#[derive(Diagnostic)]
 #[diag(session::crate_name_does_not_match)]
 pub struct CrateNameDoesNotMatch<'a> {
     #[primary_span]
@@ -186,13 +189,13 @@ pub struct CrateNameDoesNotMatch<'a> {
     pub name: Symbol,
 }
 
-#[derive(SessionDiagnostic)]
+#[derive(Diagnostic)]
 #[diag(session::crate_name_invalid)]
 pub struct CrateNameInvalid<'a> {
     pub s: &'a str,
 }
 
-#[derive(SessionDiagnostic)]
+#[derive(Diagnostic)]
 #[diag(session::crate_name_empty)]
 pub struct CrateNameEmpty {
     #[primary_span]
@@ -205,11 +208,8 @@ pub struct InvalidCharacterInCrateName<'a> {
     pub crate_name: &'a str,
 }
 
-impl crate::SessionDiagnostic<'_> for InvalidCharacterInCrateName<'_> {
-    fn into_diagnostic(
-        self,
-        sess: &Handler,
-    ) -> rustc_errors::DiagnosticBuilder<'_, ErrorGuaranteed> {
+impl IntoDiagnostic<'_> for InvalidCharacterInCrateName<'_> {
+    fn into_diagnostic(self, sess: &Handler) -> 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);