Join GitHub today
GitHub is home to over 28 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.
|
@fbstj FWIW, I have already been doing probing that like that in a few crates for a while. The |
This comment has been minimized.
This comment has been minimized.
I agree with this, and to me the same argument eliminates much of the argument for having Personally, I'd like to consider dropping this proposal down to just version numbers, at least to start, and see whether in practice we feed the need for the added complexity of accessibility. |
This comment has been minimized.
This comment has been minimized.
jrvidal
commented
Nov 9, 2018
|
I would much rather prefer fostering better user-land solutions, such as @cuviper's autocfg. I don't think a strong case for the advantages of the built-in attributes has been presented, or considered thoroughly in the RFC text.
(1) could be solved if a clear winner emerges in the ecosystem (maybe becoming part of the nursery). That would take care of (4) as well, although that's something could be addressed independently today by (maybe the libs team?) getting involved in those projects to provide such recommendations. I'd argue that (3) is a statement about the current state of affairs of feature-detection in the ecosystem that ignores potential improvements. I think something like (I concede point (2) Why not wait and see where this road takes us? Isn't this the preferred approach in general (i.e. build a macro before adding syntax; let user-land experiment, then nursery, then (maybe) language/std library)? (Note how the discussion about stabilizing feature names becomes moot: the community could rally around a repository of commonly used "feature flags" wrapping a curated set of compile-time tests.) Also: what about having the And a final spitball about point (2) above: what if Cargo itself had a notion of feature-detection, where it attempts to compile every file in |
This comment was marked as disruptive content.
This comment was marked as disruptive content.
alexreg
commented
Nov 9, 2018
|
@jrvidal Better? That's very hacky. It's not better in any way. |
This comment has been minimized.
This comment has been minimized.
|
@alexreg Please keep an eye on your tone here and keep critiques specific and constructive. |
This comment has been minimized.
This comment has been minimized.
I am personally fine with slimming this RFC down to However, note that
I'm going to nominate this RFC so that we can discuss how to proceed.
While autocfg uses a powerful approach, I don't see it as an improvement on Furthermore, when you look into the documentation of
This RFC brings these concepts into the language itself eliminating the need for
Library solutions cannot to my knowledge get around
I don't agree here and I don't think any library solution can be as ergonomic or scalable as an in-language solution. I'd also note that we are talking about compile time reflection about the language itself, so baking such reflection into the language isn't strange at all.
I think this point is central and impacts points 1, 3, and 4 to such a degree that in my view, there's not much more to say. While you have to use
Not always; and in this case I think we've had quite a long testing period for version checking with
The discussion doesn't become moot, the mechanism just moved around. I don't think moving feature gate name tests to be done by
This seems like an indirection to me... The compiler already knows its own version... why should it tell Cargo the version so that Cargo can tell the compiler the version? Furthermore, if the structured information is needed for other reasons, then we can offer that atop of
That automates the work of |
Centril
added
the
I-nominated
label
Nov 9, 2018
This comment has been minimized.
This comment has been minimized.
jrvidal
commented
Nov 10, 2018
Those are valid points but (minor nit) the scaling concern might be a stretch. If a library writer is at the point where they're managing too many
Someone suggested upthread that Now, I haven't thought much about it but: couldn't a crate achieve a similar effect today (without
I'm all
(Emphasis mine) I don't think this is a fair statement at all
I meant that the discussion about stability of feature gate names in the compiler becomes moot. If it were in a library, it would follow semver, it could go beyond 1.x, and it would unburden compiler devs from committing to and bike-shedding names. FWIW I don't have may arguments against |
This comment has been minimized.
This comment has been minimized.
|
Even as the author of
FWIW, I've been using similar probes in the num crates for Raw version checking has been in practice for quite a long time, e.g. |
This comment has been minimized.
This comment has been minimized.
It is my personal experience that it doesn't scale and produces a mess. :)
Why? To what end? These complications doesn't seem to offer any advantages; having the language introspect about its own version is a simple and effective solution without any contortions.
The Rust language is versioned. When we release new versions of
I was referring to the limitations of
It is mostly RFC authors (e.g myself) and contributors to libstd who invent new feature gates, not compiler devs. I don't want to encourage any bikeshedding in this department whether it be done by some external crate or by compiler devs; it seems like a waste of time. |
This comment was marked as disruptive content.
This comment was marked as disruptive content.
alexreg
commented
Nov 10, 2018
|
@aturon Are you having a laugh? Am I not allowed to have an opinion on anything? To be frank, I expressed myself in a perfectly polite way. You could have easily asked, "would you like to expand on that", instead of attacking me. In any case, the author already discussed approaches based on |
This comment has been minimized.
This comment has been minimized.
|
@alexreg We care a lot about how we treat each other in the Rust community, especially in formal spaces like RFC threads. See the code of conduct for some insight into the basic spirit we strive for (and also, on how one should react when being called out). If you'd like to discuss these points further, please do so privately with the moderation team. |
Centril
referenced this pull request
Nov 11, 2018
Open
proptest-derive: #[inline] + `no_cfg` Cargo feature gate #106
This comment has been minimized.
This comment has been minimized.
|
So, when I originally reviewed this, I really don't want to see this RFC pared back to only On the contrary, I'd be thrilled to see this RFC pared back to only |
This comment has been minimized.
This comment has been minimized.
|
I personally think having both With respect to
And then I further elaborated:
When working on AltSysrq/proptest#106, I realized that I needed #[derive(Debug, Arbitrary)]
struct MyType { ... }
// == generates ==v
#[cfg(all(
any(test, feature = "prop"),
accessible(::proptest::prelude::Arbitrary)
)]
impl Arbitrary for MyType { ... }Here, |
This comment has been minimized.
This comment has been minimized.
|
The problem with how If |
This comment has been minimized.
This comment has been minimized.
|
@Nemo157 I don't feel like that's an unreasonable example. Code that touches unstable features may break. |
This comment has been minimized.
This comment has been minimized.
|
Maybe allowing |
This comment has been minimized.
This comment has been minimized.
|
@Nemo157 If I'm understanding you correctly you are mostly concerned about what the RFC presents as idiomatic usage to some learner who might read the RFC at some point (and that we should pick examples that are not as risky...)? I could definitely introduce better examples + leave notes that doing this on unstable features carries risks; that is an utterly fair thing to ask. |
This comment has been minimized.
This comment has been minimized.
|
Oh, and the problem with that example is not that it may break for a user of the |
This comment has been minimized.
This comment has been minimized.
|
Adding another example, even a primary example, that applies to stable seems completely reasonable. |
This was referenced Nov 14, 2018
Centril
added
A-paths
A-versioning
A-cfg
labels
Nov 22, 2018
Centril
added some commits
Nov 29, 2018
This comment has been minimized.
This comment has been minimized.
|
For greater flexibility, usefulness, and user facing simplicity, I have specified that @rfcbot resolve macros-and-attributes @Nemo157 I have changed the language in the RFC and examples to favor uses of |
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.