9936: proc_macro_api: make commit & date suffix of binary version optional r=lnicola a=lnicola

Closes #9916

bors r+

Co-authored-by: Florian sp1rit​ <sp1ritCS@protonmail.com>
Co-authored-by: Laurențiu Nicola <lnicola@dend.ro>
This commit is contained in:
bors[bot] 2021-08-17 16:26:05 +00:00 committed by GitHub
commit d1ba993136
No known key found for this signature in database
GPG key ID: 4AEE18F83AFDEB23

View file

@ -14,8 +14,8 @@ use snap::read::FrameDecoder as SnapDecoder;
pub struct RustCInfo { pub struct RustCInfo {
pub version: (usize, usize, usize), pub version: (usize, usize, usize),
pub channel: String, pub channel: String,
pub commit: String, pub commit: Option<String>,
pub date: String, pub date: Option<String>,
} }
/// Read rustc dylib information /// Read rustc dylib information
@ -38,18 +38,24 @@ pub fn read_dylib_info(dylib_path: &AbsPath) -> io::Result<RustCInfo> {
let version = version_parts.next().ok_or_else(|| err!("no version"))?; let version = version_parts.next().ok_or_else(|| err!("no version"))?;
let channel = version_parts.next().unwrap_or_default().to_string(); let channel = version_parts.next().unwrap_or_default().to_string();
let commit = items.next().ok_or_else(|| err!("no commit info"))?; let commit = match items.next() {
// remove ( Some(commit) => {
if commit.len() == 0 { match commit.len() {
return Err(err!("commit format error")); 0 => None,
} _ => Some(commit[1..].to_string() /* remove ( */),
let commit = commit[1..].to_string(); }
let date = items.next().ok_or_else(|| err!("no date info"))?; }
// remove ) None => None,
if date.len() == 0 { };
return Err(err!("date format error")); let date = match items.next() {
} Some(date) => {
let date = date[0..date.len() - 2].to_string(); match date.len() {
0 => None,
_ => Some(date[0..date.len() - 2].to_string() /* remove ) */),
}
}
None => None,
};
let version_numbers = version let version_numbers = version
.split('.') .split('.')