Skip to content

Ensure inferred let pattern types are well-formed#157013

Open
s7tya wants to merge 1 commit into
rust-lang:mainfrom
s7tya:fix-let-pat-inferred-wf
Open

Ensure inferred let pattern types are well-formed#157013
s7tya wants to merge 1 commit into
rust-lang:mainfrom
s7tya:fix-let-pat-inferred-wf

Conversation

@s7tya
Copy link
Copy Markdown
Contributor

@s7tya s7tya commented May 27, 2026

Fixes #150040

This registers a well-formedness obligation for inferred let pattern types when the pattern contains ref bindings.

Previously, let PAT; without an explicit type annotation could infer a non-well-formed pattern input type, such as [str; 2] or (str, str). Some bindings inside the pattern can still have well-formed local types, for example ref x gives x: &str, so checking only the binding locals missed the enclosing array or tuple type. As a result, invalid unsized array/tuple pattern types were accepted and could later lead to layout ICEs.

The new check registers a WF obligation for the inferred declaration type after pattern checking.

@rustbot rustbot added S-waiting-on-review Status: Awaiting review from the assignee but also interested parties. T-compiler Relevant to the compiler team, which will review and decide on the PR/issue. labels May 27, 2026
@rustbot
Copy link
Copy Markdown
Collaborator

rustbot commented May 27, 2026

r? @mejrs

rustbot has assigned @mejrs.
They will have a look at your PR within the next two weeks and either review your PR or reassign to another reviewer.

Use r? to explicitly pick a reviewer

Why was this reviewer chosen?

The reviewer was selected based on:

  • Owners of files modified in this PR: compiler
  • compiler expanded to 73 candidates
  • Random selection from 18 candidates

@mejrs
Copy link
Copy Markdown
Contributor

mejrs commented May 27, 2026

r? @lcnr

@rustbot rustbot assigned lcnr and unassigned mejrs May 27, 2026
@mejrs mejrs added the needs-crater This change needs a crater run to check for possible breakage in the ecosystem. label May 27, 2026
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

needs-crater This change needs a crater run to check for possible breakage in the ecosystem. S-waiting-on-review Status: Awaiting review from the assignee but also interested parties. T-compiler Relevant to the compiler team, which will review and decide on the PR/issue.

Projects

None yet

Development

Successfully merging this pull request may close these issues.

Array patterns and tuple patterns don't properly check for Sized

4 participants