提交 c5fc2609 编写于 作者: C Camille GILLOT

Rename rustc_mir to rustc_const_eval.

上级 fd9c04fe
...@@ -3605,6 +3605,7 @@ dependencies = [ ...@@ -3605,6 +3605,7 @@ dependencies = [
"either", "either",
"itertools 0.9.0", "itertools 0.9.0",
"polonius-engine", "polonius-engine",
"rustc_const_eval",
"rustc_data_structures", "rustc_data_structures",
"rustc_errors", "rustc_errors",
"rustc_graphviz", "rustc_graphviz",
...@@ -3613,7 +3614,6 @@ dependencies = [ ...@@ -3613,7 +3614,6 @@ dependencies = [
"rustc_infer", "rustc_infer",
"rustc_lexer", "rustc_lexer",
"rustc_middle", "rustc_middle",
"rustc_mir",
"rustc_mir_dataflow", "rustc_mir_dataflow",
"rustc_serialize", "rustc_serialize",
"rustc_session", "rustc_session",
...@@ -3708,6 +3708,30 @@ dependencies = [ ...@@ -3708,6 +3708,30 @@ dependencies = [
"tracing", "tracing",
] ]
[[package]]
name = "rustc_const_eval"
version = "0.0.0"
dependencies = [
"either",
"gsgdt",
"rustc_apfloat",
"rustc_ast",
"rustc_attr",
"rustc_data_structures",
"rustc_errors",
"rustc_hir",
"rustc_index",
"rustc_infer",
"rustc_macros",
"rustc_middle",
"rustc_mir_dataflow",
"rustc_session",
"rustc_span",
"rustc_target",
"rustc_trait_selection",
"tracing",
]
[[package]] [[package]]
name = "rustc_data_structures" name = "rustc_data_structures"
version = "0.0.0" version = "0.0.0"
...@@ -3746,6 +3770,7 @@ dependencies = [ ...@@ -3746,6 +3770,7 @@ dependencies = [
"rustc_ast", "rustc_ast",
"rustc_ast_pretty", "rustc_ast_pretty",
"rustc_codegen_ssa", "rustc_codegen_ssa",
"rustc_const_eval",
"rustc_data_structures", "rustc_data_structures",
"rustc_error_codes", "rustc_error_codes",
"rustc_errors", "rustc_errors",
...@@ -3756,7 +3781,6 @@ dependencies = [ ...@@ -3756,7 +3781,6 @@ dependencies = [
"rustc_lint", "rustc_lint",
"rustc_metadata", "rustc_metadata",
"rustc_middle", "rustc_middle",
"rustc_mir",
"rustc_parse", "rustc_parse",
"rustc_plugin_impl", "rustc_plugin_impl",
"rustc_save_analysis", "rustc_save_analysis",
...@@ -3919,6 +3943,7 @@ dependencies = [ ...@@ -3919,6 +3943,7 @@ dependencies = [
"rustc_builtin_macros", "rustc_builtin_macros",
"rustc_codegen_llvm", "rustc_codegen_llvm",
"rustc_codegen_ssa", "rustc_codegen_ssa",
"rustc_const_eval",
"rustc_data_structures", "rustc_data_structures",
"rustc_errors", "rustc_errors",
"rustc_expand", "rustc_expand",
...@@ -3927,7 +3952,6 @@ dependencies = [ ...@@ -3927,7 +3952,6 @@ dependencies = [
"rustc_lint", "rustc_lint",
"rustc_metadata", "rustc_metadata",
"rustc_middle", "rustc_middle",
"rustc_mir",
"rustc_mir_build", "rustc_mir_build",
"rustc_mir_transform", "rustc_mir_transform",
"rustc_monomorphize", "rustc_monomorphize",
...@@ -4073,30 +4097,6 @@ dependencies = [ ...@@ -4073,30 +4097,6 @@ dependencies = [
"tracing", "tracing",
] ]
[[package]]
name = "rustc_mir"
version = "0.0.0"
dependencies = [
"either",
"gsgdt",
"rustc_apfloat",
"rustc_ast",
"rustc_attr",
"rustc_data_structures",
"rustc_errors",
"rustc_hir",
"rustc_index",
"rustc_infer",
"rustc_macros",
"rustc_middle",
"rustc_mir_dataflow",
"rustc_session",
"rustc_span",
"rustc_target",
"rustc_trait_selection",
"tracing",
]
[[package]] [[package]]
name = "rustc_mir_build" name = "rustc_mir_build"
version = "0.0.0" version = "0.0.0"
...@@ -4148,12 +4148,12 @@ dependencies = [ ...@@ -4148,12 +4148,12 @@ dependencies = [
"itertools 0.9.0", "itertools 0.9.0",
"rustc_ast", "rustc_ast",
"rustc_attr", "rustc_attr",
"rustc_const_eval",
"rustc_data_structures", "rustc_data_structures",
"rustc_errors", "rustc_errors",
"rustc_hir", "rustc_hir",
"rustc_index", "rustc_index",
"rustc_middle", "rustc_middle",
"rustc_mir",
"rustc_mir_dataflow", "rustc_mir_dataflow",
"rustc_serialize", "rustc_serialize",
"rustc_session", "rustc_session",
......
...@@ -21,7 +21,7 @@ rustc_index = { path = "../rustc_index" } ...@@ -21,7 +21,7 @@ rustc_index = { path = "../rustc_index" }
rustc_infer = { path = "../rustc_infer" } rustc_infer = { path = "../rustc_infer" }
rustc_lexer = { path = "../rustc_lexer" } rustc_lexer = { path = "../rustc_lexer" }
rustc_middle = { path = "../rustc_middle" } rustc_middle = { path = "../rustc_middle" }
rustc_mir = { path = "../rustc_mir" } rustc_const_eval = { path = "../rustc_const_eval" }
rustc_mir_dataflow = { path = "../rustc_mir_dataflow" } rustc_mir_dataflow = { path = "../rustc_mir_dataflow" }
rustc_serialize = { path = "../rustc_serialize" } rustc_serialize = { path = "../rustc_serialize" }
rustc_session = { path = "../rustc_session" } rustc_session = { path = "../rustc_session" }
......
...@@ -1695,7 +1695,7 @@ fn explain_deref_coercion(&mut self, loan: &BorrowData<'tcx>, err: &mut Diagnost ...@@ -1695,7 +1695,7 @@ fn explain_deref_coercion(&mut self, loan: &BorrowData<'tcx>, err: &mut Diagnost
Some((method_did, method_substs)), Some((method_did, method_substs)),
) = ( ) = (
&self.body[loan.reserve_location.block].terminator, &self.body[loan.reserve_location.block].terminator,
rustc_mir::util::find_self_call( rustc_const_eval::util::find_self_call(
tcx, tcx,
self.body, self.body,
loan.assigned_place.local, loan.assigned_place.local,
......
...@@ -899,12 +899,13 @@ pub(super) fn move_spans( ...@@ -899,12 +899,13 @@ pub(super) fn move_spans(
kind: TerminatorKind::Call { fn_span, from_hir_call, .. }, .. kind: TerminatorKind::Call { fn_span, from_hir_call, .. }, ..
}) = &self.body[location.block].terminator }) = &self.body[location.block].terminator
{ {
let (method_did, method_substs) = if let Some(info) = rustc_mir::util::find_self_call( let (method_did, method_substs) = if let Some(info) =
self.infcx.tcx, rustc_const_eval::util::find_self_call(
&self.body, self.infcx.tcx,
target_temp, &self.body,
location.block, target_temp,
) { location.block,
) {
info info
} else { } else {
return normal_ret; return normal_ret;
......
...@@ -16,8 +16,8 @@ ...@@ -16,8 +16,8 @@
use crate::diagnostics::BorrowedContentSource; use crate::diagnostics::BorrowedContentSource;
use crate::MirBorrowckCtxt; use crate::MirBorrowckCtxt;
use rustc_const_eval::util::collect_writes::FindAssignments;
use rustc_errors::{Applicability, DiagnosticBuilder}; use rustc_errors::{Applicability, DiagnosticBuilder};
use rustc_mir::util::collect_writes::FindAssignments;
#[derive(Copy, Clone, Debug, Eq, PartialEq)] #[derive(Copy, Clone, Debug, Eq, PartialEq)]
pub(crate) enum AccessKind { pub(crate) enum AccessKind {
......
...@@ -41,7 +41,7 @@ ...@@ -41,7 +41,7 @@
use rustc_trait_selection::traits::query::Fallible; use rustc_trait_selection::traits::query::Fallible;
use rustc_trait_selection::traits::{self, ObligationCause, PredicateObligations}; use rustc_trait_selection::traits::{self, ObligationCause, PredicateObligations};
use rustc_mir::transform::{ use rustc_const_eval::transform::{
check_consts::ConstCx, promote_consts::is_const_fn_in_array_repeat_expression, check_consts::ConstCx, promote_consts::is_const_fn_in_array_repeat_expression,
}; };
use rustc_mir_dataflow::impls::MaybeInitializedPlaces; use rustc_mir_dataflow::impls::MaybeInitializedPlaces;
......
[package] [package]
name = "rustc_mir" name = "rustc_const_eval"
version = "0.0.0" version = "0.0.0"
edition = "2018" edition = "2018"
......
...@@ -22,7 +22,7 @@ rustc_feature = { path = "../rustc_feature" } ...@@ -22,7 +22,7 @@ rustc_feature = { path = "../rustc_feature" }
rustc_hir = { path = "../rustc_hir" } rustc_hir = { path = "../rustc_hir" }
rustc_hir_pretty = { path = "../rustc_hir_pretty" } rustc_hir_pretty = { path = "../rustc_hir_pretty" }
rustc_metadata = { path = "../rustc_metadata" } rustc_metadata = { path = "../rustc_metadata" }
rustc_mir = { path = "../rustc_mir" } rustc_const_eval = { path = "../rustc_const_eval" }
rustc_parse = { path = "../rustc_parse" } rustc_parse = { path = "../rustc_parse" }
rustc_plugin_impl = { path = "../rustc_plugin_impl" } rustc_plugin_impl = { path = "../rustc_plugin_impl" }
rustc_save_analysis = { path = "../rustc_save_analysis" } rustc_save_analysis = { path = "../rustc_save_analysis" }
......
...@@ -32,7 +32,7 @@ rustc_symbol_mangling = { path = "../rustc_symbol_mangling" } ...@@ -32,7 +32,7 @@ rustc_symbol_mangling = { path = "../rustc_symbol_mangling" }
rustc_codegen_llvm = { path = "../rustc_codegen_llvm", optional = true } rustc_codegen_llvm = { path = "../rustc_codegen_llvm", optional = true }
rustc_hir = { path = "../rustc_hir" } rustc_hir = { path = "../rustc_hir" }
rustc_metadata = { path = "../rustc_metadata" } rustc_metadata = { path = "../rustc_metadata" }
rustc_mir = { path = "../rustc_mir" } rustc_const_eval = { path = "../rustc_const_eval" }
rustc_mir_build = { path = "../rustc_mir_build" } rustc_mir_build = { path = "../rustc_mir_build" }
rustc_mir_transform = { path = "../rustc_mir_transform" } rustc_mir_transform = { path = "../rustc_mir_transform" }
rustc_monomorphize = { path = "../rustc_monomorphize" } rustc_monomorphize = { path = "../rustc_monomorphize" }
......
...@@ -22,7 +22,6 @@ ...@@ -22,7 +22,6 @@
use rustc_middle::middle::cstore::{MetadataLoader, MetadataLoaderDyn}; use rustc_middle::middle::cstore::{MetadataLoader, MetadataLoaderDyn};
use rustc_middle::ty::query::Providers; use rustc_middle::ty::query::Providers;
use rustc_middle::ty::{self, GlobalCtxt, ResolverOutputs, TyCtxt}; use rustc_middle::ty::{self, GlobalCtxt, ResolverOutputs, TyCtxt};
use rustc_mir as mir;
use rustc_mir_build as mir_build; use rustc_mir_build as mir_build;
use rustc_parse::{parse_crate_from_file, parse_crate_from_source_str}; use rustc_parse::{parse_crate_from_file, parse_crate_from_source_str};
use rustc_passes::{self, hir_stats, layout_test}; use rustc_passes::{self, hir_stats, layout_test};
...@@ -738,8 +737,8 @@ pub fn prepare_outputs( ...@@ -738,8 +737,8 @@ pub fn prepare_outputs(
let providers = &mut Providers::default(); let providers = &mut Providers::default();
providers.analysis = analysis; providers.analysis = analysis;
proc_macro_decls::provide(providers); proc_macro_decls::provide(providers);
rustc_const_eval::provide(providers);
rustc_middle::hir::provide(providers); rustc_middle::hir::provide(providers);
mir::provide(providers);
mir_borrowck::provide(providers); mir_borrowck::provide(providers);
mir_build::provide(providers); mir_build::provide(providers);
rustc_mir_transform::provide(providers); rustc_mir_transform::provide(providers);
......
...@@ -8,7 +8,7 @@ ...@@ -8,7 +8,7 @@
//! - **MIR.** The "mid-level (M) intermediate representation (IR)" is //! - **MIR.** The "mid-level (M) intermediate representation (IR)" is
//! defined in the `mir` module. This module contains only the //! defined in the `mir` module. This module contains only the
//! *definition* of the MIR; the passes that transform and operate //! *definition* of the MIR; the passes that transform and operate
//! on MIR are found in `rustc_mir` crate. //! on MIR are found in `rustc_const_eval` crate.
//! - **Types.** The internal representation of types used in rustc is //! - **Types.** The internal representation of types used in rustc is
//! defined in the `ty` module. This includes the **type context** //! defined in the `ty` module. This includes the **type context**
//! (or `tcx`), which is the central context during most of //! (or `tcx`), which is the central context during most of
......
...@@ -1170,7 +1170,7 @@ pub struct VarDebugInfo<'tcx> { ...@@ -1170,7 +1170,7 @@ pub struct VarDebugInfo<'tcx> {
/// [CFG]: https://rustc-dev-guide.rust-lang.org/appendix/background.html#cfg /// [CFG]: https://rustc-dev-guide.rust-lang.org/appendix/background.html#cfg
/// [data-flow analyses]: /// [data-flow analyses]:
/// https://rustc-dev-guide.rust-lang.org/appendix/background.html#what-is-a-dataflow-analysis /// https://rustc-dev-guide.rust-lang.org/appendix/background.html#what-is-a-dataflow-analysis
/// [`CriticalCallEdges`]: ../../rustc_mir/transform/add_call_guards/enum.AddCallGuards.html#variant.CriticalCallEdges /// [`CriticalCallEdges`]: ../../rustc_const_eval/transform/add_call_guards/enum.AddCallGuards.html#variant.CriticalCallEdges
/// [guide-mir]: https://rustc-dev-guide.rust-lang.org/mir/ /// [guide-mir]: https://rustc-dev-guide.rust-lang.org/mir/
pub struct BasicBlock { pub struct BasicBlock {
derive [HashStable] derive [HashStable]
......
...@@ -219,7 +219,7 @@ pub struct BorrowCheckResult<'tcx> { ...@@ -219,7 +219,7 @@ pub struct BorrowCheckResult<'tcx> {
/// The result of the `mir_const_qualif` query. /// The result of the `mir_const_qualif` query.
/// ///
/// Each field (except `error_occured`) corresponds to an implementer of the `Qualif` trait in /// Each field (except `error_occured`) corresponds to an implementer of the `Qualif` trait in
/// `rustc_mir/src/transform/check_consts/qualifs.rs`. See that file for more information on each /// `rustc_const_eval/src/transform/check_consts/qualifs.rs`. See that file for more information on each
/// `Qualif`. /// `Qualif`.
#[derive(Clone, Copy, Debug, Default, TyEncodable, TyDecodable, HashStable)] #[derive(Clone, Copy, Debug, Default, TyEncodable, TyDecodable, HashStable)]
pub struct ConstQualifs { pub struct ConstQualifs {
...@@ -313,7 +313,7 @@ pub struct ClosureOutlivesRequirement<'tcx> { ...@@ -313,7 +313,7 @@ pub struct ClosureOutlivesRequirement<'tcx> {
/// are interesting (for error reporting). Order of variants indicates sort /// are interesting (for error reporting). Order of variants indicates sort
/// order of the category, thereby influencing diagnostic output. /// order of the category, thereby influencing diagnostic output.
/// ///
/// See also `rustc_mir::borrow_check::constraints`. /// See also `rustc_const_eval::borrow_check::constraints`.
#[derive(Copy, Clone, Debug, Eq, PartialEq, PartialOrd, Ord, Hash)] #[derive(Copy, Clone, Debug, Eq, PartialEq, PartialOrd, Ord, Hash)]
#[derive(TyEncodable, TyDecodable, HashStable)] #[derive(TyEncodable, TyDecodable, HashStable)]
pub enum ConstraintCategory { pub enum ConstraintCategory {
......
...@@ -643,7 +643,7 @@ pub fn discr_ty(&self, tcx: TyCtxt<'tcx>) -> Ty<'tcx> { ...@@ -643,7 +643,7 @@ pub fn discr_ty(&self, tcx: TyCtxt<'tcx>) -> Ty<'tcx> {
} }
/// This returns the types of the MIR locals which had to be stored across suspension points. /// This returns the types of the MIR locals which had to be stored across suspension points.
/// It is calculated in rustc_mir::transform::generator::StateTransform. /// It is calculated in rustc_const_eval::transform::generator::StateTransform.
/// All the types here must be in the tuple in GeneratorInterior. /// All the types here must be in the tuple in GeneratorInterior.
/// ///
/// The locals are grouped by their variant number. Note that some locals may /// The locals are grouped by their variant number. Note that some locals may
...@@ -1268,7 +1268,7 @@ pub fn for_def(def: &ty::GenericParamDef) -> ParamConst { ...@@ -1268,7 +1268,7 @@ pub fn for_def(def: &ty::GenericParamDef) -> ParamConst {
/// Representation of regions. Note that the NLL checker uses a distinct /// Representation of regions. Note that the NLL checker uses a distinct
/// representation of regions. For this reason, it internally replaces all the /// representation of regions. For this reason, it internally replaces all the
/// regions with inference variables -- the index of the variable is then used /// regions with inference variables -- the index of the variable is then used
/// to index into internal NLL data structures. See `rustc_mir::borrow_check` /// to index into internal NLL data structures. See `rustc_const_eval::borrow_check`
/// module for more information. /// module for more information.
/// ///
/// ## The Region lattice within a given function /// ## The Region lattice within a given function
......
...@@ -11,7 +11,7 @@ ...@@ -11,7 +11,7 @@
//! `visit_results`. The following example uses the `ResultsCursor` approach. //! `visit_results`. The following example uses the `ResultsCursor` approach.
//! //!
//! ```ignore (cross-crate-imports) //! ```ignore (cross-crate-imports)
//! use rustc_mir::dataflow::Analysis; // Makes `into_engine` available. //! use rustc_const_eval::dataflow::Analysis; // Makes `into_engine` available.
//! //!
//! fn do_my_analysis(tcx: TyCtxt<'tcx>, body: &mir::Body<'tcx>) { //! fn do_my_analysis(tcx: TyCtxt<'tcx>, body: &mir::Body<'tcx>) {
//! let analysis = MyAnalysis::new() //! let analysis = MyAnalysis::new()
......
...@@ -18,7 +18,7 @@ rustc_errors = { path = "../rustc_errors" } ...@@ -18,7 +18,7 @@ rustc_errors = { path = "../rustc_errors" }
rustc_hir = { path = "../rustc_hir" } rustc_hir = { path = "../rustc_hir" }
rustc_index = { path = "../rustc_index" } rustc_index = { path = "../rustc_index" }
rustc_middle = { path = "../rustc_middle" } rustc_middle = { path = "../rustc_middle" }
rustc_mir = { path = "../rustc_mir" } rustc_const_eval = { path = "../rustc_const_eval" }
rustc_mir_dataflow = { path = "../rustc_mir_dataflow" } rustc_mir_dataflow = { path = "../rustc_mir_dataflow" }
rustc_serialize = { path = "../rustc_serialize" } rustc_serialize = { path = "../rustc_serialize" }
rustc_session = { path = "../rustc_session" } rustc_session = { path = "../rustc_session" }
......
...@@ -29,8 +29,8 @@ ...@@ -29,8 +29,8 @@
use rustc_trait_selection::traits; use rustc_trait_selection::traits;
use crate::MirPass; use crate::MirPass;
use rustc_mir::const_eval::ConstEvalErr; use rustc_const_eval::const_eval::ConstEvalErr;
use rustc_mir::interpret::{ use rustc_const_eval::interpret::{
self, compile_time_machine, AllocId, Allocation, ConstValue, CtfeValidationMode, Frame, ImmTy, self, compile_time_machine, AllocId, Allocation, ConstValue, CtfeValidationMode, Frame, ImmTy,
Immediate, InterpCx, InterpResult, LocalState, LocalValue, MemPlace, MemoryKind, OpTy, Immediate, InterpCx, InterpResult, LocalState, LocalValue, MemPlace, MemoryKind, OpTy,
Operand as InterpOperand, PlaceTy, Scalar, ScalarMaybeUninit, StackPopCleanup, StackPopUnwind, Operand as InterpOperand, PlaceTy, Scalar, ScalarMaybeUninit, StackPopCleanup, StackPopUnwind,
......
...@@ -19,6 +19,7 @@ ...@@ -19,6 +19,7 @@
extern crate rustc_middle; extern crate rustc_middle;
use required_consts::RequiredConstsVisitor; use required_consts::RequiredConstsVisitor;
use rustc_const_eval::util;
use rustc_data_structures::fx::FxHashSet; use rustc_data_structures::fx::FxHashSet;
use rustc_data_structures::steal::Steal; use rustc_data_structures::steal::Steal;
use rustc_hir as hir; use rustc_hir as hir;
...@@ -29,7 +30,6 @@ ...@@ -29,7 +30,6 @@
use rustc_middle::mir::{traversal, Body, ConstQualifs, MirPhase, Promoted}; use rustc_middle::mir::{traversal, Body, ConstQualifs, MirPhase, Promoted};
use rustc_middle::ty::query::Providers; use rustc_middle::ty::query::Providers;
use rustc_middle::ty::{self, TyCtxt, TypeFoldable}; use rustc_middle::ty::{self, TyCtxt, TypeFoldable};
use rustc_mir::util;
use rustc_span::{Span, Symbol}; use rustc_span::{Span, Symbol};
mod abort_unwinding_calls; mod abort_unwinding_calls;
...@@ -73,10 +73,10 @@ ...@@ -73,10 +73,10 @@
mod uninhabited_enum_branching; mod uninhabited_enum_branching;
mod unreachable_prop; mod unreachable_prop;
use rustc_mir::transform::check_consts; use rustc_const_eval::transform::check_consts;
use rustc_mir::transform::promote_consts; use rustc_const_eval::transform::promote_consts;
use rustc_mir::transform::validate; use rustc_const_eval::transform::validate;
use rustc_mir::transform::MirPass; use rustc_const_eval::transform::MirPass;
use rustc_mir_dataflow::rustc_peek; use rustc_mir_dataflow::rustc_peek;
pub fn provide(providers: &mut Providers) { pub fn provide(providers: &mut Providers) {
......
//! This pass lowers calls to core::slice::len to just Len op. //! This pass lowers calls to core::slice::len to just Len op.
//! It should run before inlining! //! It should run before inlining!
use crate::MirPass;
use rustc_hir::def_id::DefId; use rustc_hir::def_id::DefId;
use rustc_index::vec::IndexVec; use rustc_index::vec::IndexVec;
use rustc_middle::mir::*; use rustc_middle::mir::*;
use rustc_middle::ty::{self, TyCtxt}; use rustc_middle::ty::{self, TyCtxt};
use rustc_mir::transform::MirPass;
pub struct LowerSliceLenCalls; pub struct LowerSliceLenCalls;
......
...@@ -134,7 +134,7 @@ fn run_pass(&self, tcx: TyCtxt<'tcx>, body: &mut Body<'tcx>) { ...@@ -134,7 +134,7 @@ fn run_pass(&self, tcx: TyCtxt<'tcx>, body: &mut Body<'tcx>) {
let const_cmp = Operand::const_from_scalar( let const_cmp = Operand::const_from_scalar(
tcx, tcx,
switch_ty, switch_ty,
rustc_mir::interpret::Scalar::from_uint(val, size), rustc_const_eval::interpret::Scalar::from_uint(val, size),
rustc_span::DUMMY_SP, rustc_span::DUMMY_SP,
); );
let op = if f_b { BinOp::Eq } else { BinOp::Ne }; let op = if f_b { BinOp::Eq } else { BinOp::Ne };
......
//! This calculates the types which has storage which lives across a suspension point in a //! This calculates the types which has storage which lives across a suspension point in a
//! generator from the perspective of typeck. The actual types used at runtime //! generator from the perspective of typeck. The actual types used at runtime
//! is calculated in `rustc_mir::transform::generator` and may be a subset of the //! is calculated in `rustc_const_eval::transform::generator` and may be a subset of the
//! types computed here. //! types computed here.
use super::FnCtxt; use super::FnCtxt;
......
...@@ -11,6 +11,7 @@ ...@@ -11,6 +11,7 @@
use rustc_ast as ast; use rustc_ast as ast;
use rustc_attr as attr; use rustc_attr as attr;
use rustc_const_eval::const_eval::{is_const_fn, is_unstable_const_fn};
use rustc_data_structures::fx::{FxHashMap, FxHashSet}; use rustc_data_structures::fx::{FxHashMap, FxHashSet};
use rustc_hir as hir; use rustc_hir as hir;
use rustc_hir::def::{CtorKind, DefKind, Res}; use rustc_hir::def::{CtorKind, DefKind, Res};
...@@ -22,7 +23,6 @@ ...@@ -22,7 +23,6 @@
use rustc_middle::ty::subst::{InternalSubsts, Subst}; use rustc_middle::ty::subst::{InternalSubsts, Subst};
use rustc_middle::ty::{self, AdtKind, DefIdTree, Lift, Ty, TyCtxt}; use rustc_middle::ty::{self, AdtKind, DefIdTree, Lift, Ty, TyCtxt};
use rustc_middle::{bug, span_bug}; use rustc_middle::{bug, span_bug};
use rustc_mir::const_eval::{is_const_fn, is_unstable_const_fn};
use rustc_span::hygiene::{AstPass, MacroKind}; use rustc_span::hygiene::{AstPass, MacroKind};
use rustc_span::symbol::{kw, sym, Ident, Symbol}; use rustc_span::symbol::{kw, sym, Ident, Symbol};
use rustc_span::{self, ExpnKind}; use rustc_span::{self, ExpnKind};
......
...@@ -34,6 +34,7 @@ ...@@ -34,6 +34,7 @@
extern crate rustc_ast_lowering; extern crate rustc_ast_lowering;
extern crate rustc_ast_pretty; extern crate rustc_ast_pretty;
extern crate rustc_attr; extern crate rustc_attr;
extern crate rustc_const_eval;
extern crate rustc_data_structures; extern crate rustc_data_structures;
extern crate rustc_driver; extern crate rustc_driver;
extern crate rustc_errors; extern crate rustc_errors;
...@@ -49,7 +50,6 @@ ...@@ -49,7 +50,6 @@
extern crate rustc_lint_defs; extern crate rustc_lint_defs;
extern crate rustc_metadata; extern crate rustc_metadata;
extern crate rustc_middle; extern crate rustc_middle;
extern crate rustc_mir;
extern crate rustc_parse; extern crate rustc_parse;
extern crate rustc_passes; extern crate rustc_passes;
extern crate rustc_resolve; extern crate rustc_resolve;
......
...@@ -3,7 +3,7 @@ ...@@ -3,7 +3,7 @@
# Check that cross-crate inlined items are inlined in all compilation units # Check that cross-crate inlined items are inlined in all compilation units
# that refer to them, and not in any other compilation units. # that refer to them, and not in any other compilation units.
# Note that we have to pass `-C codegen-units=6` because up to two CGUs may be # Note that we have to pass `-C codegen-units=6` because up to two CGUs may be
# created for each source module (see `rustc_mir::monomorphize::partitioning`). # created for each source module (see `rustc_const_eval::monomorphize::partitioning`).
all: all:
$(RUSTC) cci_lib.rs $(RUSTC) cci_lib.rs
......
...@@ -17,6 +17,7 @@ ...@@ -17,6 +17,7 @@
extern crate rustc_ast; extern crate rustc_ast;
extern crate rustc_ast_pretty; extern crate rustc_ast_pretty;
extern crate rustc_attr; extern crate rustc_attr;
extern crate rustc_const_eval;
extern crate rustc_data_structures; extern crate rustc_data_structures;
extern crate rustc_errors; extern crate rustc_errors;
extern crate rustc_hir; extern crate rustc_hir;
...@@ -24,7 +25,6 @@ ...@@ -24,7 +25,6 @@
extern crate rustc_lexer; extern crate rustc_lexer;
extern crate rustc_lint; extern crate rustc_lint;
extern crate rustc_middle; extern crate rustc_middle;
extern crate rustc_mir;
extern crate rustc_session; extern crate rustc_session;
extern crate rustc_span; extern crate rustc_span;
extern crate rustc_target; extern crate rustc_target;
......
...@@ -366,7 +366,7 @@ fn check_terminator( ...@@ -366,7 +366,7 @@ fn check_terminator(
} }
fn is_const_fn(tcx: TyCtxt<'_>, def_id: DefId, msrv: Option<&RustcVersion>) -> bool { fn is_const_fn(tcx: TyCtxt<'_>, def_id: DefId, msrv: Option<&RustcVersion>) -> bool {
rustc_mir::const_eval::is_const_fn(tcx, def_id) rustc_const_eval::const_eval::is_const_fn(tcx, def_id)
&& tcx.lookup_const_stability(def_id).map_or(true, |const_stab| { && tcx.lookup_const_stability(def_id).map_or(true, |const_stab| {
if let rustc_attr::StabilityLevel::Stable { since } = const_stab.level { if let rustc_attr::StabilityLevel::Stable { since } = const_stab.level {
// Checking MSRV is manually necessary because `rustc` has no such concept. This entire // Checking MSRV is manually necessary because `rustc` has no such concept. This entire
......
Markdown is supported
0% .
You are about to add 0 people to the discussion. Proceed with caution.
先完成此消息的编辑!
想要评论请 注册