diff options
| author | Nilstrieb <48135649+Nilstrieb@users.noreply.github.com> | 2023-02-22 20:51:29 +0000 | 
|---|---|---|
| committer | Nilstrieb <48135649+Nilstrieb@users.noreply.github.com> | 2023-02-23 18:42:36 +0000 | 
| commit | 025d2a147ff3dcde8f00ad5bc43b446837bd0240 (patch) | |
| tree | c762a9797ea8144815ebbf3f722ecd9005c04b43 /compiler/rustc_const_eval/src/lib.rs | |
| parent | b869e84e581612f4a30a4bca63bd9e90e9a17003 (diff) | |
| download | rust-025d2a147ff3dcde8f00ad5bc43b446837bd0240.tar.gz rust-025d2a147ff3dcde8f00ad5bc43b446837bd0240.zip | |
Unify validity checks into a single query
Previously, there were two queries to check whether a type allows the 0x01 or zeroed bitpattern. I am planning on adding a further initness to check, truly uninit for MaybeUninit, which would make this three queries. This seems overkill for such a small feature, so this PR unifies them into one.
Diffstat (limited to 'compiler/rustc_const_eval/src/lib.rs')
| -rw-r--r-- | compiler/rustc_const_eval/src/lib.rs | 7 | 
1 files changed, 2 insertions, 5 deletions
| diff --git a/compiler/rustc_const_eval/src/lib.rs b/compiler/rustc_const_eval/src/lib.rs index fc6d61c79c2..092a7dc3d3b 100644 --- a/compiler/rustc_const_eval/src/lib.rs +++ b/compiler/rustc_const_eval/src/lib.rs @@ -38,7 +38,6 @@ use rustc_errors::{DiagnosticMessage, SubdiagnosticMessage}; use rustc_macros::fluent_messages; use rustc_middle::ty; use rustc_middle::ty::query::Providers; -use rustc_target::abi::InitKind; fluent_messages! { "../locales/en-US.ftl" } @@ -62,9 +61,7 @@ pub fn provide(providers: &mut Providers) { let (param_env, value) = param_env_and_value.into_parts(); const_eval::deref_mir_constant(tcx, param_env, value) }; - providers.permits_uninit_init = |tcx, param_env_and_ty| { - util::might_permit_raw_init(tcx, param_env_and_ty, InitKind::UninitMitigated0x01Fill) + providers.check_validity_of_init = |tcx, (init_kind, param_env_and_ty)| { + util::might_permit_raw_init(tcx, init_kind, param_env_and_ty) }; - providers.permits_zero_init = - |tcx, param_env_and_ty| util::might_permit_raw_init(tcx, param_env_and_ty, InitKind::Zero); } | 
