File tree Expand file tree Collapse file tree 1 file changed +7
-8
lines changed Expand file tree Collapse file tree 1 file changed +7
-8
lines changed Original file line number Diff line number Diff line change @@ -124,19 +124,18 @@ fn should_notify() -> bool {
124124/// have more than one) so the token requesting strategy must likewise be global.
125125///
126126/// Usually this doesn't matter too much, as you're not wanting to set the token
127- /// requests unless you're in the one-rustc-per-process model, and we help out
128- /// here a bit by not resetting it once it's set (i.e., only the first init will
129- /// change the value) .
127+ /// requests unless you're in the one-rustc-per-process model. If this is called
128+ /// twice with different values, then we will panic, as that likely represents a
129+ /// bug in the calling code .
130130pub fn initialize ( token_requests : bool ) {
131131 lazy_static:: initialize ( & GLOBAL_CLIENT ) ;
132132 lazy_static:: initialize ( & HELPER ) ;
133- let previous = TOKEN_REQUESTS . compare_and_swap (
134- EMPTY ,
135- if token_requests { CARGO_REQUESTED } else { MAKE_REQUESTED } ,
136- Ordering :: SeqCst ,
137- ) ;
133+ let new = if token_requests { CARGO_REQUESTED } else { MAKE_REQUESTED } ;
134+ let previous = TOKEN_REQUESTS . compare_and_swap ( EMPTY , new, Ordering :: SeqCst ) ;
138135 if previous == EMPTY {
139136 log:: info!( "initialized rustc jobserver, set token_requests={:?}" , token_requests) ;
137+ } else if previous != new {
138+ panic ! ( "attempted to initialize jobserver with different token request setting" ) ;
140139 }
141140}
142141
You can’t perform that action at this time.
0 commit comments