-
Notifications
You must be signed in to change notification settings - Fork 13.8k
Implement #[rustc_align_static(N)]
on static
s
#146178
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
Conversation
The Miri subtree was changed cc @rust-lang/miri Some changes occurred in compiler/rustc_attr_parsing Some changes occurred in compiler/rustc_passes/src/check_attr.rs Some changes occurred to the CTFE / Miri interpreter cc @rust-lang/miri Some changes occurred in compiler/rustc_codegen_gcc Some changes occurred to the CTFE machinery |
What do you mean by "use"? How does a feature "use" an attribute? |
), | ||
// FIXME(#82232, #143834): temporarily renamed to mitigate `#[align]` nameres ambiguity | ||
gated!(rustc_align, Normal, template!(List: &["alignment"]), DuplicatesOk, EncodeCrossCrate::No, fn_align, experimental!(rustc_align)), | ||
gated!(rustc_align_static, Normal, template!(List: &["alignment"]), DuplicatesOk, EncodeCrossCrate::No, static_align, experimental!(rustc_align_static)), |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
@RalfJung this is where the attribute gets declared, and the feature name on this line (static_align
in this case) must be unique
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
That's very odd, why does it have to be unique? That's not how features work anywhere else in the compiler, AFAIK.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
ah, sorry, what I meant by unique is that an attribute must be tied to one unstable feature. #[rustc_align]
is already tied to fn_align
, so it can't also be used for static_align
.
So, one unstable feature can "contain" multiple attributes, but an attribute always is tied to only one unstable feature.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Ah, by "attribute used for feature" you mean "attribute is gated by feature". That's a rather confusing and non-standard way of saying things.^^
So what you want is to have a separate feature gate for aligning functions vs aligning statics, and the attribute registration macro isn't flexible enough to allow that. rustc_align
is for functions only, despite its name sounding more general.
Since these are all temporary names anyway, I guess it doesn't matter too much, but when it comes to stabilization we very much might need the ability to stabilize an attribute in some positions while leaving it unstable elsewhere. Otherwise we have no way of unstably extending where an existing stable attribute can be used. So this limitation of attribute feature gating seems like it could become problematic. Cc @jdonszelmann
This needs tests for:
|
This comment has been minimized.
This comment has been minimized.
Is there any interesting behavior to test here? (I'll add a test for the attribute being valid).
hmm, the rust/library/std/src/sys/thread_local/native/mod.rs Lines 107 to 110 in fd75a9c
|
190ad9c
to
07f4381
Compare
#[rustc_align_static(N)]
on static
s#[rustc_align_static(N)]
on static
s
This comment has been minimized.
This comment has been minimized.
07f4381
to
d66847e
Compare
This comment has been minimized.
This comment has been minimized.
Here is an implementation for |
d66847e
to
6f0825e
Compare
This comment has been minimized.
This comment has been minimized.
That's odd, the miri tests pass for me locally. Do those somehow cache the standard library even when you don't pass |
389dad1
to
602e757
Compare
Miri has its own standard library build but it should usually be recompiled automatically when anything changed. |
The error might only occur after merging the branch with latest master (which happens implicitly in CI). |
Doesn’t that apply only to Bors CI? (E.g. Bors try or Bors r+) |
some minor questions: @rustbot author |
Reminder, once the PR becomes ready for a review, use |
We need a different attribute than `rustc_align` because unstable attributes are tied to their feature (we can't have two unstable features use the same unstable attribute). Otherwise this uses all of the same infrastructure as `#[rustc_align]`.
af834f3
to
cbacd00
Compare
Keeping them separate seemed most flexible in terms of what/how to stabilize. What we'll do exactly is a bit up in the air, pending a path forward for making @rustbot ready |
@bors r=jdonszelmann,ralfjung |
…lmann,ralfjung Implement `#[rustc_align_static(N)]` on `static`s Tracking issue: rust-lang#146177 ```rust #![feature(static_align)] #[rustc_align_static(64)] static SO_ALIGNED: u64 = 0; ``` We need a different attribute than `rustc_align` because unstable attributes are tied to their feature (we can't have two unstable features use the same unstable attribute). Otherwise this uses all of the same infrastructure as `#[rustc_align]`. r? `@traviscross`
…lmann,ralfjung Implement `#[rustc_align_static(N)]` on `static`s Tracking issue: rust-lang#146177 ```rust #![feature(static_align)] #[rustc_align_static(64)] static SO_ALIGNED: u64 = 0; ``` We need a different attribute than `rustc_align` because unstable attributes are tied to their feature (we can't have two unstable features use the same unstable attribute). Otherwise this uses all of the same infrastructure as `#[rustc_align]`. r? ``@traviscross``
@bors r=jdonszelmann,ralfjung,traviscross |
💡 This pull request was already approved, no need to approve it again.
|
Note that a stabilization PR should just swap the feature gate, not rename anything. (That makes it easier to review, easier to revert, and ensures the thing we had on nightly is actually what we are stabilizing.) So if in the stable form, the attributes should have the same name, then that rename should happen separately from stabilization. But IIUC, in this case the name itself is still subject to bikeshedding. |
Rollup of 6 pull requests Successful merges: - #144765 (inclusive `Range`s: change `end` to `last`) - #145177 (std: move `thread` into `sys`) - #146178 (Implement `#[rustc_align_static(N)]` on `static`s) - #146368 (CI: rfl: move job forward to Linux v6.17-rc5 to remove temporary commits) - #146378 (Update wasm-component-ld to 0.5.17) - #146391 (Trim paths less in MIR dumping) r? `@ghost` `@rustbot` modify labels: rollup
Rollup of 5 pull requests Successful merges: - #144765 (inclusive `Range`s: change `end` to `last`) - #146178 (Implement `#[rustc_align_static(N)]` on `static`s) - #146368 (CI: rfl: move job forward to Linux v6.17-rc5 to remove temporary commits) - #146378 (Update wasm-component-ld to 0.5.17) - #146391 (Trim paths less in MIR dumping) r? `@ghost` `@rustbot` modify labels: rollup
Rollup of 5 pull requests Successful merges: - #144765 (inclusive `Range`s: change `end` to `last`) - #146178 (Implement `#[rustc_align_static(N)]` on `static`s) - #146368 (CI: rfl: move job forward to Linux v6.17-rc5 to remove temporary commits) - #146378 (Update wasm-component-ld to 0.5.17) - #146391 (Trim paths less in MIR dumping) r? `@ghost` `@rustbot` modify labels: rollup
Rollup merge of #146178 - folkertdev:static-align, r=jdonszelmann,ralfjung,traviscross Implement `#[rustc_align_static(N)]` on `static`s Tracking issue: #146177 ```rust #![feature(static_align)] #[rustc_align_static(64)] static SO_ALIGNED: u64 = 0; ``` We need a different attribute than `rustc_align` because unstable attributes are tied to their feature (we can't have two unstable features use the same unstable attribute). Otherwise this uses all of the same infrastructure as `#[rustc_align]`. r? `@traviscross`
Rollup of 5 pull requests Successful merges: - rust-lang/rust#144765 (inclusive `Range`s: change `end` to `last`) - rust-lang/rust#146178 (Implement `#[rustc_align_static(N)]` on `static`s) - rust-lang/rust#146368 (CI: rfl: move job forward to Linux v6.17-rc5 to remove temporary commits) - rust-lang/rust#146378 (Update wasm-component-ld to 0.5.17) - rust-lang/rust#146391 (Trim paths less in MIR dumping) r? `@ghost` `@rustbot` modify labels: rollup
Tracking issue: #146177
We need a different attribute than
rustc_align
because unstable attributes are tied to their feature (we can't have two unstable features use the same unstable attribute). Otherwise this uses all of the same infrastructure as#[rustc_align]
.r? @traviscross