Merge pull request #2034 from Aaron1011/update-rust

Update for latest Rust
This commit is contained in:
Oliver Schneider 2017-09-09 14:47:40 +02:00 committed by GitHub
commit 9c9a4953c3
16 changed files with 40 additions and 39 deletions

View File

@ -1,9 +1,10 @@
# Change Log # Change Log
All notable changes to this project will be documented in this file. All notable changes to this project will be documented in this file.
## Upcoming ## 0.0.158
* New lint: [`manual_memcpy`] * New lint: [`manual_memcpy`]
* [`cast_lossless`] no longer has redundant parentheses in its suggestions * [`cast_lossless`] no longer has redundant parentheses in its suggestions
* Update to *rustc 1.22.0-nightly (dead08cb3 2017-09-08)*
## 0.0.157 - 2017-09-04 ## 0.0.157 - 2017-09-04
* Update to *rustc 1.22.0-nightly (981ce7d8d 2017-09-03)* * Update to *rustc 1.22.0-nightly (981ce7d8d 2017-09-03)*

6
Cargo.lock generated
View File

@ -1,6 +1,6 @@
[root] [root]
name = "clippy_lints" name = "clippy_lints"
version = "0.0.157" version = "0.0.158"
dependencies = [ dependencies = [
"itertools 0.6.2 (registry+https://github.com/rust-lang/crates.io-index)", "itertools 0.6.2 (registry+https://github.com/rust-lang/crates.io-index)",
"lazy_static 0.2.8 (registry+https://github.com/rust-lang/crates.io-index)", "lazy_static 0.2.8 (registry+https://github.com/rust-lang/crates.io-index)",
@ -73,11 +73,11 @@ source = "registry+https://github.com/rust-lang/crates.io-index"
[[package]] [[package]]
name = "clippy" name = "clippy"
version = "0.0.157" version = "0.0.158"
dependencies = [ dependencies = [
"cargo_metadata 0.2.3 (registry+https://github.com/rust-lang/crates.io-index)", "cargo_metadata 0.2.3 (registry+https://github.com/rust-lang/crates.io-index)",
"clippy-mini-macro-test 0.1.0", "clippy-mini-macro-test 0.1.0",
"clippy_lints 0.0.157", "clippy_lints 0.0.158",
"compiletest_rs 0.2.10 (registry+https://github.com/rust-lang/crates.io-index)", "compiletest_rs 0.2.10 (registry+https://github.com/rust-lang/crates.io-index)",
"duct 0.8.2 (registry+https://github.com/rust-lang/crates.io-index)", "duct 0.8.2 (registry+https://github.com/rust-lang/crates.io-index)",
"lazy_static 0.2.8 (registry+https://github.com/rust-lang/crates.io-index)", "lazy_static 0.2.8 (registry+https://github.com/rust-lang/crates.io-index)",

View File

@ -1,6 +1,6 @@
[package] [package]
name = "clippy" name = "clippy"
version = "0.0.157" version = "0.0.158"
authors = [ authors = [
"Manish Goregaokar <manishsmail@gmail.com>", "Manish Goregaokar <manishsmail@gmail.com>",
"Andre Bogus <bogusandre@gmail.com>", "Andre Bogus <bogusandre@gmail.com>",
@ -31,7 +31,7 @@ path = "src/main.rs"
[dependencies] [dependencies]
# begin automatic update # begin automatic update
clippy_lints = { version = "0.0.157", path = "clippy_lints" } clippy_lints = { version = "0.0.158", path = "clippy_lints" }
# end automatic update # end automatic update
cargo_metadata = "0.2" cargo_metadata = "0.2"

View File

@ -1,7 +1,7 @@
[package] [package]
name = "clippy_lints" name = "clippy_lints"
# begin automatic update # begin automatic update
version = "0.0.157" version = "0.0.158"
# end automatic update # end automatic update
authors = [ authors = [
"Manish Goregaokar <manishsmail@gmail.com>", "Manish Goregaokar <manishsmail@gmail.com>",

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.mir_const_qualif(def_id);
cx.tcx.hir.body(cx.tcx.hir.body_owned_by(id)) cx.tcx.hir.body(cx.tcx.hir.body_owned_by(id))
} else { } else {
cx.tcx.sess.cstore.item_body(cx.tcx, def_id) cx.tcx.extern_const_body(def_id)
}; };
fetch_int_literal(cx, &body.value) fetch_int_literal(cx, &body.value)
}) })

View File

@ -297,7 +297,7 @@ impl<'c, 'cc> ConstEvalLateContext<'c, 'cc> {
self.tcx.mir_const_qualif(def_id); self.tcx.mir_const_qualif(def_id);
self.tcx.hir.body(self.tcx.hir.body_owned_by(id)) self.tcx.hir.body(self.tcx.hir.body_owned_by(id))
} else { } else {
self.tcx.sess.cstore.item_body(self.tcx, def_id) self.tcx.extern_const_body(def_id)
}; };
let ret = cx.expr(&body.value); let ret = cx.expr(&body.value);
if ret.is_some() { if ret.is_some() {

View File

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

View File

@ -63,20 +63,20 @@ impl<'a, 'tcx> LateLintPass<'a, 'tcx> for EqOp {
return; return;
} }
let (trait_id, requires_ref) = match op.node { let (trait_id, requires_ref) = match op.node {
BiAdd => (cx.tcx.lang_items.add_trait(), false), BiAdd => (cx.tcx.lang_items().add_trait(), false),
BiSub => (cx.tcx.lang_items.sub_trait(), false), BiSub => (cx.tcx.lang_items().sub_trait(), false),
BiMul => (cx.tcx.lang_items.mul_trait(), false), BiMul => (cx.tcx.lang_items().mul_trait(), false),
BiDiv => (cx.tcx.lang_items.div_trait(), false), BiDiv => (cx.tcx.lang_items().div_trait(), false),
BiRem => (cx.tcx.lang_items.rem_trait(), false), BiRem => (cx.tcx.lang_items().rem_trait(), false),
// don't lint short circuiting ops // don't lint short circuiting ops
BiAnd | BiOr => return, BiAnd | BiOr => return,
BiBitXor => (cx.tcx.lang_items.bitxor_trait(), false), BiBitXor => (cx.tcx.lang_items().bitxor_trait(), false),
BiBitAnd => (cx.tcx.lang_items.bitand_trait(), false), BiBitAnd => (cx.tcx.lang_items().bitand_trait(), false),
BiBitOr => (cx.tcx.lang_items.bitor_trait(), false), BiBitOr => (cx.tcx.lang_items().bitor_trait(), false),
BiShl => (cx.tcx.lang_items.shl_trait(), false), BiShl => (cx.tcx.lang_items().shl_trait(), false),
BiShr => (cx.tcx.lang_items.shr_trait(), false), BiShr => (cx.tcx.lang_items().shr_trait(), false),
BiNe | BiEq => (cx.tcx.lang_items.eq_trait(), true), BiNe | BiEq => (cx.tcx.lang_items().eq_trait(), true),
BiLt | BiLe | BiGe | BiGt => (cx.tcx.lang_items.ord_trait(), true), BiLt | BiLe | BiGe | BiGt => (cx.tcx.lang_items().ord_trait(), true),
}; };
if let Some(trait_id) = trait_id { if let Some(trait_id) = trait_id {
#[allow(match_same_arms)] #[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. /// 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 { 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, &[]), Some(debug) => implements_trait(cx, ty, debug, &[]),
None => false, 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 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, Some(id) => id,
None => return, None => return,
}; };

View File

@ -75,7 +75,7 @@ impl<'a, 'tcx> LateLintPass<'a, 'tcx> for NeedlessPassByValue {
} }
// Allows these to be passed by value. // 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 asref_trait = need!(get_trait_def_id(cx, &paths::ASREF_TRAIT));
let borrow_trait = need!(get_trait_def_id(cx, &paths::BORROW_TRAIT)); let borrow_trait = need!(get_trait_def_id(cx, &paths::BORROW_TRAIT));

View File

@ -40,7 +40,7 @@ impl<'a, 'tcx> LateLintPass<'a, 'tcx> for Pass {
if_let_chain! {[ if_let_chain! {[
let ItemImpl(_, _, _, _, Some(ref trait_ref), _, ref impl_items) = item.node, let ItemImpl(_, _, _, _, Some(ref trait_ref), _, ref impl_items) = item.node,
!is_automatically_derived(&*item.attrs), !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 trait_ref.path.def.def_id() == eq_trait
], { ], {
for impl_item in impl_items { for impl_item in impl_items {

View File

@ -40,7 +40,7 @@ impl<'a, 'tcx> LateLintPass<'a, 'tcx> for ShouldAssertEq {
let ExprUnary(UnOp::UnNot, ref cond) = cond.node, let ExprUnary(UnOp::UnNot, ref cond) = cond.node,
let ExprBinary(ref binop, ref expr1, ref expr2) = cond.node, let ExprBinary(ref binop, ref expr1, ref expr2) = cond.node,
is_direct_expn_of(e.span, "assert").is_some(), 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 debug = is_expn_of(e.span, "debug_assert").map_or("", |_| "debug_");
let sugg = match binop.node { 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 hir_id = cx.tcx.hir.node_to_hir_id(ast_ty.id);
let def = cx.tables.qpath_def(qpath, hir_id); let def = cx.tables.qpath_def(qpath, hir_id);
if let Some(def_id) = opt_def_id(def) { 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); let last = last_path_segment(qpath);
if_let_chain! {[ if_let_chain! {[
!last.parameters.parenthesized, !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); let def = cx.tables.qpath_def(qpath, hir_id);
if_let_chain! {[ if_let_chain! {[
let Some(def_id) = opt_def_id(def), 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 QPath::Resolved(None, ref path) = *qpath,
let [ref bx] = *path.segments, let [ref bx] = *path.segments,
!bx.parameters.parenthesized, !bx.parameters.parenthesized,

View File

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

View File

@ -15,6 +15,7 @@ use std::borrow::Cow;
use std::env; use std::env;
use std::mem; use std::mem;
use std::str::FromStr; use std::str::FromStr;
use std::rc::Rc;
use syntax::ast::{self, LitKind}; use syntax::ast::{self, LitKind};
use syntax::attr; use syntax::attr;
use syntax::codemap::{CompilerDesugaringKind, ExpnFormat, ExpnInfo, Span, DUMMY_SP}; 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. /// Get the definition associated to a path.
pub fn path_to_def(cx: &LateContext, path: &[&str]) -> Option<def::Def> { 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 let krate = crates
.iter() .iter()
.find(|&&krate| cstore.crate_name(krate) == path[0]); .find(|&&krate| cx.tcx.crate_name(krate) == path[0]);
if let Some(krate) = krate { if let Some(krate) = krate {
let krate = DefId { let krate = DefId {
krate: *krate, krate: *krate,
index: CRATE_DEF_INDEX, 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(); let mut path_it = path.iter().skip(1).peekable();
loop { loop {
@ -297,13 +297,13 @@ pub fn path_to_def(cx: &LateContext, path: &[&str]) -> Option<def::Def> {
None => return None, 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 item.ident.name == *segment {
if path_it.peek().is_none() { if path_it.peek().is_none() {
return Some(item.def); 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; break;
} }
} }