File tree Expand file tree Collapse file tree 2 files changed +21
-1
lines changed Expand file tree Collapse file tree 2 files changed +21
-1
lines changed Original file line number Diff line number Diff line change @@ -589,7 +589,15 @@ impl BuildOutput {
589
589
// to set RUSTC_BOOTSTRAP.
590
590
// If this is a nightly build, setting RUSTC_BOOTSTRAP wouldn't affect the
591
591
// behavior, so still only give a warning.
592
- if nightly_features_allowed {
592
+ // NOTE: cargo only allows nightly features on RUSTC_BOOTSTRAP=1, but we
593
+ // want setting any value of RUSTC_BOOTSTRAP to downgrade this to a warning
594
+ // (so that `RUSTC_BOOTSTRAP=pkg_name` will work)
595
+ let rustc_bootstrap_allows = |name : & str | {
596
+ std:: env:: var ( "RUSTC_BOOTSTRAP" ) . map_or ( false , |var| {
597
+ var. split ( ',' ) . any ( |s| s == name)
598
+ } )
599
+ } ;
600
+ if nightly_features_allowed || rustc_bootstrap_allows ( & * pkg_name) {
593
601
warnings. push ( format ! ( "Cannot set `RUSTC_BOOTSTRAP={}` from {}.\n \
594
602
note: Crates cannot set `RUSTC_BOOTSTRAP` themselves, as doing so would subvert the stability guarantees of Rust for your project.",
595
603
val, whence
Original file line number Diff line number Diff line change @@ -129,4 +129,16 @@ fn rustc_bootstrap() {
129
129
. masquerade_as_nightly_cargo ( )
130
130
. with_stderr_contains ( "warning: Cannot set `RUSTC_BOOTSTRAP=1` [..]" )
131
131
. run ( ) ;
132
+ // RUSTC_BOOTSTRAP set to the name of the crate
133
+ p. cargo ( "build" )
134
+ . env ( "RUSTC_BOOTSTRAP" , "foo" )
135
+ . with_stderr_contains ( "warning: Cannot set `RUSTC_BOOTSTRAP=1` [..]" )
136
+ . run ( ) ;
137
+ // RUSTC_BOOTSTRAP set to some random value
138
+ p. cargo ( "build" )
139
+ . env ( "RUSTC_BOOTSTRAP" , "bar" )
140
+ . with_stderr_contains ( "error: Cannot set `RUSTC_BOOTSTRAP=1` [..]" )
141
+ . with_stderr_contains ( "help: [..] set the environment variable `RUSTC_BOOTSTRAP=foo` [..]" )
142
+ . with_status ( 101 )
143
+ . run ( ) ;
132
144
}
You can’t perform that action at this time.
0 commit comments