Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Auto merge of rust-lang#12409 - lowr:fix/usize-overflow, r=Veykril
fix overflow during type inference for tuple struct patterns The following code causes integer overflow during type inference for (malformed) tuple struct patterns. ```rust struct S(usize); let S(.., a, b) = S(1); ``` It has been panicking only in debug builds, and working in a way in release builds but it was inconsistent with type inference for tuple patterns: ```rust struct S(usize); let S(.., a, b) = S(1); // a -> unknown, b -> usize let (.., a, b) = (1,); // a -> usize, b -> unknown ``` With this PR, the overflow no longer happens by utilizing `saturating_sub()` like in other places and type inference for tuple struct patterns is in line with that for tuple patterns.
- Loading branch information