Skip to content

implement #![feature(macroless_generic_const_args)] - #159058

Merged
rust-bors[bot] merged 1 commit into
rust-lang:mainfrom
khyperia:macroless_generic_const_args
Jul 21, 2026
Merged

implement #![feature(macroless_generic_const_args)]#159058
rust-bors[bot] merged 1 commit into
rust-lang:mainfrom
khyperia:macroless_generic_const_args

Conversation

@khyperia

@khyperia khyperia commented Jul 10, 2026

Copy link
Copy Markdown
Contributor

tracking issue: #159006

lots of description of what is happening here in the tracking issue, not gonna copypaste it into here :)

the test situation is that after discussion with boxy of whether our mgca tests should be:

  • keep them under only min_generic_const_args, and add direct_const_arg!() where it's needed
  • keep the code contents as-is, and add #![feature(macroless_generic_const_args)] where it's needed

the second seems more desirable, so that's what I did. There are still quite a few tests that only have min_generic_const_args without macroless_generic_const_args (140 of them, to be exact - rg --files-without-match macroless_generic_const_args $(rg -g '*.rs' --files-with-matches min_generic_const_args tests) | wc -l, and now 90 with macroless_generic_const_args)

r? @BoxyUwU

@rustbot

rustbot commented Jul 10, 2026

Copy link
Copy Markdown
Collaborator

Some changes occurred in tests/ui/sanitizer

cc @rcvalle

HIR ty lowering was modified

cc @fmease

@rustbot rustbot added PG-exploit-mitigations Project group: Exploit mitigations 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 10, 2026
@rustbot

rustbot commented Jul 10, 2026

Copy link
Copy Markdown
Collaborator

BoxyUwU is currently at their maximum review capacity.
They may take a while to respond.

Comment on lines 2688 to 2698
ConstItemRhsKind::TypeConst { rhs: Some(anon) } => {
hir::ConstItemRhs::TypeConst(self.lower_anon_const_to_const_arg_and_alloc(anon))
hir::ConstItemRhs::TypeConst(self.arena.alloc(
match self.can_lower_expr_to_const_arg_direct(
&anon.value,
DirectConstArgContext::MacrolessMinGenericConstArgs,
) {
Ok(()) => self.lower_expr_to_const_arg_direct(&anon.value, Some(anon.id)),
Err(err) => err.emit(self),
},
))
}

@khyperia khyperia Jul 10, 2026

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.

ConstItemRhsKind::TypeConst no longer needs to contain an AnonConst, it can parse identically to the rhs of a regular const, as a normal expr now.

Doing so I've left undone for now, will do so in a followup, it gets a bit more involved (and it's related to this #158617 (comment) that I might do at the same time)

View changes since the review

@rust-log-analyzer

This comment has been minimized.

@khyperia
khyperia force-pushed the macroless_generic_const_args branch from 925742b to 4e77ce1 Compare July 10, 2026 10:06
@rustbot

rustbot commented Jul 10, 2026

Copy link
Copy Markdown
Collaborator

This PR changes a file inside tests/crashes. If a crash was fixed, please move into the corresponding ui subdir and add 'Fixes #' to the PR description to autoclose the issue upon merge.

@rustbot rustbot added the T-rustdoc-frontend Relevant to the rustdoc-frontend team, which will review and decide on the web UI/UX output. label Jul 10, 2026
}
```

Using `#![macroless_generic_const_args]` enables you to write the above without the macro:

@kn1g78 kn1g78 Jul 10, 2026

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

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

I think this should be #![feature(macroless_generic_const_args)], as shown in the example below.

View changes since the review

@rust-bors

This comment has been minimized.

@khyperia
khyperia force-pushed the macroless_generic_const_args branch from 4e77ce1 to 6862ede Compare July 18, 2026 08:17
@rustbot

rustbot commented Jul 18, 2026

Copy link
Copy Markdown
Collaborator

This PR was rebased onto a different main commit. Here's a range-diff highlighting what actually changed.

Rebasing is a normal part of keeping PRs up to date, so no action is needed—this note is just to help reviewers.

@BoxyUwU BoxyUwU left a comment

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.

what's the behaviour of direct!(Foo { field: T::ASSOC })? Because I dont think we wan't to accept such a thing, instead field: direct!(T::ASSOC) should be required. Ideally macroful gca should not expose macroless gca's heuristic to any extent because then it needs to be figured out for stabilization 🤔

View changes since this review

@khyperia
khyperia force-pushed the macroless_generic_const_args branch from 6862ede to a388f03 Compare July 20, 2026 16:25
@BoxyUwU

BoxyUwU commented Jul 21, 2026

Copy link
Copy Markdown
Member

@bors r+

thx :3

@rust-bors

rust-bors Bot commented Jul 21, 2026

Copy link
Copy Markdown
Contributor

📌 Commit a388f03 has been approved by BoxyUwU

It is now in the queue for this repository.

@rust-bors rust-bors Bot 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 Jul 21, 2026
rust-bors Bot pushed a commit that referenced this pull request Jul 21, 2026
…uwer

Rollup of 7 pull requests

Successful merges:

 - #155617 (Replace `jemalloc` bootstrap options with `override-allocator`)
 - #156225 (feat(num): improve error messages for `TryFromIntError`)
 - #159058 (implement #![feature(macroless_generic_const_args)])
 - #159435 (core: implement `Rng` for references)
 - #159471 (Make `Global` and `System` allocators unstably implement `const Clone + const Default`.)
 - #159590 (Remove some dead code)
 - #159636 (Improve some comments (and an error message))
@rust-bors
rust-bors Bot merged commit fd4b1d5 into rust-lang:main Jul 21, 2026
13 checks passed
@rustbot rustbot added this to the 1.99.0 milestone Jul 21, 2026
rust-timer added a commit that referenced this pull request Jul 21, 2026
Rollup merge of #159058 - khyperia:macroless_generic_const_args, r=BoxyUwU

implement #![feature(macroless_generic_const_args)]

tracking issue: #159006

lots of description of what is happening here in the tracking issue, not gonna copypaste it into here :)

the test situation is that after discussion with boxy of whether our mgca tests should be:

- keep them under only `min_generic_const_args`, and add `direct_const_arg!()` where it's needed
- keep the code contents as-is, and add `#![feature(macroless_generic_const_args)]` where it's needed

the second seems more desirable, so that's what I did. There are still quite a few tests that only have `min_generic_const_args` without `macroless_generic_const_args` (140 of them, to be exact - `rg --files-without-match macroless_generic_const_args $(rg -g '*.rs' --files-with-matches min_generic_const_args tests) | wc -l`, and now 90 with `macroless_generic_const_args`)

r? @BoxyUwU
@khyperia
khyperia deleted the macroless_generic_const_args branch July 22, 2026 07:14
github-actions Bot pushed a commit to rust-lang/rustc-dev-guide that referenced this pull request Jul 23, 2026
…uwer

Rollup of 7 pull requests

Successful merges:

 - rust-lang/rust#155617 (Replace `jemalloc` bootstrap options with `override-allocator`)
 - rust-lang/rust#156225 (feat(num): improve error messages for `TryFromIntError`)
 - rust-lang/rust#159058 (implement #![feature(macroless_generic_const_args)])
 - rust-lang/rust#159435 (core: implement `Rng` for references)
 - rust-lang/rust#159471 (Make `Global` and `System` allocators unstably implement `const Clone + const Default`.)
 - rust-lang/rust#159590 (Remove some dead code)
 - rust-lang/rust#159636 (Improve some comments (and an error message))
JonathanBrouwer added a commit to JonathanBrouwer/rust that referenced this pull request Aug 10, 2026
…wU,bit-aloo

clean up handling of paths in mgca

related tracking issue: rust-lang#132980

Handling of ambiguous type-or-constant argument paths was really wonky and distinct from the regular `can_lower_expr_to_const_arg_direct` lowering paths. Clean that up and unify it, as discussed here rust-lang#158479 (comment)

Also, do a bunch of other little cleanups at the same time while I'm here:

- add support for parens to the inside of direct_const_arg! and macroless_generic_const_args (idk why this wasn't a thing before)
- add constant and lifetime ribs when resolving TyKind::DirectConstArg - note the TyKind, not ExprKind (~~I am unsure if/how this changes behavior~~ added a test, `direct-const-arg-correct-rib.rs`) - this was discussed here rust-lang#158617 (comment)
- minor debug logging change
- various minor code shuffles/cleanups
- add test for `direct_const_arg!(_)` inferring to a type - this test should have been added in rust-lang#159058 which added this behavior (well, changed the behavior from an ICE to inferring to a type)
- add a test asserting the current behavior of parens/braces/underscores on stable - one or two of these cases already have tests elsewhere, but it's nice to assert the whole set, and also assert the whole set in the same place so it's easily visible to be able to give me confidence the whole set actually is tested (both positives and negatives are important here)
- add a test similar to the previous one, but with mgca enabled, asserting all combinations now compile successfully

r? @BoxyUwU
rust-timer added a commit that referenced this pull request Aug 10, 2026
Rollup merge of #160216 - khyperia:gca-path-cleanup, r=BoxyUwU,bit-aloo

clean up handling of paths in mgca

related tracking issue: #132980

Handling of ambiguous type-or-constant argument paths was really wonky and distinct from the regular `can_lower_expr_to_const_arg_direct` lowering paths. Clean that up and unify it, as discussed here #158479 (comment)

Also, do a bunch of other little cleanups at the same time while I'm here:

- add support for parens to the inside of direct_const_arg! and macroless_generic_const_args (idk why this wasn't a thing before)
- add constant and lifetime ribs when resolving TyKind::DirectConstArg - note the TyKind, not ExprKind (~~I am unsure if/how this changes behavior~~ added a test, `direct-const-arg-correct-rib.rs`) - this was discussed here #158617 (comment)
- minor debug logging change
- various minor code shuffles/cleanups
- add test for `direct_const_arg!(_)` inferring to a type - this test should have been added in #159058 which added this behavior (well, changed the behavior from an ICE to inferring to a type)
- add a test asserting the current behavior of parens/braces/underscores on stable - one or two of these cases already have tests elsewhere, but it's nice to assert the whole set, and also assert the whole set in the same place so it's easily visible to be able to give me confidence the whole set actually is tested (both positives and negatives are important here)
- add a test similar to the previous one, but with mgca enabled, asserting all combinations now compile successfully

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

Labels

PG-exploit-mitigations Project group: Exploit mitigations 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. T-rustdoc-frontend Relevant to the rustdoc-frontend team, which will review and decide on the web UI/UX output.

Projects

None yet

Development

Successfully merging this pull request may close these issues.

5 participants