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

let Some(list) = args.list() else { return };

let Some(align) = list.single() else {
cx.dcx()
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 these error messages will become much nicer. I expect that to merge this week, which would simplify this PR a little. I'm tempted to ask you to rebase on that, but let's wait for @oli-obk s review on that. If that ones takes long we can merge this first as is.

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'll leave the scheduling up to you :)

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?

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
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 92fa35d to 61e20fa Compare June 16, 2025 11:24
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-author Status: This is awaiting some action (such as code changes or more information) from the author. 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.

5 participants