Code cleaning
This commit is contained in:
parent
bf7ce6a1a6
commit
d0401f7f47
3 changed files with 9 additions and 10 deletions
|
@ -168,11 +168,11 @@ pub struct CodegenResults {
|
||||||
pub crate_info: CrateInfo,
|
pub crate_info: CrateInfo,
|
||||||
}
|
}
|
||||||
|
|
||||||
pub enum CodegenErrors {
|
pub enum CodegenErrors<'a> {
|
||||||
WrongFileType,
|
WrongFileType,
|
||||||
EmptyVersionNumber,
|
EmptyVersionNumber,
|
||||||
EncodingVersionMismatch { version_array: String, rlink_version: String },
|
EncodingVersionMismatch { version_array: String, rlink_version: u32 },
|
||||||
RustcVersionMismatch { rustc_version: String, current_version: String },
|
RustcVersionMismatch { rustc_version: String, current_version: &'a str },
|
||||||
}
|
}
|
||||||
|
|
||||||
pub fn provide(providers: &mut Providers) {
|
pub fn provide(providers: &mut Providers) {
|
||||||
|
@ -219,7 +219,7 @@ impl CodegenResults {
|
||||||
encoder.finish()
|
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
|
// The Decodable machinery is not used here because it panics if the input data is invalid
|
||||||
// and because its internal representation may change.
|
// and because its internal representation may change.
|
||||||
if !data.starts_with(RLINK_MAGIC) {
|
if !data.starts_with(RLINK_MAGIC) {
|
||||||
|
@ -235,7 +235,7 @@ impl CodegenResults {
|
||||||
if u32::from_be_bytes(version_array) != RLINK_VERSION {
|
if u32::from_be_bytes(version_array) != RLINK_VERSION {
|
||||||
return Err(CodegenErrors::EncodingVersionMismatch {
|
return Err(CodegenErrors::EncodingVersionMismatch {
|
||||||
version_array: String::from_utf8_lossy(&version_array).to_string(),
|
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 {
|
if rustc_version != current_version {
|
||||||
return Err(CodegenErrors::RustcVersionMismatch {
|
return Err(CodegenErrors::RustcVersionMismatch {
|
||||||
rustc_version: rustc_version.to_string(),
|
rustc_version: rustc_version.to_string(),
|
||||||
current_version: current_version.to_string(),
|
current_version,
|
||||||
});
|
});
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
|
@ -18,14 +18,14 @@ pub(crate) struct RLinkEmptyVersionNumber;
|
||||||
#[diag(driver::rlink_encoding_version_mismatch)]
|
#[diag(driver::rlink_encoding_version_mismatch)]
|
||||||
pub(crate) struct RLinkEncodingVersionMismatch {
|
pub(crate) struct RLinkEncodingVersionMismatch {
|
||||||
pub version_array: String,
|
pub version_array: String,
|
||||||
pub rlink_version: String,
|
pub rlink_version: u32,
|
||||||
}
|
}
|
||||||
|
|
||||||
#[derive(SessionDiagnostic)]
|
#[derive(SessionDiagnostic)]
|
||||||
#[diag(driver::rlink_rustc_version_mismatch)]
|
#[diag(driver::rlink_rustc_version_mismatch)]
|
||||||
pub(crate) struct RLinkRustcVersionMismatch {
|
pub(crate) struct RLinkRustcVersionMismatch<'a> {
|
||||||
pub rustc_version: String,
|
pub rustc_version: String,
|
||||||
pub current_version: String,
|
pub current_version: &'a str,
|
||||||
}
|
}
|
||||||
|
|
||||||
#[derive(SessionDiagnostic)]
|
#[derive(SessionDiagnostic)]
|
||||||
|
|
|
@ -163,7 +163,6 @@ decl_derive!(
|
||||||
decl_derive!(
|
decl_derive!(
|
||||||
[SessionSubdiagnostic, attributes(
|
[SessionSubdiagnostic, attributes(
|
||||||
// struct/variant attributes
|
// struct/variant attributes
|
||||||
diag,
|
|
||||||
label,
|
label,
|
||||||
help,
|
help,
|
||||||
note,
|
note,
|
||||||
|
|
Loading…
Add table
Add a link
Reference in a new issue