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: #[cfg(accessible(..) / version(..))] #2523
Conversation
Centril
added some commits
Aug 10, 2018
Centril
added
the
T-lang
label
Aug 12, 2018
Centril
self-assigned this
Aug 12, 2018
Centril
changed the title
RFC: #[cfg(accessible(..) / version(..) / nightly)]
RFC: #[cfg(accessible(..) / version = ".." / nightly)]
Aug 12, 2018
This comment has been minimized.
This comment has been minimized.
|
cc @MajorBreakfast re. use case for futures. :) |
This comment has been minimized.
This comment has been minimized.
|
Updated to mention the |
Nemo157
reviewed
Jan 11, 2019
| fn do_stuff() { | ||
| ... | ||
| } | ||
| ``` |
This comment has been minimized.
This comment has been minimized.
Nemo157
Jan 11, 2019
Contributor
What happens if there are overlapping fields and inherent items in a type? e.g. if the above Person struct was extended in the future with an inherent method pub fn ssn(&self) -> Result<ValidatedSSN, ValidationError> would there be any way to distinguish between this method and the ssn field?
This comment has been minimized.
This comment has been minimized.
Centril
Jan 11, 2019
•
Author
Contributor
I don't think you could distinguish. Similarly, if you had a macro named foo and a function named foo you couldn't distinguish between those either since accessible considers all namespaces. If you wanted this level of accuracy then, as potential future work, accessible(field, ::foobar::Person::ssn) and accessible(fn, ::foobar::Person::ssn) could be possible.
HeroicKatora
referenced this pull request
Jan 13, 2019
Closed
Use of deprecated `std::str::trim_left` #852
This comment has been minimized.
This comment has been minimized.
|
Can we say that |
This comment has been minimized.
This comment has been minimized.
|
@scottmcm One of the standard reasons to do this will be to add integration with unstable APIs and continue to support them once stable. (That said, |
This comment has been minimized.
This comment has been minimized.
|
So I think that there is some risk with nightly and I am personally happy to accept either approach. It sounds like @joshtriplett prefers Also, I think we'd want to check the absence of
That's what the reference says. :) |
This comment has been minimized.
This comment has been minimized.
|
After a Discord discussion, I think my request is the following:
|
This comment has been minimized.
This comment has been minimized.
|
@scottmcm I agree; if you're using I would phrase the second point differently, though. Using accessible isn't "preemptively adding stable support", it's adding optional support for an unstable feature. If you're using that you and the feature changes out from under you then you get to keep all the pieces. I would just suggest documenting that using accessible to access an unstable feature means you're subject to breakage if that unstable feature changes. |
This comment has been minimized.
This comment has been minimized.
|
If you make a stable release using |
dwijnand
referenced this pull request
Feb 1, 2019
Open
Environment variable for the Rust version #4408
dekellum
referenced this pull request
Feb 2, 2019
Closed
ATOMIC_USIZE_INIT deprecated in rust 1.34 #320
This comment has been minimized.
This comment has been minimized.
|
@scottmcm, @joshtriplett: I've tried to outline the changes you requested in the RFC and I've also updated relevant RFCs (#1105 and #1122) with links back to this one. Hopefully the added text should cover the spirit of what you said. Ideally, we can polish the finer details in the actual documentation to-be-written if we should stabilize. Let me know what you think... :) |
This comment has been minimized.
This comment has been minimized.
|
The updates cover what I wanted. Agreed that specific details of the wording can be worked out later. @rfcbot reviewed |
This comment has been minimized.
This comment has been minimized.
moxian
commented
Mar 16, 2019
•
|
There are two totally distinct use cases for
I believe nobody in this thread has the problem with the former case. If you Consider a simple, but useful crate like boolinator. Imagine the author adds a Allowing such usage is nothing short of a time bomb. Compare this situation with the crate introducing
From personal experience: if the No matter how much documentation you put around it, people will misuse it. And it's not them, but other people who will pay the price. I don't like being unable to update rust version due to third-order dependency accidentally misusing a feature I don't care about. My proposal:
|
This comment has been minimized.
This comment has been minimized.
|
@moxian For completeness, I suspect compatibility with past unstable compilers is also a use case someone might have, and I think we can't forbid unstable future-proofing without also forbidding unstable past-proofing, so presumably your suggestion is to forbid both (which seems entirely reasonable to me; I just think it's an important detail to keep in mind). |
This comment has been minimized.
This comment has been minimized.
moxian
commented
Mar 17, 2019
•
|
@Ixrec thanks for bringing this up! (This is probably not what you're referring to, but adding for completeness) My proposal indeed prevents currently-stable code from being compiled with old nightly compiler. This is not a goal, but a side-effect.
It is also true that this does not allow currently nightly-only code to past-proof itself against past nightly compilers (and this is something nightly-only crate authors might want). P.s.: And, yes, we can't allow past-proofing (current stable) -> (old nightly) without also allowing future proofing (current nightly) -> (future stable), and the latter one inevitably leads to problems. |
This comment has been minimized.
This comment has been minimized.
moxian
commented
Mar 17, 2019
|
Since I'm already here, I'll comment on the I think "feature detection" achieves everything that "version detection" does but in a more portable way in regards to alternative compilers, and at no cost* to rustc. I would prefer there to not be a * Needing to stabilize feature gate names is a cost, but one does not need to stabilize feature gate names in order to implement achieve feature detection. Read below. The only way in which "feature detection" is inferior is working around bugs in old rustc releases (as described in #2523 (comment)). But My reading of #2523 (comment) and #2523 (comment) is that matching feature gate names is a poor idea, but having a plain list of implemented features under Now let me summarize the unaddressed arguments raised specifically against this approach, and give my answers: .0 (paraphrasing #2523 (comment) by @rpjohnst ): We don't want to stabilize feature gate names, but we are open to adding items under .1a #2523 (comment) by @Ixrec
Since, as noted by @scottmcm above (#2523 (comment)), we should only "past-proof" things, this is a non-question - you cannot cfg on an unstable feature. I'm fine with allowing nightly only code to .1b (same comment)
I don't know .2 #2523 (comment) by @Centril
On the contrary, I think this is a good thing. .3a #2523 (comment) by @Centril
These complications
.3b (same comment)
It would be nice to not needlessly hinder development of "not-fully-conformant" Rust compilers. In fact, AFAIK there's only one conformant Rust compiler - TL;DRThe biggest reason to add |
This comment has been minimized.
This comment has been minimized.
dekellum
commented
Mar 22, 2019
Regarding the pushback against adding
|
This comment has been minimized.
This comment has been minimized.
I think this is actually a perfect example. All those build scripts will stop working with an alternative implementation of the Rust compiler unless the alternative exactly mirrors the main Rust compiler versioning. |
This comment has been minimized.
This comment has been minimized.
dekellum
commented
Mar 22, 2019
|
@jethrogb I don't think that is true. Feel free to elaborate though? Take a look at how this currently working, for example: https://github.com/Geal/nom/blob/master/build.rs |
This comment has been minimized.
This comment has been minimized.
|
Right, that checks whether the Rust compiler is a particular version and then enables a feature that happens to have been introduced in that version, as opposed to checking whether the compiler that's used supports a feature. |
This comment has been minimized.
This comment has been minimized.
dekellum
commented
Mar 22, 2019
•
|
Well OK, sure, if we can't get anywhere with this feature here... ...then build scripts like nom's (linked above) will get extended to handle the versions of your theoretical alternative rust compilers, like it does now for Otherwise, no, I don't think this is a good example of the abuse that has been implied, or just FUD, in some of the pushback written above. |
Centril commentedAug 12, 2018
•
edited
Permit users to
#[cfg(..)]on whether:#[cfg(version(1.27))]).#[cfg(accessible(::std::mem::ManuallyDrop))]).To @eddyb, @rpjohnst, @kennytm, @aturon, and @rkruppe for discussing the feature with me.
To @Mark-Simulacrum, @MajorBreakfast, @alexreg, @alercah, and @joshtriplett for reviewing the draft version of this RFC.