rust-lang / rust-lang/rust-analyzer
panic: rowan: `assertion `left == right` failed`
Open
Nobody has claimed this yet.
C-bug
I-panic
- Dominant language
- Rust
- Stars
- 16.9k
- Forks
- 2.2k
- Avg merge
- 1d 12h
- Merged PRs (30d)
- 72
Description
macro_rules! bar {
() => {#}
}
fn expect() {
let _ = bar!();
}
RUSTFLAGS="" ~/.rustup/toolchains/master/bin/rust-analyzer highlight < code.rs
thread 'main' (1776065) panicked at /rust/deps/rowan-0.15.19/src/green/builder.rs:113:9:
assertion `left == right` failed
left: 2
right: 1
stack backtrace:
0: 0x7fdf62e0a566 - <<std[7a677e1801b0b374]::sys::backtrace::BacktraceLock>::print::DisplayBacktrace as core[8947f86082328bb0]::fmt::Display>::fmt
1: 0x7fdf6340ec88 - core[8947f86082328bb0]::fmt::write
2: 0x7fdf62e1f9dc - <std[7a677e1801b0b374]::sys::stdio::unix::Stderr as core[8947f86082328bb0]::io::write::Write>::write_fmt
3: 0x7fdf62dde8ea - std[7a677e1801b0b374]::panicking::default_hook::{closure#0}
4: 0x7fdf62dfcc83 - std[7a677e1801b0b374]::panicking::default_hook
5: 0x7fdf62dfd0eb - std[7a677e1801b0b374]::panicking::panic_with_hook
6: 0x7fdf62dde9a2 - std[7a677e1801b0b374]::panicking::panic_handler::{closure#0}
7: 0x7fdf62dd2e89 - std[7a677e1801b0b374]::sys::backtrace::__rust_end_short_backtrace::<std[7a677e1801b0b374]::panicking::panic_handler::{closure#0}, !>
8: 0x7fdf62de02fd - __rustc[3266c8557f45551c]::rust_begin_unwind
9: 0x7fdf5fb5c47c - core[8947f86082328bb0]::panicking::panic_fmt
10: 0x7fdf61767683 - core[8947f86082328bb0]::panicking::assert_failed_inner
11: 0x7fdf6152d2b0 - core[8947f86082328bb0]::panicking::assert_failed::<usize, usize>
12: 0x5630a2193d9d - <syntax[5b320011d0873dc9]::syntax_node::SyntaxTreeBuilder>::finish_raw
13: 0x5630a2193f1b - <syntax[5b320011d0873dc9]::syntax_node::SyntaxTreeBuilder>::finish
14: 0x5630a21d532b - syntax_bridge[5c2156e1db67bca]::token_tree_to_syntax_node
15: 0x5630a0e76e22 - <hir_expand[9bbf63f0f992eec0]::MacroCallId as <hir_expand[9bbf63f0f992eec0]::MacroCallId>::parse_macro_expansion::InnerTrait_>::parse_macro_expansion_
16: 0x5630a0e269ad - <salsa[f6baacb4446d11cc]::function::IngredientImpl<<hir_expand[9bbf63f0f992eec0]::MacroCallId>::parse_macro_expansion::_::parse_macro_expansion__Configuration_>>::execute
17: 0x5630a0e22c41 - <salsa[f6baacb4446d11cc]::function::IngredientImpl<<hir_expand[9bbf63f0f992eec0]::MacroCallId>::parse_macro_expansion::_::parse_macro_expansion__Configuration_>>::fetch
18: 0x5630a0dce1ec - <std[7a677e1801b0b374]::thread::local::LocalKey<salsa[f6baacb4446d11cc]::attach::Attached>>::with::<salsa[f6baacb4446d11cc]::attach::attach<&mbe[f88504abd11633ae]::ValueResult<(syntax[5b320011d0873dc9]::Parse<rowan[9525a1ce97a2250d]::api::SyntaxNode<syntax[5b320011d0873dc9]::syntax_node::RustLanguage>>, span[b7b32e967f36a6cb]::map::SpanMap), hir_expand[9bbf63f0f992eec0]::ExpandError>, dyn base_db[e7983c07c0bf84a9]::SourceDatabase, <hir_expand[9bbf63f0f992eec0]::MacroCallId>::parse_macro_expansion::parse_macro_expansion_::{closure#0}>::{closure#0}, &mbe[f88504abd11633ae]::ValueResult<(syntax[5b320011d0873dc9]::Parse<rowan[9525a1ce97a2250d]::api::SyntaxNode<syntax[5b320011d0873dc9]::syntax_node::RustLanguage>>, span[b7b32e967f36a6cb]::map::SpanMap), hir_expand[9bbf63f0f992eec0]::ExpandError>>
19: 0x5630a0b70a85 - <hir_def[d4d7874b73d21e36]::expr_store::lower::ExprCollector>::collect_macro_call::<syntax[5b320011d0873dc9]::ast::generated::nodes::Expr, core[8947f86082328bb0]::option::Option<core[8947f86082328bb0]::option::Option<la_arena[f5c86c771458cdda]::Idx<hir_def[d4d7874b73d21e36]::hir::Expr>>>, <hir_def[d4d7874b73d21e36]::expr_store::lower::ExprCollector>::maybe_collect_expr::{closure#35}>
20: 0x5630a0c729d3 - <hir_def[d4d7874b73d21e36]::expr_store::lower::ExprCollector>::maybe_collect_expr
21: 0x5630a0c66a4d - <hir_def[d4d7874b73d21e36]::expr_store::lower::ExprCollector>::collect_stmt
22: 0x5630a0b6bc78 - <hir_def[d4d7874b73d21e36]::expr_store::lower::ExprCollector>::collect_block_::<<hir_def[d4d7874b73d21e36]::expr_store::lower::ExprCollector>::collect_block::{closure#0}>
23: 0x5630a0c72a48 - <hir_def[d4d7874b73d21e36]::expr_store::lower::ExprCollector>::maybe_collect_expr
24: 0x5630a0c6c0c8 - <hir_def[d4d7874b73d21e36]::expr_store::lower::ExprCollector>::collect_expr_opt
25: 0x5630a0d09fae - <hir_def[d4d7874b73d21e36]::expr_store::body::Body as <hir_def[d4d7874b73d21e36]::expr_store::body::Body>::with_source_map::InnerTrait_>::with_source_map_
26: 0x5630a0c230e0 - <salsa[f6baacb4446d11cc]::function::IngredientImpl<<hir_def[d4d7874b73d21e36]::expr_store::body::Body>::with_source_map::_::with_source_map__Configuration_>>::execute
27: 0x5630a0cbd646 - <hir_def[d4d7874b73d21e36]::expr_store::body::Body>::with_source_map
28: 0x5630a0c83579 - <hir_def[d4d7874b73d21e36]::expr_store::ExpressionStore>::with_source_map
29: 0x5630a0af2b84 - <hir[7d9bbb24bae6c127]::semantics::SemanticsImpl>::get_unsafe_ops
30: 0x5630a145d313 - ide[6233e951667d8107]::syntax_highlighting::highlight
31: 0x5630a149703e - ide[6233e951667d8107]::syntax_highlighting::html::highlight_as_html_with_config
32: 0x5630a13fde4c - <ide[6233e951667d8107]::Analysis>::highlight_as_html
33: 0x5630a1e4c932 - <rust_analyzer[9f47c25af0fec260]::cli::flags::Highlight>::run
34: 0x5630a20ec0f4 - rust_analyzer[9193986eb7972329]::main
35: 0x5630a20827d3 - std[7a677e1801b0b374]::sys::backtrace::__rust_begin_short_backtrace::<fn() -> core[8947f86082328bb0]::result::Result<std[7a677e1801b0b374]::process::ExitCode, anyhow[6c3359fcb7bf7f47]::Error>, core[8947f86082328bb0]::result::Result<std[7a677e1801b0b374]::process::ExitCode, anyhow[6c3359fcb7bf7f47]::Error>>
36: 0x5630a20e5142 - std[7a677e1801b0b374]::rt::lang_start::<core[8947f86082328bb0]::result::Result<std[7a677e1801b0b374]::process::ExitCode, anyhow[6c3359fcb7bf7f47]::Error>>::{closure#0}
37: 0x7fdf6456b599 - std[7a677e1801b0b374]::rt::lang_start_internal
38: 0x5630a2105238 - main
39: 0x7fdf5de27741 - <unknown>
40: 0x7fdf5de27879 - __libc_start_main
41: 0x5630a09f6709 - <unknown>
42: 0x0 - <unknown>
rust-analyzer 1.99.0-nightly (da80ed0 2026-07-14)
Contributor guide
First steps
- Read the whole issue, then the project's contributing guide.
- Comment on the issue to say you are picking it up — it saves two people doing the same work.
- Fork the repository and make your change on a branch.
- Open a pull request that references the issue number.
Research direction
Reproduce the panic with the shown rust-analyzer highlight command, then trace the stack from SyntaxTreeBuilder::finish_raw through token_tree_to_syntax_node and macro expansion. Add regression coverage for this macro input and verify that highlighting completes without panicking.
Written by the indexing model from the issue text.
Assessment
- Tech stack
- rust
- Domain
- compilers, devtools
- Issue type
- Bug
- Difficulty
- 3/5
- Estimated time
- 1-2 days
- Activity status
- Quiet
- Clarity
- Mostly clear
- Newbie friendliness
- 50/100