{"record":{"id":"22875adc62745348","repo":"rust-lang/rust-analyzer","slug":"bad-tag-other","errorCode":null,"errorMessage":"bad tag: {other}","messagePattern":"bad tag: (.+?)","errorType":"panic","errorClass":null,"httpStatus":null,"severity":"error","filePath":"crates/proc-macro-api/src/legacy_protocol/msg/flat.rs","lineNumber":844,"sourceCode":"                        let text = self.text[repr.text as usize].as_str();\n                        let (is_raw, text) = if self.version >= EXTENDED_LEAF_DATA {\n                            (\n                                if repr.is_raw { tt::IdentIsRaw::Yes } else { tt::IdentIsRaw::No },\n                                text,\n                            )\n                        } else {\n                            tt::IdentIsRaw::split_from_symbol(text)\n                        };\n                        s.push(\n                            tt::Leaf::Ident(tt::Ident {\n                                sym: Symbol::intern(text),\n                                span: read_span(repr.id),\n                                is_raw,\n                            })\n                            .into(),\n                        )\n                    }\n                    other => panic!(\"bad tag: {other}\"),\n                }\n            }\n            res[i] = Some((delimiter, s));\n        }\n\n        let (delimiter, mut res) = res[0].take().unwrap();\n        res.insert(0, tt::TokenTree::Subtree(tt::Subtree { delimiter, len: res.len() as u32 }));\n        tt::TopSubtree::from_serialized(res)\n    }\n}\n\n#[cfg(feature = \"in-rust-tree\")]\nimpl<T: SpanTransformer> Reader<'_, T> {\n    pub(crate) fn read_tokenstream(\n        self,\n        span_join: impl Fn(T::Span, T::Span) -> T::Span,\n    ) -> proc_macro_srv::TokenStream<T::Span> {\n        let mut res: Vec<Option<proc_macro_srv::Group<T::Span>>> = vec![None; self.subtree.len()];","sourceCodeStart":826,"sourceCodeEnd":862,"githubUrl":"https://github.com/rust-lang/rust-analyzer/blob/e8f7e90aa3e7b26aa9a000200f606c1078da99ec/crates/proc-macro-api/src/legacy_protocol/msg/flat.rs#L826-L862","documentation":"While converting a flat legacy-protocol token stream back into `proc_macro_srv::TokenTree`s, the parser dispatches on a tag word identifying the token-tree variant (group, ident, literal, punctuation). An unrecognized tag means the buffer is corrupt or encoded by an incompatible protocol version; the reader panics with `bad tag: {other}`.","triggerScenarios":"Decoding a `SubtreeRepr`'s token stream where a token-tree tag word is not one of the known variant discriminators.","commonSituations":"Proc-macro server built against a different rust-analyzer revision than the client; hand-patched flat buffers; offset arithmetic errors that read a payload word (e.g. a span or length) as a tag.","solutions":["Rebuild the proc-macro server to match the rust-analyzer/protocol version","Check that buffer offsets are computed with the same word sizes and layout as the writer","Validate all tag values fall in the known set before decoding, or migrate to the current protocol"],"exampleFix":"// before\nlet words = &flat[i..i + 3]; // wrong stride -> reads payload as tag\n// after\nlet words = &flat[i..i + token_tree_word_count(tag)];\nassert!(tag <= MAX_KNOWN_TAG, \"unknown token tree tag {tag}\");","handlingStrategy":"validation","validationCode":"fn valid_token_tree_tag(tag: u32) -> bool { tag <= 3 }","typeGuard":"fn is_known_tt_tag(tag: u32) -> bool {\n    matches!(tag, 0..=3)\n}","tryCatchPattern":null,"preventionTips":["Match word strides and offsets exactly with the writer's layout","Rebuild proc-macro server binaries with the matching rust-analyzer revision","Sanity-check tag words before dispatch during decoding","Migrate from the legacy flat protocol to the current one"],"tags":["rust","proc-macro","protocol-decoding","panic"],"backgroundTag":"protocol-encoding-mismatch","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"}