@@ -55,6 +55,11 @@ r[cfg.predicate.not]
55
55
r[ cfg.predicate.literal]
56
56
* ` true ` or ` false ` literals, which are always true or false respectively.
57
57
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
+
58
63
r[ cfg.option-spec]
59
64
_ Configuration options_ are either names or key-value pairs, and are either set or unset.
60
65
@@ -299,6 +304,25 @@ r[cfg.proc_macro]
299
304
Set when the crate being compiled is being compiled with the ` proc_macro `
300
305
[ crate type] .
301
306
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
+
302
326
r[ cfg.panic]
303
327
### ` panic `
304
328
@@ -371,6 +395,12 @@ fn needs_not_foo() {
371
395
// ...
372
396
}
373
397
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
+
374
404
// This function is only included when the panic strategy is set to unwind
375
405
#[cfg(panic = " unwind" )]
376
406
fn when_unwinding () {
0 commit comments