File tree Expand file tree Collapse file tree 1 file changed +20
-14
lines changed
crates/proc_macro_api/src Expand file tree Collapse file tree 1 file changed +20
-14
lines changed Original file line number Diff line number Diff line change @@ -14,8 +14,8 @@ use snap::read::FrameDecoder as SnapDecoder;
1414pub 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 ( '.' )
You can’t perform that action at this time.
0 commit comments