use rustc::infer::anon_types::AnonTypeDecl;
use rustc::infer::type_variable::{TypeVariableOrigin};
use rustc::middle::region;
+use rustc::mir::interpret::{GlobalId};
use rustc::ty::subst::{Kind, Subst, Substs};
use rustc::traits::{self, FulfillmentContext, ObligationCause, ObligationCauseCode};
use rustc::ty::{self, Ty, TyCtxt, Visibility, ToPredicate};
use rustc::ty::adjustment::{Adjust, Adjustment, AutoBorrow, AutoBorrowMutability};
use rustc::ty::fold::TypeFoldable;
use rustc::ty::maps::Providers;
-use rustc::ty::util::{Representability, IntTypeExt};
+use rustc::ty::util::{Representability, IntTypeExt, Discr};
use errors::{DiagnosticBuilder, DiagnosticId};
use require_c_abi_if_variadic;
use rustc::hir::map::Node;
use rustc::hir::{self, PatKind};
use rustc::middle::lang_items;
-use rustc_const_math::ConstInt;
mod autoderef;
pub mod dropck;
}
fcx.demand_suptype(span, ret_ty, actual_return_ty);
- if fcx.tcx.sess.features.borrow().termination_trait {
+ if fcx.tcx.features().termination_trait {
// If the termination trait language item is activated, check that the main return type
// implements the termination trait.
if let Some(term_id) = fcx.tcx.lang_items().termination() {
let repr_type_ty = def.repr.discr_type().to_ty(tcx);
if repr_type_ty == tcx.types.i128 || repr_type_ty == tcx.types.u128 {
- if !tcx.sess.features.borrow().repr128 {
+ if !tcx.features().repr128 {
emit_feature_err(&tcx.sess.parse_sess,
"repr128",
sp,
}
}
- let mut disr_vals: Vec<ConstInt> = Vec::new();
+ let mut disr_vals: Vec<Discr<'tcx>> = Vec::new();
for (discr, v) in def.discriminants(tcx).zip(vs) {
// Check for duplicate discriminant values
- if let Some(i) = disr_vals.iter().position(|&x| x == discr) {
+ if let Some(i) = disr_vals.iter().position(|&x| x.val == discr.val) {
let variant_i_node_id = tcx.hir.as_local_node_id(def.variants[i].did).unwrap();
let variant_i = tcx.hir.expect_variant(variant_i_node_id);
let i_span = match variant_i.node.disr_expr {
};
}
ty::TyRawPtr(..) => {
- err.note(&format!("`{0}` is a native pointer; perhaps you need to deref \
- with `(*{0}).{1}`",
- self.tcx.hir.node_to_pretty_string(base.id),
- field.node));
+ let base = self.tcx.hir.node_to_pretty_string(base.id);
+ let msg = format!("`{}` is a native pointer; try dereferencing it", base);
+ let suggestion = format!("(*{}).{}", base, field.node);
+ err.span_suggestion(field.span, &msg, suggestion);
}
_ => {}
}
}
hir::ExprRepeat(ref element, count) => {
let count_def_id = tcx.hir.body_owner_def_id(count);
- let param_env = ty::ParamEnv::empty(traits::Reveal::UserFacing);
+ let param_env = ty::ParamEnv::empty();
let substs = Substs::identity_for_item(tcx.global_tcx(), count_def_id);
- let count = tcx.const_eval(param_env.and((count_def_id, substs)));
+ let instance = ty::Instance::resolve(
+ tcx.global_tcx(),
+ param_env,
+ count_def_id,
+ substs,
+ ).unwrap();
+ let global_id = GlobalId {
+ instance,
+ promoted: None
+ };
+ let count = tcx.const_eval(param_env.and(global_id));
if let Err(ref err) = count {
- err.report(tcx, tcx.def_span(count_def_id), "constant expression");
+ err.report(tcx, tcx.def_span(count_def_id), "constant expression");
}
let uty = match expected {
};
if let Ok(count) = count {
- let zero_or_one = count.val.to_const_int().and_then(|count| {
- count.to_u64().map(|count| count <= 1)
- }).unwrap_or(false);
+ let zero_or_one = count.val.to_raw_bits().map_or(false, |count| count <= 1);
if !zero_or_one {
// For [foo, ..n] where n > 1, `foo` must have
// Copy type: