Unnamed repository; edit this file 'description' to name the repository.
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]>
bors[bot] 2021-08-17
parent 75f2a5b · parent f69225c · commit d1ba993
-rw-r--r--crates/proc_macro_api/src/version.rs34
1 files changed, 20 insertions, 14 deletions
diff --git a/crates/proc_macro_api/src/version.rs b/crates/proc_macro_api/src/version.rs
index fa2b60fcb9..4c065c93c4 100644
--- a/crates/proc_macro_api/src/version.rs
+++ b/crates/proc_macro_api/src/version.rs
@@ -14,8 +14,8 @@ use snap::read::FrameDecoder as SnapDecoder;
pub struct RustCInfo {
pub version: (usize, usize, usize),
pub channel: String,
- pub commit: String,
- pub date: String,
+ pub commit: Option<String>,
+ pub date: Option<String>,
}
/// 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 channel = version_parts.next().unwrap_or_default().to_string();
- let commit = items.next().ok_or_else(|| err!("no commit info"))?;
- // remove (
- if commit.len() == 0 {
- return Err(err!("commit format error"));
- }
- let commit = commit[1..].to_string();
- let date = items.next().ok_or_else(|| err!("no date info"))?;
- // remove )
- if date.len() == 0 {
- return Err(err!("date format error"));
- }
- let date = date[0..date.len() - 2].to_string();
+ let commit = match items.next() {
+ Some(commit) => {
+ match commit.len() {
+ 0 => None,
+ _ => Some(commit[1..].to_string() /* remove ( */),
+ }
+ }
+ None => None,
+ };
+ let date = match items.next() {
+ Some(date) => {
+ match date.len() {
+ 0 => None,
+ _ => Some(date[0..date.len() - 2].to_string() /* remove ) */),
+ }
+ }
+ None => None,
+ };
let version_numbers = version
.split('.')