-
Notifications
You must be signed in to change notification settings - Fork 1.6k
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
RFC: #[cfg(accessible(..) / version(..))] #2523
Merged
+976
−0
Merged
Changes from 1 commit
Commits
Show all changes
50 commits
Select commit
Hold shift + click to select a range
ab8d6b3
rfc, cfg-path-version: initial version.
Centril 4670370
rfc, cfg-path-version: fix unbalanced parens.
Centril e0f0fea
rfc, cfg-path-version: fix typo.
Centril d564d75
rfc, cfg-path-version: fix incorrect summary.
Centril 091e470
rfc, cfg-path-version: fix typos.
Centril 8477b57
rfc, cfg-path-version: use semver caret requirements.
Centril d44a484
rfc, cfg-path-version: bnf consistency.
Centril c06eb95
rfc, cfg-path-version: use version = '..' and motivate it.
Centril eb3ec27
rfc, cfg-path-version: define 'nightly' in terms of #![feature(..)]
Centril 65dd139
rfc, cfg-path-version: note that path_exists only sees public things …
Centril 144ff93
rfc, cfg-path-version: use path_exists = '..'.
Centril 13bdfac
rfc, cfg-path-version: note on canary builds.
Centril c54db7f
rfc, cfg-path-version: meta grammar changes..
Centril a5f69b9
rfc, cfg-path-version: optional dependencies are out of scope.
Centril 8832ea4
rfc, cfg-path-version: note use case of working around compiler bugs.
Centril fb30214
rfc, cfg-path-version: talk about the lint.
Centril 7201651
rfc, cfg-path-version: crater stuff not a drawback.
Centril 2fce9e6
rfc, cfg-path-version: clarify re. old versions using this.
Centril fdf3ed7
rfc, cfg-path-version: implementation questions re. path_exists.
Centril 6442367
rfc, cfg-path-version: justify meta grammar changes.
Centril de60af4
rfc, cfg-path-version: justify preventing relative paths.
Centril 72ee5fa
rfc, cfg-path-version: justify nightly instead of if_possible_feature.
Centril 77bf1d6
rfc, cfg-path-version: path_exists -> accessible + talk about fields.
Centril 8c9858a
rfc, cfg-path-version: refresh start date.
Centril 09f23a8
rfc, cfg-path-version: fix typo
Centril 7ca8a5f
rfc, cfg-path-version: reword a bit
Centril c4d7c2c
rfc, cfg-path-version: remove abnf highlighting
Centril 9cedd5a
rfc, cfg-path-version: fix typo.
Centril 3abb76f
rfc, cfg-path-version: talk about SomeFeature
Centril 4601f1c
rfc, cfg-path-version: add `usable` to bikeshed.
Centril 4cad91d
rfc, cfg-path-version: version = '..' => version(..)
Centril 457da19
rfc, cfg-path-version: fix eddybs review comments.
Centril e7840f4
rfc, cfg-path-version: remove #[cfg(nightly)] from proposal.
Centril 1cf87f6
rfc, inferred-type-aliases: discuss semantics of version(..) in depth.
Centril 210e909
rfc, cfg-path-version: fix bugs.
Centril 592de81
rfc, cfg-path-version: talk more about relative paths.
Centril 7aa9cef
rfc, cfg-path-version: more rigorous bikeshed wrt. accessible.
Centril 63b4eac
rfc, cfg-path-version: clang as prior art.
Centril f0dc1e6
rfc, cfg-path-version: discuss rust_feature.
Centril c6d47e7
rfc, cfg-path-version: elaborate on reachable.
Centril 0b12c54
rfc, cfg-path-version: add error-chain#101 as an example.
Centril 16ef0b2
rfc, cfg-path-version: discuss has_attr as future work.
Centril 3333882
rfc, cfg-path-version: fix word wrap.
Centril e0de3bb
rfc, cfg-path-version: highlight the risks of unstable.
Centril 96ec9e7
rfc, cfg-path-version: consider attributes & macros.
Centril 40bc0f5
rfc, cfg-path-version: fix wording in motivation.
Centril 4618306
rfc, cfg-path-version: fix formal grammar to correspond to guide.
Centril ca5a92b
rfc, cfg-path-version: mention target_has_atomic in rationale.
Centril 5b4b21a
rfc, cfg-path-version: clarify stability policy re. accessible(..).
Centril e488a3a
RFC 2523
Centril File filter
Filter by extension
Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
rfc, cfg-path-version: use version = ".." and motivate it.
- Loading branch information
commit c06eb9550226468d86e1ca9fe408eb68c1e99f16
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
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.
A drawback of this approach is that using
#[cfg(version(1.28))]
would make libsyntax fail to parse this syntax on all pre-existing toolchains.That is, if you have to support toolchains older than whatever toolchain version this attribute is this shipped in, you need to put the
#[cfg(version(...))]
behind a feature gated module like this to avoid older toolchains from trying to parse it:and then have a
build.rs
that detects the rust toolchain version and sets--cfg toolchain_supports_cfg_version
.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.
I mean, at that point, we can just implement this as a library that can be easily used from
build.rs
to define such config macros, which would allow the code above to just be written as: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.
Note that the following syntax does not have this problem and is IIRC backward compatible down to Rust 1.0:
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.
@gnzlbg I think everyone considering using this feature understands that it will only work going forward, in versions that support
version
andaccessible
. That"s still quite useful.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.
@joshtriplett when it comes to older versions, there"s a difference between "doesn"t work" and "can"t be parsed". I"d like to avoid the second situation if possible.
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 does bring though the idea that whichever release
version
becomes stable will probably become the new minimum stable rust version that a lot of libraries will bump to. It might be good to pair it"s release with a major feature(s) so that the most amount of people can be benefit from them.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.
It"s probably not that difficult to support two versions; it"s mostly just a bit of parsing inside or outside the string and they"ll be uniform otherwise.
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.
@XAMPPRocky that"s pretty clever =P will just have to find some major feature to couple with heh.
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.
At best, depending on how
cfg(version)
is shipped, projects might be able to just use it for detecting newer features, but it will live alongside the feature-detection code that these projects are already using. The "old" feature detection code is simple and low maintenance, so bumping the MSRV to be able to exclusively usecfg(version)
is something that doesn"t add much value, while compromising something that"s important for these project: the only reason a project would do feature detection is to be able to support older toolchains, so the project must see value in that.I think that maybe eventually all projects might be able to just use
cfg(version)
, but that will be a consequence of them bumping the MSRV due to other issues, and not because there is a lot of value in bumping the MSRV to a toolchain that supportscfg(version)
.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.
I don"t think
cfg(version)
has to be immediately valuable. Eventually more features will be covered undercfg(version)
than those features that aren"t, and then it will be more compelling for more libraries.Unless your MSRV is one version behind
cfg(version)
your value won"t be exclusivelycfg(version)
. If your MSRV is 1.15 for example andcfg(version)
was released in 1.40.0 you"d be getting everything from 1.16.0–1.40.0, and you"d be able to usecfg(version)
to ease future feature development.