{"id":"e1583a7f7f4901aa","repo":"rust-lang/rust","slug":"unknown-query-modifier","errorCode":null,"errorMessage":"unknown query modifier","messagePattern":"unknown query modifier","errorType":"validation","errorClass":"syn::Error","httpStatus":null,"severity":"error","filePath":"compiler/rustc_macros/src/query.rs","lineNumber":204,"sourceCode":"            // `desc { \"foo {}\", tcx.item_path(key) }`\n            let attr_content;\n            braced!(attr_content in input);\n            let expr_list = attr_content.parse_terminated(Expr::parse, Token![,])?;\n            try_insert!(desc = Desc { modifier, expr_list });\n        } else if modifier == \"eval_always\" {\n            try_insert!(eval_always = modifier);\n        } else if modifier == \"feedable\" {\n            try_insert!(feedable = modifier);\n        } else if modifier == \"handle_cycle_error\" {\n            try_insert!(handle_cycle_error = modifier);\n        } else if modifier == \"no_force\" {\n            try_insert!(no_force = modifier);\n        } else if modifier == \"no_hash\" {\n            try_insert!(no_hash = modifier);\n        } else if modifier == \"separate_provide_extern\" {\n            try_insert!(separate_provide_extern = modifier);\n        } else {\n            return Err(Error::new(modifier.span(), \"unknown query modifier\"));\n        }\n    }\n    let Some(desc) = desc else {\n        return Err(input.error(\"no description provided\"));\n    };\n    Ok(QueryModifiers {\n        // tidy-alphabetical-start\n        arena_cache,\n        cache_on_disk,\n        depth_limit,\n        desc,\n        eval_always,\n        feedable,\n        handle_cycle_error,\n        no_force,\n        no_hash,\n        separate_provide_extern,\n        // tidy-alphabetical-end","sourceCodeStart":186,"sourceCodeEnd":222,"githubUrl":"https://github.com/rust-lang/rust/blob/22057b88b091743bc0fd8d592a9264f0a6951403/compiler/rustc_macros/src/query.rs#L186-L222","documentation":"Thrown by parse_query_modifiers (query.rs:204) in the rustc_queries proc-macro when a token inside a query's modifier braces does not match any of the ten recognized modifier names. The parser is an if/else-if chain (query.rs:178-205) ending in a catch-all Err, so any unrecognized identifier (or a keyword reached via a typo) is rejected with the span of that identifier.","triggerScenarios":"Writing a query whose braces block contains a modifier name not in the set {arena_cache, cache_on_disk, depth_limit, desc, eval_always, feedable, handle_cycle_error, no_force, no_hash, separate_provide_extern}; e.g. `query foo(k: K) -> V { cycle_error, desc {\"x\"} }` (should be handle_cycle_error) or placing a stray token/typo in the modifier list.","commonSituations":"Contributing a new query to rustc and guessing a modifier name; renaming a modifier without updating all call sites; using an older modifier name that was renamed across rustc versions; copying an example from outdated documentation.","solutions":["Correct the modifier identifier to one of the supported names listed in query.rs:178-202 (and rustc_middle::query::modifiers).","If you genuinely need a new modifier, add it to QueryModifiers (query.rs:137-150), the parse chain, and make_modifiers_stream before using it.","Check for typos and trailing punctuation that may have produced an unexpected token."],"exampleFix":"// before\nquery type_of(key: DefId) -> Ty<'tcx> {\n    cycle_error\n    desc { \"type of `{}`\", tcx.def_path_str(key) }\n}\n\n// after\nquery type_of(key: DefId) -> Ty<'tcx> {\n    handle_cycle_error\n    desc { \"type of `{}`\", tcx.def_path_str(key) }\n}","handlingStrategy":"validation","validationCode":"const KNOWN: &[&str] = &[\"eval_always\",\"dep_kind\",\"anon\",\"feedable\",\"cycle_delay\",\"no_fetch\"];\nfn is_known_modifier(m: &str) -> bool { KNOWN.contains(&m) }\n// for m in used { assert!(is_known_modifier(m), \"unknown query modifier {m}\"); }","typeGuard":"fn modifier_kind(m: &str) -> Option<&'static str> {\n    match m {\n        \"eval_always\" | \"dep_kind\" | \"anon\" | \"feedable\" => Some(m),\n        _ => None,\n    }\n}","tryCatchPattern":null,"preventionTips":["Keep a single source of truth for allowed modifier strings and diff it against query.rs:204","Reject unknown modifiers in a pre-commit lint before they reach the proc macro","Add a unit test asserting every documented modifier passes is_known_modifier"],"tags":["rustc-internals","proc-macro","query-system","compile-error"],"analyzedSha":"22057b88b091743bc0fd8d592a9264f0a6951403","analyzedAt":"2026-08-03T08:09:25.915Z","schemaVersion":2}