2015-08-18 17:59:21 -04:00
|
|
|
/*!
|
|
|
|
|
2020-02-21 11:03:21 -03:00
|
|
|
Rust MIR: a lowered representation of Rust.
|
2015-08-18 17:59:21 -04:00
|
|
|
|
|
|
|
*/
|
|
|
|
|
2021-03-04 13:06:01 +01:00
|
|
|
#![feature(assert_matches)]
|
2016-02-11 18:05:28 +02:00
|
|
|
#![feature(box_patterns)]
|
2020-12-30 18:48:40 +01:00
|
|
|
#![feature(control_flow_enum)]
|
2020-04-27 19:01:30 +02:00
|
|
|
#![feature(decl_macro)]
|
2020-08-27 23:02:46 -07:00
|
|
|
#![feature(exact_size_is_empty)]
|
2022-03-16 20:49:54 +11:00
|
|
|
#![feature(let_chains)]
|
2021-10-16 03:45:14 +02:00
|
|
|
#![feature(let_else)]
|
2021-03-04 13:06:01 +01:00
|
|
|
#![feature(map_try_insert)]
|
2020-05-09 13:59:21 +02:00
|
|
|
#![feature(min_specialization)]
|
2021-05-16 18:53:20 +02:00
|
|
|
#![feature(slice_ptr_get)]
|
2021-03-10 08:48:09 -06:00
|
|
|
#![feature(option_get_or_insert_default)]
|
2020-12-30 18:48:40 +01:00
|
|
|
#![feature(never_type)]
|
|
|
|
#![feature(trait_alias)]
|
|
|
|
#![feature(trusted_len)]
|
|
|
|
#![feature(trusted_step)]
|
|
|
|
#![feature(try_blocks)]
|
2022-05-29 01:19:52 -07:00
|
|
|
#![feature(yeet_expr)]
|
2021-09-01 21:05:35 +02:00
|
|
|
#![recursion_limit = "256"]
|
2022-02-23 08:06:22 -05:00
|
|
|
#![allow(rustc::potential_query_instability)]
|
2015-08-18 17:59:21 -04:00
|
|
|
|
|
|
|
#[macro_use]
|
2020-08-13 23:05:01 -07:00
|
|
|
extern crate tracing;
|
2019-07-23 18:50:47 +03:00
|
|
|
#[macro_use]
|
2020-03-29 16:41:09 +02:00
|
|
|
extern crate rustc_middle;
|
2015-08-18 17:59:21 -04:00
|
|
|
|
2018-08-24 16:39:25 +02:00
|
|
|
pub mod const_eval;
|
2017-12-14 11:36:28 +01:00
|
|
|
pub mod interpret;
|
2015-11-10 21:38:36 +01:00
|
|
|
pub mod transform;
|
2017-03-09 20:10:05 +02:00
|
|
|
pub mod util;
|
2016-09-15 18:18:40 -07:00
|
|
|
|
2020-03-29 16:41:09 +02:00
|
|
|
use rustc_middle::ty::query::Providers;
|
2017-02-20 03:55:28 +02:00
|
|
|
|
2020-07-05 23:00:14 +03:00
|
|
|
pub fn provide(providers: &mut Providers) {
|
2020-01-01 18:06:00 +01:00
|
|
|
const_eval::provide(providers);
|
2020-09-19 10:57:14 +02:00
|
|
|
providers.eval_to_const_value_raw = const_eval::eval_to_const_value_raw_provider;
|
2020-08-20 18:55:07 +02:00
|
|
|
providers.eval_to_allocation_raw = const_eval::eval_to_allocation_raw_provider;
|
2019-10-24 17:35:02 -07:00
|
|
|
providers.const_caller_location = const_eval::const_caller_location;
|
2022-04-12 18:14:28 +02:00
|
|
|
providers.try_destructure_const = |tcx, param_env_and_val| {
|
|
|
|
let (param_env, c) = param_env_and_val.into_parts();
|
|
|
|
const_eval::try_destructure_const(tcx, param_env, c).ok()
|
2020-01-11 15:22:36 +13:00
|
|
|
};
|
2022-04-12 18:14:28 +02:00
|
|
|
providers.eval_to_valtree = |tcx, param_env_and_value| {
|
2021-02-22 14:09:24 +00:00
|
|
|
let (param_env, raw) = param_env_and_value.into_parts();
|
2022-04-12 18:14:28 +02:00
|
|
|
const_eval::eval_to_valtree(tcx, param_env, raw)
|
2021-02-22 14:09:24 +00:00
|
|
|
};
|
2022-04-12 18:14:28 +02:00
|
|
|
providers.try_destructure_mir_constant = |tcx, param_env_and_value| {
|
|
|
|
let (param_env, value) = param_env_and_value.into_parts();
|
|
|
|
const_eval::try_destructure_mir_constant(tcx, param_env, value).ok()
|
2022-04-21 16:37:24 +02:00
|
|
|
};
|
2022-04-12 18:14:28 +02:00
|
|
|
providers.valtree_to_const_val =
|
|
|
|
|tcx, (ty, valtree)| const_eval::valtree_to_const_value(tcx, ty, valtree);
|
2020-07-01 11:41:38 +02:00
|
|
|
providers.deref_const = |tcx, param_env_and_value| {
|
|
|
|
let (param_env, value) = param_env_and_value.into_parts();
|
|
|
|
const_eval::deref_const(tcx, param_env, value)
|
|
|
|
};
|
2022-04-12 18:14:28 +02:00
|
|
|
providers.deref_mir_constant = |tcx, param_env_and_value| {
|
|
|
|
let (param_env, value) = param_env_and_value.into_parts();
|
|
|
|
const_eval::deref_mir_constant(tcx, param_env, value)
|
|
|
|
};
|
2017-03-14 12:22:38 -07:00
|
|
|
}
|