{"record":{"id":"7035c7379a30b6c3","repo":"EpicGames/lore","slug":"expected-state","errorCode":null,"errorMessage":"expected `state`","messagePattern":"expected `state`","errorType":"validation","errorClass":"syn::Error","httpStatus":null,"severity":"error","filePath":"lore-macro/src/lore_instrument.rs","lineNumber":21,"sourceCode":"use proc_macro::TokenStream;\nuse quote::quote;\nuse syn::ItemFn;\nuse syn::parse::Parse;\nuse syn::parse::ParseStream;\n\nstruct LoreInstrumentArgs {\n    state_path: Option<syn::Path>,\n}\n\nimpl Parse for LoreInstrumentArgs {\n    fn parse(input: ParseStream<'_>) -> syn::Result<Self> {\n        if input.is_empty() {\n            return Ok(LoreInstrumentArgs { state_path: None });\n        }\n\n        let ident: syn::Ident = input.parse()?;\n        if ident != \"state\" {\n            return Err(syn::Error::new(ident.span(), \"expected `state`\"));\n        }\n        let _eq: syn::Token![=] = input.parse()?;\n        let lit: syn::LitStr = input.parse()?;\n        let path: syn::Path = lit.parse()?;\n        Ok(LoreInstrumentArgs {\n            state_path: Some(path),\n        })\n    }\n}\n\npub fn lore_instrument_impl(args: TokenStream, item: TokenStream) -> TokenStream {\n    let args = syn::parse_macro_input!(args as LoreInstrumentArgs);\n    let input = syn::parse_macro_input!(item as ItemFn);\n\n    let state_path = args.state_path.unwrap_or_else(|| {\n        syn::parse_str(\"lore_telemetry::execution_state::ServerExecutionState\").unwrap()\n    });\n","sourceCodeStart":3,"sourceCodeEnd":39,"githubUrl":"https://github.com/EpicGames/lore/blob/074eb0b0d1194c997d7cf28b55519e3e197b3e23/lore-macro/src/lore_instrument.rs#L3-L39","documentation":"The `lore_instrument` attribute macro parses its arguments manually and requires the first token to be the exact identifier `state`, followed by `=` and a string literal path. When the attribute is invoked with any other key name (or a bare value), the macro raises this compile-time error pointing at the unexpected identifier. It is a macro-input validation failure, not a runtime fault.","triggerScenarios":"Writing `#[lore_instrument(path = \"state.json\")]`, `#[lore_instrument(\"state.json\")]`, a misspelled key like `#[lore_instrument(states = ...)]`, or any attribute argument that does not start with the literal token `state`.","commonSituations":"Copying an attribute from a different macro, misreading the macro's docs, refactoring the attribute name after a library API change, or IDE autocompletion inserting the wrong key.","solutions":["Change the attribute's first argument to the exact form `state = \"<path>\"`.","Check the lore-macro docs/tests for the accepted invocation syntax of `lore_instrument`.","If the error points at a token that isn't yours, verify you are attaching the attribute to a supported item."],"exampleFix":"// before\n#[lore_instrument(path = \"state.json\")]\nfn handler() {}\n\n// after\n#[lore_instrument(state = \"state.json\")]\nfn handler() {}","handlingStrategy":"validation","validationCode":"// Compile-time: the attribute must literally be: #[lore_instrument(state = \"<path>\")]\n// Verify before building:\n// grep -R '#\\[lore_instrument(' src/ | grep -v 'state = '","typeGuard":null,"tryCatchPattern":null,"preventionTips":["Always write the attribute as `state = \"path\"` — the key name is fixed by the macro.","Copy invocations from the macro's own doc examples/tests, not from other macros.","Let rust-analyzer's attribute expansion/caret point at the offending token when refactoring."],"tags":["rust","proc-macro","compile-error"],"backgroundTag":"missing-required-argument","analyzedSha":"074eb0b0d1194c997d7cf28b55519e3e197b3e23","analyzedAt":"2026-09-13T09:00:57.509Z","contentChangedAt":"2026-09-13T09:00:57.509Z","schemaVersion":2},"datasetVersion":"2026-09-16T09:17:16.951Z"}