about summary refs log tree commit diff
diff options
context:
space:
mode:
authorAdrian Tombu <adrian@otso.fr>2022-08-25 19:04:00 +0200
committerAdrian Tombu <adrian@otso.fr>2022-08-25 19:04:00 +0200
commitd0401f7f475a2cad5c81114ff916b766b3cbd9c6 (patch)
treec021e5e2a168103685181f4cdbb8acb3bee13b1f
parentbf7ce6a1a605d897832783a3d0c830d2466d90be (diff)
downloadrust-d0401f7f475a2cad5c81114ff916b766b3cbd9c6.tar.gz
rust-d0401f7f475a2cad5c81114ff916b766b3cbd9c6.zip
Code cleaning
-rw-r--r--compiler/rustc_codegen_ssa/src/lib.rs12
-rw-r--r--compiler/rustc_driver/src/session_diagnostics.rs6
-rw-r--r--compiler/rustc_macros/src/lib.rs1
3 files changed, 9 insertions, 10 deletions
diff --git a/compiler/rustc_codegen_ssa/src/lib.rs b/compiler/rustc_codegen_ssa/src/lib.rs
index d6fa1a15373..0faf51b062b 100644
--- a/compiler/rustc_codegen_ssa/src/lib.rs
+++ b/compiler/rustc_codegen_ssa/src/lib.rs
@@ -168,11 +168,11 @@ pub struct CodegenResults {
     pub crate_info: CrateInfo,
 }
 
-pub enum CodegenErrors {
+pub enum CodegenErrors<'a> {
     WrongFileType,
     EmptyVersionNumber,
-    EncodingVersionMismatch { version_array: String, rlink_version: String },
-    RustcVersionMismatch { rustc_version: String, current_version: String },
+    EncodingVersionMismatch { version_array: String, rlink_version: u32 },
+    RustcVersionMismatch { rustc_version: String, current_version: &'a str },
 }
 
 pub fn provide(providers: &mut Providers) {
@@ -219,7 +219,7 @@ impl CodegenResults {
         encoder.finish()
     }
 
-    pub fn deserialize_rlink(data: Vec<u8>) -> Result<Self, CodegenErrors> {
+    pub fn deserialize_rlink<'a>(data: Vec<u8>) -> Result<Self, CodegenErrors<'a>> {
         // The Decodable machinery is not used here because it panics if the input data is invalid
         // and because its internal representation may change.
         if !data.starts_with(RLINK_MAGIC) {
@@ -235,7 +235,7 @@ impl CodegenResults {
         if u32::from_be_bytes(version_array) != RLINK_VERSION {
             return Err(CodegenErrors::EncodingVersionMismatch {
                 version_array: String::from_utf8_lossy(&version_array).to_string(),
-                rlink_version: RLINK_VERSION.to_string(),
+                rlink_version: RLINK_VERSION,
             });
         }
 
@@ -245,7 +245,7 @@ impl CodegenResults {
         if rustc_version != current_version {
             return Err(CodegenErrors::RustcVersionMismatch {
                 rustc_version: rustc_version.to_string(),
-                current_version: current_version.to_string(),
+                current_version,
             });
         }
 
diff --git a/compiler/rustc_driver/src/session_diagnostics.rs b/compiler/rustc_driver/src/session_diagnostics.rs
index 90197ad935e..fe64d0fca9b 100644
--- a/compiler/rustc_driver/src/session_diagnostics.rs
+++ b/compiler/rustc_driver/src/session_diagnostics.rs
@@ -18,14 +18,14 @@ pub(crate) struct RLinkEmptyVersionNumber;
 #[diag(driver::rlink_encoding_version_mismatch)]
 pub(crate) struct RLinkEncodingVersionMismatch {
     pub version_array: String,
-    pub rlink_version: String,
+    pub rlink_version: u32,
 }
 
 #[derive(SessionDiagnostic)]
 #[diag(driver::rlink_rustc_version_mismatch)]
-pub(crate) struct RLinkRustcVersionMismatch {
+pub(crate) struct RLinkRustcVersionMismatch<'a> {
     pub rustc_version: String,
-    pub current_version: String,
+    pub current_version: &'a str,
 }
 
 #[derive(SessionDiagnostic)]
diff --git a/compiler/rustc_macros/src/lib.rs b/compiler/rustc_macros/src/lib.rs
index bcf406bcb95..87d7ab6ed51 100644
--- a/compiler/rustc_macros/src/lib.rs
+++ b/compiler/rustc_macros/src/lib.rs
@@ -163,7 +163,6 @@ decl_derive!(
 decl_derive!(
     [SessionSubdiagnostic, attributes(
         // struct/variant attributes
-        diag,
         label,
         help,
         note,