rust/compiler/rustc_const_eval/src/lib.rs

61 lines
2.3 KiB
Rust
Raw Normal View History

// tidy-alphabetical-start
2023-11-13 07:39:17 -05:00
#![allow(internal_features)]
#![allow(rustc::diagnostic_outside_of_impl)]
2023-11-13 07:39:17 -05:00
#![doc(rust_logo)]
#![feature(assert_matches)]
2016-02-11 18:05:28 +02:00
#![feature(box_patterns)]
#![feature(decl_macro)]
#![feature(if_let_guard)]
#![feature(let_chains)]
#![feature(never_type)]
#![feature(rustdoc_internals)]
#![feature(slice_ptr_get)]
#![feature(strict_overflow_ops)]
#![feature(trait_alias)]
#![feature(try_blocks)]
2024-10-14 14:46:44 -07:00
#![feature(unqualified_local_imports)]
2022-05-29 01:19:52 -07:00
#![feature(yeet_expr)]
2024-10-14 14:46:44 -07:00
#![warn(unqualified_local_imports)]
// tidy-alphabetical-end
2015-08-18 17:59:21 -04:00
pub mod check_consts;
2019-12-22 17:42:04 -05:00
pub mod const_eval;
2022-06-28 21:26:05 -07:00
mod errors;
2019-12-22 17:42:04 -05:00
pub mod interpret;
pub mod util;
use std::sync::atomic::AtomicBool;
use rustc_middle::ty;
use rustc_middle::util::Providers;
pub use self::errors::ReportErrorExt;
rustc_fluent_macro::fluent_messages! { "../messages.ftl" }
pub fn provide(providers: &mut Providers) {
const_eval::provide(providers);
providers.tag_for_variant = const_eval::tag_for_variant_provider;
providers.eval_to_const_value_raw = const_eval::eval_to_const_value_raw_provider;
providers.eval_to_allocation_raw = const_eval::eval_to_allocation_raw_provider;
providers.eval_static_initializer = const_eval::eval_static_initializer_provider;
providers.hooks.const_caller_location = util::caller_location::const_caller_location_provider;
providers.eval_to_valtree = |tcx, ty::PseudoCanonicalInput { typing_env, value }| {
const_eval::eval_to_valtree(tcx, typing_env, value)
};
2023-10-31 17:38:41 +00:00
providers.hooks.try_destructure_mir_constant_for_user_output =
const_eval::try_destructure_mir_constant_for_user_output;
providers.valtree_to_const_val =
|tcx, cv| const_eval::valtree_to_const_value(tcx, ty::TypingEnv::fully_monomorphized(), cv);
providers.check_validity_requirement = |tcx, (init_kind, param_env_and_ty)| {
util::check_validity_requirement(tcx, init_kind, param_env_and_ty)
};
providers.hooks.validate_scalar_in_layout =
|tcx, scalar, layout| util::validate_scalar_in_layout(tcx, scalar, layout);
}
/// `rustc_driver::main` installs a handler that will set this to `true` if
/// the compiler has been sent a request to shut down, such as by a Ctrl-C.
/// This static lives here because it is only read by the interpreter.
pub static CTRL_C_RECEIVED: AtomicBool = AtomicBool::new(false);