2015-08-18 21:59:21 +00:00
|
|
|
/*!
|
|
|
|
|
2020-02-21 14:03:21 +00:00
|
|
|
Rust MIR: a lowered representation of Rust.
|
2015-08-18 21:59:21 +00:00
|
|
|
|
|
|
|
*/
|
|
|
|
|
2023-05-17 10:30:14 +00:00
|
|
|
#![deny(rustc::untranslatable_diagnostic)]
|
2021-03-04 12:06:01 +00:00
|
|
|
#![feature(assert_matches)]
|
2016-02-11 16:05:28 +00:00
|
|
|
#![feature(box_patterns)]
|
2020-04-27 17:01:30 +00:00
|
|
|
#![feature(decl_macro)]
|
2020-08-28 06:02:46 +00:00
|
|
|
#![feature(exact_size_is_empty)]
|
2022-08-20 18:40:08 +00:00
|
|
|
#![feature(let_chains)]
|
2021-03-04 12:06:01 +00:00
|
|
|
#![feature(map_try_insert)]
|
2020-05-09 11:59:21 +00:00
|
|
|
#![feature(min_specialization)]
|
2021-05-16 16:53:20 +00:00
|
|
|
#![feature(slice_ptr_get)]
|
2021-03-10 14:48:09 +00:00
|
|
|
#![feature(option_get_or_insert_default)]
|
2020-12-30 17:48:40 +00:00
|
|
|
#![feature(never_type)]
|
|
|
|
#![feature(trait_alias)]
|
|
|
|
#![feature(trusted_len)]
|
|
|
|
#![feature(trusted_step)]
|
|
|
|
#![feature(try_blocks)]
|
2022-05-29 08:19:52 +00:00
|
|
|
#![feature(yeet_expr)]
|
2022-12-21 16:32:16 +00:00
|
|
|
#![feature(if_let_guard)]
|
2021-09-01 19:05:35 +00:00
|
|
|
#![recursion_limit = "256"]
|
2015-08-18 21:59:21 +00:00
|
|
|
|
|
|
|
#[macro_use]
|
2020-08-14 06:05:01 +00:00
|
|
|
extern crate tracing;
|
2019-07-23 15:50:47 +00:00
|
|
|
#[macro_use]
|
2020-03-29 14:41:09 +00:00
|
|
|
extern crate rustc_middle;
|
2015-08-18 21:59:21 +00:00
|
|
|
|
2018-08-24 14:39:25 +00:00
|
|
|
pub mod const_eval;
|
2022-06-29 04:26:05 +00:00
|
|
|
mod errors;
|
2017-12-14 10:36:28 +00:00
|
|
|
pub mod interpret;
|
2015-11-10 20:38:36 +00:00
|
|
|
pub mod transform;
|
2017-03-09 18:10:05 +00:00
|
|
|
pub mod util;
|
2016-09-16 01:18:40 +00:00
|
|
|
|
2023-05-17 10:30:14 +00:00
|
|
|
pub use errors::ReportErrorExt;
|
|
|
|
|
2022-10-13 09:13:02 +00:00
|
|
|
use rustc_errors::{DiagnosticMessage, SubdiagnosticMessage};
|
2023-04-16 12:33:00 +00:00
|
|
|
use rustc_fluent_macro::fluent_messages;
|
2023-05-15 04:24:45 +00:00
|
|
|
use rustc_middle::query::Providers;
|
2023-09-22 09:14:39 +00:00
|
|
|
use rustc_middle::{hooks, ty};
|
2017-02-20 01:55:28 +00:00
|
|
|
|
2023-03-02 23:18:38 +00:00
|
|
|
fluent_messages! { "../messages.ftl" }
|
2022-10-13 09:13:02 +00:00
|
|
|
|
2023-09-22 09:14:39 +00:00
|
|
|
pub fn provide(providers: &mut Providers, hooks: &mut hooks::Providers) {
|
2020-01-01 17:06:00 +00:00
|
|
|
const_eval::provide(providers);
|
2020-09-19 08:57:14 +00:00
|
|
|
providers.eval_to_const_value_raw = const_eval::eval_to_const_value_raw_provider;
|
2020-08-20 16:55:07 +00:00
|
|
|
providers.eval_to_allocation_raw = const_eval::eval_to_allocation_raw_provider;
|
2019-10-25 00:35:02 +00:00
|
|
|
providers.const_caller_location = const_eval::const_caller_location;
|
2022-04-12 16:14:28 +00: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 16:14:28 +00:00
|
|
|
const_eval::eval_to_valtree(tcx, param_env, raw)
|
2021-02-22 14:09:24 +00:00
|
|
|
};
|
2023-09-22 09:14:39 +00:00
|
|
|
hooks.try_destructure_mir_constant_for_diagnostics =
|
|
|
|
const_eval::try_destructure_mir_constant_for_diagnostics;
|
2022-02-16 09:56:01 +00:00
|
|
|
providers.valtree_to_const_val = |tcx, (ty, valtree)| {
|
|
|
|
const_eval::valtree_to_const_value(tcx, ty::ParamEnv::empty().and(ty), valtree)
|
2020-07-01 09:41:38 +00:00
|
|
|
};
|
2023-02-26 21:50:19 +00:00
|
|
|
providers.check_validity_requirement = |tcx, (init_kind, param_env_and_ty)| {
|
|
|
|
util::check_validity_requirement(tcx, init_kind, param_env_and_ty)
|
2023-01-22 22:06:28 +00:00
|
|
|
};
|
2017-03-14 19:22:38 +00:00
|
|
|
}
|