File tree Expand file tree Collapse file tree 1 file changed +23
-0
lines changed Expand file tree Collapse file tree 1 file changed +23
-0
lines changed Original file line number Diff line number Diff line change 17
17
18
18
fn main ( ) {
19
19
lalrpop ( ) ;
20
+ rust_nightly ( ) ;
20
21
}
21
22
22
23
fn lalrpop ( ) {
@@ -28,3 +29,25 @@ fn lalrpop() {
28
29
. process_file ( source)
29
30
. unwrap ( ) ;
30
31
}
32
+
33
+ fn rust_nightly ( ) {
34
+ let rustc = std:: env:: var ( "RUSTC" ) . unwrap ( ) ;
35
+ let version = std:: process:: Command :: new ( rustc)
36
+ . arg ( "--version" )
37
+ . output ( )
38
+ . unwrap ( ) ;
39
+
40
+ assert ! ( version. status. success( ) ) ;
41
+
42
+ // Nightly output:
43
+ // rustc 1.64.0-nightly (affe0d3a0 2022-08-05)
44
+ // Stable output:
45
+ // rustc 1.64.0 (a55dd71d5 2022-09-19)
46
+
47
+ let stdout = String :: from_utf8 ( version. stdout ) . unwrap ( ) ;
48
+ assert ! ( stdout. contains( "rustc" ) , "Sanity check" ) ;
49
+ let nightly = stdout. contains ( "nightly" ) ;
50
+ if nightly {
51
+ println ! ( "cargo:rustc-cfg=rust_nightly" ) ;
52
+ }
53
+ }
You can’t perform that action at this time.
0 commit comments