[package]
name = "clippy"
-version = "0.0.36"
+version = "0.0.37"
authors = [
"Manish Goregaokar <manishsmail@gmail.com>",
"Andre Bogus <bogusandre@gmail.com>",
use rustc::lint::*;
use rustc::middle::const_eval::lookup_const_by_id;
-use rustc::middle::def::*;
+use rustc::middle::def::{Def, PathResolution};
use rustc_front::hir::*;
use rustc_front::util::is_comparison_binop;
use syntax::codemap::Span;
// borrowing.
let def_map = cx.tcx.def_map.borrow();
match def_map.get(&lit.id) {
- Some(&PathResolution { base_def: DefConst(def_id), ..}) => Some(def_id),
+ Some(&PathResolution { base_def: Def::Const(def_id), ..}) => Some(def_id),
_ => None,
}
}
use rustc::lint::LateContext;
use rustc::middle::const_eval::lookup_const_by_id;
use rustc::middle::def::PathResolution;
-use rustc::middle::def::Def::*;
+use rustc::middle::def::Def;
use rustc_front::hir::*;
use syntax::ptr::P;
use std::char;
fn fetch_path(&mut self, e: &Expr) -> Option<Constant> {
if let Some(lcx) = self.lcx {
let mut maybe_id = None;
- if let Some(&PathResolution { base_def: DefConst(id), ..}) = lcx.tcx.def_map.borrow().get(&e.id) {
+ if let Some(&PathResolution { base_def: Def::Const(id), ..}) = lcx.tcx.def_map.borrow().get(&e.id) {
maybe_id = Some(id);
}
// separate if lets to avoid double borrowing the def_map
use rustc::lint::*;
+use rustc::front::map::Node::NodeStmt;
use rustc_front::hir::*;
use rustc_front::intravisit as visit;
-use rustc::front::map::Node;
use rustc::middle::ty;
use rustc::middle::ty::adjustment::AutoAdjustment;
use rustc::middle::expr_use_visitor::*;
return;
}
if let Categorization::Rvalue(..) = cmt.cat {
- if let Some(Node::NodeStmt(st)) = self.cx
+ if let Some(NodeStmt(st)) = self.cx
.tcx
.map
.find(self.cx.tcx.map.get_parent_node(cmt.id)) {
use rustc::lint::*;
use syntax::codemap::Span;
use rustc_front::intravisit::{Visitor, walk_ty, walk_ty_param_bound, walk_fn_decl, walk_generics};
-use rustc::middle::def::Def::{DefTy, DefTrait, DefStruct};
+use rustc::middle::def::Def;
use std::collections::{HashSet, HashMap};
use utils::{in_external_macro, span_lint};
if params.lifetimes.is_empty() {
if let Some(def) = self.cx.tcx.def_map.borrow().get(&ty.id).map(|r| r.full_def()) {
match def {
- DefTy(def_id, _) | DefStruct(def_id) => {
+ Def::TyAlias(def_id) | Def::Struct(def_id) => {
let type_scheme = self.cx.tcx.lookup_item_type(def_id);
for _ in type_scheme.generics.regions.as_slice() {
self.record(&None);
}
}
- DefTrait(def_id) => {
+ Def::Trait(def_id) => {
let trait_def = self.cx.tcx.trait_defs.borrow()[&def_id];
for _ in &trait_def.generics.regions {
self.record(&None);
use reexport::*;
use rustc_front::intravisit::{Visitor, walk_expr, walk_block, walk_decl};
use rustc::middle::ty;
-use rustc::middle::def::DefLocal;
+use rustc::middle::def::Def;
use consts::{constant_simple, Constant};
use rustc::front::map::Node::NodeBlock;
use std::borrow::Cow;
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 DefLocal(_, node_id) = path_res.base_def {
+ if let Def::Local(_, node_id) = path_res.base_def {
return Some(node_id);
}
}
use rustc::lint::{LateContext, LateLintPass, LintArray, LintPass};
-use rustc::middle::def::{DefStruct, DefVariant};
+use rustc::middle::def::Def;
use rustc_front::hir::{Expr, ExprCall, ExprLit, ExprPath, ExprStruct};
use rustc_front::hir::{Stmt, StmtSemi};
ExprCall(ref callee, ref args) => {
let def = cx.tcx.def_map.borrow().get(&callee.id).map(|d| d.full_def());
match def {
- Some(DefStruct(..)) |
- Some(DefVariant(..)) => args.iter().all(|arg| has_no_effect(cx, arg)),
+ Some(Def::Struct(..)) |
+ Some(Def::Variant(..)) => args.iter().all(|arg| has_no_effect(cx, arg)),
_ => false,
}
}
use rustc::lint::*;
use rustc_front::hir::*;
+use rustc::front::map::NodeItem;
use rustc::middle::ty;
-use rustc::front::map::Node;
use utils::{span_lint, match_type};
use utils::{STRING_PATH, VEC_PATH};
fn check_impl_item(&mut self, cx: &LateContext, item: &ImplItem) {
if let ImplItemKind::Method(ref sig, _) = item.node {
- if let Some(Node::NodeItem(it)) = cx.tcx.map.find(cx.tcx.map.get_parent(item.id)) {
+ if let Some(NodeItem(it)) = cx.tcx.map.find(cx.tcx.map.get_parent(item.id)) {
if let ItemImpl(_, _, _, Some(_), _, _) = it.node {
return; // ignore trait impls
}
use rustc_front::intravisit::{Visitor, FnKind};
use rustc::lint::*;
-use rustc::middle::def::Def::{DefVariant, DefStruct};
+use rustc::middle::def::Def;
use utils::{is_from_for_desugar, in_external_macro, snippet, span_lint, span_note_and_lint, DiagnosticWrapper};
fn is_binding(cx: &LateContext, pat: &Pat) -> bool {
match cx.tcx.def_map.borrow().get(&pat.id).map(|d| d.full_def()) {
- Some(DefVariant(..)) | Some(DefStruct(..)) => false,
+ Some(Def::Variant(..)) | Some(Def::Struct(..)) => false,
_ => true,
}
}
};
match def {
- cstore::DlDef(def::DefTrait(trait_id)) => Some(trait_id),
+ cstore::DlDef(def::Def::Trait(trait_id)) => Some(trait_id),
_ => None,
}
}