Skip to content

use #[align] attribute for fn_align #142507

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

Open
wants to merge 1 commit into
base: master
Choose a base branch
from

Conversation

folkertdev
Copy link
Contributor

Tracking issue: #82232

rust-lang/rfcs#3806 decides to add the #[align] attribute for alignment of various items. Right now it's used for functions with fn_align, in the future it will get more uses (statics, struct fields, etc.)

(the RFC finishes FCP today)

r? @ghost

@rustbot rustbot added A-attributes Area: Attributes (`#[…]`, `#![…]`) T-compiler Relevant to the compiler team, which will review and decide on the PR/issue. labels Jun 14, 2025
@rust-log-analyzer

This comment has been minimized.

@folkertdev folkertdev force-pushed the fn-align-align-attribute branch from 3d85cf8 to 8769e96 Compare June 14, 2025 15:24
@rust-log-analyzer

This comment has been minimized.

@folkertdev folkertdev force-pushed the fn-align-align-attribute branch from 8769e96 to 92fa35d Compare June 14, 2025 16:13
@folkertdev
Copy link
Contributor Author

@traviscross the FCP on #[align] is completed, but there is some discussion over there. I haven't seen anyone object to using #[align] though. Can we move forward with the attribute name change here (and then stabilize #140261), or should T-lang discuss the attribute change again first?

@traviscross
Copy link
Contributor

Given the RFC acceptance, this change is good to go as a lang matter.

Copy link
Contributor Author

@folkertdev folkertdev left a comment

Choose a reason for hiding this comment

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

Nice, in that case

r? @jdonszelmann

@folkertdev folkertdev marked this pull request as ready for review June 15, 2025 19:29
@rustbot rustbot added the S-waiting-on-review Status: Awaiting review from the assignee but also interested parties. label Jun 15, 2025
@rustbot
Copy link
Collaborator

rustbot commented Jun 15, 2025

The Miri subtree was changed

cc @rust-lang/miri

Some changes occurred in compiler/rustc_codegen_ssa

cc @WaffleLapkin

Some changes occurred in compiler/rustc_codegen_ssa/src/codegen_attrs.rs

cc @jdonszelmann

Some changes occurred in compiler/rustc_passes/src/check_attr.rs

cc @jdonszelmann

Some changes occurred in compiler/rustc_attr_parsing

cc @jdonszelmann

Some changes occurred in compiler/rustc_attr_data_structures

cc @jdonszelmann

@jdonszelmann
Copy link
Contributor

On my to-do list! Will take a look somewhere this week :)

cx: &'c mut AcceptContext<'_, '_, S>,
args: &'c ArgParser<'_>,
) {
// The builtin attributes parser already emits an error in this case.
Copy link
Contributor

Choose a reason for hiding this comment

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

by the template logic? I'd quite like to move those checks here at some point, including the templates. For converted attributes I usually have added an exception there to ignore attributes with new-style parsers so that these checks do do something, and all checks happen in one place. If you wouldn't mind, could you do the same for align?

Copy link
Contributor

Choose a reason for hiding this comment

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

With #138165 you don't need to make a new diagnostic for this either which should make your life easier.

Copy link
Contributor Author

Choose a reason for hiding this comment

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

by the template logic?

Exactly

If you wouldn't mind, could you do the same for align?

Do you have an example here? E.g ConfusablesParser also seems to ignore this case?

Copy link
Contributor

Choose a reason for hiding this comment

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

yea! I've been making exceptions to new attributes here:


and then add proper validation for them here:

(n.b. I exhaustively match and error on all cases)

Copy link
Contributor Author

Choose a reason for hiding this comment

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

I think those links are to #138165? Should I rebase on that now? (happy to, but could also do a follow-up later)

Copy link
Contributor

Choose a reason for hiding this comment

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

I think rebasing would be nice, then this parser is in a much nicer state. Otherwise I'll go back to fix it next week again. That #138165 seems to make good progress.

fluent::passes_repr_align_function,
)
.emit();
self.dcx().emit_err(errors::ReprAlignShouldBeAlign {
Copy link
Contributor

Choose a reason for hiding this comment

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

love these helpful diagnostics :)

@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 Jun 15, 2025
@folkertdev folkertdev force-pushed the fn-align-align-attribute branch from 92fa35d to 61e20fa Compare June 16, 2025 11:24
@bors
Copy link
Collaborator

bors commented Jun 16, 2025

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

@jdonszelmann
Copy link
Contributor

@folkertdev master now has these changes to diagnostics :)

@folkertdev folkertdev force-pushed the fn-align-align-attribute branch from 61e20fa to ba3c409 Compare June 18, 2025 09:50
@rust-log-analyzer

This comment has been minimized.

Right now it's used for functions with `fn_align`, in the future it will
get more uses (statics, struct fields, etc.)
@folkertdev folkertdev force-pushed the fn-align-align-attribute branch from ba3c409 to 1fdf2b5 Compare June 18, 2025 10:37
@jdonszelmann
Copy link
Contributor

much better

@jdonszelmann
Copy link
Contributor

jdonszelmann commented Jun 18, 2025

bors-r-plus

@bors rollup=always

@bors
Copy link
Collaborator

bors commented Jun 18, 2025

📌 Commit 1fdf2b5 has been approved by jdonszelmann

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 Jun 18, 2025
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
A-attributes Area: Attributes (`#[…]`, `#![…]`) 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