@@ -16,8 +16,14 @@ macro_rules! set {
1616}
1717
1818macro_rules! declare_features {
19+ ( __status_to_bool active) => {
20+ false
21+ } ;
22+ ( __status_to_bool incomplete) => {
23+ true
24+ } ;
1925 ( $(
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) ,
2127 ) +) => {
2228 /// Represents active features that are currently being implemented or
2329 /// currently being considered for addition/removal.
@@ -67,6 +73,21 @@ macro_rules! declare_features {
6773 pub fn unordered_const_ty_params( & self ) -> bool {
6874 self . const_generics || self . const_generics_defaults
6975 }
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+ }
7091 }
7192 } ;
7293}
@@ -305,7 +326,7 @@ declare_features! (
305326 ( active, cfg_target_thread_local, "1.7.0" , Some ( 29594 ) , None ) ,
306327
307328 /// Allows specialization of implementations (RFC 1210).
308- ( active , specialization, "1.7.0" , Some ( 31844 ) , None ) ,
329+ ( incomplete , specialization, "1.7.0" , Some ( 31844 ) , None ) ,
309330
310331 /// A minimal, sound subset of specialization intended to be used by the
311332 /// standard library until the soundness issues with specialization
@@ -342,7 +363,7 @@ declare_features! (
342363 ( active, abi_ptx, "1.15.0" , Some ( 38788 ) , None ) ,
343364
344365 /// 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 ) ,
346367
347368 /// Allows `#[link(kind="static-nobundle"...)]`.
348369 ( active, static_nobundle, "1.16.0" , Some ( 37403 ) , None ) ,
@@ -384,7 +405,7 @@ declare_features! (
384405 ( active, in_band_lifetimes, "1.23.0" , Some ( 44524 ) , None ) ,
385406
386407 /// 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 ) ,
388409
389410 /// Allows defining `trait X = A + B;` alias items.
390411 ( active, trait_alias, "1.24.0" , Some ( 41517 ) , None ) ,
@@ -429,7 +450,7 @@ declare_features! (
429450 ( active, proc_macro_hygiene, "1.30.0" , Some ( 54727 ) , None ) ,
430451
431452 /// 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 ) ,
433454
434455 /// Allows custom test frameworks with `#![test_runner]` and `#[test_case]`.
435456 ( active, custom_test_frameworks, "1.30.0" , Some ( 50297 ) , None ) ,
@@ -438,7 +459,7 @@ declare_features! (
438459 ( active, custom_inner_attributes, "1.30.0" , Some ( 54726 ) , None ) ,
439460
440461 /// 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 ) ,
442463
443464 /// Allows using `reason` in lint attributes and the `#[expect(lint)]` lint check.
444465 ( active, lint_reasons, "1.31.0" , Some ( 54503 ) , None ) ,
@@ -450,7 +471,7 @@ declare_features! (
450471 ( active, ffi_returns_twice, "1.34.0" , Some ( 58314 ) , None ) ,
451472
452473 /// 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 ) ,
454475
455476 /// Allows using `#[optimize(X)]`.
456477 ( active, optimize_attribute, "1.34.0" , Some ( 54882 ) , None ) ,
@@ -462,7 +483,7 @@ declare_features! (
462483 ( active, associated_type_bounds, "1.34.0" , Some ( 52662 ) , None ) ,
463484
464485 /// 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 ) ,
466487
467488 /// Allows #[repr(transparent)] on unions (RFC 2645).
468489 ( active, transparent_unions, "1.37.0" , Some ( 60405 ) , None ) ,
@@ -474,13 +495,13 @@ declare_features! (
474495 ( active, async_closure, "1.37.0" , Some ( 62290 ) , None ) ,
475496
476497 /// 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 ) ,
478499
479500 /// Allows the definition of `const extern fn` and `const unsafe extern fn`.
480501 ( active, const_extern_fn, "1.40.0" , Some ( 64926 ) , None ) ,
481502
482503 /// 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 ) ,
484505
485506 /// Allows making `dyn Trait` well-formed even if `Trait` is not object safe.
486507 /// In that case, `dyn Trait: Trait` does not hold. Moreover, coercions and
@@ -516,10 +537,10 @@ declare_features! (
516537 ( active, bindings_after_at, "1.41.0" , Some ( 65490 ) , None ) ,
517538
518539 /// 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 ) ,
520541
521542 /// 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 ) ,
523544
524545 /// Allows the use of `no_sanitize` attribute.
525546 ( active, no_sanitize, "1.42.0" , Some ( 39699 ) , None ) ,
@@ -552,16 +573,16 @@ declare_features! (
552573 ( active, format_args_capture, "1.46.0" , Some ( 67984 ) , None ) ,
553574
554575 /// 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 ) ,
556577
557578 /// Allows calling `transmute` in const fn
558579 ( active, const_fn_transmute, "1.46.0" , Some ( 53605 ) , None ) ,
559580
560581 /// 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 ) ,
562583
563584 /// 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 ) ,
565586
566587 /// Allows basic arithmetic on floating point types in a `const fn`.
567588 ( active, const_fn_floating_point_arithmetic, "1.48.0" , Some ( 57241 ) , None ) ,
@@ -582,7 +603,7 @@ declare_features! (
582603 ( active, isa_attribute, "1.48.0" , Some ( 74727 ) , None ) ,
583604
584605 /// 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 ) ,
586607
587608 /// Allows unsized fn parameters.
588609 ( active, unsized_fn_params, "1.49.0" , Some ( 48055 ) , None ) ,
@@ -594,7 +615,7 @@ declare_features! (
594615 ( active, cfg_panic, "1.49.0" , Some ( 77443 ) , None ) ,
595616
596617 /// 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 ) ,
598619
599620 /// Allows const generics to have default values (e.g. `struct Foo<const N: usize = 3>(...);`).
600621 ( active, const_generics_defaults, "1.51.0" , Some ( 44580 ) , None ) ,
@@ -618,7 +639,7 @@ declare_features! (
618639 ( active, min_type_alias_impl_trait, "1.52.0" , Some ( 63063 ) , None ) ,
619640
620641 /// 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 ) ,
622643
623644 // Allows setting the threshold for the `large_assignments` lint.
624645 ( active, large_assignments, "1.52.0" , Some ( 83518 ) , None ) ,
@@ -661,7 +682,7 @@ declare_features! (
661682 ( active, native_link_modifiers_as_needed, "1.53.0" , Some ( 81490 ) , None ) ,
662683
663684 /// 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 ) ,
665686
666687 /// Allows qualified paths in struct expressions, struct patterns and tuple struct patterns.
667688 ( active, more_qualified_paths, "1.54.0" , Some ( 80080 ) , None ) ,
@@ -671,31 +692,6 @@ declare_features! (
671692 // -------------------------------------------------------------------------
672693) ;
673694
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-
699695/// Some features are not allowed to be used together at the same time, if
700696/// the two are present, produce an error.
701697///
0 commit comments