]> git.proxmox.com Git - rustc.git/blob - compiler/rustc_const_eval/src/lib.rs
New upstream version 1.70.0+dfsg1
[rustc.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(decl_macro)]
10 #![feature(exact_size_is_empty)]
11 #![feature(let_chains)]
12 #![feature(map_try_insert)]
13 #![feature(min_specialization)]
14 #![feature(slice_ptr_get)]
15 #![feature(option_get_or_insert_default)]
16 #![feature(never_type)]
17 #![feature(trait_alias)]
18 #![feature(trusted_len)]
19 #![feature(trusted_step)]
20 #![feature(try_blocks)]
21 #![feature(yeet_expr)]
22 #![feature(if_let_guard)]
23 #![recursion_limit = "256"]
24
25 #[macro_use]
26 extern crate tracing;
27 #[macro_use]
28 extern crate rustc_middle;
29
30 pub mod const_eval;
31 mod errors;
32 pub mod interpret;
33 pub mod transform;
34 pub mod util;
35
36 use rustc_errors::{DiagnosticMessage, SubdiagnosticMessage};
37 use rustc_macros::fluent_messages;
38 use rustc_middle::ty;
39 use rustc_middle::ty::query::Providers;
40
41 fluent_messages! { "../messages.ftl" }
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.check_validity_requirement = |tcx, (init_kind, param_env_and_ty)| {
64 util::check_validity_requirement(tcx, init_kind, param_env_and_ty)
65 };
66 }