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
Tracking issue for RFC 2523, #[cfg(version(..))]
#64796
Comments
@csmoe Are you working on this? If not I might want to try out this task first since @petrochenkov mentioned that this task is easier than |
@pickfire I didn't have much bandwidth on this, seems you have already made some progress on |
Can anyone please help to write up the mentoring instructions. Based on what I know, this should be similar to #64797 (comment)
I believed step 1 and 2 should be the same. For step 3, based on what I know requires me to modify somewhere around rust/src/libsyntax/attr/builtin.rs Lines 566 to 568 in b56b239
Based on |
Hi, @pickfire. Are you still working on this? |
No, I was stuck working on this and don't know how to proceed. |
Ok, thanks for quick response. I'll take my shot at this. |
@mibac138 Do you want me to publish my progress? |
@pickfire sure, that'd be great! |
@mibac138 Err, no need. You have already done more than me, I don't know how to change the |
Status update: #71314 implemented this RFC with a slightly different syntax - #[cfg(version("1.2.3"))] instead of The reason is that Additionally, the |
Implement RFC 2523, `#[cfg(version(..))]` Hi! This is my first contribution to rust, I hope I didn't miss anything. I tried to implement this feature so that `#[cfg(version(1.44.0))]` works but the parser was printing an error that I wasn't sure how to fix so I just opted for implementing `#[cfg(version("1.44.0"))]` (note the quotes). Tracking issue: rust-lang#64796
The RFC had an unresolved question about how this feature would interact with nightly/beta. Should Currently, the implementation returns true. E.G. for #![feature(cfg_version)]
fn main() {
test();
}
#[cfg(version("1.45.0"))]
fn test() {
println!("Yes")
}
#[cfg(not(version("1.45.0")))]
fn test() {
println!("No")
} IMO, this is a mistake. The main use-case for |
That sounds like good reasoning to me, but I've not been following this RFC that closely. @joshtriplett -- I feel like you were "liaison'ing" for this before we had a term for it, do you have a take? |
Nominating for lang-team meeting to discuss |
Which is most useful, the way it is, AFAICT. Isn't there a way to combine this with cfg test(s) for "train", e.g. beta or nightly and unstable feature gates? |
Code written for the stable compiler should not have to know about beta or nightly. |
I'm not surprised with that as a goal, but I can think of cases where for practical reasons I nead to dev on 1.45 nightly with expectation that it will then work on 1.45 stable. I'm surprised if I'm the only one. |
On Wed, May 19, 2021 at 11:48:04AM -0700, est31 wrote:
Yeah, that wouldn't need `lib_has` actually. It could be exposed directly as part of `cfg(accessible)` with an absolute path. After the `::`, at least on edition 2018 and beyond, there has to follow a crate name. If it doesn't find the crate as part of the prelude or std/alloc/etc it can just error, regardless of whether anything beyond is accessible or not. Even on edition 2015 you are not allowed to shadow crates from the prelude.
That works, and it's nicely forwards-compatible. A version of
`cfg(accessible(::some::path))` limited to std/alloc/core/prelude would
be plenty to address this.
|
I propose to add the specific nightly compiler commit to the attribute, as in: #[cfg(version("1.54.0-nightly (ed597e7e1 2021-06-08)"))] Such that nightly builds earlier than that (or after than that) would consider the code annotated with that attribute as "conditionally disabled code" even if it is exactly |
Setting aside the fact that I don't believe this is the appropriate time or place to discuss that (a new issue should be opened imo), that would effectively preclude an alternative implementation of Rust from ever existing. Matching the behavior of an exact SHA and date would not be worth the effort to say the least. |
That is true though |
Not inherently; it would just allow Rust code to detect the exact compiler version it's running on. That might be useful for code that intends to be pinned to a specific compiler version. |
I expect alternative implementations to target stable rust, not nightly. So a feature to pin a particular nightly would not need to be implemented by alternative rust compilers (or they could even be implemented with alternative semantics). |
Regarding:
Yes, please! I have a bunch of projects (and contribute to a bunch of others) that want to support at least the version available in Debian stable. However additional features would be sometimes useful. Unfortunately, this would not work as-is. Let's say I want to do this: #cfg(version= "1.60")
struct Foo;
// ... If I write such code it'll behave strangely:
To an uninformed observer this would look like certain versions had regression. To solve this I propose renaming |
@Kixunil yeah the same behaviour occurs with I think the best solution to the problem is to just wait it out, because even if this feature exists, projects will increase their MSRV eventually to one that supports |
@est31 WTF, "Rust" is name of the programming language so if you make a fork it's reasonable to keep the name of the language. Does the trademark disallow people forking? IMO |
I'd agree that lang_version is better than just version. |
The copyright doesn't but the trademark rights are separate and it's up to the owner of the trademark to set the policy. When the trademarks were owned by Mozilla, they were under basically the same rules as the Firefox trademark. Some distros were forced to create different branding for their Firefox builds even though they only added a few patches. Not familiar enough with what the foundation's been doing to tell whether there has been any change of the trademark policy. The website still treats the trademarks as if they were owned by Mozilla. Even if, such policies can change any minute. Also, generally it's a good idea to rename a project when forking it to avoid confusion, even if you are not required to do so. I feel that fairness owes it that if possible, it would be best to not refer to the name of the language in proper language features.
I like |
@rfcbot cancel Hi all. This has been in FCP for a very long time and so I am going to cancel the FCP (my personal philosophy is that FCPs should not last this long). I believe it is currently blocked waiting on progress around some kind of subset of cfg-accessible, as described by @joshtriplett here (or perhaps in comments that @joshtriplett is referencing there). If somebody would like to move this issue forward: The next step would be to open a separate issue regarding that proposal and link it from here, and perhaps we can try to drive that work forward with mentorship or other means? |
@nikomatsakis proposal cancelled. |
It looks like |
#64797 appears to have stalled out somewhat. I'd like to make an argument for why I believe it'd be appropriate to consider stabilizing this even before
|
I hit a bug in Rustc today, where rustc fails to derive This is important for the project I'm working on as it's Mesa, the OpenGL/Vulkan/OpenCL/etc.. implementation for the Linux desktop and we need to be mindful of what Rustc version to support. Edit: Apparently it was |
This is a tracking issue for
#[cfg(version(..))]
(rust-lang/rfcs#2523).Steps:
Unresolved questions:
What is
cfg(version(...))
relative to in terms of nightly compilers?We could check against what
rustc --version
says, e.g. nightly being1.40.0
, beta being1.39.0
, and stable being1.38.0
. We could also havecfg(version(...))
at most be relative to the beta compiler. See the RFC for a longer discussion.#[cfg(version(..))]
#64796 (comment)Should we also support
version = "..."
so that crates having a MSRV below whenversion(...)
was stabilized can use the flag?Dependency updates cause language changes (src tarballs are vendored without respecting lockfile #79010)
The text was updated successfully, but these errors were encountered: