Skip to content

Commit d1ba993

Browse files
bors[bot]sp1ritCSlnicola
authored
Merge #9936
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​ <[email protected]> Co-authored-by: Laurențiu Nicola <[email protected]>
2 parents 75f2a5b + f69225c commit d1ba993

File tree

1 file changed

+20
-14
lines changed

1 file changed

+20
-14
lines changed

crates/proc_macro_api/src/version.rs

Lines changed: 20 additions & 14 deletions
Original file line numberDiff line numberDiff line change
@@ -14,8 +14,8 @@ use snap::read::FrameDecoder as SnapDecoder;
1414
pub struct RustCInfo {
1515
pub version: (usize, usize, usize),
1616
pub channel: String,
17-
pub commit: String,
18-
pub date: String,
17+
pub commit: Option<String>,
18+
pub date: Option<String>,
1919
}
2020

2121
/// Read rustc dylib information
@@ -38,18 +38,24 @@ pub fn read_dylib_info(dylib_path: &AbsPath) -> io::Result<RustCInfo> {
3838
let version = version_parts.next().ok_or_else(|| err!("no version"))?;
3939
let channel = version_parts.next().unwrap_or_default().to_string();
4040

41-
let commit = items.next().ok_or_else(|| err!("no commit info"))?;
42-
// remove (
43-
if commit.len() == 0 {
44-
return Err(err!("commit format error"));
45-
}
46-
let commit = commit[1..].to_string();
47-
let date = items.next().ok_or_else(|| err!("no date info"))?;
48-
// remove )
49-
if date.len() == 0 {
50-
return Err(err!("date format error"));
51-
}
52-
let date = date[0..date.len() - 2].to_string();
41+
let commit = match items.next() {
42+
Some(commit) => {
43+
match commit.len() {
44+
0 => None,
45+
_ => Some(commit[1..].to_string() /* remove ( */),
46+
}
47+
}
48+
None => None,
49+
};
50+
let date = match items.next() {
51+
Some(date) => {
52+
match date.len() {
53+
0 => None,
54+
_ => Some(date[0..date.len() - 2].to_string() /* remove ) */),
55+
}
56+
}
57+
None => None,
58+
};
5359

5460
let version_numbers = version
5561
.split('.')

0 commit comments

Comments
 (0)