]> git.lizzy.rs Git - rust.git/blob - compiler/rustc_const_eval/src/lib.rs
Correctly handle path stability for 'use tree' items
[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_chains)]
13 #![feature(let_else)]
14 #![feature(map_try_insert)]
15 #![feature(min_specialization)]
16 #![feature(slice_ptr_get)]
17 #![feature(option_get_or_insert_default)]
18 #![feature(never_type)]
19 #![feature(trait_alias)]
20 #![feature(trusted_len)]
21 #![feature(trusted_step)]
22 #![feature(try_blocks)]
23 #![feature(yeet_expr)]
24 #![feature(is_some_with)]
25 #![recursion_limit = "256"]
26 #![allow(rustc::potential_query_instability)]
27
28 #[macro_use]
29 extern crate tracing;
30 #[macro_use]
31 extern crate rustc_middle;
32
33 pub mod const_eval;
34 mod errors;
35 pub mod interpret;
36 pub mod transform;
37 pub mod util;
38
39 use rustc_middle::ty;
40 use rustc_middle::ty::query::Providers;
41
42 pub fn provide(providers: &mut Providers) {
43     const_eval::provide(providers);
44     providers.eval_to_const_value_raw = const_eval::eval_to_const_value_raw_provider;
45     providers.eval_to_allocation_raw = const_eval::eval_to_allocation_raw_provider;
46     providers.const_caller_location = const_eval::const_caller_location;
47     providers.eval_to_valtree = |tcx, param_env_and_value| {
48         let (param_env, raw) = param_env_and_value.into_parts();
49         const_eval::eval_to_valtree(tcx, param_env, raw)
50     };
51     providers.try_destructure_mir_constant = |tcx, param_env_and_value| {
52         let (param_env, value) = param_env_and_value.into_parts();
53         const_eval::try_destructure_mir_constant(tcx, param_env, value).ok()
54     };
55     providers.valtree_to_const_val = |tcx, (ty, valtree)| {
56         const_eval::valtree_to_const_value(tcx, ty::ParamEnv::empty().and(ty), valtree)
57     };
58     providers.deref_mir_constant = |tcx, param_env_and_value| {
59         let (param_env, value) = param_env_and_value.into_parts();
60         const_eval::deref_mir_constant(tcx, param_env, value)
61     };
62 }