File tree Expand file tree Collapse file tree 2 files changed +14
-4
lines changed Expand file tree Collapse file tree 2 files changed +14
-4
lines changed Original file line number Diff line number Diff line change @@ -19,7 +19,7 @@ include!("../dylib_util.rs");
1919
2020use std:: env;
2121use std:: path:: PathBuf ;
22- use std:: process:: { Child , Command } ;
22+ use std:: process:: { exit , Child , Command } ;
2323use std:: str:: FromStr ;
2424use std:: time:: Instant ;
2525
@@ -47,7 +47,12 @@ fn main() {
4747 } else {
4848 ( "RUSTC_REAL" , "RUSTC_LIBDIR" )
4949 } ;
50- let stage = env:: var ( "RUSTC_STAGE" ) . expect ( "RUSTC_STAGE was not set" ) ;
50+ let stage = env:: var ( "RUSTC_STAGE" ) . unwrap_or_else ( |_| {
51+ // Don't panic here; it's reasonable to try and run these shims directly. Give a helpful error instead.
52+ eprintln ! ( "rustc shim: fatal: RUSTC_STAGE was not set" ) ;
53+ eprintln ! ( "rustc shim: note: use `x.py build -vvv` to see all environment variables set by bootstrap" ) ;
54+ exit ( 101 ) ;
55+ } ) ;
5156 let sysroot = env:: var_os ( "RUSTC_SYSROOT" ) . expect ( "RUSTC_SYSROOT was not set" ) ;
5257 let on_fail = env:: var_os ( "RUSTC_ON_FAIL" ) . map ( Command :: new) ;
5358
Original file line number Diff line number Diff line change 55use std:: env;
66use std:: ffi:: OsString ;
77use std:: path:: PathBuf ;
8- use std:: process:: Command ;
8+ use std:: process:: { exit , Command } ;
99
1010include ! ( "../dylib_util.rs" ) ;
1111
1212fn main ( ) {
1313 let args = env:: args_os ( ) . skip ( 1 ) . collect :: < Vec < _ > > ( ) ;
14- let stage = env:: var ( "RUSTC_STAGE" ) . expect ( "RUSTC_STAGE was not set" ) ;
14+ let stage = env:: var ( "RUSTC_STAGE" ) . unwrap_or_else ( |_| {
15+ // Don't panic here; it's reasonable to try and run these shims directly. Give a helpful error instead.
16+ eprintln ! ( "rustc shim: fatal: RUSTC_STAGE was not set" ) ;
17+ eprintln ! ( "rustc shim: note: use `x.py build -vvv` to see all environment variables set by bootstrap" ) ;
18+ exit ( 101 ) ;
19+ } ) ;
1520 let rustdoc = env:: var_os ( "RUSTDOC_REAL" ) . expect ( "RUSTDOC_REAL was not set" ) ;
1621 let libdir = env:: var_os ( "RUSTDOC_LIBDIR" ) . expect ( "RUSTDOC_LIBDIR was not set" ) ;
1722 let sysroot = env:: var_os ( "RUSTC_SYSROOT" ) . expect ( "RUSTC_SYSROOT was not set" ) ;
You can’t perform that action at this time.
0 commit comments