rust-lang / rust-lang/rust-analyzer
panic: deref patterns `deref projection of non-dereferenceable ty PlaceTy`
Open
Nobody has claimed this yet.
B-unstable
C-bug
I-panic
- Dominant language
- Rust
- Stars
- 16.9k
- Forks
- 2.2k
- Avg merge
- 1d 12h
- Merged PRs (30d)
- 72
Description
#![feature(deref_patterns)]
fn main() {
test(Some(String::new()));
}
fn test(o: Option<String>) {
match o {
Some("something else?") | _ => println!("the answer"),
}
}
this compiles with rustc
RUST_BACKTRACE=full ~/.rustup/toolchains/master/bin/rust-analyzer analysis-stats --run-all-ide-things .
Database loaded: 303.96ms, 224minstr, 48mb (metadata 166.19ms, 926kinstr, 150kb; build 16.11ms, 165kinstr, 1088b)
item trees: 1
dependency lines of code: 1_462_980, item trees: 2_900
dependency item stats: traits: 851, impl: 9_703, mods: 3_013, macro calls: 5_502, macro rules: 1_053
Item Tree Collection: 2.05s, 22ginstr, 425mb
Total Statistics:
crates: 1, mods: 1, decls: 2, bodies: 2, adts: 0, consts: 0, signatures: 2, variants: 0
Workspace:
traits: 0, macro_rules macros: 0, proc_macros: 0
lines of code: 11, item trees: 1
usages: traits: 0, impl: 0, mods: 0, macro calls: 0, macro rules: 0
Dependencies:
lines of code: 1_462_980, item trees: 2_900
declarations: traits: 851, impl: 9_703, mods: 3_013, macro calls: 5_502, macro rules: 1_053
Item Collection: 1.17s, 11ginstr, 177mb
Crate lang items: 225.67ms, 2472minstr, 31mb
Expression Store Lowering: 393.31µs, 718kinstr, 204kb
exprs: 17, ??ty: 0 (0%), ?ty: 0 (0%), !ty: 0
pats: 5, ??ty: 0 (0%), ?ty: 0 (0%), !ty: 0
panics: 0
Inference: 212.56ms, 1294minstr, 36mb
MIR lowering: 214.77µs, 312kinstr, 34kb
Mir failed bodies: 0 (0%)
Data layouts: 101.00ns, 24kinstr, 0b
Failed data layouts: 0 (100%)
Const evaluation: 12.44µs, 44kinstr, 112b
Failed const evals: 0 (100%)
0/1 0% diagnostics: /tmp/ra/a/src/main.rs
thread 'main' (833284) panicked at src/tools/rust-analyzer/crates/hir-ty/src/mir.rs:1330:21:
deref projection of non-dereferenceable ty PlaceTy { ty: String, variant_id: None }
stack backtrace:
0: 0x7fd1a542a786 - <<std[1e37345aeca07a33]::sys::backtrace::BacktraceLock>::print::DisplayBacktrace as core[702fd8b52481f6b]::fmt::Display>::fmt
1: 0x7fd1a5a0f108 - core[702fd8b52481f6b]::fmt::write
2: 0x7fd1a543f9ec - <std[1e37345aeca07a33]::sys::stdio::unix::Stderr as core[702fd8b52481f6b]::io::write::Write>::write_fmt
3: 0x7fd1a53fc40a - std[1e37345aeca07a33]::panicking::default_hook::{closure#0}
4: 0x7fd1a541cea3 - std[1e37345aeca07a33]::panicking::default_hook
5: 0x7fd1a541d30b - std[1e37345aeca07a33]::panicking::panic_with_hook
6: 0x7fd1a53fc4c2 - std[1e37345aeca07a33]::panicking::panic_handler::{closure#0}
7: 0x7fd1a53f3959 - std[1e37345aeca07a33]::sys::backtrace::__rust_end_short_backtrace::<std[1e37345aeca07a33]::panicking::panic_handler::{closure#0}, !>
8: 0x7fd1a53fde1d - __rustc[c13b5280399c33fa]::rust_begin_unwind
9: 0x7fd1a20ea73c - core[702fd8b52481f6b]::panicking::panic_fmt
10: 0x562ceb432390 - <hir_ty[e0bea5ffe6249590]::mir::PlaceTy>::projection_ty::<la_arena[8a88e1b2a9f4152b]::Idx<hir_ty[e0bea5ffe6249590]::mir::Local>>
11: 0x562ceb565627 - hir_ty[e0bea5ffe6249590]::mir::borrowck::moved_out_of_ref::{closure#0}
12: 0x562ceb568093 - <hir_ty[e0bea5ffe6249590]::mir::borrowck::_::borrowck_query_Configuration_ as salsa[6da196d40d999542]::function::Configuration>::execute::inner_::{closure#0}
13: 0x562ceb78f91d - <hir_ty[e0bea5ffe6249590]::mir::borrowck::_::borrowck_query_Configuration_ as salsa[6da196d40d999542]::function::Configuration>::execute
14: 0x562ceb59d69e - <salsa[6da196d40d999542]::function::IngredientImpl<hir_ty[e0bea5ffe6249590]::mir::borrowck::_::borrowck_query_Configuration_>>::execute
15: 0x562ceb7154f6 - hir_ty[e0bea5ffe6249590]::mir::borrowck::borrowck_query
16: 0x562cebf0d7f7 - <ide_db[638de82cedb9c87c]::RootDatabase as hir_ty[e0bea5ffe6249590]::db::HirDatabase>::borrowck
17: 0x562ceb03dc4e - <hir[b56e87ee980c34bb]::DefWithBody>::diagnostics
18: 0x562ceaff077e - <hir[b56e87ee980c34bb]::ModuleDef>::diagnostics
19: 0x562ceaffad1c - <hir[b56e87ee980c34bb]::Module>::diagnostics
20: 0x562cebec938e - ide_diagnostics[503c04d5f93eb929]::semantic_diagnostics
21: 0x562cebec39c2 - ide_diagnostics[503c04d5f93eb929]::full_diagnostics
22: 0x562ceb90cf19 - <ide[809bbcf8303a9ff9]::Analysis>::full_diagnostics
23: 0x562cec3543ef - <rust_analyzer[29694c28a86a0685]::cli::flags::AnalysisStats>::run
24: 0x562cec5fdd62 - rust_analyzer[b45ee5f09a5d6ebe]::main
25: 0x562cec594593 - std[1e37345aeca07a33]::sys::backtrace::__rust_begin_short_backtrace::<fn() -> core[702fd8b52481f6b]::result::Result<std[1e37345aeca07a33]::process::ExitCode, anyhow[f29ba2bc3bec5daa]::Error>, core[702fd8b52481f6b]::result::Result<std[1e37345aeca07a33]::process::ExitCode, anyhow[f29ba2bc3bec5daa]::Error>>
26: 0x562cec5f6f02 - std[1e37345aeca07a33]::rt::lang_start::<core[702fd8b52481f6b]::result::Result<std[1e37345aeca07a33]::process::ExitCode, anyhow[f29ba2bc3bec5daa]::Error>>::{closure#0}
27: 0x7fd1a6b9d099 - std[1e37345aeca07a33]::rt::lang_start_internal
28: 0x562cec616fe8 - main
29: 0x7fd1a0427741 - <unknown>
30: 0x7fd1a0427879 - __libc_start_main
31: 0x562ceaf08629 - <unknown>
32: 0x0 - <unknown>
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
Start at src/tools/rust-analyzer/crates/hir-ty/src/mir.rs:1330, then follow the projection_ty call from mir::borrowck::moved_out_of_ref shown in the backtrace. Reproduce with the issue's deref_patterns example and analysis-stats command; done means this input no longer panics while diagnostics complete.
Written by the indexing model from the issue text.
Assessment
- Tech stack
- rust
- Domain
- compilers
- Issue type
- Bug
- Difficulty
- 3/5
- Estimated time
- 1-2 days
- Activity status
- Quiet
- Clarity
- Mostly clear
- Newbie friendliness
- 55/100