{"record":{"id":"5d5f0058f6b28c98","repo":"rust-lang/rust","slug":"cfg-attr-has-docs","errorCode":null,"errorMessage":"cfg_attr has docs","messagePattern":"cfg_attr has docs","errorType":"panic","errorClass":null,"httpStatus":null,"severity":"error","filePath":"compiler/rustc_attr_parsing/src/attributes/cfg.rs","lineNumber":333,"sourceCode":"            match parse_in(&sess.psess, tokens.clone(), \"`cfg_attr` input\", |p| {\n                parse_cfg_attr_internal(p, sess, features, lint_node_id, cfg_attr)\n            }) {\n                Ok(r) => return Some(r),\n                Err(e) => {\n                    let suggestions = CFG_ATTR_TEMPLATE.suggestions(\n                        ParsedDescription::Attribute,\n                        cfg_attr.get_normal_item().unsafety,\n                        sym::cfg_attr,\n                    );\n                    e.with_span_suggestions(\n                        cfg_attr.get_normal_item().span,\n                        \"must be of the form\",\n                        suggestions,\n                        Applicability::HasPlaceholders,\n                    )\n                    .with_note(format!(\n                        \"for more information, visit <{}>\",\n                        CFG_ATTR_TEMPLATE.docs.expect(\"cfg_attr has docs\")\n                    ))\n                    .emit();\n                }\n            }\n        }\n        _ => {\n            let (span, reason) = if let ast::AttrArgs::Delimited(ast::DelimArgs { dspan, .. }) =\n                cfg_attr.get_normal_item().args\n            {\n                (dspan.entire(), AttributeParseErrorReason::ExpectedAtLeastOneArgument)\n            } else {\n                (cfg_attr.get_normal_item().span, AttributeParseErrorReason::ExpectedList)\n            };\n\n            sess.dcx().emit_err(AttributeParseError {\n                span,\n                inner_span: cfg_attr.get_normal_item().span,\n                template: CFG_ATTR_TEMPLATE,","sourceCodeStart":315,"sourceCodeEnd":351,"githubUrl":"https://github.com/rust-lang/rust/blob/7088e4b63a9516ebfbfe2ab2d999cf01a528ac14/compiler/rustc_attr_parsing/src/attributes/cfg.rs#L315-L351","documentation":"cfg.rs:333: when emitting a cfg_attr parse error, the compiler appends a docs link from CFG_ATTR_TEMPLATE.docs.expect(\"cfg_attr has docs\"). CFG_ATTR_TEMPLATE is a static AttributeTemplate built into the compiler; its `docs` field is populated at compiler-build time. A panic means the template was misconfigured when the compiler was compiled.","triggerScenarios":"A malformed #[cfg_attr(...)] triggers the error path that reads the template's docs link, but the static template has docs == None. This is a compiler-build configuration bug, not triggered by user code specifically.","commonSituations":"A rustc build where the cfg_attr AttributeTemplate was constructed without a docs URL; essentially impossible in a stock toolchain, only in a misbuilt/custom compiler.","solutions":["Use a stock official toolchain (rustup) rather than a custom-built compiler.","Fix the #[cfg_attr(...)] syntax that surfaced the error path (form must be #[cfg_attr(condition, attr)]).","If building the compiler, ensure the cfg_attr template includes its docs URL.","Report the issue against the custom rustc build."],"exampleFix":null,"handlingStrategy":"fallback","validationCode":null,"typeGuard":null,"tryCatchPattern":null,"preventionTips":["Use a stock official rustup toolchain instead of a custom-built compiler.","Fix the #[cfg_attr(condition, attr)] syntax that surfaces the error path.","If building the compiler, ensure the cfg_attr AttributeTemplate carries its docs URL.","Report misbuilt-compiler issues against the custom build, not upstream."],"tags":["rust","attributes","cfg","compiler-internal"],"backgroundTag":null,"analyzedSha":"7088e4b63a9516ebfbfe2ab2d999cf01a528ac14","analyzedAt":"2026-08-10T14:17:03.603Z","contentChangedAt":null,"schemaVersion":2},"datasetVersion":"2026-09-14T00:17:10.932Z"}