tokio-rs/tokio · error · syn::Error
Failed to parse value of `{field}` as bool.
Error message
Failed to parse value of `{field}` as bool. What it means
Compile-time error from `parse_bool`'s `_` arm: the value for a boolean field is not `syn::Lit::Bool`. Used only by the `start_paused` field (see `set_start_paused` calling `parse_bool(..., "start_paused")` in entry.rs:151).
Source
Thrown at tokio-macros/src/entry.rs:306
field,
s.value()
),
);
s.parse::<syn::Path>().map_err(|_| err.clone())
}
_ => Err(syn::Error::new(
span,
format!("Failed to parse value of `{field}` as path."),
)),
}
}
fn parse_bool(bool: syn::Lit, span: Span, field: &str) -> Result<bool, syn::Error> {
match bool {
syn::Lit::Bool(b) => Ok(b.value),
_ => Err(syn::Error::new(
span,
format!("Failed to parse value of `{field}` as bool."),
)),
}
}
fn contains_impl_trait(ty: &syn::Type) -> bool {
match ty {
syn::Type::ImplTrait(_) => true,
syn::Type::Array(t) => contains_impl_trait(&t.elem),
syn::Type::Ptr(t) => contains_impl_trait(&t.elem),
syn::Type::Reference(t) => contains_impl_trait(&t.elem),
syn::Type::Slice(t) => contains_impl_trait(&t.elem),
syn::Type::Tuple(t) => t.elems.iter().any(contains_impl_trait),
syn::Type::Paren(t) => contains_impl_trait(&t.elem),
syn::Type::Group(t) => contains_impl_trait(&t.elem),
syn::Type::Path(t) => match t.path.segments.last() {
Some(segment) => match &segment.arguments {
syn::PathArguments::AngleBracketed(args) => args.args.iter().any(|arg| match arg {
syn::GenericArgument::Type(t) => contains_impl_trait(t),View on GitHub (pinned to 625954f365)
Solutions
- Use an unquoted boolean literal: `#[tokio::main(flavor = "current_thread", start_paused = true)]`.
- Remember `start_paused` only works with `current_thread` flavor; set both together.
Example fix
// before
#[tokio::main(start_paused = "true")]
async fn main() {}
// after
#[tokio::main(flavor = "current_thread", start_paused = true)]
async fn main() {} Defensive patterns
Strategy: validation
Prevention
- Use unquoted Rust booleans (`true`/`false`) for `start_paused` — not `1`/`0` or quoted strings.
- `start_paused` requires `flavor = "current_thread"`; set both together.
When it happens
Trigger: `#[tokio::main(start_paused = 1)]`, `start_paused = "true"`, or `start_paused = 'y'`. Any non-boolean literal.
Common situations: Using `1`/`0` or a quoted `"true"`/`"false"` (carried over from JSON/ENV config habits); `start_paused` also requires the `current_thread` flavor, so the boolean shape must be correct before the flavor check in `build()`.
Understand the failure class
- Parsing and encoding errors: unexpected token, malformed input — why parsers reject input and how to find the real culprit.
Related errors
- Failed to parse value of `{field}` as integer.
- Failed to parse value of `{field}` as string.
- Failed to parse value of `{}` as path: "{}"
- Failed to parse value of `{field}` as path.
- The #[tokio::main] macro requires rt or rt-multi-thread.
AI-assisted analysis of tokio-rs/tokio@625954f365 (2026-08-11).
Data as JSON: /api/errors/a2194fcf5d7ea05d.
Report an issue: GitHub.