rust-lang / rust-lang/rust-analyzer
panic: `we captured CapturedPlace`
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
fn test(temp: usize) {
async |b, b| {temp}
}
RUSTFLAGS="" ~/.rustup/toolchains/master/bin/rust-analyzer highlight < code.rs
thread 'main' (991934) panicked at src/tools/rust-analyzer/crates/hir-ty/src/infer/closure/analysis.rs:1654:9:
we captured CapturedPlace {
place: Place {
base_ty: usize,
base: Upvar {
closure: Idx::<Expr>(6),
var_id: Idx::<Binding>(0),
},
projections: [],
},
info: CaptureInfo {
sources: [
CaptureSourceStack(
[
ExprId(
Idx::<Expr>(0),
),
],
),
],
capture_kind: ByValue,
},
mutability: Not,
} but it was not used in the child coroutine?
stack backtrace:
0: 0x7fe50923dd16 - <<std[a6ca0c0c096ad2d4]::sys::backtrace::BacktraceLock>::print::DisplayBacktrace as core[fae3f2c5d9acceca]::fmt::Display>::fmt
1: 0x7fe50980ec88 - core[fae3f2c5d9acceca]::fmt::write
2: 0x7fe50925318c - <std[a6ca0c0c096ad2d4]::sys::stdio::unix::Stderr as core[fae3f2c5d9acceca]::io::write::Write>::write_fmt
3: 0x7fe5092120da - std[a6ca0c0c096ad2d4]::panicking::default_hook::{closure#0}
4: 0x7fe509230433 - std[a6ca0c0c096ad2d4]::panicking::default_hook
5: 0x7fe50923089b - std[a6ca0c0c096ad2d4]::panicking::panic_with_hook
6: 0x7fe509212192 - std[a6ca0c0c096ad2d4]::panicking::panic_handler::{closure#0}
7: 0x7fe509206679 - std[a6ca0c0c096ad2d4]::sys::backtrace::__rust_end_short_backtrace::<std[a6ca0c0c096ad2d4]::panicking::panic_handler::{closure#0}, !>
8: 0x7fe509213aed - __rustc[829c20b9ecbc8940]::rust_begin_unwind
9: 0x7fe505f866fc - core[fae3f2c5d9acceca]::panicking::panic_fmt
10: 0x56173ab176ee - <hir_ty[7ac3326e862f8f23]::infer::InferenceContext>::analyze_closures_in_expr
11: 0x56173ab14b5f - <hir_ty[7ac3326e862f8f23]::infer::InferenceContext>::analyze_closures_in_expr
12: 0x56173abbc27a - hir_ty[7ac3326e862f8f23]::infer::infer_finalize
13: 0x56173abc605f - hir_ty[7ac3326e862f8f23]::infer::infer_query_with_inspect
14: 0x56173aab5e34 - <salsa[49de3200ee4334b]::function::IngredientImpl<<hir_ty[7ac3326e862f8f23]::infer::InferenceResult>::for_body::_::for_body__Configuration_>>::execute
15: 0x56173a880b97 - <salsa[49de3200ee4334b]::attach::Attached>::attach::<dyn hir_ty[7ac3326e862f8f23]::db::HirDatabase, &hir_ty[7ac3326e862f8f23]::infer::InferenceResult, <hir_ty[7ac3326e862f8f23]::infer::InferenceResult>::for_body::for_body_::{closure#0}>
16: 0x56173a4e044c - <hir[a4cfbecefd43fc5b]::semantics::SemanticsImpl>::get_unsafe_ops
17: 0x56173ae4ab43 - ide[1334d1aebe5d4db8]::syntax_highlighting::highlight
18: 0x56173ae846fe - ide[1334d1aebe5d4db8]::syntax_highlighting::html::highlight_as_html_with_config
19: 0x56173adeb67c - <ide[1334d1aebe5d4db8]::Analysis>::highlight_as_html
20: 0x56173b839082 - <rust_analyzer[748176c5a26757ef]::cli::flags::Highlight>::run
21: 0x56173bad8d54 - rust_analyzer[f4c43ad5a8782b3b]::main
22: 0x56173ba6fed3 - std[a6ca0c0c096ad2d4]::sys::backtrace::__rust_begin_short_backtrace::<fn() -> core[fae3f2c5d9acceca]::result::Result<std[a6ca0c0c096ad2d4]::process::ExitCode, anyhow[cc6cc6f972cedb14]::Error>, core[fae3f2c5d9acceca]::result::Result<std[a6ca0c0c096ad2d4]::process::ExitCode, anyhow[cc6cc6f972cedb14]::Error>>
23: 0x56173bad1da2 - std[a6ca0c0c096ad2d4]::rt::lang_start::<core[fae3f2c5d9acceca]::result::Result<std[a6ca0c0c096ad2d4]::process::ExitCode, anyhow[cc6cc6f972cedb14]::Error>>::{closure#0}
24: 0x7fe50aa20c59 - std[a6ca0c0c096ad2d4]::rt::lang_start_internal
25: 0x56173baf1ea8 - main
26: 0x7fe504227741 - <unknown>
27: 0x7fe504227879 - __libc_start_main
28: 0x56173a3e3f29 - <unknown>
29: 0x0 - <unknown>
rust-analyzer 1.99.0-nightly (2118366 2026-07-15)
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 crash with the async-closure example using the rust-analyzer highlight command. Start at src/tools/rust-analyzer/crates/hir-ty/src/infer/closure/analysis.rs:1654 and trace the closure analysis for the duplicated parameter and captured value. Done means highlighting this input completes without the panic.
Written by the indexing model from the issue text.
Assessment
- Tech stack
- rust
- Domain
- devtools
- Issue type
- Bug
- Difficulty
- 3/5
- Estimated time
- 1-2 days
- Activity status
- Quiet
- Clarity
- Clearly specified
- Newbie friendliness
- 55/100