Join GitHub today
GitHub is home to over 31 million developers working together to host and review code, manage projects, and build software together.
Sign upRFC: #[used] static variables #2386
Conversation
This was referenced Apr 3, 2018
Centril
added
the
T-lang
label
Apr 3, 2018
This comment has been minimized.
This comment has been minimized.
|
While I know that C using I personally think that |
This comment has been minimized.
This comment has been minimized.
phil-opp
commented
Apr 5, 2018
•
|
|
This comment has been minimized.
This comment has been minimized.
|
I'm inclined to merge -- this seems pretty low risk. If we come up with some other attribute that can serve this purpose, we can always deprecate |
Centril
self-assigned this
Apr 12, 2018
This comment has been minimized.
This comment has been minimized.
jminer
commented
Apr 13, 2018
|
I think the attribute should be renamed. I think a verb would fit Rust's naming conventions better instead of an adjective. My day job is mainly embedded development, and IAR's linker uses a |
This comment has been minimized.
This comment has been minimized.
mjbshaw
commented
Apr 13, 2018
•
|
Yes, "used" isn't the most straight-forward name. I personally prefer something like I'd rather have |
This comment has been minimized.
This comment has been minimized.
|
Deprecating just for the sake of name most likely won't ever happen, so if
we aren't content with the name the time to bikeshed is now.
I use both IAR and Linux toolchains and am more partial to GCC naming
convention, but admittedly #[used] clashes somewhat with #[must_use].
On Fri, Apr 13, 2018, 06:34 Michael Bradshaw <notifications@github.com>
wrote:
Yes, "used" isn't the most straight-forward name. I personally prefer
something like #[preserve(linker)] (with #[keep] as second(ish) choice; I
prefer to avoid negation where possible (e.g. #[no_remove])). The primary
benefit of the name #[used] is that it matches LLVM's and GCC's
__attribute__((used)). People familiar with LLVM's and GCC's attribute
should easily understand what #[used] does.
I'd rather have #[used] (as-is, with its current name) sooner rather than
bikeshed the name and delay its stabilization. I've got some code that's
raring to use it. A follow-up RFC could always introduce a new name (and
deprecate the "used" name).
—
You are receiving this because you are subscribed to this thread.
Reply to this email directly, view it on GitHub
<#2386 (comment)>, or mute
the thread
<https://github.com/notifications/unsubscribe-auth/AApc0v4opUHRh3QE_VB0do9ig3knZdnQks5toBzNgaJpZM4TFjol>
.
On Apr 13, 2018 06:34, "Michael Bradshaw" <notifications@github.com> wrote:
Yes, "used" isn't the most straight-forward name. I personally prefer
something like #[preserve(linker)] (with #[keep] as second(ish) choice; I
prefer to avoid negation where possible (e.g. #[no_remove])). The primary
benefit of the name #[used] is that it matches LLVM's and GCC's
__attribute__((used)). People familiar with LLVM's and GCC's attribute
should easily understand what #[used] does.
I'd rather have #[used] (as-is, with its current name) sooner rather than
bikeshed the name and delay its stabilization. I've got some code that's
raring to use it. A follow-up RFC could always introduce a new name (and
deprecate the "used" name).
—
You are receiving this because you are subscribed to this thread.
Reply to this email directly, view it on GitHub
<#2386 (comment)>, or mute
the thread
<https://github.com/notifications/unsubscribe-auth/AApc0v4opUHRh3QE_VB0do9ig3knZdnQks5toBzNgaJpZM4TFjol>
.
|
This comment has been minimized.
This comment has been minimized.
|
So, collecting what's proposed:
I would also propose |
This comment has been minimized.
This comment has been minimized.
|
@japaric We discussed this on the latest lang team meeting and the feeling was that |
This comment has been minimized.
This comment has been minimized.
ssokolow
commented
Apr 20, 2018
•
|
I'm not part of the target user base, but I don't see a 9-character name like |
This comment has been minimized.
This comment has been minimized.
jcsoo
commented
Apr 24, 2018
|
Discussed at the embedded-wg meeting, and #[link_keep] sounds fine. |
This comment has been minimized.
This comment has been minimized.
|
#[link_keep] says to me that this is something the link step (so, the
linker) should keep rather than something that should be kept intact until
linking.
…On Tue, Apr 24, 2018, 22:16 Jonathan Soo ***@***.***> wrote:
Discussed at the embedded-wg meeting, and #[link_keep] sounds fine.
—
You are receiving this because you commented.
Reply to this email directly, view it on GitHub
<#2386 (comment)>, or mute
the thread
<https://github.com/notifications/unsubscribe-auth/AApc0uBBm6mkBuiiLtPCOOv9XruD3FJXks5tr3oZgaJpZM4TFjol>
.
|
This comment has been minimized.
This comment has been minimized.
To further elaborate: we are fine with any name. Personally, I'd rather not spend much time trying to find the "perfect" name. Very few people are going to directly deal with this feature; most people will depend on it because some crate in their dependency graph is using it. Some other people will indirectly use this feature behind a macro that ensures that's not misused ( Ultimately, I think the documentation is more important than the name of the feature and that's already covered by the RFC. All the suggested names sound fine to me; anyone will do, IMO. |
This comment has been minimized.
This comment has been minimized.
|
We briefly discussed this RFC in the last lang team meeting to generally positive response. We need to resolve the naming, but I'm going to go ahead and push toward FCP/full review: @rfcbot fcp merge |
rfcbot
added
the
proposed-final-comment-period
label
Apr 26, 2018
This comment has been minimized.
This comment has been minimized.
rfcbot
commented
Apr 26, 2018
•
|
Team member @aturon has proposed to merge this. The next step is review by the rest of the tagged teams: Concerns:
Once a majority of reviewers approve (and none object), this will enter its final comment period. If you spot a major issue that hasn't been raised at any point in this process, please speak up! See this document for info about what commands tagged team members can give me. |
This comment has been minimized.
This comment has been minimized.
|
@nagisa While that reading is possible, I think in this case,
|
This comment has been minimized.
This comment has been minimized.
|
I'm fine with (Edit: no longer fine with |
This comment has been minimized.
This comment has been minimized.
|
Let me elaborate on my comment. I’m a target audience for Even with good documentation, there’s a lot of value in concept having a self-descriptive name for people who are already familiar with said concept. So, even if somebody duckduckcame upon this attribute, without knowing about it a priori, it would require them to read through the whole documentation on the attribute to make sure it does what they want it to do. Lest they miss that extremely subtle distinction between attribute keeping items until or after linking (and they wanted the latter), they would spend a good few hours pondering why the attribute is “not working”. The name is outright confusing. I do agree that the attribute doesn’t need to be very terse, though, and thus |
This comment has been minimized.
This comment has been minimized.
|
@rfcbot concern attribute-name @nagisa That's a very good point! I hadn't thought about the potential implication there, but you're right, this doesn't affect the linker, it affects the compiler. That does make Given that, I'd personally favor I think this goes beyond bikeshedding, because there's a serious question here about compatibility (with widespread existing understanding) and descriptiveness (can we make something sufficiently more descriptive that it's worth not using the name "used" with all the understanding attached to that name). |
This comment has been minimized.
This comment has been minimized.
|
My 2 cents: While I don't have a strong opinion on the name, I tend to think that using a "familiar" name is a decent thing, in the absence of a strong alternative -- that is, I expect that most people who want this feature will go looking for it by asking "what is the equivalent to |
This comment has been minimized.
This comment has been minimized.
|
OK; So I was writing this comment about how That said, if Beyond this RFC, and on a tangent, @joshtriplett raised the idea on the lang meeting today of some more general mechanism by which you can search for an attribute via https://doc.rust-lang.org/nightly/std/?search=%23%5Bused%5D. cc @rust-lang/docs on that. |
This comment has been minimized.
This comment has been minimized.
|
@Centril Thanks for capturing that! I do think that'd be generally useful for things like "what do you call |
This comment has been minimized.
This comment has been minimized.
|
@joshtriplett At least for the "what's the trait associated with this operator", we've just gotten those added in thanks to rust-lang/rust#49757 and rust-lang/rust#50231. The issue for searching for specific attributes in the standard library docs is that most often there's no page for it to land on. The Reference is the better place for that. |
This comment has been minimized.
This comment has been minimized.
|
@QuietMisdreavus The reference is not searchable tho (can we change that?); Couldn't the standard library documentation simply take all attributes and link to the reference? |
This comment has been minimized.
This comment has been minimized.
|
This comment has been minimized.
This comment has been minimized.
|
I don't see why In #2386 (comment) it's rather the |
This comment has been minimized.
This comment has been minimized.
|
So trying again... can we develop consensus on that (Mark this comment with |
This comment has been minimized.
This comment has been minimized.
Exactly. That's also consistent with GCC/LLVM: |
This comment has been minimized.
This comment has been minimized.
repax
commented
May 8, 2018
|
I have three issues with
Please consider my library example above. An I'm not against anything here in particular. I just see this moment as an opportunity to choose a better name. |
This comment has been minimized.
This comment has been minimized.
|
@rfcbot resolved attribute-name We discussed this in the lang team meeting, and ended up deciding to paint this bikeshed |
rfcbot
added
proposed-final-comment-period
disposition-merge
final-comment-period
and removed
proposed-final-comment-period
labels
May 17, 2018
This comment has been minimized.
This comment has been minimized.
rfcbot
commented
May 17, 2018
|
|
This comment has been minimized.
This comment has been minimized.
frehberg
commented
May 23, 2018
|
I would use this annotation to prevent the optimizer from eliminating unused variables, so my proposal would be #[keep_unused] |
This comment has been minimized.
This comment has been minimized.
|
#[link_used] |
This comment has been minimized.
This comment has been minimized.
anirudhb
commented
May 26, 2018
|
@frehberg That seems more like it would keep all unused variables. That might make Rust's 'unused variable' lint useless on statics. |
rfcbot
added
the
finished-final-comment-period
label
May 27, 2018
This comment has been minimized.
This comment has been minimized.
rfcbot
commented
May 27, 2018
|
The final comment period, with a disposition to merge, as per the review above, is now complete. |
rfcbot
removed
the
final-comment-period
label
May 27, 2018
Centril
merged commit 5d2beda
into
rust-lang:master
May 27, 2018
This comment has been minimized.
This comment has been minimized.
|
Huzzah! This RFC is merged! Tracking issue: rust-lang/rust#40289 |
This comment has been minimized.
This comment has been minimized.
euclio
commented
May 30, 2018
|
I'm probably too late to chime in, but was |
This comment has been minimized.
This comment has been minimized.
|
@euclio Not a bad idea, but the |
This comment has been minimized.
This comment has been minimized.
euclio
commented
May 30, 2018
|
Ah, I should've taken a look at the list of attributes. |
This comment has been minimized.
This comment has been minimized.
|
|
This comment has been minimized.
This comment has been minimized.
CryZe
commented
Jun 6, 2018
|
Yeah, imo it should definitely have link as part of the attribute somewhere
Liigo Zhuang <notifications@github.com> schrieb am Mi. 6. Juni 2018 um
05:13:
… #[used] is misleading. It's used until linking, but not used at writing
or compiling code.
should be #[to_be_used] or #[maybe_useful], or #[useful] for short?
useful also implies: compiler, don't dismiss this item, it's useful for
later use, i.e. linking.
—
You are receiving this because you are subscribed to this thread.
Reply to this email directly, view it on GitHub
<#2386 (comment)>, or mute
the thread
<https://github.com/notifications/unsubscribe-auth/ABYmbjZbz4ucUETdD1FLR4skv7hql46Dks5t50jDgaJpZM4TFjol>
.
|
japaric commentedApr 3, 2018
•
edited by Centril
RFC to stabilize the experimental
#[used]feature added in rust-lang/rust#39987.This feature has been in the compiler for a bit over a year; it's being widely used in embedded /
no-std context; and it has had no bugs filled against it (other than rust-lang/rust#41628 which was
filled shortly after the feature was added).
Tracking issue: rust-lang/rust#40289.
The embedded WG would like to see this feature stabilized in time for the edition release as it appears often in core components of the embedded ecosystem; it's not a blocker for the edition release though as it can be worked around.
Rendered
cc @aturon