Skip to content

Conversation

Nadrieril
Copy link
Member

I made it a bit less ad-hoc. In particular, I removed is_inline: bool that was just caching the output of tcx.def_kind(def_id). This makes inline consts a tiny bit less special in patterns.

r? @oli-obk

cc @Zalathar

@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 Mar 29, 2025
@rust-log-analyzer

This comment has been minimized.

@Nadrieril Nadrieril force-pushed the simplify-expandedconstant branch from e3f6e6a to 0a75955 Compare March 29, 2025 14:55
@Nadrieril
Copy link
Member Author

Nadrieril commented Mar 29, 2025

@oli-obk I assigned you for the last two commits, I'm not confident what I'm doing is correct. Also wondering if there's a cleaner way to write this.

Comment on lines 621 to 677
hir::PatExprKind::Lit { lit, negated } => {
let ct_ty = self.typeck_results.node_type(expr.hir_id);
let lit_input = LitToConstInput { lit: &lit.node, ty: ct_ty, neg: *negated };
let constant = self.tcx.at(expr.span).lit_to_const(lit_input);
self.const_to_pat(constant, ct_ty, expr.hir_id, lit.span).kind
}
Copy link
Contributor

Choose a reason for hiding this comment

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

I've been meaning to do this tweak for a while, so I'm glad to see it happen here. 👍

@Zalathar
Copy link
Contributor

I assume that any changes to inline-const patterns specifically will become mostly irrelevant (and untestable) if/when #138492 removes feature(inline_const_pat).

@oli-obk
Copy link
Contributor

oli-obk commented Mar 31, 2025

@oli-obk I assigned you for the last two commits, I'm not confident what I'm doing is correct. Also wondering if there's a cleaner way to write this.

The cleanest way is not to write it at all 😆 #138492 is removing inline consts entirely

@bors
Copy link
Collaborator

bors commented Apr 2, 2025

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

@Nadrieril Nadrieril force-pushed the simplify-expandedconstant branch from 0a75955 to d912c03 Compare April 6, 2025 15:35
@Nadrieril
Copy link
Member Author

I'm getting mixed signals about how fully we're removing inline_const_pats. In the meantime, this PR is up for review.

@oli-obk
Copy link
Contributor

oli-obk commented Apr 7, 2025

@bors r+

@bors
Copy link
Collaborator

bors commented Apr 7, 2025

📌 Commit d912c03 has been approved by oli-obk

It is now in the queue for this repository.

@bors bors added S-waiting-on-bors Status: Waiting on bors to run and complete tests. Bors will change the label on completion. and removed S-waiting-on-review Status: Awaiting review from the assignee but also interested parties. labels Apr 7, 2025
bors added a commit to rust-lang-ci/rust that referenced this pull request Apr 7, 2025
Rollup of 9 pull requests

Successful merges:

 - rust-lang#139035 (Add new `PatKind::Missing` variants)
 - rust-lang#139108 (Simplify `thir::PatKind::ExpandedConstant`)
 - rust-lang#139112 (Implement `super let`)
 - rust-lang#139365 (Default auto traits: fix perf)
 - rust-lang#139397 (coverage: Build the CGU's global file table as late as possible)
 - rust-lang#139455 ( Remove support for `extern "rust-intrinsic"` blocks)
 - rust-lang#139461 (Stop calling `source_span` query in significant drop order code)
 - rust-lang#139465 (add sret handling for scalar autodiff)
 - rust-lang#139466 (Trivial tweaks to stop tracking source span directly)

r? `@ghost`
`@rustbot` modify labels: rollup
@bors bors merged commit 9955b76 into rust-lang:master Apr 7, 2025
6 checks passed
@rustbot rustbot added this to the 1.88.0 milestone Apr 7, 2025
rust-timer added a commit to rust-lang-ci/rust that referenced this pull request Apr 7, 2025
Rollup merge of rust-lang#139108 - Nadrieril:simplify-expandedconstant, r=oli-obk

Simplify `thir::PatKind::ExpandedConstant`

I made it a bit less ad-hoc. In particular, I removed `is_inline: bool` that was just caching the output of `tcx.def_kind(def_id)`. This makes inline consts a tiny bit less special in patterns.

r? `@oli-obk`

cc `@Zalathar`
@Nadrieril Nadrieril deleted the simplify-expandedconstant branch April 7, 2025 20:04
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