@@ -55,6 +55,11 @@ r[cfg.predicate.not]
5555r[ cfg.predicate.literal]
5656* ` true ` or ` false ` literals, which are always true or false respectively.
5757
58+ r[ cfg.predicate.version]
59+ * ` version() ` with a version number inside. It is true if the language version
60+ the compiler targets is higher or equal to the contained version number.
61+ It is false otherwise.
62+
5863r[ cfg.option-spec]
5964_ Configuration options_ are either names or key-value pairs, and are either set or unset.
6065
@@ -299,6 +304,25 @@ r[cfg.proc_macro]
299304Set when the crate being compiled is being compiled with the ` proc_macro `
300305[ crate type] .
301306
307+ r[ cfg.version]
308+ ## The ` version() ` predicate
309+
310+ r[ cfg.version.behaviour]
311+ The ` version() ` predicate evaluates to true if both:
312+
313+ * The version number contained inside follows the format and
314+ * The version number contained inside is less than or equal to the version
315+ of the language the compiler targets. Usually the compiler version and
316+ language version match. So compiler version ` 1.50.0 ` targets language
317+ ` 1.50.0 ` .
318+
319+ r[ cfg.version.format]
320+ In order for it to be considered of valid format, the version number has to
321+ follow either the ` "a.b.c" ` scheme or the ` "a.b" ` scheme, where ` a,b,c ` are
322+ decimal integers between ` 0 ` and ` 65535 ` , inclusively. Semantically, assume ` c `
323+ to be 0 if not present. Order wise, version numbers behave as if they were
324+ Rust tuples ` (a,b,c) ` with ` a,b,c ` being ` u16 ` integers.
325+
302326r[ cfg.panic]
303327### ` panic `
304328
@@ -371,6 +395,12 @@ fn needs_not_foo() {
371395 // ...
372396}
373397
398+ // This function is only included if the language version is newer than 1.50.0
399+ #[cfg(version(" 1.50.0" ))]
400+ fn needs_new_compiler () {
401+ // ...
402+ }
403+
374404// This function is only included when the panic strategy is set to unwind
375405#[cfg(panic = " unwind" )]
376406fn when_unwinding () {
0 commit comments