Skip to content

Commit 4363203

Browse files
committed
tokio-macros: put local validation logic with the rest
1 parent 6e24a24 commit 4363203

File tree

1 file changed

+8
-5
lines changed

1 file changed

+8
-5
lines changed

tokio-macros/src/entry.rs

Lines changed: 8 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -18,11 +18,7 @@ impl RuntimeFlavor {
1818
match s {
1919
"current_thread" => Ok(RuntimeFlavor::CurrentThread),
2020
"multi_thread" => Ok(RuntimeFlavor::Threaded),
21-
"local" => if cfg!(tokio_unstable) {
22-
Ok(RuntimeFlavor::Local)
23-
} else {
24-
Err("The local runtime flavor is only available when `tokio_unstable` is set.".to_string())
25-
}
21+
"local" => Ok(RuntimeFlavor::Local),
2622
"single_thread" => Err("The single threaded runtime flavor is called `current_thread`.".to_string()),
2723
"basic_scheduler" => Err("The `basic_scheduler` runtime flavor has been renamed to `current_thread`.".to_string()),
2824
"threaded_scheduler" => Err("The `threaded_scheduler` runtime flavor has been renamed to `multi_thread`.".to_string()),
@@ -183,6 +179,13 @@ impl Configuration {
183179
use RuntimeFlavor as F;
184180

185181
let flavor = self.flavor.unwrap_or(self.default_flavor);
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+
186189
let worker_threads = match (flavor, self.worker_threads) {
187190
(F::CurrentThread | F::Local, Some((_, worker_threads_span))) => {
188191
let msg = format!(

0 commit comments

Comments
 (0)