summary refs log tree commit diff
path: root/compiler/rustc_codegen_ssa/src
diff options
context:
space:
mode:
authorJhonny Bill Mena <jhonnybillm@gmail.com>2022-10-04 13:25:13 -0400
committerJhonny Bill Mena <jhonnybillm@gmail.com>2022-10-07 10:03:45 -0400
commita25f939170bb73d813c5eb4cbed631253ba0cc15 (patch)
tree0b0504b2d0489e200e94b63e2a3949834b4649d4 /compiler/rustc_codegen_ssa/src
parent12aa84bdf3231f563b7f86186dbece2023d1235a (diff)
downloadrust-a25f939170bb73d813c5eb4cbed631253ba0cc15.tar.gz
rust-a25f939170bb73d813c5eb4cbed631253ba0cc15.zip
Address PR comments
- UPDATE - revert migration of logs

- UPDATE - use derive on LinkRlibError enum

- [Gardening] UPDATE - alphabetically sort fluent_messages

- UPDATE - use PathBuf and unify both AddNativeLibrary to use Display (which is what PathBuf uses when conforming to IntoDiagnosticArg)

- UPDATE - fluent messages sort after rebase
Diffstat (limited to 'compiler/rustc_codegen_ssa/src')
-rw-r--r--compiler/rustc_codegen_ssa/src/back/link.rs10
-rw-r--r--compiler/rustc_codegen_ssa/src/back/linker.rs6
-rw-r--r--compiler/rustc_codegen_ssa/src/errors.rs42
3 files changed, 13 insertions, 45 deletions
diff --git a/compiler/rustc_codegen_ssa/src/back/link.rs b/compiler/rustc_codegen_ssa/src/back/link.rs
index ac2a8f969df..e798fb421df 100644
--- a/compiler/rustc_codegen_ssa/src/back/link.rs
+++ b/compiler/rustc_codegen_ssa/src/back/link.rs
@@ -362,10 +362,7 @@ fn link_rlib<'a>(
                 continue;
             }
             ab.add_archive(&location, Box::new(|_| false)).unwrap_or_else(|error| {
-                sess.emit_fatal(errors::AddNativeLibrary {
-                    library_path: &location.to_string_lossy(),
-                    error,
-                });
+                sess.emit_fatal(errors::AddNativeLibrary { library_path: location, error });
             });
         }
     }
@@ -381,10 +378,7 @@ fn link_rlib<'a>(
         );
 
         ab.add_archive(&output_path, Box::new(|_| false)).unwrap_or_else(|error| {
-            sess.emit_fatal(errors::AddNativeLibrary {
-                library_path: &output_path.display().to_string(),
-                error,
-            });
+            sess.emit_fatal(errors::AddNativeLibrary { library_path: output_path, error });
         });
     }
 
diff --git a/compiler/rustc_codegen_ssa/src/back/linker.rs b/compiler/rustc_codegen_ssa/src/back/linker.rs
index debcffcd326..bad22ccb1fe 100644
--- a/compiler/rustc_codegen_ssa/src/back/linker.rs
+++ b/compiler/rustc_codegen_ssa/src/back/linker.rs
@@ -91,13 +91,13 @@ pub fn get_linker<'a>(
                     arg.push(format!("{}\\lib\\{}\\store", root_lib_path.display(), a));
                     cmd.arg(&arg);
                 } else {
-                    sess.emit_warning(errors::UnsupportedArch);
+                    warn!("arch is not supported");
                 }
             } else {
-                sess.emit_warning(errors::MsvcPathNotFound);
+                warn!("MSVC root path lib location not found");
             }
         } else {
-            sess.emit_warning(errors::LinkExeNotFound);
+            warn!("link.exe not found");
         }
     }
 
diff --git a/compiler/rustc_codegen_ssa/src/errors.rs b/compiler/rustc_codegen_ssa/src/errors.rs
index 6bd1dc2e03f..bd399ffb5a6 100644
--- a/compiler/rustc_codegen_ssa/src/errors.rs
+++ b/compiler/rustc_codegen_ssa/src/errors.rs
@@ -31,18 +31,6 @@ pub struct SymbolFileWriteFailure {
 }
 
 #[derive(Diagnostic)]
-#[diag(codegen_ssa::unsupported_arch)]
-pub struct UnsupportedArch;
-
-#[derive(Diagnostic)]
-#[diag(codegen_ssa::msvc_path_not_found)]
-pub struct MsvcPathNotFound;
-
-#[derive(Diagnostic)]
-#[diag(codegen_ssa::link_exe_not_found)]
-pub struct LinkExeNotFound;
-
-#[derive(Diagnostic)]
 #[diag(codegen_ssa::ld64_unimplemented_modifier)]
 pub struct Ld64UnimplementedModifier;
 
@@ -115,8 +103,8 @@ pub struct IncompatibleLinkingModifiers;
 
 #[derive(Diagnostic)]
 #[diag(codegen_ssa::add_native_library)]
-pub struct AddNativeLibrary<'a> {
-    pub library_path: &'a str,
+pub struct AddNativeLibrary {
+    pub library_path: PathBuf,
     pub error: Error,
 }
 
@@ -129,30 +117,16 @@ pub struct MultipleExternalFuncDecl<'a> {
     pub library_name: &'a str,
 }
 
+#[derive(Diagnostic)]
 pub enum LinkRlibError {
+    #[diag(codegen_ssa::rlib_missing_format)]
     MissingFormat,
+
+    #[diag(codegen_ssa::rlib_only_rmeta_found)]
     OnlyRmetaFound { crate_name: Symbol },
-    NotFound { crate_name: Symbol },
-}
 
-impl IntoDiagnostic<'_, !> for LinkRlibError {
-    fn into_diagnostic(self, handler: &Handler) -> DiagnosticBuilder<'_, !> {
-        match self {
-            LinkRlibError::MissingFormat => {
-                handler.struct_fatal(fluent::codegen_ssa::rlib_missing_format)
-            }
-            LinkRlibError::OnlyRmetaFound { crate_name } => {
-                let mut diag = handler.struct_fatal(fluent::codegen_ssa::rlib_only_rmeta_found);
-                diag.set_arg("crate_name", crate_name);
-                diag
-            }
-            LinkRlibError::NotFound { crate_name } => {
-                let mut diag = handler.struct_fatal(fluent::codegen_ssa::rlib_not_found);
-                diag.set_arg("crate_name", crate_name);
-                diag
-            }
-        }
-    }
+    #[diag(codegen_ssa::rlib_not_found)]
+    NotFound { crate_name: Symbol },
 }
 
 #[derive(Diagnostic)]