{"record":{"id":"4e6b713c626f2e10","repo":"rust-lang/rust-analyzer","slug":"no-block","errorCode":null,"errorMessage":"no block","messagePattern":"no block","errorType":"panic","errorClass":null,"httpStatus":null,"severity":"warning","filePath":"crates/span/src/ast_id.rs","lineNumber":1042,"sourceCode":"            macro_call_bar_id.raw.hash_value(),\n            \"hashes are equal\"\n        );\n    }\n\n    #[test]\n    fn blocks_with_no_items_have_no_id() {\n        let syntax = SourceFile::parse(\n            r#\"\nfn foo() {\n    let foo = 1;\n    bar(foo);\n}\n        \"#,\n            Edition::CURRENT,\n        )\n        .syntax_node();\n        let ast_id_map = AstIdMap::from_source(&syntax);\n        let block = syntax.descendants().find_map(ast::BlockExpr::cast).expect(\"no block\");\n        assert!(ast_id_map.ast_id_for_block(&block).is_none());\n    }\n}\n","sourceCodeStart":1024,"sourceCodeEnd":1046,"githubUrl":"https://github.com/rust-lang/rust-analyzer/blob/e8f7e90aa3e7b26aa9a000200f606c1078da99ec/crates/span/src/ast_id.rs#L1024-L1046","documentation":"This expect lives in the test blocks_with_no_items_have_no_id: it asserts the fixture source actually contains a BlockExpr before checking that item-free blocks get no AST id. Panicking with 'no block' means the test fixture no longer parses into any BlockExpr, i.e. the fixture text or Edition drifted rather than production behavior failing.","triggerScenarios":"Only when running rust-analyzer's span crate tests after someone edited the fixture source string or parser grammar so the fixture no longer contains a castable BlockExpr.","commonSituations":"Developers refactoring the test fixture, changing Edition::CURRENT handling, or modifying the parser such that the fixture's block is no longer parsed as ast::BlockExpr.","solutions":["Inspect the fixture string in the test and restore a construct that parses as a BlockExpr.","Run the parser/debug dump on the fixture to see what it now parses into.","If grammar changed intentionally, update the test to cast the correct new node type."],"exampleFix":"// before (fixture changed so no block parses)\nlet block = syntax.descendants().find_map(ast::BlockExpr::cast).expect(\"no block\");\n// after\nlet block = syntax.descendants().find_map(ast::BlockExpr::cast)\n    .unwrap_or_else(|| panic!(\"fixture no longer contains a BlockExpr: {syntax:?}\"));","handlingStrategy":"validation","validationCode":"assert!(syntax.descendants().any(|n| ast::BlockExpr::can_cast(n.kind())),\n    \"fixture no longer contains a BlockExpr\");","typeGuard":null,"tryCatchPattern":null,"preventionTips":["Re-verify fixtures after parser/grammar changes","Keep fixture strings minimal and annotated per testing conventions","Run the span crate tests whenever touching parser code"],"tags":["rust-analyzer","tests","fixture","panic"],"backgroundTag":"test-fixture-drift","analyzedSha":"e8f7e90aa3e7b26aa9a000200f606c1078da99ec","analyzedAt":"2026-09-03T21:08:06.959Z","contentChangedAt":"2026-09-03T21:08:06.959Z","schemaVersion":2},"datasetVersion":"2026-09-11T07:07:21.782Z"}