Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Use ConstArgKind::Path for all single-segment paths, not just params under min_generic_const_args #131081

Merged
merged 2 commits into from
Nov 19, 2024

Conversation

camelid
Copy link
Member

@camelid camelid commented Oct 1, 2024

r? @BoxyUwU

edit by @BoxyUwU:

This PR introduces a min_generic_const_args feature gate and implements some preliminary work for it, representing all const arguments that are single segment paths as ConstArg::Path instead of only those that resolve to a const generic parameter. There are a few bits of follow up work after this lands:

  • Figure out how to represent Foo<{ STATIC }>
  • Figure out how to evaluate Foo<{ EnumVariantConstructor }>
  • Make param env normalization handle non-anon-consts
  • Move try_from_lit and from_anon_const to hir ty lowering too

@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 Oct 1, 2024
@camelid camelid force-pushed the const-path-it-all branch from 2b73426 to 87b1f29 Compare October 1, 2024 04:51
@rust-log-analyzer

This comment has been minimized.

@camelid camelid force-pushed the const-path-it-all branch from c43d981 to 883a4ba Compare October 6, 2024 22:41
@rust-log-analyzer

This comment has been minimized.

@bors
Copy link
Contributor

bors commented Oct 13, 2024

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

@rust-log-analyzer

This comment has been minimized.

@bors
Copy link
Contributor

bors commented Oct 21, 2024

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

@camelid camelid force-pushed the const-path-it-all branch 2 times, most recently from 4494a71 to 034661e Compare October 21, 2024 16:29
@rust-log-analyzer

This comment has been minimized.

@rust-log-analyzer

This comment has been minimized.

@rust-log-analyzer

This comment has been minimized.

@rust-log-analyzer

This comment has been minimized.

compiler/rustc_ast_lowering/src/lib.rs Outdated Show resolved Hide resolved
compiler/rustc_ast_lowering/src/lib.rs Outdated Show resolved Hide resolved
@rust-log-analyzer

This comment has been minimized.

@rust-log-analyzer

This comment has been minimized.

@camelid camelid changed the title Begin to use ConstArgKind::Path for all paths, not just params Use ConstArgKind::Path for all single-segment paths, not just params Oct 28, 2024
@camelid camelid marked this pull request as ready for review October 28, 2024 18:50
@rustbot
Copy link
Collaborator

rustbot commented Oct 28, 2024

HIR ty lowering was modified

cc @fmease

@rust-log-analyzer

This comment has been minimized.

Copy link
Member

@BoxyUwU BoxyUwU left a comment

Choose a reason for hiding this comment

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

✨ thanks for working on this, excited to be able to add the min_generic_const_args feature gate soon after all of these refactorings 😅

compiler/rustc_ast_lowering/src/lib.rs Show resolved Hide resolved
compiler/rustc_ast_lowering/src/lib.rs Show resolved Hide resolved
compiler/rustc_ast_lowering/src/lib.rs Show resolved Hide resolved
compiler/rustc_const_eval/src/const_eval/eval_queries.rs Outdated Show resolved Hide resolved
compiler/rustc_hir_analysis/src/collect.rs Show resolved Hide resolved
compiler/rustc_hir_analysis/src/lib.rs Outdated Show resolved Hide resolved
compiler/rustc_middle/src/ty/consts.rs Show resolved Hide resolved
compiler/rustc_hir_analysis/src/hir_ty_lowering/mod.rs Outdated Show resolved Hide resolved
compiler/rustc_hir_analysis/src/hir_ty_lowering/mod.rs Outdated Show resolved Hide resolved
compiler/rustc_hir_analysis/src/hir_ty_lowering/mod.rs Outdated Show resolved Hide resolved
@bors
Copy link
Contributor

bors commented Oct 31, 2024

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

@rust-log-analyzer

This comment has been minimized.

@BoxyUwU
Copy link
Member

BoxyUwU commented Nov 14, 2024

also you'll need to squash all these commits before merging

@BoxyUwU BoxyUwU 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 Nov 15, 2024
Co-authored-by: Boxy UwU <[email protected]>
Co-authored-by: León Orell Valerian Liehr <[email protected]>
@BoxyUwU BoxyUwU changed the title Use ConstArgKind::Path for all single-segment paths, not just params Use ConstArgKind::Path for all single-segment paths, not just params under min_generic_const_params Nov 19, 2024
@BoxyUwU BoxyUwU changed the title Use ConstArgKind::Path for all single-segment paths, not just params under min_generic_const_params Use ConstArgKind::Path for all single-segment paths, not just params under min_generic_const_args Nov 19, 2024
@rust-log-analyzer

This comment has been minimized.

@BoxyUwU
Copy link
Member

BoxyUwU commented Nov 19, 2024

rebased and squashed commits for you as well as blessing the stable mir test now that those changes have been reverted. we can follow up on everything else later. Having the feature gate will be super nice thanks :3

@bors r+

@bors
Copy link
Contributor

bors commented Nov 19, 2024

📌 Commit 473b5d5 has been approved by BoxyUwU

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-author Status: This is awaiting some action (such as code changes or more information) from the author. labels Nov 19, 2024
bors added a commit to rust-lang-ci/rust that referenced this pull request Nov 19, 2024
…iaskrgr

Rollup of 4 pull requests

Successful merges:

 - rust-lang#131081 (Use `ConstArgKind::Path` for all single-segment paths, not just params under `min_generic_const_args`)
 - rust-lang#132577 (Report the `unexpected_cfgs` lint in external macros)
 - rust-lang#133023 (Merge `-Zhir-stats` into `-Zinput-stats`)
 - rust-lang#133200 (ignore an occasionally-failing test in Miri)

r? `@ghost`
`@rustbot` modify labels: rollup
bors added a commit to rust-lang-ci/rust that referenced this pull request Nov 19, 2024
…iaskrgr

Rollup of 4 pull requests

Successful merges:

 - rust-lang#131081 (Use `ConstArgKind::Path` for all single-segment paths, not just params under `min_generic_const_args`)
 - rust-lang#132577 (Report the `unexpected_cfgs` lint in external macros)
 - rust-lang#133023 (Merge `-Zhir-stats` into `-Zinput-stats`)
 - rust-lang#133200 (ignore an occasionally-failing test in Miri)

r? `@ghost`
`@rustbot` modify labels: rollup
@bors bors merged commit 5f586ef into rust-lang:master Nov 19, 2024
6 checks passed
@rustbot rustbot added this to the 1.84.0 milestone Nov 19, 2024
rust-timer added a commit to rust-lang-ci/rust that referenced this pull request Nov 19, 2024
Rollup merge of rust-lang#131081 - camelid:const-path-it-all, r=BoxyUwU

Use `ConstArgKind::Path` for all single-segment paths, not just params under `min_generic_const_args`

r? `@BoxyUwU`

edit by `@BoxyUwU:`

This PR introduces a `min_generic_const_args` feature gate and implements some preliminary work for it, representing all const arguments that are single segment paths as `ConstArg::Path` instead of only those that resolve to a const generic parameter. There are a few bits of follow up work after this lands:
- Figure out how to represent `Foo<{ STATIC }>`
- Figure out how to evaluate `Foo<{ EnumVariantConstructor }>`
- Make param env normalization handle non-anon-consts
- Move `try_from_lit` and `from_anon_const` to hir ty lowering too
@camelid camelid deleted the const-path-it-all branch November 20, 2024 06:29
camelid added a commit to camelid/rust that referenced this pull request Nov 29, 2024
These operations are much more about lowering the HIR than about
`Const`s themselves. They fit better in hir_ty_lowering with
`lower_const_arg` (formerly `Const::from_const_arg`) and the rest.

To accomplish this, `const_evaluatable_predicates_of` had to be changed
to not use `from_anon_const` anymore. Instead of visiting the HIR and
lowering anon consts on the fly, it now visits the `rustc_middle::ty`
data structures instead and directly looks for `UnevaluatedConst`s. This
approach was proposed in:
rust-lang#131081 (comment)
camelid added a commit to camelid/rust that referenced this pull request Nov 29, 2024
These operations are much more about lowering the HIR than about
`Const`s themselves. They fit better in hir_ty_lowering with
`lower_const_arg` (formerly `Const::from_const_arg`) and the rest.

To accomplish this, `const_evaluatable_predicates_of` had to be changed
to not use `from_anon_const` anymore. Instead of visiting the HIR and
lowering anon consts on the fly, it now visits the `rustc_middle::ty`
data structures instead and directly looks for `UnevaluatedConst`s. This
approach was proposed in:
rust-lang#131081 (comment)
camelid added a commit to camelid/rust that referenced this pull request Nov 29, 2024
These operations are much more about lowering the HIR than about
`Const`s themselves. They fit better in hir_ty_lowering with
`lower_const_arg` (formerly `Const::from_const_arg`) and the rest.

To accomplish this, `const_evaluatable_predicates_of` had to be changed
to not use `from_anon_const` anymore. Instead of visiting the HIR and
lowering anon consts on the fly, it now visits the `rustc_middle::ty`
data structures instead and directly looks for `UnevaluatedConst`s. This
approach was proposed in:
rust-lang#131081 (comment)
bors added a commit to rust-lang-ci/rust that referenced this pull request Nov 29, 2024
Move `Const::{from_anon_const,try_from_lit}` to hir_ty_lowering

Fixes rust-lang#128176.
This accomplishes one of the followup items from rust-lang#131081.

These operations are much more about lowering the HIR than about
`Const`s themselves. They fit better in hir_ty_lowering with
`lower_const_arg` (formerly `Const::from_const_arg`) and the rest.

To accomplish this, `const_evaluatable_predicates_of` had to be changed
to not use `from_anon_const` anymore. Instead of visiting the HIR and
lowering anon consts on the fly, it now visits the `rustc_middle::ty`
data structures instead and directly looks for `UnevaluatedConst`s. This
approach was proposed in:
rust-lang#131081 (comment)

r? `@BoxyUwU`
BoxyUwU pushed a commit to BoxyUwU/rust that referenced this pull request Dec 2, 2024
These operations are much more about lowering the HIR than about
`Const`s themselves. They fit better in hir_ty_lowering with
`lower_const_arg` (formerly `Const::from_const_arg`) and the rest.

To accomplish this, `const_evaluatable_predicates_of` had to be changed
to not use `from_anon_const` anymore. Instead of visiting the HIR and
lowering anon consts on the fly, it now visits the `rustc_middle::ty`
data structures instead and directly looks for `UnevaluatedConst`s. This
approach was proposed in:
rust-lang#131081 (comment)
BoxyUwU pushed a commit to camelid/rust that referenced this pull request Dec 2, 2024
These operations are much more about lowering the HIR than about
`Const`s themselves. They fit better in hir_ty_lowering with
`lower_const_arg` (formerly `Const::from_const_arg`) and the rest.

To accomplish this, `const_evaluatable_predicates_of` had to be changed
to not use `from_anon_const` anymore. Instead of visiting the HIR and
lowering anon consts on the fly, it now visits the `rustc_middle::ty`
data structures instead and directly looks for `UnevaluatedConst`s. This
approach was proposed in:
rust-lang#131081 (comment)
BoxyUwU pushed a commit to camelid/rust that referenced this pull request Dec 2, 2024
These operations are much more about lowering the HIR than about
`Const`s themselves. They fit better in hir_ty_lowering with
`lower_const_arg` (formerly `Const::from_const_arg`) and the rest.

To accomplish this, `const_evaluatable_predicates_of` had to be changed
to not use `from_anon_const` anymore. Instead of visiting the HIR and
lowering anon consts on the fly, it now visits the `rustc_middle::ty`
data structures instead and directly looks for `UnevaluatedConst`s. This
approach was proposed in:
rust-lang#131081 (comment)
GuillaumeGomez added a commit to GuillaumeGomez/rust that referenced this pull request Dec 2, 2024
…xyUwU

Move `Const::{from_anon_const,try_from_lit}` to hir_ty_lowering

Fixes rust-lang#128176.
This accomplishes one of the followup items from rust-lang#131081.

These operations are much more about lowering the HIR than about
`Const`s themselves. They fit better in hir_ty_lowering with
`lower_const_arg` (formerly `Const::from_const_arg`) and the rest.

To accomplish this, `const_evaluatable_predicates_of` had to be changed
to not use `from_anon_const` anymore. Instead of visiting the HIR and
lowering anon consts on the fly, it now visits the `rustc_middle::ty`
data structures instead and directly looks for `UnevaluatedConst`s. This
approach was proposed in:
rust-lang#131081 (comment)

r? `@BoxyUwU`
rust-timer added a commit to rust-lang-ci/rust that referenced this pull request Dec 3, 2024
Rollup merge of rust-lang#133610 - camelid:move-from_anon_const, r=BoxyUwU

Move `Const::{from_anon_const,try_from_lit}` to hir_ty_lowering

Fixes rust-lang#128176.
This accomplishes one of the followup items from rust-lang#131081.

These operations are much more about lowering the HIR than about
`Const`s themselves. They fit better in hir_ty_lowering with
`lower_const_arg` (formerly `Const::from_const_arg`) and the rest.

To accomplish this, `const_evaluatable_predicates_of` had to be changed
to not use `from_anon_const` anymore. Instead of visiting the HIR and
lowering anon consts on the fly, it now visits the `rustc_middle::ty`
data structures instead and directly looks for `UnevaluatedConst`s. This
approach was proposed in:
rust-lang#131081 (comment)

r? `@BoxyUwU`
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