mirror of
https://github.com/rust-lang/rust.git
synced 2025-11-17 02:56:25 +00:00
The place previously used here was that of the temporary holding the reference returned by `Deref::deref` or `DerefMut::deref_mut`. However, since the inner pattern of `deref!(inner)` expects the deref-target type itself, this would ICE when that type was inspected (e.g. by the EUV case for slice patterns). This adds a deref projection to fix that. Since current in-tree consumers of EUV (upvar inference and clippy) don't care about Rvalues, the place could be simplified to `self.cat_rvalue(pat.hir_id, self.pat_ty_adjusted(subpat)?)` to save some cycles. I personally find EUV to be a bit fragile, so I've opted for pedantic correctness. Maybe a `HACK` comment would suffice though?
16 lines
388 B
Rust
16 lines
388 B
Rust
//@ check-pass
|
|
//! Regression test for ICE in `rustc_hir_typeck::expr_use_visitor` on nesting a slice pattern
|
|
//! inside a deref pattern inside a closure: rust-lang/rust#125059
|
|
|
|
#![feature(deref_patterns)]
|
|
#![allow(incomplete_features, unused)]
|
|
|
|
fn simple_vec(vec: Vec<u32>) -> u32 {
|
|
(|| match Vec::<u32>::new() {
|
|
deref!([]) => 100,
|
|
_ => 2000,
|
|
})()
|
|
}
|
|
|
|
fn main() {}
|