{"record":{"id":"39923bf0580002c9","repo":"tokio-rs/tokio","slug":"failed-to-parse-value-of-field-as-string","errorCode":null,"errorMessage":"Failed to parse value of `{field}` as string.","messagePattern":"Failed to parse value of `(.+?)` as string\\.","errorType":"validation","errorClass":"syn::Error","httpStatus":null,"severity":"error","filePath":"tokio-macros/src/entry.rs","lineNumber":276,"sourceCode":"            Err(e) => Err(syn::Error::new(\n                span,\n                format!(\"Failed to parse value of `{field}` as integer: {e}\"),\n            )),\n        },\n        _ => Err(syn::Error::new(\n            span,\n            format!(\"Failed to parse value of `{field}` as integer.\"),\n        )),\n    }\n}\n\nfn parse_string(int: syn::Lit, span: Span, field: &str) -> Result<String, syn::Error> {\n    match int {\n        syn::Lit::Str(s) => Ok(s.value()),\n        syn::Lit::Verbatim(s) => Ok(s.to_string()),\n        _ => Err(syn::Error::new(\n            span,\n            format!(\"Failed to parse value of `{field}` as string.\"),\n        )),\n    }\n}\n\nfn parse_path(lit: syn::Lit, span: Span, field: &str) -> Result<Path, syn::Error> {\n    match lit {\n        syn::Lit::Str(s) => {\n            let err = syn::Error::new(\n                span,\n                format!(\n                    \"Failed to parse value of `{}` as path: \\\"{}\\\"\",\n                    field,\n                    s.value()\n                ),\n            );\n            s.parse::<syn::Path>().map_err(|_| err.clone())\n        }\n        _ => Err(syn::Error::new(","sourceCodeStart":258,"sourceCodeEnd":294,"githubUrl":"https://github.com/tokio-rs/tokio/blob/625954f365727668cb02d04172b34f1149637728/tokio-macros/src/entry.rs#L258-L294","documentation":"Compile-time error from `parse_string`'s `_` arm. The attribute value for a string-typed field is neither `syn::Lit::Str` nor `syn::Lit::Verbatim`. It backs the `name`, `flavor`, and `unhandled_panic` fields (see `set_name`, `set_flavor`, `set_unhandled_panic` in entry.rs).","triggerScenarios":"`#[tokio::main(flavor = 5)]` (int), `flavor = true` (bool), or `flavor = 'a'` (char). Any non-string-literal value where the macro expects a string.","commonSituations":"Forgetting to quote the flavor value (`flavor = multi_thread` reads as a path, not a string — that hits a different path); passing a bool/number for `name` or `unhandled_panic`; copy-paste from a language where enum-like values are unquoted.","solutions":["Quote the value: `#[tokio::main(flavor = \"multi_thread\")]`.","For `unhandled_panic`, use `\"ignore\"` or `\"shutdown_runtime\"` as a string.","Confirm the field name is spelled exactly (`flavor`, `name`, `unhandled_panic`)."],"exampleFix":"// before\n#[tokio::main(flavor = 5)]\nasync fn main() {}\n\n// after\n#[tokio::main(flavor = \"multi_thread\")]\nasync fn main() {}","handlingStrategy":"validation","validationCode":null,"typeGuard":null,"tryCatchPattern":null,"preventionTips":["Quote `flavor`, `name`, and `unhandled_panic` values as string literals.","Allowed `flavor` values: `\"current_thread\"`, `\"local\"`, `\"multi_thread\"`.","Allowed `unhandled_panic` values: `\"ignore\"`, `\"shutdown_runtime\"`."],"tags":["rust","tokio","macros","configuration","compile-time"],"backgroundTag":null,"analyzedSha":"625954f365727668cb02d04172b34f1149637728","analyzedAt":"2026-08-11T17:46:45.378Z","contentChangedAt":"2026-08-11T17:46:45.378Z","schemaVersion":2},"datasetVersion":"2026-09-14T05:17:10.506Z"}