Skip to content

Use query for Variant InhabitedPredicate#159541

Open
camsteffen wants to merge 1 commit into
rust-lang:mainfrom
camsteffen:inhabited-variant-query
Open

Use query for Variant InhabitedPredicate#159541
camsteffen wants to merge 1 commit into
rust-lang:mainfrom
camsteffen:inhabited-variant-query

Conversation

@camsteffen

@camsteffen camsteffen commented Jul 19, 2026

Copy link
Copy Markdown
Contributor

View all comments

It looks like there may be some benefit from caching.

@rustbot

rustbot commented Jul 19, 2026

Copy link
Copy Markdown
Collaborator

Some changes occurred in exhaustiveness checking

cc @Nadrieril

Some changes occurred in match checking

cc @Nadrieril

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

rustbot commented Jul 19, 2026

Copy link
Copy Markdown
Collaborator

r? @folkertdev

rustbot has assigned @folkertdev.
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 74 candidates
  • Random selection from 17 candidates

@rust-log-analyzer

This comment has been minimized.

@camsteffen

Copy link
Copy Markdown
Contributor Author

@rustbot author

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

rustbot commented Jul 19, 2026

Copy link
Copy Markdown
Collaborator

Reminder, once the PR becomes ready for a review, use @rustbot ready.

Comment thread compiler/rustc_mir_build/src/thir/pattern/check_match.rs
let adt = tcx.adt_def(def_id);
variant_inhabited_predicate(tcx, adt.non_enum_variant())
}
DefKind::Variant => {

@Nadrieril Nadrieril Jul 19, 2026

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Feels unexpected to me that a Variant would be an admissible input for a function called something_adt; this deserves an extra comment imo

View changes since the review

@Nadrieril Nadrieril Jul 19, 2026

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I think I'd prefer to rename the query to inhabited_predicate_for_def and have it return an EarlyBinder<InhabitedPredicate>

Copy link
Copy Markdown
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I did the rename but still looking into EarlyBinder. Maybe that can be a separate PR?

@Nadrieril Nadrieril Jul 19, 2026

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

It's just a wrapper that says "btw, the value you get from this query needs to be passed generic arguments", it's what we use for the output of most queries that get type-related information about a DefId, just as a reminder

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Also happy to leave that, it's not crucial

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Since both are potentially performance-affecting, let's move to TypeFolder later?

Copy link
Copy Markdown
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Okay how bout we merge this as is and I'll add EarlyBinder with or without TypeFolder separately.

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

makes a lot of sense yes!

Copy link
Copy Markdown
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Oh it seems I can't just use EarlyBinder by itself because EarlyBinder::bind requires TypeFoldable.

Also I just found out that TypeFoldable requires TypeVisitable, so I don't think that's practical.

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

oh! well, let's just leave things like this then

@Nadrieril

Copy link
Copy Markdown
Member

r? me

I left a few comments as I was passing by but the most important is the perf run ofc

@rustbot rustbot assigned Nadrieril and unassigned folkertdev Jul 19, 2026
@camsteffen
camsteffen force-pushed the inhabited-variant-query branch from 2c18d60 to 553f6c8 Compare July 19, 2026 12:44
@Nadrieril

Copy link
Copy Markdown
Member

@bors try @rust-timer queue

@rust-timer

This comment has been minimized.

@rustbot rustbot added the S-waiting-on-perf Status: Waiting on a perf run to be completed. label Jul 19, 2026
@rust-bors

This comment has been minimized.

rust-bors Bot pushed a commit that referenced this pull request Jul 19, 2026
Use query for Variant InhabitedPredicate
@rust-bors

rust-bors Bot commented Jul 19, 2026

Copy link
Copy Markdown
Contributor

☀️ Try build successful (CI)
Build commit: 2421524 (242152418e59c924e48149b9736f96f695f67745)
Base parent: 234c31c (234c31cd674e11703f15d290cba7ff81dfe8b4b8)

@rust-timer

This comment has been minimized.

@rust-timer

Copy link
Copy Markdown
Collaborator

Finished benchmarking commit (2421524): comparison URL.

Overall result: ✅ improvements - no action needed

Benchmarking means the PR may be perf-sensitive. It's automatically marked not fit for rolling up. Overriding is possible but disadvised: it risks changing compiler perf.

@bors rollup=never rustc-perf
@rustbot label: -S-waiting-on-perf -perf-regression

Instruction count

Our most reliable metric. Used to determine the overall result above. However, even this metric can be noisy.

mean range count
Regressions ❌
(primary)
- - 0
Regressions ❌
(secondary)
- - 0
Improvements ✅
(primary)
-0.3% [-0.4%, -0.3%] 2
Improvements ✅
(secondary)
- - 0
All ❌✅ (primary) -0.3% [-0.4%, -0.3%] 2

Max RSS (memory usage)

Results (primary 0.9%, secondary -0.1%)

A less reliable metric. May be of interest, but not used to determine the overall result above.

mean range count
Regressions ❌
(primary)
0.9% [0.9%, 0.9%] 1
Regressions ❌
(secondary)
6.5% [5.1%, 8.0%] 2
Improvements ✅
(primary)
- - 0
Improvements ✅
(secondary)
-3.5% [-4.1%, -2.7%] 4
All ❌✅ (primary) 0.9% [0.9%, 0.9%] 1

Cycles

Results (primary 2.1%, secondary -2.5%)

A less reliable metric. May be of interest, but not used to determine the overall result above.

mean range count
Regressions ❌
(primary)
2.1% [2.1%, 2.1%] 1
Regressions ❌
(secondary)
- - 0
Improvements ✅
(primary)
- - 0
Improvements ✅
(secondary)
-2.5% [-2.8%, -2.1%] 2
All ❌✅ (primary) 2.1% [2.1%, 2.1%] 1

Binary size

Results (secondary -0.1%)

A less reliable metric. May be of interest, but not used to determine the overall result above.

mean range count
Regressions ❌
(primary)
- - 0
Regressions ❌
(secondary)
- - 0
Improvements ✅
(primary)
- - 0
Improvements ✅
(secondary)
-0.1% [-0.1%, -0.1%] 3
All ❌✅ (primary) - - 0

Bootstrap: 488.235s -> 485.708s (-0.52%)
Artifact size: 392.45 MiB -> 391.72 MiB (-0.19%)

@rustbot rustbot removed the S-waiting-on-perf Status: Waiting on a perf run to be completed. label Jul 19, 2026
@Nadrieril

Copy link
Copy Markdown
Member

Small but with a green tendency, I say why not

@Nadrieril

Copy link
Copy Markdown
Member

@bors r+

@rust-bors

rust-bors Bot commented Jul 20, 2026

Copy link
Copy Markdown
Contributor

📌 Commit 553f6c8 has been approved by Nadrieril

It is now in the queue for this repository.

@rust-bors rust-bors Bot added the S-waiting-on-bors Status: Waiting on bors to run and complete tests. Bors will change the label on completion. label Jul 20, 2026
@rust-bors rust-bors Bot removed the S-waiting-on-author Status: This is awaiting some action (such as code changes or more information) from the author. label Jul 20, 2026
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

S-waiting-on-bors Status: Waiting on bors to run and complete tests. Bors will change the label on completion. 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.

6 participants