Skip to content

Consider structurally impossible Sized predicates in MIR#156609

Open
qaijuang wants to merge 2 commits into
rust-lang:mainfrom
qaijuang:mir-opt-impossible-sized-predicates
Open

Consider structurally impossible Sized predicates in MIR#156609
qaijuang wants to merge 2 commits into
rust-lang:mainfrom
qaijuang:mir-opt-impossible-sized-predicates

Conversation

@qaijuang
Copy link
Copy Markdown
Contributor

@qaijuang qaijuang commented May 15, 2026

Fixes #156051

ImpossiblePredicates filters predicates mentioning local generics before invoking the trait solver, which avoids normalization and solver work in generic contexts, thereby skipping predicates such as dyn Trait<T>: Sized, even though they are impossible for every substitution.

This PR adds a narrow structural fast path for positive Sized predicates whose self type is known-unsized without normalization, letting the pass clear unreachable bodies before later MIR opts can evaluate SizedTypeProperties constants such as size_of::<Self>().

@rustbot rustbot added S-waiting-on-author Status: This is awaiting some action (such as code changes or more information) from the author. T-compiler Relevant to the compiler team, which will review and decide on the PR/issue. labels May 15, 2026
@qaijuang qaijuang marked this pull request as ready for review May 15, 2026 16:04
@rustbot
Copy link
Copy Markdown
Collaborator

rustbot commented May 15, 2026

Some changes occurred to MIR optimizations

cc @rust-lang/wg-mir-opt

@rustbot rustbot added S-waiting-on-review Status: Awaiting review from the assignee but also interested parties. and removed S-waiting-on-author Status: This is awaiting some action (such as code changes or more information) from the author. labels May 15, 2026
@rustbot
Copy link
Copy Markdown
Collaborator

rustbot commented May 15, 2026

r? @TaKO8Ki

rustbot has assigned @TaKO8Ki.
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, mir, mir-opt
  • compiler, mir, mir-opt expanded to 73 candidates
  • Random selection from 17 candidates

@qaijuang
Copy link
Copy Markdown
Contributor Author

cc @matthiaskrgr

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

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.

[ICE]: wasm: unsized type for size_of

3 participants