-
Notifications
You must be signed in to change notification settings - Fork 12.8k
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
upgrade thread_local! invocation syntax #34077
Conversation
r? @aturon (rust_highfive has picked a reviewer for you, use r? to override) |
@@ -106,12 +106,20 @@ pub struct LocalKey<T: 'static> { | |||
#[stable(feature = "rust1", since = "1.0.0")] | |||
#[allow_internal_unstable] |
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.
this attribute must be redundant since I was able to simply copy the macro into a playpen, right?
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.
OK, it shouldn't be redundant because __thread_local_inner!
is marked unstable, but something is failing to check that!
BTW, RFC 1422 However, as long as RFC 1575 languishes, it requires the ugly reparse trick. |
It might be good to do a crater run just to be super sure this doesn't break anything, but otherwise this is a change in the API of the macro so I'm gonna tag with T-libs to ensure it receives discussion. There is some previous discussion about allowing attributes on thread locals but it ended up largely being inconclusive (and didn't happen despite the name of the PR and the merging of the PR). |
Oh and also, can you be sure to add tests which exercise this syntax as well? |
I'll add tests and comments in the morning. I just read that previous discussion and it seems to me to support this The change to allow semicolons and multiple declarations is just sugar, but
|
I think this is ready for cratering cc @brson |
I'll start a crater run. |
Here are the toolchain builds:
When these are done I can run the crate builds. |
I've started the crate builds. |
@durka https://gist.github.com/brson/b15d70b39e356af286cbf404c0d07286 sorry it took so long. |
No regressions! |
cc @rust-lang/libs Any concerns about this change? Passes crater with no regressions. |
👍 |
); | ||
|
||
// rule 2: handle a single private declaration | ||
($(#[$attr:meta])* static $name:ident: $t:ty = $init:expr $(;)*) => ( |
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.
This'll unfortunately accept syntax like:
thread_local!(static FOO: usize = 2 ;;;;;;;;;;;;;;;;;;;;;);
Although I'm not sure how much we can do about that.
I'd prefer to not accept the syntax I mentioned above, but I don't feel particularly strongly about that and would be fine landing. |
I don't have strong opinions about this. |
@alexcrichton so add a one-or-none macro matcher :)
|
@alexcrichton fixed, at the expense of accepting |
Ok, thanks @durka! This does mean that |
The libs team discussed this during triage today and the conclusion was to merge. Thanks again for the PR and the patience @durka! If you want to squash the commits I'll r+ |
🏁 |
Looks like the travis error is probably legit:
|
That's what I get for not testing my doc example! Though I did test it in
|
Allows declaring multiple statics in one macro invocation, and supports attaching attributes to the generated items.
@alexcrichton OK, I think it's a bug and I filed #34418. Travis should pass now (if it fails again I'll relent and run the build locally). |
⌛ Testing commit fc28ee2 with merge aeebcfd... |
💔 Test failed - auto-mac-64-opt |
Spurious failure, LLVM didn't build
|
@bors: retry On Thu, Jun 23, 2016 at 4:19 PM, Alex Burka notifications@github.com
|
⌛ Testing commit fc28ee2 with merge c7e8ee9... |
💔 Test failed - auto-mac-cross-ios-opt |
@bors: retry On Thu, Jun 23, 2016 at 4:54 PM, bors notifications@github.com wrote:
|
upgrade thread_local! invocation syntax Allows declaring multiple statics in one macro invocation, and supports attaching attributes to the generated items. In particular, `#![forbid(missing_docs, unused)]` is now tenable on a crate/module containing thread locals. For an example see [here](https://is.gd/aVFZZF). This change is fully backwards compatible as far as I can tell. cc @frankmcsherry
Allows declaring multiple statics in one macro invocation, and supports attaching attributes to the generated items. In particular,
#![forbid(missing_docs, unused)]
is now tenable on a crate/module containing thread locals.For an example see here. This change is fully backwards compatible as far as I can tell.
cc @frankmcsherry