@@ -16,8 +16,14 @@ macro_rules! set {
16
16
}
17
17
18
18
macro_rules! declare_features {
19
+ ( __status_to_bool active) => {
20
+ false
21
+ } ;
22
+ ( __status_to_bool incomplete) => {
23
+ true
24
+ } ;
19
25
( $(
20
- $( #[ doc = $doc: tt] ) * ( active , $feature: ident, $ver: expr, $issue: expr, $edition: expr) ,
26
+ $( #[ doc = $doc: tt] ) * ( $status : ident , $feature: ident, $ver: expr, $issue: expr, $edition: expr) ,
21
27
) +) => {
22
28
/// Represents active features that are currently being implemented or
23
29
/// currently being considered for addition/removal.
@@ -67,6 +73,21 @@ macro_rules! declare_features {
67
73
pub fn unordered_const_ty_params( & self ) -> bool {
68
74
self . const_generics || self . const_generics_defaults
69
75
}
76
+
77
+ /// Some features are known to be incomplete and using them is likely to have
78
+ /// unanticipated results, such as compiler crashes. We warn the user about these
79
+ /// to alert them.
80
+ pub fn incomplete( & self , feature: Symbol ) -> bool {
81
+ match feature {
82
+ $(
83
+ sym:: $feature => declare_features!( __status_to_bool $status) ,
84
+ ) *
85
+ // accepted and removed features aren't in this file but are never incomplete
86
+ _ if self . declared_lang_features. iter( ) . any( |f| f. 0 == feature) => false ,
87
+ _ if self . declared_lib_features. iter( ) . any( |f| f. 0 == feature) => false ,
88
+ _ => panic!( "`{}` was not listed in `declare_features`" , feature) ,
89
+ }
90
+ }
70
91
}
71
92
} ;
72
93
}
@@ -305,7 +326,7 @@ declare_features! (
305
326
( active, cfg_target_thread_local, "1.7.0" , Some ( 29594 ) , None ) ,
306
327
307
328
/// Allows specialization of implementations (RFC 1210).
308
- ( active , specialization, "1.7.0" , Some ( 31844 ) , None ) ,
329
+ ( incomplete , specialization, "1.7.0" , Some ( 31844 ) , None ) ,
309
330
310
331
/// A minimal, sound subset of specialization intended to be used by the
311
332
/// standard library until the soundness issues with specialization
@@ -342,7 +363,7 @@ declare_features! (
342
363
( active, abi_ptx, "1.15.0" , Some ( 38788 ) , None ) ,
343
364
344
365
/// Allows the `#[repr(i128)]` attribute for enums.
345
- ( active , repr128, "1.16.0" , Some ( 56071 ) , None ) ,
366
+ ( incomplete , repr128, "1.16.0" , Some ( 56071 ) , None ) ,
346
367
347
368
/// Allows `#[link(kind="static-nobundle"...)]`.
348
369
( active, static_nobundle, "1.16.0" , Some ( 37403 ) , None ) ,
@@ -384,7 +405,7 @@ declare_features! (
384
405
( active, in_band_lifetimes, "1.23.0" , Some ( 44524 ) , None ) ,
385
406
386
407
/// Allows associated types to be generic, e.g., `type Foo<T>;` (RFC 1598).
387
- ( active , generic_associated_types, "1.23.0" , Some ( 44265 ) , None ) ,
408
+ ( incomplete , generic_associated_types, "1.23.0" , Some ( 44265 ) , None ) ,
388
409
389
410
/// Allows defining `trait X = A + B;` alias items.
390
411
( active, trait_alias, "1.24.0" , Some ( 41517 ) , None ) ,
@@ -429,7 +450,7 @@ declare_features! (
429
450
( active, proc_macro_hygiene, "1.30.0" , Some ( 54727 ) , None ) ,
430
451
431
452
/// Allows unsized rvalues at arguments and parameters.
432
- ( active , unsized_locals, "1.30.0" , Some ( 48055 ) , None ) ,
453
+ ( incomplete , unsized_locals, "1.30.0" , Some ( 48055 ) , None ) ,
433
454
434
455
/// Allows custom test frameworks with `#![test_runner]` and `#[test_case]`.
435
456
( active, custom_test_frameworks, "1.30.0" , Some ( 50297 ) , None ) ,
@@ -438,7 +459,7 @@ declare_features! (
438
459
( active, custom_inner_attributes, "1.30.0" , Some ( 54726 ) , None ) ,
439
460
440
461
/// Allows `impl Trait` in bindings (`let`, `const`, `static`).
441
- ( active , impl_trait_in_bindings, "1.30.0" , Some ( 63065 ) , None ) ,
462
+ ( incomplete , impl_trait_in_bindings, "1.30.0" , Some ( 63065 ) , None ) ,
442
463
443
464
/// Allows using `reason` in lint attributes and the `#[expect(lint)]` lint check.
444
465
( active, lint_reasons, "1.31.0" , Some ( 54503 ) , None ) ,
@@ -450,7 +471,7 @@ declare_features! (
450
471
( active, ffi_returns_twice, "1.34.0" , Some ( 58314 ) , None ) ,
451
472
452
473
/// Allows const generic types (e.g. `struct Foo<const N: usize>(...);`).
453
- ( active , const_generics, "1.34.0" , Some ( 44580 ) , None ) ,
474
+ ( incomplete , const_generics, "1.34.0" , Some ( 44580 ) , None ) ,
454
475
455
476
/// Allows using `#[optimize(X)]`.
456
477
( active, optimize_attribute, "1.34.0" , Some ( 54882 ) , None ) ,
@@ -462,7 +483,7 @@ declare_features! (
462
483
( active, associated_type_bounds, "1.34.0" , Some ( 52662 ) , None ) ,
463
484
464
485
/// Allows `if/while p && let q = r && ...` chains.
465
- ( active , let_chains, "1.37.0" , Some ( 53667 ) , None ) ,
486
+ ( incomplete , let_chains, "1.37.0" , Some ( 53667 ) , None ) ,
466
487
467
488
/// Allows #[repr(transparent)] on unions (RFC 2645).
468
489
( active, transparent_unions, "1.37.0" , Some ( 60405 ) , None ) ,
@@ -474,13 +495,13 @@ declare_features! (
474
495
( active, async_closure, "1.37.0" , Some ( 62290 ) , None ) ,
475
496
476
497
/// Allows `impl Trait` to be used inside type aliases (RFC 2515).
477
- ( active , type_alias_impl_trait, "1.38.0" , Some ( 63063 ) , None ) ,
498
+ ( incomplete , type_alias_impl_trait, "1.38.0" , Some ( 63063 ) , None ) ,
478
499
479
500
/// Allows the definition of `const extern fn` and `const unsafe extern fn`.
480
501
( active, const_extern_fn, "1.40.0" , Some ( 64926 ) , None ) ,
481
502
482
503
/// Allows the use of raw-dylibs (RFC 2627).
483
- ( active , raw_dylib, "1.40.0" , Some ( 58713 ) , None ) ,
504
+ ( incomplete , raw_dylib, "1.40.0" , Some ( 58713 ) , None ) ,
484
505
485
506
/// Allows making `dyn Trait` well-formed even if `Trait` is not object safe.
486
507
/// In that case, `dyn Trait: Trait` does not hold. Moreover, coercions and
@@ -516,10 +537,10 @@ declare_features! (
516
537
( active, bindings_after_at, "1.41.0" , Some ( 65490 ) , None ) ,
517
538
518
539
/// Allows `impl const Trait for T` syntax.
519
- ( active , const_trait_impl, "1.42.0" , Some ( 67792 ) , None ) ,
540
+ ( incomplete , const_trait_impl, "1.42.0" , Some ( 67792 ) , None ) ,
520
541
521
542
/// Allows `T: ?const Trait` syntax in bounds.
522
- ( active , const_trait_bound_opt_out, "1.42.0" , Some ( 67794 ) , None ) ,
543
+ ( incomplete , const_trait_bound_opt_out, "1.42.0" , Some ( 67794 ) , None ) ,
523
544
524
545
/// Allows the use of `no_sanitize` attribute.
525
546
( active, no_sanitize, "1.42.0" , Some ( 39699 ) , None ) ,
@@ -552,16 +573,16 @@ declare_features! (
552
573
( active, format_args_capture, "1.46.0" , Some ( 67984 ) , None ) ,
553
574
554
575
/// Lazily evaluate constants. This allows constants to depend on type parameters.
555
- ( active , lazy_normalization_consts, "1.46.0" , Some ( 72219 ) , None ) ,
576
+ ( incomplete , lazy_normalization_consts, "1.46.0" , Some ( 72219 ) , None ) ,
556
577
557
578
/// Allows calling `transmute` in const fn
558
579
( active, const_fn_transmute, "1.46.0" , Some ( 53605 ) , None ) ,
559
580
560
581
/// Allows `if let` guard in match arms.
561
- ( active , if_let_guard, "1.47.0" , Some ( 51114 ) , None ) ,
582
+ ( incomplete , if_let_guard, "1.47.0" , Some ( 51114 ) , None ) ,
562
583
563
584
/// Allows non-trivial generic constants which have to be manually propagated upwards.
564
- ( active , const_evaluatable_checked, "1.48.0" , Some ( 76560 ) , None ) ,
585
+ ( incomplete , const_evaluatable_checked, "1.48.0" , Some ( 76560 ) , None ) ,
565
586
566
587
/// Allows basic arithmetic on floating point types in a `const fn`.
567
588
( active, const_fn_floating_point_arithmetic, "1.48.0" , Some ( 57241 ) , None ) ,
@@ -582,7 +603,7 @@ declare_features! (
582
603
( active, isa_attribute, "1.48.0" , Some ( 74727 ) , None ) ,
583
604
584
605
/// Allow anonymous constants from an inline `const` block
585
- ( active , inline_const, "1.49.0" , Some ( 76001 ) , None ) ,
606
+ ( incomplete , inline_const, "1.49.0" , Some ( 76001 ) , None ) ,
586
607
587
608
/// Allows unsized fn parameters.
588
609
( active, unsized_fn_params, "1.49.0" , Some ( 48055 ) , None ) ,
@@ -594,7 +615,7 @@ declare_features! (
594
615
( active, cfg_panic, "1.49.0" , Some ( 77443 ) , None ) ,
595
616
596
617
/// Allows capturing disjoint fields in a closure/generator (RFC 2229).
597
- ( active , capture_disjoint_fields, "1.49.0" , Some ( 53488 ) , None ) ,
618
+ ( incomplete , capture_disjoint_fields, "1.49.0" , Some ( 53488 ) , None ) ,
598
619
599
620
/// Allows const generics to have default values (e.g. `struct Foo<const N: usize = 3>(...);`).
600
621
( active, const_generics_defaults, "1.51.0" , Some ( 44580 ) , None ) ,
@@ -618,7 +639,7 @@ declare_features! (
618
639
( active, min_type_alias_impl_trait, "1.52.0" , Some ( 63063 ) , None ) ,
619
640
620
641
/// Allows associated types in inherent impls.
621
- ( active , inherent_associated_types, "1.52.0" , Some ( 8995 ) , None ) ,
642
+ ( incomplete , inherent_associated_types, "1.52.0" , Some ( 8995 ) , None ) ,
622
643
623
644
// Allows setting the threshold for the `large_assignments` lint.
624
645
( active, large_assignments, "1.52.0" , Some ( 83518 ) , None ) ,
@@ -661,7 +682,7 @@ declare_features! (
661
682
( active, native_link_modifiers_as_needed, "1.53.0" , Some ( 81490 ) , None ) ,
662
683
663
684
/// Allows unnamed fields of struct and union type
664
- ( active , unnamed_fields, "1.53.0" , Some ( 49804 ) , None ) ,
685
+ ( incomplete , unnamed_fields, "1.53.0" , Some ( 49804 ) , None ) ,
665
686
666
687
/// Allows qualified paths in struct expressions, struct patterns and tuple struct patterns.
667
688
( active, more_qualified_paths, "1.54.0" , Some ( 80080 ) , None ) ,
@@ -671,31 +692,6 @@ declare_features! (
671
692
// -------------------------------------------------------------------------
672
693
) ;
673
694
674
- /// Some features are known to be incomplete and using them is likely to have
675
- /// unanticipated results, such as compiler crashes. We warn the user about these
676
- /// to alert them.
677
- pub const INCOMPLETE_FEATURES : & [ Symbol ] = & [
678
- sym:: if_let_guard,
679
- sym:: impl_trait_in_bindings,
680
- sym:: generic_associated_types,
681
- sym:: const_generics,
682
- sym:: let_chains,
683
- sym:: raw_dylib,
684
- sym:: const_evaluatable_checked,
685
- sym:: const_trait_impl,
686
- sym:: const_trait_bound_opt_out,
687
- sym:: lazy_normalization_consts,
688
- sym:: specialization,
689
- sym:: inline_const,
690
- sym:: repr128,
691
- sym:: unsized_locals,
692
- sym:: capture_disjoint_fields,
693
- sym:: inherent_associated_types,
694
- sym:: type_alias_impl_trait,
695
- sym:: rustc_insignificant_dtor,
696
- sym:: unnamed_fields,
697
- ] ;
698
-
699
695
/// Some features are not allowed to be used together at the same time, if
700
696
/// the two are present, produce an error.
701
697
///
0 commit comments