Skip to content

implement #![feature(macroless_generic_const_args)]#159058

Open
khyperia wants to merge 1 commit into
rust-lang:mainfrom
khyperia:macroless_generic_const_args
Open

implement #![feature(macroless_generic_const_args)]#159058
khyperia wants to merge 1 commit into
rust-lang:mainfrom
khyperia:macroless_generic_const_args

Conversation

@khyperia

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 :)

this embeds within it #158640 so this should not merge until that PR is merged and I can rebase on top of it. (that fix is required for this PR to function)

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 (142 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 86 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

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-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. 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