rust-lang/rust · error · syn::Error
unknown query modifier
Error message
unknown query modifier
What it means
Emitted by parse_query_modifiers in the rustc_queries! macro when an identifier in the modifier block doesn't match any of the ten known modifier keys: arena_cache, cache_on_disk, depth_limit, desc, eval_always, feedable, handle_cycle_error, no_force, no_hash, separate_provide_extern. The else branch of the if-else chain (query.rs:204) produces this error at the unknown identifier's span.
Solutions
- Check the canonical list in query.rs:178-202 or rustc_middle::query::modifiers for the exact spelling of each modifier.
- Correct the typo — note that all modifiers use snake_case.
- If the modifier exists in a different rustc version, update your source tree to match the version you're compiling.
Example fix
// before
query foo(key: DefId) -> Ty<'tcx> {
desc { "foo for `{}`", key }
eval_alwyas
}
// after: fix the typo
query foo(key: DefId) -> Ty<'tcx> {
desc { "foo for `{}`", key }
eval_always
} Defensive patterns
Strategy: validation
Validate before calling
// Validate modifier names against the known set before committing.
const VALID_MODIFIERS: &[&str] = &[
"arena_cache", "cache_on_disk", "depth_limit", "desc",
"eval_always", "feedable", "handle_cycle_error",
"no_force", "no_hash", "separate_provide_extern",
];
fn is_valid_modifier(name: &str) -> bool {
VALID_MODIFIERS.contains(&name)
} Try / catch
// Compile-time error — cannot be caught at runtime. // Fix the typo or remove the unknown modifier.
Prevention
- Reference the modifier list in query.rs (lines 178-202) for exact spelling.
- All modifier names are snake_case identifiers.
- Run cargo check after editing query declarations to catch typos early.
When it happens
Trigger: Typing a modifier name incorrectly (e.g., "eval_alwyas", "cach_on_disk") or using a modifier that doesn't exist in this version of the compiler. The modifier block is the { } body of a query declaration.
Common situations: Typo in modifier name; using a modifier from a newer/older rustc version; guessing a modifier name instead of checking the documented list; copy-paste from documentation that uses a different name.
Related errors
- attributes must be outer attributes (`///`), not inner…
- attributes not supported on queries
- duplicate modifier
- Expected a string literal
- CFG_RELEASE env var
AI-assisted analysis of rust-lang/rust@7088e4b63a (2026-08-10).
Data as JSON: /api/errors/e1583a7f7f4901aa.
Report an issue: GitHub.
Appendix: source
Thrown at compiler/rustc_macros/src/query.rs:204
// `desc { "foo {}", tcx.item_path(key) }`
let attr_content;
braced!(attr_content in input);
let expr_list = attr_content.parse_terminated(Expr::parse, Token![,])?;
try_insert!(desc = Desc { modifier, expr_list });
} else if modifier == "eval_always" {
try_insert!(eval_always = modifier);
} else if modifier == "feedable" {
try_insert!(feedable = modifier);
} else if modifier == "handle_cycle_error" {
try_insert!(handle_cycle_error = modifier);
} else if modifier == "no_force" {
try_insert!(no_force = modifier);
} else if modifier == "no_hash" {
try_insert!(no_hash = modifier);
} else if modifier == "separate_provide_extern" {
try_insert!(separate_provide_extern = modifier);
} else {
return Err(Error::new(modifier.span(), "unknown query modifier"));
}
}
let Some(desc) = desc else {
return Err(input.error("no description provided"));
};
Ok(QueryModifiers {
// tidy-alphabetical-start
arena_cache,
cache_on_disk,
depth_limit,
desc,
eval_always,
feedable,
handle_cycle_error,
no_force,
no_hash,
separate_provide_extern,
// tidy-alphabetical-endView on GitHub (pinned to 7088e4b63a)