]> git.lizzy.rs Git - rust.git/blob - compiler/rustc_const_eval/src/lib.rs
Auto merge of #100495 - RalfJung:miri, r=RalfJung
[rust.git] / compiler / rustc_const_eval / src / lib.rs
1 /*!
2
3 Rust MIR: a lowered representation of Rust.
4
5 */
6
7 #![feature(assert_matches)]
8 #![feature(box_patterns)]
9 #![feature(control_flow_enum)]
10 #![feature(decl_macro)]
11 #![feature(exact_size_is_empty)]
12 #![feature(let_else)]
13 #![feature(map_try_insert)]
14 #![feature(min_specialization)]
15 #![feature(slice_ptr_get)]
16 #![feature(option_get_or_insert_default)]
17 #![feature(never_type)]
18 #![feature(trait_alias)]
19 #![feature(trusted_len)]
20 #![feature(trusted_step)]
21 #![feature(try_blocks)]
22 #![feature(yeet_expr)]
23 #![feature(is_some_with)]
24 #![recursion_limit = "256"]
25 #![allow(rustc::potential_query_instability)]
26
27 #[macro_use]
28 extern crate tracing;
29 #[macro_use]
30 extern crate rustc_middle;
31
32 pub mod const_eval;
33 mod errors;
34 pub mod interpret;
35 mod might_permit_raw_init;
36 pub mod transform;
37 pub mod util;
38
39 use rustc_middle::ty;
40 use rustc_middle::ty::query::Providers;
41 use rustc_target::abi::InitKind;
42
43 pub fn provide(providers: &mut Providers) {
44     const_eval::provide(providers);
45     providers.eval_to_const_value_raw = const_eval::eval_to_const_value_raw_provider;
46     providers.eval_to_allocation_raw = const_eval::eval_to_allocation_raw_provider;
47     providers.const_caller_location = const_eval::const_caller_location;
48     providers.eval_to_valtree = |tcx, param_env_and_value| {
49         let (param_env, raw) = param_env_and_value.into_parts();
50         const_eval::eval_to_valtree(tcx, param_env, raw)
51     };
52     providers.try_destructure_mir_constant = |tcx, param_env_and_value| {
53         let (param_env, value) = param_env_and_value.into_parts();
54         const_eval::try_destructure_mir_constant(tcx, param_env, value).ok()
55     };
56     providers.valtree_to_const_val = |tcx, (ty, valtree)| {
57         const_eval::valtree_to_const_value(tcx, ty::ParamEnv::empty().and(ty), valtree)
58     };
59     providers.deref_mir_constant = |tcx, param_env_and_value| {
60         let (param_env, value) = param_env_and_value.into_parts();
61         const_eval::deref_mir_constant(tcx, param_env, value)
62     };
63     providers.permits_uninit_init =
64         |tcx, ty| might_permit_raw_init::might_permit_raw_init(tcx, ty, InitKind::Uninit);
65     providers.permits_zero_init =
66         |tcx, ty| might_permit_raw_init::might_permit_raw_init(tcx, ty, InitKind::Zero);
67 }