-
Notifications
You must be signed in to change notification settings - Fork 531
Document #[cfg(version(...))] #1828
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
base: master
Are you sure you want to change the base?
Changes from all commits
File filter
Filter by extension
Conversations
Jump to
Diff view
Diff view
There are no files selected for viewing
Original file line number | Diff line number | Diff line change | ||||||||
---|---|---|---|---|---|---|---|---|---|---|
|
@@ -55,6 +55,11 @@ r[cfg.predicate.not] | |||||||||
r[cfg.predicate.literal] | ||||||||||
* `true` or `false` literals, which are always true or false respectively. | ||||||||||
|
||||||||||
r[cfg.predicate.version] | ||||||||||
* `version()` with a version number inside. It is true if the language version | ||||||||||
the compiler targets is higher or equal to the contained version number. | ||||||||||
It is false otherwise. | ||||||||||
|
||||||||||
r[cfg.option-spec] | ||||||||||
_Configuration options_ are either names or key-value pairs, and are either set or unset. | ||||||||||
|
||||||||||
|
@@ -299,6 +304,25 @@ r[cfg.proc_macro] | |||||||||
Set when the crate being compiled is being compiled with the `proc_macro` | ||||||||||
[crate type]. | ||||||||||
|
||||||||||
r[cfg.version] | ||||||||||
## The `version()` predicate | ||||||||||
Comment on lines
+307
to
+308
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. It seems a little confusing to have both this and And the section header should probably be third level, and match the style of the other options.
Suggested change
|
||||||||||
|
||||||||||
r[cfg.version.behaviour] | ||||||||||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Currently using American English for the reference.
Suggested change
|
||||||||||
The `version()` predicate evaluates to true if both: | ||||||||||
|
||||||||||
* The version number contained inside follows the format and | ||||||||||
* The version number contained inside is less than or equal to the version | ||||||||||
of the language the compiler targets. Usually the compiler version and | ||||||||||
language version match. So compiler version `1.50.0` targets language | ||||||||||
`1.50.0`. | ||||||||||
Comment on lines
+315
to
+317
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Usually the reference focuses on the language and not specifics about the compiler or specific implementations. The text here seems a little confusing in that regard. I would probably just strike this content.
Suggested change
|
||||||||||
|
||||||||||
r[cfg.version.format] | ||||||||||
In order for it to be considered of valid format, the version number has to | ||||||||||
follow either the `"a.b.c"` scheme or the `"a.b"` scheme, where `a,b,c` are | ||||||||||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more.
Suggested change
|
||||||||||
decimal integers between `0` and `65535`, inclusively. Semantically, assume `c` | ||||||||||
to be 0 if not present. Order wise, version numbers behave as if they were | ||||||||||
Rust tuples `(a,b,c)` with `a,b,c` being `u16` integers. | ||||||||||
|
||||||||||
r[cfg.panic] | ||||||||||
### `panic` | ||||||||||
|
||||||||||
|
@@ -371,6 +395,12 @@ fn needs_not_foo() { | |||||||||
// ... | ||||||||||
} | ||||||||||
|
||||||||||
// This function is only included if the language version is newer than 1.50.0 | ||||||||||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Should this be "at least 1.50.0"? Or "greater than or equal to"? |
||||||||||
#[cfg(version("1.50.0"))] | ||||||||||
fn needs_new_compiler() { | ||||||||||
// ... | ||||||||||
} | ||||||||||
|
||||||||||
// This function is only included when the panic strategy is set to unwind | ||||||||||
#[cfg(panic = "unwind")] | ||||||||||
fn when_unwinding() { | ||||||||||
|
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 needs grammar, above, as for the other predicates.