@@ -21,6 +21,15 @@ use rustc_version::{version_meta, version_meta_for, Channel, Version, VersionMet
21
21
use ansi_term:: Colour :: Red ;
22
22
23
23
fn main ( ) {
24
+ check_rustc_version ( ) ;
25
+
26
+ // Forward the profile to the main compilation
27
+ println ! ( "cargo:rustc-env=PROFILE={}" , env:: var( "PROFILE" ) . unwrap( ) ) ;
28
+ // Don't rebuild even if nothing changed
29
+ println ! ( "cargo:rerun-if-changed=build.rs" ) ;
30
+ }
31
+
32
+ fn check_rustc_version ( ) {
24
33
let string = include_str ! ( "min_version.txt" ) ;
25
34
let min_version_meta = version_meta_for ( string)
26
35
. expect ( "Could not parse version string in min_version.txt" ) ;
@@ -31,10 +40,17 @@ fn main() {
31
40
let min_date_str = min_version_meta. clone ( ) . commit_date
32
41
. expect ( "min_version.txt does not contain a rustc commit date" ) ;
33
42
43
+ // Dev channel (rustc built from git) does not have any date or commit information in rustc -vV
44
+ // `current_version_meta.commit_date` would crash, so we return early here.
45
+ if current_version_meta. channel == Channel :: Dev {
46
+ return
47
+ }
48
+
34
49
let current_version = current_version_meta. clone ( ) . semver ;
35
50
let current_date_str = current_version_meta. clone ( ) . commit_date
36
51
. expect ( "current rustc version information does not contain a rustc commit date" ) ;
37
52
53
+
38
54
let print_version_err = |version : & Version , date : & str | {
39
55
eprintln ! ( "> {} {}. {} {}.\n " ,
40
56
"Installed rustc version is:" ,
@@ -69,11 +85,6 @@ fn main() {
69
85
print_version_err ( & current_version, & * current_date_str) ;
70
86
panic ! ( "Aborting compilation due to incompatible compiler." )
71
87
}
72
-
73
- // Forward the profile to the main compilation
74
- println ! ( "cargo:rustc-env=PROFILE={}" , env:: var( "PROFILE" ) . unwrap( ) ) ;
75
- // Don't rebuild even if nothing changed
76
- println ! ( "cargo:rerun-if-changed=build.rs" ) ;
77
88
}
78
89
79
90
fn correct_channel ( version_meta : & VersionMeta ) -> bool {
0 commit comments