Update for latest Rust

This is mainly due to https://github.com/rust-lang/rust/commit/dead08cb33134
This commit is contained in:
Aaron Hill 2017-09-09 01:23:08 -04:00
parent 6edab5662d
commit 8adc42b5b4
No known key found for this signature in database
GPG Key ID: B4087E510E98B164
12 changed files with 32 additions and 32 deletions

View File

@ -307,7 +307,7 @@ fn fetch_int_literal(cx: &LateContext, lit: &Expr) -> Option<u128> {
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)
cx.tcx.extern_const_body(def_id)
};
fetch_int_literal(cx, &body.value)
})

View File

@ -297,7 +297,7 @@ fn fetch_path(&mut self, qpath: &QPath, id: HirId) -> Option<Constant> {
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)
self.tcx.extern_const_body(def_id)
};
let ret = cx.expr(&body.value);
if ret.is_some() {

View File

@ -93,7 +93,7 @@ fn check_hash_peq<'a, 'tcx>(
) {
if_let_chain! {[
match_path(&trait_ref.path, &paths::HASH),
let Some(peq_trait_def_id) = cx.tcx.lang_items.eq_trait()
let Some(peq_trait_def_id) = cx.tcx.lang_items().eq_trait()
], {
// Look for the PartialEq implementations for `ty`
cx.tcx.for_each_relevant_impl(peq_trait_def_id, ty, |impl_id| {

View File

@ -63,20 +63,20 @@ fn check_expr(&mut self, cx: &LateContext<'a, 'tcx>, e: &'tcx Expr) {
return;
}
let (trait_id, requires_ref) = match op.node {
BiAdd => (cx.tcx.lang_items.add_trait(), false),
BiSub => (cx.tcx.lang_items.sub_trait(), false),
BiMul => (cx.tcx.lang_items.mul_trait(), false),
BiDiv => (cx.tcx.lang_items.div_trait(), false),
BiRem => (cx.tcx.lang_items.rem_trait(), false),
BiAdd => (cx.tcx.lang_items().add_trait(), false),
BiSub => (cx.tcx.lang_items().sub_trait(), false),
BiMul => (cx.tcx.lang_items().mul_trait(), false),
BiDiv => (cx.tcx.lang_items().div_trait(), false),
BiRem => (cx.tcx.lang_items().rem_trait(), false),
// don't lint short circuiting ops
BiAnd | BiOr => return,
BiBitXor => (cx.tcx.lang_items.bitxor_trait(), false),
BiBitAnd => (cx.tcx.lang_items.bitand_trait(), false),
BiBitOr => (cx.tcx.lang_items.bitor_trait(), false),
BiShl => (cx.tcx.lang_items.shl_trait(), false),
BiShr => (cx.tcx.lang_items.shr_trait(), false),
BiNe | BiEq => (cx.tcx.lang_items.eq_trait(), true),
BiLt | BiLe | BiGe | BiGt => (cx.tcx.lang_items.ord_trait(), true),
BiBitXor => (cx.tcx.lang_items().bitxor_trait(), false),
BiBitAnd => (cx.tcx.lang_items().bitand_trait(), false),
BiBitOr => (cx.tcx.lang_items().bitor_trait(), false),
BiShl => (cx.tcx.lang_items().shl_trait(), false),
BiShr => (cx.tcx.lang_items().shr_trait(), false),
BiNe | BiEq => (cx.tcx.lang_items().eq_trait(), true),
BiLt | BiLe | BiGe | BiGt => (cx.tcx.lang_items().ord_trait(), true),
};
if let Some(trait_id) = trait_id {
#[allow(match_same_arms)]

View File

@ -1302,7 +1302,7 @@ fn get_error_type<'a>(cx: &LateContext, ty: Ty<'a>) -> Option<Ty<'a>> {
/// This checks whether a given type is known to implement Debug.
fn has_debug_impl<'a, 'b>(ty: Ty<'a>, cx: &LateContext<'b, 'a>) -> bool {
match cx.tcx.lang_items.debug_trait() {
match cx.tcx.lang_items().debug_trait() {
Some(debug) => implements_trait(cx, ty, debug, &[]),
None => false,
}

View File

@ -497,7 +497,7 @@ fn check_to_owned(cx: &LateContext, expr: &Expr, other: &Expr) {
};
let other_ty = cx.tables.expr_ty_adjusted(other);
let partial_eq_trait_id = match cx.tcx.lang_items.eq_trait() {
let partial_eq_trait_id = match cx.tcx.lang_items().eq_trait() {
Some(id) => id,
None => return,
};

View File

@ -75,7 +75,7 @@ fn check_fn(
}
// Allows these to be passed by value.
let fn_trait = need!(cx.tcx.lang_items.fn_trait());
let fn_trait = need!(cx.tcx.lang_items().fn_trait());
let asref_trait = need!(get_trait_def_id(cx, &paths::ASREF_TRAIT));
let borrow_trait = need!(get_trait_def_id(cx, &paths::BORROW_TRAIT));

View File

@ -40,7 +40,7 @@ fn check_item(&mut self, cx: &LateContext<'a, 'tcx>, item: &'tcx Item) {
if_let_chain! {[
let ItemImpl(_, _, _, _, Some(ref trait_ref), _, ref impl_items) = item.node,
!is_automatically_derived(&*item.attrs),
let Some(eq_trait) = cx.tcx.lang_items.eq_trait(),
let Some(eq_trait) = cx.tcx.lang_items().eq_trait(),
trait_ref.path.def.def_id() == eq_trait
], {
for impl_item in impl_items {

View File

@ -40,7 +40,7 @@ fn check_expr(&mut self, cx: &LateContext<'a, 'tcx>, e: &'tcx Expr) {
let ExprUnary(UnOp::UnNot, ref cond) = cond.node,
let ExprBinary(ref binop, ref expr1, ref expr2) = cond.node,
is_direct_expn_of(e.span, "assert").is_some(),
let Some(debug_trait) = cx.tcx.lang_items.debug_trait(),
let Some(debug_trait) = cx.tcx.lang_items().debug_trait(),
], {
let debug = is_expn_of(e.span, "debug_assert").map_or("", |_| "debug_");
let sugg = match binop.node {

View File

@ -151,7 +151,7 @@ fn check_ty(cx: &LateContext, ast_ty: &hir::Ty, is_local: bool) {
let hir_id = cx.tcx.hir.node_to_hir_id(ast_ty.id);
let def = cx.tables.qpath_def(qpath, hir_id);
if let Some(def_id) = opt_def_id(def) {
if Some(def_id) == cx.tcx.lang_items.owned_box() {
if Some(def_id) == cx.tcx.lang_items().owned_box() {
let last = last_path_segment(qpath);
if_let_chain! {[
!last.parameters.parenthesized,
@ -209,7 +209,7 @@ fn check_ty(cx: &LateContext, ast_ty: &hir::Ty, is_local: bool) {
let def = cx.tables.qpath_def(qpath, hir_id);
if_let_chain! {[
let Some(def_id) = opt_def_id(def),
Some(def_id) == cx.tcx.lang_items.owned_box(),
Some(def_id) == cx.tcx.lang_items().owned_box(),
let QPath::Resolved(None, ref path) = *qpath,
let [ref bx] = *path.segments,
!bx.parameters.parenthesized,

View File

@ -360,12 +360,12 @@ fn print_item(cx: &LateContext, item: &hir::Item) {
}
match item.node {
hir::ItemExternCrate(ref _renamed_from) => {
if let Some(crate_id) = cx.tcx.sess.cstore.extern_mod_stmt_cnum(item.id) {
let source = cx.tcx.sess.cstore.used_crate_source(crate_id);
if let Some(src) = source.dylib {
if let Some(crate_id) = cx.tcx.extern_mod_stmt_cnum(cx.tcx.hir.node_to_hir_id(item.id)) {
let source = cx.tcx.used_crate_source(crate_id);
if let Some(ref src) = source.dylib {
println!("extern crate dylib source: {:?}", src.0);
}
if let Some(src) = source.rlib {
if let Some(ref src) = source.rlib {
println!("extern crate rlib source: {:?}", src.0);
}
} else {

View File

@ -15,6 +15,7 @@
use std::env;
use std::mem;
use std::str::FromStr;
use std::rc::Rc;
use syntax::ast::{self, LitKind};
use syntax::attr;
use syntax::codemap::{CompilerDesugaringKind, ExpnFormat, ExpnInfo, Span, DUMMY_SP};
@ -277,18 +278,17 @@ pub fn match_path_ast(path: &ast::Path, segments: &[&str]) -> bool {
/// Get the definition associated to a path.
pub fn path_to_def(cx: &LateContext, path: &[&str]) -> Option<def::Def> {
let cstore = &cx.tcx.sess.cstore;
let crates = cstore.crates();
let crates = cx.tcx.crates();
let krate = crates
.iter()
.find(|&&krate| cstore.crate_name(krate) == path[0]);
.find(|&&krate| cx.tcx.crate_name(krate) == path[0]);
if let Some(krate) = krate {
let krate = DefId {
krate: *krate,
index: CRATE_DEF_INDEX,
};
let mut items = cstore.item_children(krate, cx.tcx.sess);
let mut items = cx.tcx.item_children(krate);
let mut path_it = path.iter().skip(1).peekable();
loop {
@ -297,13 +297,13 @@ pub fn path_to_def(cx: &LateContext, path: &[&str]) -> Option<def::Def> {
None => return None,
};
for item in &mem::replace(&mut items, vec![]) {
for item in mem::replace(&mut items, Rc::new(vec![])).iter() {
if item.ident.name == *segment {
if path_it.peek().is_none() {
return Some(item.def);
}
items = cstore.item_children(item.def.def_id(), cx.tcx.sess);
items = cx.tcx.item_children(item.def.def_id());
break;
}
}