diff options
| author | Michael Goulet <michael@errs.io> | 2024-05-24 15:49:17 -0400 |
|---|---|---|
| committer | Michael Goulet <michael@errs.io> | 2024-05-24 16:20:48 -0400 |
| commit | 61aac551b81573d160f19bafbf6deb83f8f0b2be (patch) | |
| tree | faf05e4d9298631c272db1452dde8542a5dab924 | |
| parent | 1af490de424ac07fbeb3b1a0a1268cad43fdf49d (diff) | |
| download | rust-61aac551b81573d160f19bafbf6deb83f8f0b2be.tar.gz rust-61aac551b81573d160f19bafbf6deb83f8f0b2be.zip | |
Structurally resolve before builtin_index in EUV
| -rw-r--r-- | compiler/rustc_hir_typeck/src/expr_use_visitor.rs | 6 | ||||
| -rw-r--r-- | tests/ui/traits/next-solver/typeck/index-of-projection.rs | 13 |
2 files changed, 18 insertions, 1 deletions
diff --git a/compiler/rustc_hir_typeck/src/expr_use_visitor.rs b/compiler/rustc_hir_typeck/src/expr_use_visitor.rs index 89f62577506..0ba4bd090f5 100644 --- a/compiler/rustc_hir_typeck/src/expr_use_visitor.rs +++ b/compiler/rustc_hir_typeck/src/expr_use_visitor.rs @@ -1741,7 +1741,11 @@ 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 diff --git a/tests/ui/traits/next-solver/typeck/index-of-projection.rs b/tests/ui/traits/next-solver/typeck/index-of-projection.rs new file mode 100644 index 00000000000..5023be0bb14 --- /dev/null +++ b/tests/ui/traits/next-solver/typeck/index-of-projection.rs @@ -0,0 +1,13 @@ +//@ 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[..]; + }; +} |
