rename mir -> thir around abstract consts
This commit is contained in:
parent
15101c8e95
commit
406d2ab95d
22 changed files with 287 additions and 284 deletions
|
@ -6,7 +6,7 @@
|
|||
//! this is not as easy.
|
||||
//!
|
||||
//! In this case we try to build an abstract representation of this constant using
|
||||
//! `mir_abstract_const` which can then be checked for structural equality with other
|
||||
//! `thir_abstract_const` which can then be checked for structural equality with other
|
||||
//! generic constants mentioned in the `caller_bounds` of the current environment.
|
||||
use rustc_data_structures::sync::Lrc;
|
||||
use rustc_errors::ErrorReported;
|
||||
|
@ -14,9 +14,9 @@ use rustc_hir::def::DefKind;
|
|||
use rustc_index::vec::IndexVec;
|
||||
use rustc_infer::infer::InferCtxt;
|
||||
use rustc_middle::mir;
|
||||
use rustc_middle::mir::abstract_const::{Node, NodeId, NotConstEvaluatable};
|
||||
use rustc_middle::mir::interpret::ErrorHandled;
|
||||
use rustc_middle::thir;
|
||||
use rustc_middle::thir::abstract_const::{Node, NodeId, NotConstEvaluatable};
|
||||
use rustc_middle::ty::subst::{Subst, SubstsRef};
|
||||
use rustc_middle::ty::{self, TyCtxt, TypeFoldable};
|
||||
use rustc_session::lint;
|
||||
|
@ -197,7 +197,7 @@ impl<'tcx> AbstractConst<'tcx> {
|
|||
tcx: TyCtxt<'tcx>,
|
||||
uv: ty::Unevaluated<'tcx, ()>,
|
||||
) -> Result<Option<AbstractConst<'tcx>>, ErrorReported> {
|
||||
let inner = tcx.mir_abstract_const_opt_const_arg(uv.def)?;
|
||||
let inner = tcx.thir_abstract_const_opt_const_arg(uv.def)?;
|
||||
debug!("AbstractConst::new({:?}) = {:?}", uv, inner);
|
||||
Ok(inner.map(|inner| AbstractConst { inner, substs: uv.substs(tcx) }))
|
||||
}
|
||||
|
@ -421,10 +421,10 @@ impl<'a, 'tcx> AbstractConstBuilder<'a, 'tcx> {
|
|||
}
|
||||
|
||||
/// Builds an abstract const, do not use this directly, but use `AbstractConst::new` instead.
|
||||
pub(super) fn mir_abstract_const<'tcx>(
|
||||
pub(super) fn thir_abstract_const<'tcx>(
|
||||
tcx: TyCtxt<'tcx>,
|
||||
def: ty::WithOptConstParam<LocalDefId>,
|
||||
) -> Result<Option<&'tcx [mir::abstract_const::Node<'tcx>]>, ErrorReported> {
|
||||
) -> Result<Option<&'tcx [thir::abstract_const::Node<'tcx>]>, ErrorReported> {
|
||||
if tcx.features().generic_const_exprs {
|
||||
match tcx.def_kind(def.did) {
|
||||
// FIXME(generic_const_exprs): We currently only do this for anonymous constants,
|
||||
|
@ -435,7 +435,7 @@ pub(super) fn mir_abstract_const<'tcx>(
|
|||
DefKind::AnonConst => (),
|
||||
_ => return Ok(None),
|
||||
}
|
||||
|
||||
|
||||
let body = tcx.thir_body(def);
|
||||
if body.0.borrow().exprs.is_empty() {
|
||||
// type error in constant, there is no thir
|
||||
|
|
|
@ -19,7 +19,7 @@ use rustc_hir::intravisit::Visitor;
|
|||
use rustc_hir::GenericParam;
|
||||
use rustc_hir::Item;
|
||||
use rustc_hir::Node;
|
||||
use rustc_middle::mir::abstract_const::NotConstEvaluatable;
|
||||
use rustc_middle::thir::abstract_const::NotConstEvaluatable;
|
||||
use rustc_middle::ty::error::ExpectedFound;
|
||||
use rustc_middle::ty::fold::TypeFolder;
|
||||
use rustc_middle::ty::{
|
||||
|
|
|
@ -5,8 +5,8 @@ use rustc_data_structures::obligation_forest::{ObligationForest, ObligationProce
|
|||
use rustc_errors::ErrorReported;
|
||||
use rustc_hir as hir;
|
||||
use rustc_infer::traits::{SelectionError, TraitEngine, TraitEngineExt as _, TraitObligation};
|
||||
use rustc_middle::mir::abstract_const::NotConstEvaluatable;
|
||||
use rustc_middle::mir::interpret::ErrorHandled;
|
||||
use rustc_middle::thir::abstract_const::NotConstEvaluatable;
|
||||
use rustc_middle::ty::error::{ExpectedFound, TypeError};
|
||||
use rustc_middle::ty::subst::SubstsRef;
|
||||
use rustc_middle::ty::ToPredicate;
|
||||
|
|
|
@ -827,16 +827,16 @@ pub fn provide(providers: &mut ty::query::Providers) {
|
|||
vtable_entries,
|
||||
vtable_trait_upcasting_coercion_new_vptr_slot,
|
||||
subst_and_check_impossible_predicates,
|
||||
mir_abstract_const: |tcx, def_id| {
|
||||
thir_abstract_const: |tcx, def_id| {
|
||||
let def_id = def_id.expect_local();
|
||||
if let Some(def) = ty::WithOptConstParam::try_lookup(def_id, tcx) {
|
||||
tcx.mir_abstract_const_of_const_arg(def)
|
||||
tcx.thir_abstract_const_of_const_arg(def)
|
||||
} else {
|
||||
const_evaluatable::mir_abstract_const(tcx, ty::WithOptConstParam::unknown(def_id))
|
||||
const_evaluatable::thir_abstract_const(tcx, ty::WithOptConstParam::unknown(def_id))
|
||||
}
|
||||
},
|
||||
mir_abstract_const_of_const_arg: |tcx, (did, param_did)| {
|
||||
const_evaluatable::mir_abstract_const(
|
||||
thir_abstract_const_of_const_arg: |tcx, (did, param_did)| {
|
||||
const_evaluatable::thir_abstract_const(
|
||||
tcx,
|
||||
ty::WithOptConstParam { did, const_param_did: Some(param_did) },
|
||||
)
|
||||
|
|
|
@ -836,7 +836,7 @@ fn contains_illegal_self_type_reference<'tcx, T: TypeFoldable<'tcx>>(
|
|||
//
|
||||
// This shouldn't really matter though as we can't really use any
|
||||
// constants which are not considered const evaluatable.
|
||||
use rustc_middle::mir::abstract_const::Node;
|
||||
use rustc_middle::thir::abstract_const::Node;
|
||||
if let Ok(Some(ct)) = AbstractConst::new(self.tcx, uv.shrink()) {
|
||||
const_evaluatable::walk_abstract_const(self.tcx, ct, |node| match node.root() {
|
||||
Node::Leaf(leaf) => {
|
||||
|
|
|
@ -34,8 +34,8 @@ use rustc_hir as hir;
|
|||
use rustc_hir::def_id::DefId;
|
||||
use rustc_infer::infer::LateBoundRegionConversionTime;
|
||||
use rustc_middle::dep_graph::{DepKind, DepNodeIndex};
|
||||
use rustc_middle::mir::abstract_const::NotConstEvaluatable;
|
||||
use rustc_middle::mir::interpret::ErrorHandled;
|
||||
use rustc_middle::thir::abstract_const::NotConstEvaluatable;
|
||||
use rustc_middle::ty::fast_reject;
|
||||
use rustc_middle::ty::print::with_no_trimmed_paths;
|
||||
use rustc_middle::ty::relate::TypeRelation;
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue