EpicGames/lore · error · syn::Error
expected `state`
Error message
expected `state`
What it means
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.
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.
Example fix
// before
#[lore_instrument(path = "state.json")]
fn handler() {}
// after
#[lore_instrument(state = "state.json")]
fn handler() {} Defensive patterns
Strategy: validation
Validate before calling
// Compile-time: the attribute must literally be: #[lore_instrument(state = "<path>")]
// Verify before building:
// grep -R '#\[lore_instrument(' src/ | grep -v 'state = ' Prevention
- 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.
When it happens
Trigger: 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`.
Common situations: 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.
Understand the failure class
Background: "missing required argument" and "the following required arguments were not provided": what required-argument errors mean and how to fix them — this error's family across 20 libraries.
Related errors
- Failed to open log file
- {e}
- Networking not supported on this OS
- [environment.endpoint] auth_url is set but [server.auth] is…
- [environment.endpoint] auth_url and [server.auth]…
AI-assisted analysis of EpicGames/lore@074eb0b0d1 (2026-09-13).
Data as JSON: /api/errors/7035c7379a30b6c3.
Report an issue: GitHub.
Appendix: source
Thrown at lore-macro/src/lore_instrument.rs:21
use proc_macro::TokenStream;
use quote::quote;
use syn::ItemFn;
use syn::parse::Parse;
use syn::parse::ParseStream;
struct LoreInstrumentArgs {
state_path: Option<syn::Path>,
}
impl Parse for LoreInstrumentArgs {
fn parse(input: ParseStream<'_>) -> syn::Result<Self> {
if input.is_empty() {
return Ok(LoreInstrumentArgs { state_path: None });
}
let ident: syn::Ident = input.parse()?;
if ident != "state" {
return Err(syn::Error::new(ident.span(), "expected `state`"));
}
let _eq: syn::Token![=] = input.parse()?;
let lit: syn::LitStr = input.parse()?;
let path: syn::Path = lit.parse()?;
Ok(LoreInstrumentArgs {
state_path: Some(path),
})
}
}
pub fn lore_instrument_impl(args: TokenStream, item: TokenStream) -> TokenStream {
let args = syn::parse_macro_input!(args as LoreInstrumentArgs);
let input = syn::parse_macro_input!(item as ItemFn);
let state_path = args.state_path.unwrap_or_else(|| {
syn::parse_str("lore_telemetry::execution_state::ServerExecutionState").unwrap()
});
View on GitHub (pinned to 074eb0b0d1)