@@ -180,12 +180,6 @@ impl Configuration {
180180
181181 let flavor = self . flavor . unwrap_or ( self . default_flavor ) ;
182182
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-
189183 let worker_threads = match ( flavor, self . worker_threads ) {
190184 ( F :: CurrentThread | F :: Local , Some ( ( _, worker_threads_span) ) ) => {
191185 let msg = format ! (
@@ -427,7 +421,13 @@ fn parse_knobs(mut input: ItemFn, is_test: bool, config: FinalConfig) -> TokenSt
427421 } ,
428422 } ;
429423
424+ let mut checks = vec ! [ ] ;
425+
430426 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+ } ) ;
431431 quote_spanned ! { last_stmt_start_span=> build_local( Default :: default ( ) ) }
432432 } else {
433433 quote_spanned ! { last_stmt_start_span=> build( ) }
@@ -452,11 +452,13 @@ fn parse_knobs(mut input: ItemFn, is_test: bool, config: FinalConfig) -> TokenSt
452452 quote ! { }
453453 } ;
454454
455+
455456 let body_ident = quote ! { body } ;
456457 // This explicit `return` is intentional. See tokio-rs/tokio#4636
457458 let last_block = quote_spanned ! { last_stmt_end_span=>
458459 #[ allow( clippy:: expect_used, clippy:: diverging_sub_expression, clippy:: needless_return) ]
459460 {
461+ #( #checks) *
460462 return #rt
461463 . enable_all( )
462464 . #build
0 commit comments