Skip to content

Commit 61aac55

Browse files
Structurally resolve before builtin_index in EUV
1 parent 1af490d commit 61aac55

File tree

2 files changed

+18
-1
lines changed

2 files changed

+18
-1
lines changed

compiler/rustc_hir_typeck/src/expr_use_visitor.rs

+5-1
Original file line numberDiff line numberDiff line change
@@ -1741,7 +1741,11 @@ impl<'tcx, Cx: TypeInformationCtxt<'tcx>, D: Delegate<'tcx>> ExprUseVisitor<'tcx
17411741
}
17421742

17431743
PatKind::Slice(before, ref slice, after) => {
1744-
let Some(element_ty) = place_with_id.place.ty().builtin_index() else {
1744+
let Some(element_ty) = self
1745+
.cx
1746+
.try_structurally_resolve_type(pat.span, place_with_id.place.ty())
1747+
.builtin_index()
1748+
else {
17451749
debug!("explicit index of non-indexable type {:?}", place_with_id);
17461750
return Err(self
17471751
.cx
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,13 @@
1+
//@ compile-flags: -Znext-solver
2+
//@ check-pass
3+
4+
// Fixes a regression in `rustc_attr` where we weren't normalizing the
5+
// output type of a index operator performing a `Ty::builtin_index` call,
6+
// leading to an ICE.
7+
8+
fn main() {
9+
let mut vec = [1, 2, 3];
10+
let x = || {
11+
let [..] = &vec[..];
12+
};
13+
}

0 commit comments

Comments
 (0)