Skip to content

Normalize field type for InhabitedPredicate - #158921

Draft
camsteffen wants to merge 1 commit into
rust-lang:mainfrom
camsteffen:inhabitedpredicate-normalize
Draft

Normalize field type for InhabitedPredicate#158921
camsteffen wants to merge 1 commit into
rust-lang:mainfrom
camsteffen:inhabitedpredicate-normalize

Conversation

@camsteffen

Copy link
Copy Markdown
Contributor

Normalizing the field type can sometimes lead to a simpler InhabitedPredicate. For instance if a projection alias can be resolved.

@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 Jul 7, 2026
@rustbot

rustbot commented Jul 7, 2026

Copy link
Copy Markdown
Collaborator

r? @wesleywiser

rustbot has assigned @wesleywiser.
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, types
  • compiler, types expanded to 75 candidates
  • Random selection from 18 candidates

@rust-log-analyzer

Copy link
Copy Markdown
Collaborator

The job aarch64-gnu-llvm-21-1 failed! Check out the build log: (web) (plain enhanced) (plain)

Click to see the possible cause of the failure (guessed by this bot)
---- [ui] tests/ui/associated-types/normalization-ice-issue-149746.rs stdout ----

error: Error: expected failure status (Some(1)) but received status Some(101).
status: exit status: 101
command: env -u RUSTC_LOG_COLOR RUSTC_ICE="0" RUST_BACKTRACE="short" "/checkout/obj/build/aarch64-unknown-linux-gnu/stage2/bin/rustc" "/checkout/tests/ui/associated-types/normalization-ice-issue-149746.rs" "-Zthreads=1" "-Zsimulate-remapped-rust-src-base=/rustc/FAKE_PREFIX" "-Ztranslate-remapped-path-to-local-path=no" "-Z" "ignore-directory-in-diagnostics-source-blocks=/cargo" "-Z" "ignore-directory-in-diagnostics-source-blocks=/checkout/vendor" "--sysroot" "/checkout/obj/build/aarch64-unknown-linux-gnu/stage2" "--target=aarch64-unknown-linux-gnu" "--check-cfg" "cfg(test,FALSE)" "--error-format" "json" "--json" "future-incompat" "-Ccodegen-units=1" "-Zui-testing" "-Zdeduplicate-diagnostics=no" "-Zwrite-long-types-to-disk=no" "-Cstrip=debuginfo" "--emit" "metadata" "-C" "prefer-dynamic" "--out-dir" "/checkout/obj/build/aarch64-unknown-linux-gnu/test/ui/associated-types/normalization-ice-issue-149746" "-A" "unused" "-W" "unused_attributes" "-A" "internal_features" "-A" "incomplete_features" "-A" "unused_parens" "-A" "unused_braces" "-Crpath" "-Cdebuginfo=0" "-Lnative=/checkout/obj/build/aarch64-unknown-linux-gnu/native/rust-test-helpers" "--edition=2015"
stdout: none
--- stderr -------------------------------
error[E0277]: expected an `FnMut()` closure, found `T`
##[error]  --> /checkout/tests/ui/associated-types/normalization-ice-issue-149746.rs:6:24
   |
LL |     _significant_drop: <() as Owner>::Ty<T>,
   |                        ^^^^^^^^^^^^^^^^^^^^ expected an `FnMut()` closure, found `T`
   |
   = note: wrap the `T` in a closure with no arguments: `|| { /* code */ }`
note: required by a bound in `Owner::Ty`
  --> /checkout/tests/ui/associated-types/normalization-ice-issue-149746.rs:3:26
   |
LL | trait Owner { type Ty<T: FnMut()>; }
   |                          ^^^^^^^ required by this bound in `Owner::Ty`
help: consider restricting type parameter `T` with trait `FnMut`
   |
LL | pub struct Warns<T: FnMut()> {
   |                   +++++++++

warning: changes to closure capture in Rust 2021 will affect drop order
##[warning]  --> /checkout/tests/ui/associated-types/normalization-ice-issue-149746.rs:12:9
   |
LL |     _ = || w.field
   |         ^^ -------
   |            |     |
   |            |     in Rust 2018, `w` is dropped here, but in Rust 2021, only `w.field` will be dropped here as part of the closure
   |            in Rust 2018, this closure captures all of `w`, but in Rust 2021, it will only capture `w.field`
   |
   = note: for more information, see <https://doc.rust-lang.org/edition-guide/rust-2021/disjoint-capture-in-closures.html>
note: the lint level is defined here
  --> /checkout/tests/ui/associated-types/normalization-ice-issue-149746.rs:2:9
   |
LL | #![warn(rust_2021_incompatible_closure_captures)]
   |         ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
help: add a dummy let to cause `w` to be fully captured
   |
LL |     _ = || { let _ = &w; w.field }
   |            +++++++++++++         +

@camsteffen
camsteffen marked this pull request as draft July 7, 2026 19:05
@rustbot rustbot added S-waiting-on-author Status: This is awaiting some action (such as code changes or more information) from the author. and removed S-waiting-on-review Status: Awaiting review from the assignee but also interested parties. labels Jul 7, 2026
@wesleywiser

Copy link
Copy Markdown
Member

I don't really understand if this is a reasonable thing to do or not.

r? types

@rustbot rustbot added the T-types Relevant to the types team, which will review and decide on the PR/issue. label Jul 7, 2026
@rustbot rustbot assigned oli-obk and unassigned wesleywiser Jul 7, 2026
@camsteffen

Copy link
Copy Markdown
Contributor Author

The tests seem to be fixable. I would also like to hear a types expert's opinion on whether this looks like a sensible idea. If yes, maybe a perf run. Also I wonder if it might make sense to only normalize if an Alias is encountered.

@rust-bors

rust-bors Bot commented Sep 6, 2026

Copy link
Copy Markdown
Contributor

☔ The latest upstream changes (presumably #159541) made this pull request unmergeable. Please resolve the merge conflicts by rebasing.

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

Labels

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. T-types Relevant to the types team, which will review and decide on the PR/issue.

Projects

None yet

Development

Successfully merging this pull request may close these issues.

5 participants