Merge pull request #1237 from Manishearth/rustup

Rustup to *rustc 1.13.0-nightly (d0623cf7b 2016-09-26)* and bump to 0.0.91
This commit is contained in:
Martin Carton 2016-09-28 01:15:33 +02:00 committed by GitHub
commit fe27ac5fd2
10 changed files with 70 additions and 64 deletions

View File

@ -1,6 +1,9 @@
# Change Log
All notable changes to this project will be documented in this file.
## 0.0.91 — 2016-09-28
* Rustup to *rustc 1.13.0-nightly (d0623cf7b 2016-09-26)*
## 0.0.90 — 2016-09-09
* Rustup to *rustc 1.13.0-nightly (f1f40f850 2016-09-09)*

View File

@ -1,6 +1,6 @@
[package]
name = "clippy"
version = "0.0.90"
version = "0.0.91"
authors = [
"Manish Goregaokar <manishsmail@gmail.com>",
"Andre Bogus <bogusandre@gmail.com>",
@ -25,7 +25,7 @@ test = false
[dependencies]
# begin automatic update
clippy_lints = { version = "0.0.90", path = "clippy_lints" }
clippy_lints = { version = "0.0.91", path = "clippy_lints" }
# end automatic update
[dev-dependencies]

View File

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

View File

@ -4,7 +4,6 @@ use rustc::hir::*;
use rustc::hir::def::Def;
use rustc::hir::map::Node::NodeItem;
use rustc::lint::{LateLintPass, LintPass, LateContext, LintArray, LintContext};
use rustc::middle::cstore::DefLike;
use syntax::ast::NodeId;
use syntax::codemap::Span;
use utils::span_lint;
@ -61,7 +60,7 @@ impl EnumGlobUse {
} else {
let child = cx.sess().cstore.item_children(def.full_def().def_id());
if let Some(child) = child.first() {
if let DefLike::DlDef(Def::Variant(..)) = child.def {
if let Some(Def::Variant(..)) = cx.tcx.sess.cstore.describe_def(child.def_id) {
span_lint(cx, ENUM_GLOB_USE, item.span, "don't use glob imports for enum variants");
}
}

View File

@ -1,6 +1,6 @@
use rustc::lint::*;
use rustc::hir::def_id::DefId;
use rustc::ty::{self, MethodTraitItemId, ImplOrTraitItemId};
use rustc::ty::{self, ImplOrTraitItem};
use rustc::hir::*;
use syntax::ast::{Lit, LitKind, Name};
use syntax::codemap::{Span, Spanned};
@ -184,23 +184,20 @@ fn check_len_zero(cx: &LateContext, span: Span, name: &Name, args: &[P<Expr>], l
/// Check if this type has an `is_empty` method.
fn has_is_empty(cx: &LateContext, expr: &Expr) -> bool {
/// Get an `ImplOrTraitItem` and return true if it matches `is_empty(self)`.
fn is_is_empty(cx: &LateContext, id: &ImplOrTraitItemId) -> bool {
if let MethodTraitItemId(def_id) = *id {
if let ty::MethodTraitItem(ref method) = cx.tcx.impl_or_trait_item(def_id) {
method.name.as_str() == "is_empty" && method.fty.sig.skip_binder().inputs.len() == 1
} else {
false
}
fn is_is_empty(item: &ImplOrTraitItem) -> bool {
if let ty::MethodTraitItem(ref method) = *item {
method.name.as_str() == "is_empty" && method.fty.sig.skip_binder().inputs.len() == 1
} else {
false
}
}
/// Check the inherent impl's items for an `is_empty(self)` method.
fn has_is_empty_impl(cx: &LateContext, id: &DefId) -> bool {
let impl_items = cx.tcx.impl_items.borrow();
cx.tcx.inherent_impls.borrow().get(id).map_or(false, |ids| {
ids.iter().any(|iid| impl_items.get(iid).map_or(false, |iids| iids.iter().any(|i| is_is_empty(cx, i))))
fn has_is_empty_impl(cx: &LateContext, id: DefId) -> bool {
cx.tcx.inherent_impls.borrow()[&id].iter().any(|imp| {
cx.tcx.impl_or_trait_items(*imp).iter().any(|item| {
is_is_empty(&cx.tcx.impl_or_trait_item(*item))
})
})
}
@ -208,13 +205,12 @@ fn has_is_empty(cx: &LateContext, expr: &Expr) -> bool {
match ty.sty {
ty::TyTrait(_) => {
cx.tcx
.trait_item_def_ids
.borrow()
.get(&ty.ty_to_def_id().expect("trait impl not found"))
.map_or(false, |ids| ids.iter().any(|i| is_is_empty(cx, i)))
.impl_or_trait_items(ty.ty_to_def_id().expect("trait impl not found"))
.iter()
.any(|item| is_is_empty(&cx.tcx.impl_or_trait_item(*item)))
}
ty::TyProjection(_) => ty.ty_to_def_id().map_or(false, |id| has_is_empty_impl(cx, &id)),
ty::TyAdt(id, _) => has_is_empty_impl(cx, &id.did),
ty::TyProjection(_) => ty.ty_to_def_id().map_or(false, |id| has_is_empty_impl(cx, id)),
ty::TyAdt(id, _) => has_is_empty_impl(cx, id.did),
ty::TyArray(..) | ty::TyStr => true,
_ => false,
}

View File

@ -755,7 +755,10 @@ impl<'v, 't> Visitor<'v> for VarVisitor<'v, 't> {
if let Some(def) = def_map.get(&seqexpr.id) {
match def.base_def {
Def::Local(..) | Def::Upvar(..) => {
let extent = self.cx.tcx.region_maps.var_scope(def.base_def.var_id());
let def_id = def.base_def.def_id();
let node_id = self.cx.tcx.map.as_local_node_id(def_id).unwrap();
let extent = self.cx.tcx.region_maps.var_scope(node_id);
self.indexed.insert(seqvar.segments[0].name, Some(extent));
return; // no need to walk further
}
@ -1040,7 +1043,8 @@ impl<'v, 't> Visitor<'v> for InitializeVisitor<'v, 't> {
fn var_def_id(cx: &LateContext, expr: &Expr) -> Option<NodeId> {
if let Some(path_res) = cx.tcx.def_map.borrow().get(&expr.id) {
if let Def::Local(_, node_id) = path_res.base_def {
if let Def::Local(def_id) = path_res.base_def {
let node_id = cx.tcx.map.as_local_node_id(def_id).expect("That DefId should be valid");
return Some(node_id);
}
}

View File

@ -443,7 +443,9 @@ fn in_attributes_expansion(cx: &LateContext, expr: &Expr) -> bool {
/// Test whether `def` is a variable defined outside a macro.
fn non_macro_local(cx: &LateContext, def: &def::Def) -> bool {
match *def {
def::Def::Local(_, id) | def::Def::Upvar(_, id, _, _) => {
def::Def::Local(id) | def::Def::Upvar(id, _, _) => {
let id = cx.tcx.map.as_local_node_id(id).expect("That DefId should be valid");
if let Some(span) = cx.tcx.map.opt_span(id) {
!in_macro(cx, span)
} else {

View File

@ -127,18 +127,21 @@ declare_lint! {
fn check_let_unit(cx: &LateContext, decl: &Decl) {
if let DeclLocal(ref local) = decl.node {
let bindtype = &cx.tcx.pat_ty(&local.pat).sty;
if *bindtype == ty::TyTuple(&[]) {
if in_external_macro(cx, decl.span) || in_macro(cx, local.pat.span) {
return;
match *bindtype {
ty::TyTuple(slice) if slice.is_empty() => {
if in_external_macro(cx, decl.span) || in_macro(cx, local.pat.span) {
return;
}
if higher::is_from_for_desugar(decl) {
return;
}
span_lint(cx,
LET_UNIT_VALUE,
decl.span,
&format!("this let-binding has unit value. Consider omitting `let {} =`",
snippet(cx, local.pat.span, "..")));
}
if higher::is_from_for_desugar(decl) {
return;
}
span_lint(cx,
LET_UNIT_VALUE,
decl.span,
&format!("this let-binding has unit value. Consider omitting `let {} =`",
snippet(cx, local.pat.span, "..")));
_ => (),
}
}
}
@ -193,18 +196,23 @@ impl LateLintPass for UnitCmp {
}
if let ExprBinary(ref cmp, ref left, _) = expr.node {
let op = cmp.node;
let sty = &cx.tcx.expr_ty(left).sty;
if *sty == ty::TyTuple(&[]) && op.is_comparison() {
let result = match op {
BiEq | BiLe | BiGe => "true",
_ => "false",
};
span_lint(cx,
UNIT_CMP,
expr.span,
&format!("{}-comparison of unit values detected. This will always be {}",
op.as_str(),
result));
if op.is_comparison() {
let sty = &cx.tcx.expr_ty(left).sty;
match *sty {
ty::TyTuple(slice) if slice.is_empty() => {
let result = match op {
BiEq | BiLe | BiGe => "true",
_ => "false",
};
span_lint(cx,
UNIT_CMP,
expr.span,
&format!("{}-comparison of unit values detected. This will always be {}",
op.as_str(),
result));
}
_ => ()
}
}
}
}

View File

@ -1,9 +1,8 @@
use reexport::*;
use rustc::hir::*;
use rustc::hir::def_id::DefId;
use rustc::hir::def_id::{DefId, CRATE_DEF_INDEX};
use rustc::hir::map::Node;
use rustc::lint::{LintContext, LateContext, Level, Lint};
use rustc::middle::cstore;
use rustc::session::Session;
use rustc::traits::Reveal;
use rustc::traits;
@ -216,13 +215,14 @@ pub fn match_path_ast(path: &ast::Path, segments: &[&str]) -> bool {
/// Get the definition associated to a path.
/// TODO: investigate if there is something more efficient for that.
pub fn path_to_def(cx: &LateContext, path: &[&str]) -> Option<cstore::DefLike> {
pub fn path_to_def(cx: &LateContext, path: &[&str]) -> Option<def::Def> {
let cstore = &cx.tcx.sess.cstore;
let crates = cstore.crates();
let krate = crates.iter().find(|&&krate| cstore.crate_name(krate) == path[0]);
if let Some(krate) = krate {
let mut items = cstore.crate_top_level_items(*krate);
let krate = DefId { krate: *krate, index: CRATE_DEF_INDEX };
let mut items = cstore.item_children(krate);
let mut path_it = path.iter().skip(1).peekable();
loop {
@ -234,16 +234,10 @@ pub fn path_to_def(cx: &LateContext, path: &[&str]) -> Option<cstore::DefLike> {
for item in &mem::replace(&mut items, vec![]) {
if item.name.as_str() == *segment {
if path_it.peek().is_none() {
return Some(item.def);
return cx.tcx.sess.cstore.describe_def(item.def_id);
}
let def_id = match item.def {
cstore::DefLike::DlDef(def) => def.def_id(),
cstore::DefLike::DlImpl(def_id) => def_id,
_ => panic!("Unexpected {:?}", item.def),
};
items = cstore.item_children(def_id);
items = cstore.item_children(item.def_id);
break;
}
}
@ -261,7 +255,7 @@ pub fn get_trait_def_id(cx: &LateContext, path: &[&str]) -> Option<DefId> {
};
match def {
cstore::DlDef(def::Def::Trait(trait_id)) => Some(trait_id),
def::Def::Trait(trait_id) => Some(trait_id),
_ => None,
}
}

View File

@ -9,7 +9,7 @@ extern crate syntax;
use clippy_lints::consts::{constant_simple, Constant, FloatWidth};
use rustc_const_math::ConstInt;
use rustc::hir::*;
use syntax::ast::{LitIntType, LitKind, StrStyle};
use syntax::ast::{LitIntType, LitKind, NodeId, StrStyle};
use syntax::codemap::{Spanned, COMMAND_LINE_SP};
use syntax::parse::token::InternedString;
use syntax::ptr::P;
@ -24,7 +24,7 @@ fn spanned<T>(t: T) -> Spanned<T> {
fn expr(n: Expr_) -> Expr {
Expr {
id: 1,
id: NodeId::new(1),
node: n,
span: COMMAND_LINE_SP,
attrs: ThinVec::new(),