@@ -180,12 +180,6 @@ impl Configuration {
180
180
181
181
let flavor = self . flavor . unwrap_or ( self . default_flavor ) ;
182
182
183
- if flavor == F :: Local && !cfg ! ( tokio_unstable) {
184
- let msg = "The local runtime flavor is only available when `tokio_unstable` is set."
185
- . to_string ( ) ;
186
- return Err ( syn:: Error :: new ( Span :: call_site ( ) , msg) ) ;
187
- }
188
-
189
183
let worker_threads = match ( flavor, self . worker_threads ) {
190
184
( F :: CurrentThread | F :: Local , Some ( ( _, worker_threads_span) ) ) => {
191
185
let msg = format ! (
@@ -427,7 +421,13 @@ fn parse_knobs(mut input: ItemFn, is_test: bool, config: FinalConfig) -> TokenSt
427
421
} ,
428
422
} ;
429
423
424
+ let mut checks = vec ! [ ] ;
425
+
430
426
let build = if let RuntimeFlavor :: Local = config. flavor {
427
+ checks. push ( quote ! {
428
+ #[ cfg( not( tokio_unstable) ) ]
429
+ compile_error!( "The local runtime flavor is only available when `tokio_unstable` is set." ) ;
430
+ } ) ;
431
431
quote_spanned ! { last_stmt_start_span=> build_local( Default :: default ( ) ) }
432
432
} else {
433
433
quote_spanned ! { last_stmt_start_span=> build( ) }
@@ -452,11 +452,13 @@ fn parse_knobs(mut input: ItemFn, is_test: bool, config: FinalConfig) -> TokenSt
452
452
quote ! { }
453
453
} ;
454
454
455
+
455
456
let body_ident = quote ! { body } ;
456
457
// This explicit `return` is intentional. See tokio-rs/tokio#4636
457
458
let last_block = quote_spanned ! { last_stmt_end_span=>
458
459
#[ allow( clippy:: expect_used, clippy:: diverging_sub_expression, clippy:: needless_return) ]
459
460
{
461
+ #( #checks) *
460
462
return #rt
461
463
. enable_all( )
462
464
. #build
0 commit comments