{"record":{"id":"0eb845fb3c457c98","repo":"tokio-rs/tokio","slug":"name-set-multiple-times","errorCode":null,"errorMessage":"`name` set multiple times.","messagePattern":"`name` set multiple times\\.","errorType":"validation","errorClass":"syn::Error","httpStatus":null,"severity":"error","filePath":"tokio-macros/src/entry.rs","lineNumber":106,"sourceCode":"        Configuration {\n            name: None,\n            rt_multi_thread_available: rt_multi_thread,\n            default_flavor: match is_test {\n                true => RuntimeFlavor::CurrentThread,\n                false => RuntimeFlavor::Threaded,\n            },\n            flavor: None,\n            worker_threads: None,\n            start_paused: None,\n            is_test,\n            crate_name: None,\n            unhandled_panic: None,\n        }\n    }\n\n    fn set_name(&mut self, name: syn::Lit, span: Span) -> Result<(), syn::Error> {\n        if self.name.is_some() {\n            return Err(syn::Error::new(span, \"`name` set multiple times.\"));\n        }\n\n        let runtime_name = parse_string(name, span, \"name\")?;\n        self.name = Some(runtime_name);\n        Ok(())\n    }\n\n    fn set_flavor(&mut self, runtime: syn::Lit, span: Span) -> Result<(), syn::Error> {\n        if self.flavor.is_some() {\n            return Err(syn::Error::new(span, \"`flavor` set multiple times.\"));\n        }\n\n        let runtime_str = parse_string(runtime, span, \"flavor\")?;\n        let runtime =\n            RuntimeFlavor::from_str(&runtime_str).map_err(|err| syn::Error::new(span, err))?;\n        self.flavor = Some(runtime);\n        Ok(())\n    }","sourceCodeStart":88,"sourceCodeEnd":124,"githubUrl":"https://github.com/tokio-rs/tokio/blob/625954f365727668cb02d04172b34f1149637728/tokio-macros/src/entry.rs#L88-L124","documentation":"The `#[tokio::main]` / `#[tokio::test]` attribute accepts a `name = \"...\"` option that sets the runtime builder's name. The macro's config builder (`set_name`, entry.rs:104) rejects a second `name` occurrence in the same invocation with a `syn::Error`, surfaced as a compile error.","triggerScenarios":"Writing `#[tokio::main(name = \"a\", name = \"b\")]` (or the `tokio::test` equivalent) — two `name` keys in one attribute.","commonSituations":"Merging two attribute configs by hand; copy-paste of options; editing tools that append rather than replace.","solutions":["Remove the duplicate `name` argument so it appears exactly once.","If two names were intended for different runtimes, split the code into two annotated entry points."],"exampleFix":"// before\n#[tokio::main(name = \"rt1\", name = \"rt2\")]\nasync fn main() {}\n\n// after\n#[tokio::main(name = \"rt1\")]\nasync fn main() {}","handlingStrategy":"validation","validationCode":null,"typeGuard":null,"tryCatchPattern":null,"preventionTips":["Each `#[tokio::main]`/`#[tokio::test]` option key must appear at most once — self-check your attribute before compiling.","When merging configs, replace rather than append option keys.","Keep a single canonical macro invocation per entry point."],"tags":["tokio","macros","compile-error","config","duplicate-option"],"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"}