use rustc::hir::map as hir_map;
use rustc::hir::def_id::DefId;
+use rustc::middle::const_val::ConstVal;
use rustc::middle::lang_items::{ExchangeMallocFnLangItem};
use rustc::traits;
use rustc::ty::subst::Substs;
-use rustc::ty::{self, TypeFoldable, TyCtxt};
+use rustc::ty::{self, TypeFoldable, Ty, TyCtxt};
use rustc::ty::adjustment::CustomCoerceUnsized;
use rustc::mir::{self, Location};
use rustc::mir::visit::Visitor as MirVisitor;
let recursion_depth = recursion_depths.get(&def_id).cloned().unwrap_or(0);
debug!(" => recursion depth={}", recursion_depth);
- let recursion_depth = if Some(def_id) == tcx.lang_items.drop_in_place_fn() {
+ let recursion_depth = if Some(def_id) == tcx.lang_items().drop_in_place_fn() {
// HACK: drop_in_place creates tight monomorphization loops. Give
// it more margin.
recursion_depth / 4
mir::Rvalue::NullaryOp(mir::NullOp::Box, _) => {
let tcx = self.scx.tcx();
let exchange_malloc_fn_def_id = tcx
- .lang_items
+ .lang_items()
.require(ExchangeMallocFnLangItem)
.unwrap_or_else(|e| self.scx.sess().fatal(&e));
let instance = Instance::mono(tcx, exchange_malloc_fn_def_id);
self.super_rvalue(rvalue, location);
}
- fn visit_constant(&mut self, constant: &mir::Constant<'tcx>, location: Location) {
- debug!("visiting constant {:?} @ {:?}", *constant, location);
+ fn visit_const(&mut self, constant: &&'tcx ty::Const<'tcx>, location: Location) {
+ debug!("visiting const {:?} @ {:?}", *constant, location);
- if let ty::TyFnDef(..) = constant.ty.sty {
- // function definitions are zero-sized, and only generate
- // IR when they are called/reified.
- self.super_constant(constant, location);
- return
- }
-
- if let mir::Literal::Item { def_id, substs } = constant.literal {
+ if let ConstVal::Unevaluated(def_id, substs) = constant.val {
let substs = self.scx.tcx().trans_apply_param_substs(self.param_substs,
&substs);
let instance = monomorphize::resolve(self.scx, def_id, substs);
collect_neighbours(self.scx, instance, true, self.output);
}
- self.super_constant(constant, location);
+ self.super_const(constant);
}
fn visit_terminator_kind(&mut self,
}
fn visit_drop_use<'a, 'tcx>(scx: &SharedCrateContext<'a, 'tcx>,
- ty: ty::Ty<'tcx>,
+ ty: Ty<'tcx>,
is_direct_call: bool,
output: &mut Vec<TransItem<'tcx>>)
{
}
fn visit_fn_use<'a, 'tcx>(scx: &SharedCrateContext<'a, 'tcx>,
- ty: ty::Ty<'tcx>,
+ ty: Ty<'tcx>,
is_direct_call: bool,
output: &mut Vec<TransItem<'tcx>>)
{
/// Finally, there is also the case of custom unsizing coercions, e.g. for
/// smart pointers such as `Rc` and `Arc`.
fn find_vtable_types_for_unsizing<'a, 'tcx>(scx: &SharedCrateContext<'a, 'tcx>,
- source_ty: ty::Ty<'tcx>,
- target_ty: ty::Ty<'tcx>)
- -> (ty::Ty<'tcx>, ty::Ty<'tcx>) {
- let ptr_vtable = |inner_source: ty::Ty<'tcx>, inner_target: ty::Ty<'tcx>| {
+ source_ty: Ty<'tcx>,
+ target_ty: Ty<'tcx>)
+ -> (Ty<'tcx>, Ty<'tcx>) {
+ let ptr_vtable = |inner_source: Ty<'tcx>, inner_target: Ty<'tcx>| {
if !scx.type_is_sized(inner_source) {
(inner_source, inner_target)
} else {
/// Creates a `TransItem` for each method that is referenced by the vtable for
/// the given trait/impl pair.
fn create_trans_items_for_vtable_methods<'a, 'tcx>(scx: &SharedCrateContext<'a, 'tcx>,
- trait_ty: ty::Ty<'tcx>,
- impl_ty: ty::Ty<'tcx>,
+ trait_ty: Ty<'tcx>,
+ impl_ty: Ty<'tcx>,
output: &mut Vec<TransItem<'tcx>>) {
assert!(!trait_ty.needs_subst() && !trait_ty.has_escaping_regions() &&
!impl_ty.needs_subst() && !impl_ty.has_escaping_regions());