Update to latest rustc version

This commit is contained in:
Oliver Schneider 2017-04-27 14:00:35 +02:00
parent f2ecb7f33c
commit 3b73663506
13 changed files with 27 additions and 29 deletions

View File

@ -1,10 +1,9 @@
use rustc::hir::*;
use rustc::hir::def::Def;
use rustc::lint::*;
use rustc::ty;
use rustc_const_eval::lookup_const_by_id;
use syntax::ast::LitKind;
use syntax::codemap::{Span, DUMMY_SP};
use syntax::codemap::Span;
use utils::span_lint;
/// **What it does:** Checks for incompatible bit masks in comparisons.
@ -252,7 +251,7 @@ fn fetch_int_literal(cx: &LateContext, lit: &Expr) -> Option<u128> {
if let Def::Const(def_id) = def {
lookup_const_by_id(cx.tcx, def_id, Substs::empty()).and_then(|(l, _ty)| {
let body = if let Some(id) = cx.tcx.hir.as_local_node_id(l) {
ty::queries::mir_const_qualif::get(cx.tcx, DUMMY_SP, def_id);
cx.tcx.mir_const_qualif(def_id);
cx.tcx.hir.body(cx.tcx.hir.body_owned_by(id))
} else {
cx.tcx.sess.cstore.item_body(cx.tcx, def_id)

View File

@ -13,7 +13,6 @@ use std::mem;
use std::rc::Rc;
use syntax::ast::{FloatTy, LitKind, StrStyle, NodeId};
use syntax::ptr::P;
use syntax::codemap::DUMMY_SP;
#[derive(Debug, Copy, Clone)]
pub enum FloatWidth {
@ -290,11 +289,11 @@ impl<'c, 'cc> ConstEvalLateContext<'c, 'cc> {
if let Some((const_expr, _)) = lookup_const_by_id(self.tcx, def_id, substs) {
let mut cx = ConstEvalLateContext {
tcx: self.tcx,
tables: self.tcx.item_tables(const_expr),
tables: self.tcx.typeck_tables_of(const_expr),
needed_resolution: false,
};
let body = if let Some(id) = self.tcx.hir.as_local_node_id(def_id) {
ty::queries::mir_const_qualif::get(self.tcx, DUMMY_SP, def_id);
self.tcx.mir_const_qualif(def_id);
self.tcx.hir.body(self.tcx.hir.body_owned_by(id))
} else {
self.tcx.sess.cstore.item_body(self.tcx, def_id)

View File

@ -73,7 +73,7 @@ impl LintPass for Derive {
impl<'a, 'tcx> LateLintPass<'a, 'tcx> for Derive {
fn check_item(&mut self, cx: &LateContext<'a, 'tcx>, item: &'tcx Item) {
if let ItemImpl(_, _, _, Some(ref trait_ref), _, _) = item.node {
let ty = cx.tcx.item_type(cx.tcx.hir.local_def_id(item.id));
let ty = cx.tcx.type_of(cx.tcx.hir.local_def_id(item.id));
let is_automatically_derived = is_automatically_derived(&*item.attrs);
check_hash_peq(cx, item.span, trait_ref, ty, is_automatically_derived);
@ -97,7 +97,7 @@ fn check_hash_peq<'a, 'tcx>(
match_path_old(&trait_ref.path, &paths::HASH),
let Some(peq_trait_def_id) = cx.tcx.lang_items.eq_trait()
], {
let peq_trait_def = cx.tcx.lookup_trait_def(peq_trait_def_id);
let peq_trait_def = cx.tcx.trait_def(peq_trait_def_id);
// Look for the PartialEq implementations for `ty`
peq_trait_def.for_each_relevant_impl(cx.tcx, ty, |impl_id| {

View File

@ -34,7 +34,7 @@ impl<'a, 'tcx> LateLintPass<'a, 'tcx> for EmptyEnum {
fn check_item(&mut self, cx: &LateContext, item: &Item) {
let did = cx.tcx.hir.local_def_id(item.id);
if let ItemEnum(..) = item.node {
let ty = cx.tcx.item_type(did);
let ty = cx.tcx.type_of(did);
let adt = ty.ty_adt_def().expect("already checked whether this is an enum");
if adt.variants.is_empty() {
span_lint_and_then(cx, EMPTY_ENUM, item.span, "enum with no variants", |db| {

View File

@ -46,7 +46,7 @@ impl<'a, 'tcx> LateLintPass<'a, 'tcx> for LargeEnumVariant {
fn check_item(&mut self, cx: &LateContext, item: &Item) {
let did = cx.tcx.hir.local_def_id(item.id);
if let ItemEnum(ref def, _) = item.node {
let ty = cx.tcx.item_type(did);
let ty = cx.tcx.type_of(did);
let adt = ty.ty_adt_def().expect("already checked whether this is an enum");
let mut smallest_variant: Option<(_, _)> = None;
@ -56,7 +56,7 @@ impl<'a, 'tcx> LateLintPass<'a, 'tcx> for LargeEnumVariant {
let size: u64 = variant.fields
.iter()
.map(|f| {
let ty = cx.tcx.item_type(f.did);
let ty = cx.tcx.type_of(f.did);
if ty.needs_subst() {
0 // we can't reason about generics, so we treat them as zero sized
} else {

View File

@ -94,7 +94,7 @@ fn check_trait_items(cx: &LateContext, item: &Item, trait_items: &[TraitItemRef]
has_self &&
{
let did = cx.tcx.hir.local_def_id(item.id.node_id);
let impl_ty = cx.tcx.item_type(did);
let impl_ty = cx.tcx.type_of(did);
impl_ty.fn_args().skip_binder().len() == 1
}
} else {
@ -121,7 +121,7 @@ fn check_impl_items(cx: &LateContext, item: &Item, impl_items: &[ImplItemRef]) {
has_self &&
{
let did = cx.tcx.hir.local_def_id(item.id.node_id);
let impl_ty = cx.tcx.item_type(did);
let impl_ty = cx.tcx.type_of(did);
impl_ty.fn_args().skip_binder().len() == 1
}
} else {
@ -142,7 +142,7 @@ fn check_impl_items(cx: &LateContext, item: &Item, impl_items: &[ImplItemRef]) {
if let Some(i) = impl_items.iter().find(|i| is_named_self(cx, i, "len")) {
if cx.access_levels.is_exported(i.id.node_id) {
let def_id = cx.tcx.hir.local_def_id(item.id);
let ty = cx.tcx.item_type(def_id);
let ty = cx.tcx.type_of(def_id);
span_lint(cx,
LEN_WITHOUT_IS_EMPTY,
@ -186,7 +186,7 @@ fn has_is_empty(cx: &LateContext, expr: &Expr) -> bool {
fn is_is_empty(cx: &LateContext, item: &ty::AssociatedItem) -> bool {
if let ty::AssociatedKind::Method = item.kind {
if item.name == "is_empty" {
let sig = cx.tcx.item_type(item.def_id).fn_sig();
let sig = cx.tcx.type_of(item.def_id).fn_sig();
let ty = sig.skip_binder();
ty.inputs().len() == 1
} else {

View File

@ -281,14 +281,14 @@ impl<'v, 't> RefVisitor<'v, 't> {
match self.cx.tables.qpath_def(qpath, ty.id) {
Def::TyAlias(def_id) |
Def::Struct(def_id) => {
let generics = self.cx.tcx.item_generics(def_id);
let generics = self.cx.tcx.generics_of(def_id);
for _ in generics.regions.as_slice() {
self.record(&None);
}
},
Def::Trait(def_id) => {
let trait_def = self.cx.tcx.maps.trait_def.borrow()[&def_id];
for _ in &self.cx.tcx.item_generics(trait_def.def_id).regions {
for _ in &self.cx.tcx.generics_of(trait_def.def_id).regions {
self.record(&None);
}
},

View File

@ -657,7 +657,7 @@ impl<'a, 'tcx> LateLintPass<'a, 'tcx> for Pass {
}
// check conventions w.r.t. conversion method names and predicates
let ty = cx.tcx.item_type(cx.tcx.hir.local_def_id(item.id));
let ty = cx.tcx.type_of(cx.tcx.hir.local_def_id(item.id));
let is_copy = is_copy(cx, ty, item.id);
for &(ref conv, self_kinds) in &CONVENTIONS {
if_let_chain! {[

View File

@ -99,7 +99,7 @@ impl<'a, 'tcx> LateLintPass<'a, 'tcx> for NeedlessPassByValue {
let fn_def_id = cx.tcx.hir.local_def_id(node_id);
let param_env = ty::ParameterEnvironment::for_item(cx.tcx, node_id);
let fn_sig = cx.tcx.item_type(fn_def_id).fn_sig();
let fn_sig = cx.tcx.type_of(fn_def_id).fn_sig();
let fn_sig = cx.tcx.liberate_late_bound_regions(param_env.free_id_outlive, &fn_sig);
for ((input, &ty), arg) in decl.inputs.iter().zip(fn_sig.inputs()).zip(&body.arguments) {

View File

@ -110,7 +110,7 @@ impl<'a, 'tcx> LateLintPass<'a, 'tcx> for NewWithoutDefault {
}
if decl.inputs.is_empty() && name == "new" && cx.access_levels.is_reachable(id) {
let self_ty = cx.tcx
.item_type(cx.tcx.hir.local_def_id(cx.tcx.hir.get_parent(id)));
.type_of(cx.tcx.hir.local_def_id(cx.tcx.hir.get_parent(id)));
if_let_chain!{[
self_ty.walk_shallow().next().is_none(), // implements_trait does not work with generics
same_tys(cx, self_ty, return_ty(cx, id), id),

View File

@ -113,7 +113,7 @@ impl<'a, 'tcx> LateLintPass<'a, 'tcx> for PointerPass {
fn check_fn(cx: &LateContext, decl: &FnDecl, fn_id: NodeId) {
let fn_def_id = cx.tcx.hir.local_def_id(fn_id);
let sig = cx.tcx.item_type(fn_def_id).fn_sig();
let sig = cx.tcx.type_of(fn_def_id).fn_sig();
let fn_ty = sig.skip_binder();
for (arg, ty) in decl.inputs.iter().zip(fn_ty.inputs()) {

View File

@ -364,26 +364,26 @@ fn print_item(cx: &LateContext, item: &hir::Item) {
}
},
hir::ItemUse(ref path, ref kind) => println!("{:?}, {:?}", path, kind),
hir::ItemStatic(..) => println!("static item of type {:#?}", cx.tcx.item_type(did)),
hir::ItemConst(..) => println!("const item of type {:#?}", cx.tcx.item_type(did)),
hir::ItemStatic(..) => println!("static item of type {:#?}", cx.tcx.type_of(did)),
hir::ItemConst(..) => println!("const item of type {:#?}", cx.tcx.type_of(did)),
hir::ItemFn(..) => {
let item_ty = cx.tcx.item_type(did);
let item_ty = cx.tcx.type_of(did);
println!("function of type {:#?}", item_ty);
},
hir::ItemMod(..) => println!("module"),
hir::ItemForeignMod(ref fm) => println!("foreign module with abi: {}", fm.abi),
hir::ItemGlobalAsm(ref asm) => println!("global asm: {:?}", asm),
hir::ItemTy(..) => {
println!("type alias for {:?}", cx.tcx.item_type(did));
println!("type alias for {:?}", cx.tcx.type_of(did));
},
hir::ItemEnum(..) => {
println!("enum definition of type {:?}", cx.tcx.item_type(did));
println!("enum definition of type {:?}", cx.tcx.type_of(did));
},
hir::ItemStruct(..) => {
println!("struct definition of type {:?}", cx.tcx.item_type(did));
println!("struct definition of type {:?}", cx.tcx.type_of(did));
},
hir::ItemUnion(..) => {
println!("union definition of type {:?}", cx.tcx.item_type(did));
println!("union definition of type {:?}", cx.tcx.type_of(did));
},
hir::ItemTrait(..) => {
println!("trait decl");

View File

@ -784,7 +784,7 @@ pub fn camel_case_from(s: &str) -> usize {
pub fn return_ty<'a, 'tcx>(cx: &LateContext<'a, 'tcx>, fn_item: NodeId) -> ty::Ty<'tcx> {
let parameter_env = ty::ParameterEnvironment::for_item(cx.tcx, fn_item);
let fn_def_id = cx.tcx.hir.local_def_id(fn_item);
let fn_sig = cx.tcx.item_type(fn_def_id).fn_sig();
let fn_sig = cx.tcx.type_of(fn_def_id).fn_sig();
let fn_sig = cx.tcx.liberate_late_bound_regions(parameter_env.free_id_outlive, &fn_sig);
fn_sig.output()
}