Skip to content

Commit

Permalink
Structurally resolve before builtin_index in EUV
Browse files Browse the repository at this point in the history
  • Loading branch information
compiler-errors committed May 24, 2024
1 parent 1af490d commit 19857da
Show file tree
Hide file tree
Showing 2 changed files with 16 additions and 1 deletion.
2 changes: 1 addition & 1 deletion compiler/rustc_hir_typeck/src/expr_use_visitor.rs
Original file line number Diff line number Diff line change
Expand Up @@ -1741,7 +1741,7 @@ impl<'tcx, Cx: TypeInformationCtxt<'tcx>, D: Delegate<'tcx>> ExprUseVisitor<'tcx
}

PatKind::Slice(before, ref slice, after) => {
let Some(element_ty) = place_with_id.place.ty().builtin_index() else {
let Some(element_ty) = self.cx.try_structurally_resolve_type(pat.span, place_with_id.place.ty()).builtin_index() else {
debug!("explicit index of non-indexable type {:?}", place_with_id);
return Err(self
.cx
Expand Down
15 changes: 15 additions & 0 deletions tests/ui/traits/next-solver/typeck/index-of-projection.rs
Original file line number Diff line number Diff line change
@@ -0,0 +1,15 @@
//@ compile-flags: -Znext-solver
//@ check-pass

// Fixes a regression in `rustc_attr` where we weren't normalizing the
// output type of a index operator performing a `Ty::builtin_index` call,
// leading to an ICE.

fn main() {
let mut vec = [1, 2, 3];
let x = || {
let [..] = &vec[..] else {
return;
};
};
}

0 comments on commit 19857da

Please sign in to comment.