1
Fork 0

Rollup merge of #136205 - compiler-errors:len-3, r=BoxyUwU

Properly check that array length is valid type during built-in unsizing in index

This results in duplicated errors, but this class of errors is not new; in general, we aren't really equipped to detect cases where a WF error due to a field type would be shadowed by the parent struct of that field also not being WF.

This also adds a note for these types of mismatches to make it clear that this is due to an array type.

Fixes #134352

r? boxyuwu
This commit is contained in:
Matthias Krüger 2025-01-29 15:29:41 +01:00 committed by GitHub
commit e8289d801c
No known key found for this signature in database
GPG key ID: B5690EEEBB952194
13 changed files with 63 additions and 9 deletions

View file

@ -194,6 +194,9 @@ pub enum ObligationCauseCode<'tcx> {
/// A slice or array is WF only if `T: Sized`.
SliceOrArrayElem,
/// An array `[T; N]` can only be indexed (and is only well-formed if) `N` has type usize.
ArrayLen(Ty<'tcx>),
/// A tuple is WF only if its middle elements are `Sized`.
TupleElem,