pub struct Features {
enabled_lang_features: Vec<EnabledLangFeature>,
enabled_lib_features: Vec<EnabledLibFeature>,
enabled_features: FxHashSet<Symbol>,
}
Expand description
A set of features to be used by later passes.
There are two ways to check if a language feature foo
is enabled:
- Directly with the
foo
method, e.g.if tcx.features().foo() { ... }
. - With the
enabled
method, e.g.if tcx.features.enabled(sym::foo) { ... }
.
The former is preferred. enabled
should only be used when the feature symbol is not a
constant, e.g. a parameter, or when the feature is a library feature.
Fields§
§enabled_lang_features: Vec<EnabledLangFeature>
#![feature]
attrs for language features, for error reporting.
enabled_lib_features: Vec<EnabledLibFeature>
#![feature]
attrs for non-language (library) features.
enabled_features: FxHashSet<Symbol>
enabled_lang_features
+ enabled_lib_features
.
Implementations§
Source§impl Features
impl Features
Sourcepub fn set_enabled_lang_feature(&mut self, lang_feat: EnabledLangFeature)
pub fn set_enabled_lang_feature(&mut self, lang_feat: EnabledLangFeature)
since
should be set for stable features that are nevertheless enabled with a #[feature]
attribute, indicating since when they are stable.
pub fn set_enabled_lib_feature(&mut self, lib_feat: EnabledLibFeature)
Sourcepub fn enabled_lang_features(&self) -> &Vec<EnabledLangFeature>
pub fn enabled_lang_features(&self) -> &Vec<EnabledLangFeature>
Returns a list of EnabledLangFeature
with info about:
- Feature gate name.
- The span of the
#[feature]
attribute. - For stable language features, version info for when it was stabilized.
pub fn enabled_lib_features(&self) -> &Vec<EnabledLibFeature>
pub fn enabled_features(&self) -> &FxHashSet<Symbol>
Source§impl Features
impl Features
pub fn abi_unadjusted(&self) -> bool
pub fn allocator_internals(&self) -> bool
pub fn allow_internal_unsafe(&self) -> bool
pub fn allow_internal_unstable(&self) -> bool
pub fn anonymous_lifetime_in_impl_trait(&self) -> bool
pub fn compiler_builtins(&self) -> bool
pub fn custom_mir(&self) -> bool
pub fn generic_assert(&self) -> bool
pub fn intrinsics(&self) -> bool
pub fn lang_items(&self) -> bool
pub fn lifetime_capture_rules_2024(&self) -> bool
pub fn link_cfg(&self) -> bool
pub fn more_maybe_bounds(&self) -> bool
pub fn multiple_supertrait_upcastable(&self) -> bool
pub fn negative_bounds(&self) -> bool
pub fn omit_gdb_pretty_printer_section(&self) -> bool
pub fn pattern_complexity(&self) -> bool
pub fn pattern_types(&self) -> bool
pub fn prelude_import(&self) -> bool
pub fn profiler_runtime(&self) -> bool
pub fn rustc_attrs(&self) -> bool
pub fn staged_api(&self) -> bool
pub fn test_unstable_lint(&self) -> bool
pub fn unqualified_local_imports(&self) -> bool
pub fn with_negative_coherence(&self) -> bool
pub fn abi_vectorcall(&self) -> bool
pub fn auto_traits(&self) -> bool
pub fn box_patterns(&self) -> bool
pub fn builtin_syntax(&self) -> bool
pub fn doc_notable_trait(&self) -> bool
pub fn dropck_eyepatch(&self) -> bool
pub fn dyn_compatible_for_dispatch(&self) -> bool
pub fn fundamental(&self) -> bool
pub fn link_llvm_intrinsics(&self) -> bool
pub fn linkage(&self) -> bool
pub fn needs_panic_runtime(&self) -> bool
pub fn panic_runtime(&self) -> bool
pub fn rustc_allow_const_fn_unstable(&self) -> bool
pub fn rustc_private(&self) -> bool
pub fn rustdoc_internals(&self) -> bool
pub fn rustdoc_missing_doc_code_examples(&self) -> bool
pub fn start(&self) -> bool
pub fn structural_match(&self) -> bool
pub fn unboxed_closures(&self) -> bool
pub fn aarch64_unstable_target_feature(&self) -> bool
pub fn aarch64_ver_target_feature(&self) -> bool
pub fn arm_target_feature(&self) -> bool
pub fn avx512_target_feature(&self) -> bool
pub fn bpf_target_feature(&self) -> bool
pub fn csky_target_feature(&self) -> bool
pub fn ermsb_target_feature(&self) -> bool
pub fn hexagon_target_feature(&self) -> bool
pub fn lahfsahf_target_feature(&self) -> bool
pub fn loongarch_target_feature(&self) -> bool
pub fn m68k_target_feature(&self) -> bool
pub fn mips_target_feature(&self) -> bool
pub fn powerpc_target_feature(&self) -> bool
pub fn prfchw_target_feature(&self) -> bool
pub fn riscv_target_feature(&self) -> bool
pub fn rtm_target_feature(&self) -> bool
pub fn s390x_target_feature(&self) -> bool
pub fn sparc_target_feature(&self) -> bool
pub fn sse4a_target_feature(&self) -> bool
pub fn tbm_target_feature(&self) -> bool
pub fn wasm_target_feature(&self) -> bool
pub fn x87_target_feature(&self) -> bool
pub fn abi_avr_interrupt(&self) -> bool
pub fn abi_c_cmse_nonsecure_call(&self) -> bool
pub fn abi_msp430_interrupt(&self) -> bool
pub fn abi_ptx(&self) -> bool
pub fn abi_riscv_interrupt(&self) -> bool
pub fn abi_x86_interrupt(&self) -> bool
pub fn adt_const_params(&self) -> bool
pub fn alloc_error_handler(&self) -> bool
pub fn arbitrary_self_types(&self) -> bool
pub fn arbitrary_self_types_pointers(&self) -> bool
pub fn asm_experimental_arch(&self) -> bool
pub fn asm_experimental_reg(&self) -> bool
pub fn asm_goto(&self) -> bool
pub fn asm_goto_with_outputs(&self) -> bool
pub fn asm_unwind(&self) -> bool
pub fn associated_const_equality(&self) -> bool
pub fn associated_type_defaults(&self) -> bool
pub fn async_fn_in_dyn_trait(&self) -> bool
pub fn async_fn_track_caller(&self) -> bool
pub fn async_for_loop(&self) -> bool
pub fn async_trait_bounds(&self) -> bool
pub fn c_variadic(&self) -> bool
pub fn cfg_boolean_literals(&self) -> bool
pub fn cfg_overflow_checks(&self) -> bool
pub fn cfg_relocation_model(&self) -> bool
pub fn cfg_sanitize(&self) -> bool
pub fn cfg_sanitizer_cfi(&self) -> bool
pub fn cfg_target_compact(&self) -> bool
pub fn cfg_target_has_atomic(&self) -> bool
pub fn cfg_target_has_atomic_equal_alignment(&self) -> bool
pub fn cfg_target_thread_local(&self) -> bool
pub fn cfg_ub_checks(&self) -> bool
pub fn cfg_version(&self) -> bool
pub fn cfi_encoding(&self) -> bool
pub fn closure_lifetime_binder(&self) -> bool
pub fn closure_track_caller(&self) -> bool
pub fn cmse_nonsecure_entry(&self) -> bool
pub fn const_async_blocks(&self) -> bool
pub fn const_closures(&self) -> bool
pub fn const_destruct(&self) -> bool
pub fn const_for(&self) -> bool
pub fn const_precise_live_drops(&self) -> bool
pub fn const_trait_impl(&self) -> bool
pub fn const_try(&self) -> bool
pub fn coroutine_clone(&self) -> bool
pub fn coroutines(&self) -> bool
pub fn custom_inner_attributes(&self) -> bool
pub fn custom_test_frameworks(&self) -> bool
pub fn decl_macro(&self) -> bool
pub fn default_field_values(&self) -> bool
pub fn deprecated_safe(&self) -> bool
pub fn deprecated_suggestion(&self) -> bool
pub fn deref_patterns(&self) -> bool
pub fn doc_auto_cfg(&self) -> bool
pub fn doc_cfg(&self) -> bool
pub fn doc_cfg_hide(&self) -> bool
pub fn doc_masked(&self) -> bool
pub fn dyn_star(&self) -> bool
pub fn exhaustive_patterns(&self) -> bool
pub fn explicit_tail_calls(&self) -> bool
pub fn extern_types(&self) -> bool
pub fn f128(&self) -> bool
pub fn f16(&self) -> bool
pub fn ffi_const(&self) -> bool
pub fn ffi_pure(&self) -> bool
pub fn fmt_debug(&self) -> bool
pub fn fn_align(&self) -> bool
pub fn fn_delegation(&self) -> bool
pub fn freeze_impls(&self) -> bool
pub fn gen_blocks(&self) -> bool
pub fn generic_arg_infer(&self) -> bool
pub fn generic_const_exprs(&self) -> bool
pub fn generic_const_items(&self) -> bool
pub fn global_registration(&self) -> bool
pub fn guard_patterns(&self) -> bool
pub fn half_open_range_patterns_in_slices(&self) -> bool
pub fn if_let_guard(&self) -> bool
pub fn impl_trait_in_assoc_type(&self) -> bool
pub fn impl_trait_in_bindings(&self) -> bool
pub fn impl_trait_in_fn_trait_return(&self) -> bool
pub fn inherent_associated_types(&self) -> bool
pub fn inline_const_pat(&self) -> bool
pub fn intra_doc_pointers(&self) -> bool
pub fn large_assignments(&self) -> bool
pub fn lazy_type_alias(&self) -> bool
pub fn let_chains(&self) -> bool
pub fn link_arg_attribute(&self) -> bool
pub fn macro_metavar_expr(&self) -> bool
pub fn macro_metavar_expr_concat(&self) -> bool
pub fn marker_trait_attr(&self) -> bool
pub fn min_generic_const_args(&self) -> bool
pub fn min_specialization(&self) -> bool
pub fn more_qualified_paths(&self) -> bool
pub fn must_not_suspend(&self) -> bool
pub fn mut_ref(&self) -> bool
pub fn naked_functions(&self) -> bool
pub fn native_link_modifiers_as_needed(&self) -> bool
pub fn negative_impls(&self) -> bool
pub fn never_patterns(&self) -> bool
pub fn never_type(&self) -> bool
pub fn never_type_fallback(&self) -> bool
pub fn no_core(&self) -> bool
pub fn no_sanitize(&self) -> bool
pub fn non_exhaustive_omitted_patterns_lint(&self) -> bool
pub fn non_lifetime_binders(&self) -> bool
pub fn offset_of_enum(&self) -> bool
pub fn offset_of_slice(&self) -> bool
pub fn optimize_attribute(&self) -> bool
pub fn patchable_function_entry(&self) -> bool
pub fn pin_ergonomics(&self) -> bool
pub fn postfix_match(&self) -> bool
pub fn precise_capturing_in_traits(&self) -> bool
pub fn proc_macro_hygiene(&self) -> bool
pub fn ref_pat_eat_one_layer_2024(&self) -> bool
pub fn ref_pat_eat_one_layer_2024_structural(&self) -> bool
pub fn register_tool(&self) -> bool
pub fn repr128(&self) -> bool
pub fn repr_simd(&self) -> bool
pub fn return_type_notation(&self) -> bool
pub fn rust_cold_cc(&self) -> bool
pub fn sha512_sm_x86(&self) -> bool
pub fn simd_ffi(&self) -> bool
pub fn specialization(&self) -> bool
pub fn stmt_expr_attributes(&self) -> bool
pub fn strict_provenance_lints(&self) -> bool
pub fn string_deref_patterns(&self) -> bool
pub fn target_feature_11(&self) -> bool
pub fn thread_local(&self) -> bool
pub fn trait_alias(&self) -> bool
pub fn trait_upcasting(&self) -> bool
pub fn transmute_generic_consts(&self) -> bool
pub fn transparent_unions(&self) -> bool
pub fn trivial_bounds(&self) -> bool
pub fn try_blocks(&self) -> bool
pub fn type_alias_impl_trait(&self) -> bool
pub fn type_changing_struct_update(&self) -> bool
pub fn unsafe_binders(&self) -> bool
pub fn unsafe_fields(&self) -> bool
pub fn unsized_const_params(&self) -> bool
pub fn unsized_fn_params(&self) -> bool
pub fn unsized_locals(&self) -> bool
pub fn unsized_tuple_coercion(&self) -> bool
pub fn used_with_arg(&self) -> bool
pub fn x86_amx_intrinsics(&self) -> bool
pub fn xop_target_feature(&self) -> bool
pub fn yeet_expr(&self) -> bool
Sourcepub fn incomplete(&self, feature: Symbol) -> bool
pub fn incomplete(&self, feature: Symbol) -> bool
Some features are known to be incomplete and using them is likely to have unanticipated results, such as compiler crashes. We warn the user about these to alert them.
Trait Implementations§
Auto Trait Implementations§
impl DynSend for Features
impl DynSync for Features
impl Freeze for Features
impl RefUnwindSafe for Features
impl Send for Features
impl Sync for Features
impl Unpin for Features
impl UnwindSafe for Features
Blanket Implementations§
Source§impl<T> BorrowMut<T> for Twhere
T: ?Sized,
impl<T> BorrowMut<T> for Twhere
T: ?Sized,
Source§fn borrow_mut(&mut self) -> &mut T
fn borrow_mut(&mut self) -> &mut T
Source§impl<T> CloneToUninit for Twhere
T: Clone,
impl<T> CloneToUninit for Twhere
T: Clone,
Source§impl<T> Instrument for T
impl<T> Instrument for T
Source§fn instrument(self, span: Span) -> Instrumented<Self>
fn instrument(self, span: Span) -> Instrumented<Self>
Source§fn in_current_span(self) -> Instrumented<Self>
fn in_current_span(self) -> Instrumented<Self>
Source§impl<T> IntoEither for T
impl<T> IntoEither for T
Source§fn into_either(self, into_left: bool) -> Either<Self, Self>
fn into_either(self, into_left: bool) -> Either<Self, Self>
self
into a Left
variant of Either<Self, Self>
if into_left
is true
.
Converts self
into a Right
variant of Either<Self, Self>
otherwise. Read moreSource§fn into_either_with<F>(self, into_left: F) -> Either<Self, Self>
fn into_either_with<F>(self, into_left: F) -> Either<Self, Self>
self
into a Left
variant of Either<Self, Self>
if into_left(&self)
returns true
.
Converts self
into a Right
variant of Either<Self, Self>
otherwise. Read moreSource§impl<T> Pointable for T
impl<T> Pointable for T
Source§impl<T> WithSubscriber for T
impl<T> WithSubscriber for T
Source§fn with_subscriber<S>(self, subscriber: S) -> WithDispatch<Self>
fn with_subscriber<S>(self, subscriber: S) -> WithDispatch<Self>
Source§fn with_current_subscriber(self) -> WithDispatch<Self>
fn with_current_subscriber(self) -> WithDispatch<Self>
impl<'a, T> Captures<'a> for Twhere
T: ?Sized,
Layout§
Note: Most layout information is completely unstable and may even differ between compilations. The only exception is types with certain repr(...)
attributes. Please see the Rust Reference's “Type Layout” chapter for details on type layout guarantees.
Size: 80 bytes