tokio-rs/tokio · error · syn::Error

The single threaded runtime flavor is called `current_thread

Error message

The single threaded runtime flavor is called `current_thread`.

What it means

`RuntimeFlavor::from_str` (entry.rs:18) maps the legacy spelling `single_thread` to an explicit guidance error rather than silently failing. The only correct single-threaded flavor is `current_thread`; this message points the user directly at it.

Source

Thrown at tokio-macros/src/entry.rs:22

use syn::{braced, Attribute, Ident, Path, Signature, Visibility};

// syn::AttributeArgs does not implement syn::Parse
type AttributeArgs = syn::punctuated::Punctuated<syn::Meta, syn::Token![,]>;

#[derive(Clone, Copy, PartialEq)]
enum RuntimeFlavor {
    CurrentThread,
    Threaded,
    Local,
}

impl RuntimeFlavor {
    fn from_str(s: &str) -> Result<RuntimeFlavor, String> {
        match s {
            "current_thread" => Ok(RuntimeFlavor::CurrentThread),
            "multi_thread" => Ok(RuntimeFlavor::Threaded),
            "local" => Ok(RuntimeFlavor::Local),
            "single_thread" => Err("The single threaded runtime flavor is called `current_thread`.".to_string()),
            "basic_scheduler" => Err("The `basic_scheduler` runtime flavor has been renamed to `current_thread`.".to_string()),
            "threaded_scheduler" => Err("The `threaded_scheduler` runtime flavor has been renamed to `multi_thread`.".to_string()),
            _ => Err(format!("No such runtime flavor `{s}`. The runtime flavors are `current_thread`, `local`, and `multi_thread`.")),
        }
    }
}

#[derive(Clone, Copy, PartialEq)]
enum UnhandledPanic {
    Ignore,
    ShutdownRuntime,
}

impl UnhandledPanic {
    fn from_str(s: &str) -> Result<UnhandledPanic, String> {
        match s {
            "ignore" => Ok(UnhandledPanic::Ignore),
            "shutdown_runtime" => Ok(UnhandledPanic::ShutdownRuntime),

View on GitHub (pinned to 625954f365)

Solutions

  1. Replace `flavor = "single_thread"` with `flavor = "current_thread"`.

Example fix

// before
#[tokio::main(flavor = "single_thread")]
async fn main() {}

// after
#[tokio::main(flavor = "current_thread")]
async fn main() {}
Defensive patterns

Strategy: validation

Prevention

When it happens

Trigger: Writing `#[tokio::main(flavor = "single_thread")]` — a value that looks reasonable but is not a valid flavor.

Common situations: Porting from other async runtimes (e.g. smol/async-std terminology); guessing the flavor name; outdated tutorials.

Related errors


AI-assisted analysis of tokio-rs/tokio@625954f365 (2026-08-11). Data as JSON: /api/errors/663f63760bcd6aa3. Report an issue: GitHub.