From 5d276e58969b3d5fdcdd18eabcf41756ac1bb0fb Mon Sep 17 00:00:00 2001 From: mcarton Date: Thu, 7 Apr 2016 17:46:48 +0200 Subject: [PATCH] Rustup to 1.9.0-nightly (bf5da36f1 2016-04-06) --- src/approx_const.rs | 2 +- src/array_indexing.rs | 2 +- src/attrs.rs | 2 +- src/bit_mask.rs | 7 +++--- src/blacklisted_name.rs | 2 +- src/block_in_if_condition.rs | 4 ++-- src/booleans.rs | 4 ++-- src/collapsible_if.rs | 2 +- src/consts.rs | 4 ++-- src/copies.rs | 2 +- src/cyclomatic_complexity.rs | 4 ++-- src/derive.rs | 2 +- src/drop_ref.rs | 2 +- src/entry.rs | 4 ++-- src/enum_clike.rs | 2 +- src/enum_glob_use.rs | 6 ++--- src/eq_op.rs | 5 ++-- src/escape.rs | 8 +++---- src/eta_reduction.rs | 2 +- src/format.rs | 4 ++-- src/functions.rs | 6 ++--- src/identity_op.rs | 2 +- src/len_zero.rs | 8 ++++--- src/lib.rs | 2 -- src/lifetimes.rs | 6 ++--- src/loops.rs | 8 +++---- src/map_clone.rs | 2 +- src/matches.rs | 2 +- src/methods.rs | 2 +- src/minmax.rs | 2 +- src/misc.rs | 11 ++++----- src/mut_mut.rs | 2 +- src/mut_reference.rs | 2 +- src/mutex_atomic.rs | 2 +- src/needless_bool.rs | 2 +- src/needless_update.rs | 2 +- src/new_without_default.rs | 4 ++-- src/no_effect.rs | 4 ++-- src/open_options.rs | 2 +- src/overflow_check_conditional.rs | 2 +- src/panic.rs | 2 +- src/print.rs | 4 ++-- src/ptr_arg.rs | 4 ++-- src/ranges.rs | 2 +- src/regex.rs | 3 +-- src/shadow.rs | 6 ++--- src/strings.rs | 2 +- src/swap.rs | 2 +- src/temporary_assignment.rs | 2 +- src/transmute.rs | 2 +- src/types.rs | 10 ++++---- src/unicode.rs | 2 +- src/unused_label.rs | 4 ++-- src/utils/comparisons.rs | 2 +- src/utils/hir.rs | 2 +- src/utils/mod.rs | 39 +++++++++++++++++++------------ src/vec.rs | 2 +- src/zero_div_zero.rs | 2 +- tests/compile-fail/transmute.rs | 26 ++++++++++++--------- tests/consts.rs | 3 +-- 60 files changed, 135 insertions(+), 129 deletions(-) diff --git a/src/approx_const.rs b/src/approx_const.rs index 822fbd16c326..731f1a45d094 100644 --- a/src/approx_const.rs +++ b/src/approx_const.rs @@ -1,5 +1,5 @@ use rustc::lint::*; -use rustc_front::hir::*; +use rustc::hir::*; use std::f64::consts as f64; use syntax::ast::{Lit, LitKind, FloatTy}; use utils::span_lint; diff --git a/src/array_indexing.rs b/src/array_indexing.rs index e5f54c128ef6..ce5c85500bd6 100644 --- a/src/array_indexing.rs +++ b/src/array_indexing.rs @@ -4,7 +4,7 @@ use rustc::ty::TyArray; use rustc_const_eval::EvalHint::ExprTypeChecked; use rustc_const_eval::eval_const_expr_partial; use rustc_const_math::ConstInt; -use rustc_front::hir::*; +use rustc::hir::*; use syntax::ast::RangeLimits; use utils; diff --git a/src/attrs.rs b/src/attrs.rs index 363809c37bbe..17b8a60bcb95 100644 --- a/src/attrs.rs +++ b/src/attrs.rs @@ -2,7 +2,7 @@ use reexport::*; use rustc::lint::*; -use rustc_front::hir::*; +use rustc::hir::*; use semver::Version; use syntax::ast::{Attribute, Lit, LitKind, MetaItemKind}; use syntax::attr::*; diff --git a/src/bit_mask.rs b/src/bit_mask.rs index cbe601ba1b46..45f7e5bc938c 100644 --- a/src/bit_mask.rs +++ b/src/bit_mask.rs @@ -1,8 +1,7 @@ +use rustc::hir::*; +use rustc::hir::def::{Def, PathResolution}; use rustc::lint::*; -use rustc::middle::def::{Def, PathResolution}; use rustc_const_eval::lookup_const_by_id; -use rustc_front::hir::*; -use rustc_front::util::is_comparison_binop; use syntax::ast::LitKind; use syntax::codemap::Span; use utils::span_lint; @@ -91,7 +90,7 @@ impl LintPass for BitMask { impl LateLintPass for BitMask { fn check_expr(&mut self, cx: &LateContext, e: &Expr) { if let ExprBinary(ref cmp, ref left, ref right) = e.node { - if is_comparison_binop(cmp.node) { + if cmp.node.is_comparison() { fetch_int_literal(cx, right).map_or_else(|| { fetch_int_literal(cx, left).map_or((), |cmp_val| { check_compare(cx, diff --git a/src/blacklisted_name.rs b/src/blacklisted_name.rs index 25c0bac2c374..b515da000ee6 100644 --- a/src/blacklisted_name.rs +++ b/src/blacklisted_name.rs @@ -1,5 +1,5 @@ use rustc::lint::*; -use rustc_front::hir::*; +use rustc::hir::*; use utils::span_lint; /// **What it does:** This lints about usage of blacklisted names. diff --git a/src/block_in_if_condition.rs b/src/block_in_if_condition.rs index 9cb11968abcf..1a2123fe00ae 100644 --- a/src/block_in_if_condition.rs +++ b/src/block_in_if_condition.rs @@ -1,6 +1,6 @@ use rustc::lint::{LateLintPass, LateContext, LintArray, LintPass}; -use rustc_front::hir::*; -use rustc_front::intravisit::{Visitor, walk_expr}; +use rustc::hir::*; +use rustc::hir::intravisit::{Visitor, walk_expr}; use utils::*; /// **What it does:** This lint checks for `if` conditions that use blocks to contain an expression. diff --git a/src/booleans.rs b/src/booleans.rs index 37ad927ef920..213d12b42ef4 100644 --- a/src/booleans.rs +++ b/src/booleans.rs @@ -1,6 +1,6 @@ use rustc::lint::{LintArray, LateLintPass, LateContext, LintPass}; -use rustc_front::hir::*; -use rustc_front::intravisit::*; +use rustc::hir::*; +use rustc::hir::intravisit::*; use syntax::ast::{LitKind, DUMMY_NODE_ID}; use syntax::codemap::{DUMMY_SP, dummy_spanned}; use utils::{span_lint_and_then, in_macro, snippet_opt, SpanlessEq}; diff --git a/src/collapsible_if.rs b/src/collapsible_if.rs index 74397304eda8..5674806b175a 100644 --- a/src/collapsible_if.rs +++ b/src/collapsible_if.rs @@ -13,7 +13,7 @@ //! This lint is **warn** by default use rustc::lint::*; -use rustc_front::hir::*; +use rustc::hir::*; use std::borrow::Cow; use syntax::codemap::Spanned; diff --git a/src/consts.rs b/src/consts.rs index 73f2bc4653a1..d30392e05860 100644 --- a/src/consts.rs +++ b/src/consts.rs @@ -1,10 +1,10 @@ #![allow(cast_possible_truncation)] use rustc::lint::LateContext; -use rustc::middle::def::{Def, PathResolution}; +use rustc::hir::def::{Def, PathResolution}; use rustc_const_eval::lookup_const_by_id; use rustc_const_math::{ConstInt, ConstUsize, ConstIsize}; -use rustc_front::hir::*; +use rustc::hir::*; use std::cmp::Ordering::{self, Equal}; use std::cmp::PartialOrd; use std::hash::{Hash, Hasher}; diff --git a/src/copies.rs b/src/copies.rs index b8eb97cbeed5..5b992cf38ae7 100644 --- a/src/copies.rs +++ b/src/copies.rs @@ -1,6 +1,6 @@ use rustc::lint::*; use rustc::ty; -use rustc_front::hir::*; +use rustc::hir::*; use std::collections::HashMap; use std::collections::hash_map::Entry; use syntax::parse::token::InternedString; diff --git a/src/cyclomatic_complexity.rs b/src/cyclomatic_complexity.rs index ca5acc6895fa..fcd89801ecc3 100644 --- a/src/cyclomatic_complexity.rs +++ b/src/cyclomatic_complexity.rs @@ -3,8 +3,8 @@ use rustc::lint::*; use rustc::cfg::CFG; use rustc::ty; -use rustc_front::hir::*; -use rustc_front::intravisit::{Visitor, walk_expr}; +use rustc::hir::*; +use rustc::hir::intravisit::{Visitor, walk_expr}; use syntax::ast::Attribute; use syntax::attr::*; use syntax::codemap::Span; diff --git a/src/derive.rs b/src/derive.rs index ab4f73eafc09..593118bef84a 100644 --- a/src/derive.rs +++ b/src/derive.rs @@ -3,7 +3,7 @@ use rustc::ty::subst::Subst; use rustc::ty::TypeVariants; use rustc::ty::fast_reject::simplify_type; use rustc::ty; -use rustc_front::hir::*; +use rustc::hir::*; use syntax::ast::{Attribute, MetaItemKind}; use syntax::codemap::Span; use utils::{CLONE_TRAIT_PATH, HASH_PATH}; diff --git a/src/drop_ref.rs b/src/drop_ref.rs index 7536fb1b63b0..3448e05dbac1 100644 --- a/src/drop_ref.rs +++ b/src/drop_ref.rs @@ -1,6 +1,6 @@ use rustc::lint::*; use rustc::ty; -use rustc_front::hir::*; +use rustc::hir::*; use syntax::codemap::Span; use utils::DROP_PATH; use utils::{match_def_path, span_note_and_lint}; diff --git a/src/entry.rs b/src/entry.rs index 8a4cf37c0acf..934400bc1228 100644 --- a/src/entry.rs +++ b/src/entry.rs @@ -1,6 +1,6 @@ use rustc::lint::*; -use rustc_front::hir::*; -use rustc_front::intravisit::{Visitor, walk_expr, walk_block}; +use rustc::hir::*; +use rustc::hir::intravisit::{Visitor, walk_expr, walk_block}; use syntax::codemap::Span; use utils::SpanlessEq; use utils::{BTREEMAP_PATH, HASHMAP_PATH}; diff --git a/src/enum_clike.rs b/src/enum_clike.rs index 0e2a7a5304fc..e3e8f1e5eb6d 100644 --- a/src/enum_clike.rs +++ b/src/enum_clike.rs @@ -3,7 +3,7 @@ use rustc::lint::*; use rustc::middle::const_val::ConstVal; use rustc_const_math::*; -use rustc_front::hir::*; +use rustc::hir::*; use syntax::attr::*; use utils::span_lint; diff --git a/src/enum_glob_use.rs b/src/enum_glob_use.rs index 5b29f84ef51d..671b9bb141c3 100644 --- a/src/enum_glob_use.rs +++ b/src/enum_glob_use.rs @@ -1,10 +1,10 @@ //! lint on `use`ing all variants of an enum -use rustc::front::map::Node::NodeItem; +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::def::Def; use rustc::middle::cstore::DefLike; -use rustc_front::hir::*; use syntax::ast::NodeId; use syntax::codemap::Span; use utils::span_lint; diff --git a/src/eq_op.rs b/src/eq_op.rs index 09ac6325f96f..fb06639853cd 100644 --- a/src/eq_op.rs +++ b/src/eq_op.rs @@ -1,6 +1,5 @@ +use rustc::hir::*; use rustc::lint::*; -use rustc_front::hir::*; -use rustc_front::util as ast_util; use utils::{SpanlessEq, span_lint}; /// **What it does:** This lint checks for equal operands to comparison, logical and bitwise, @@ -34,7 +33,7 @@ impl LateLintPass for EqOp { span_lint(cx, EQ_OP, e.span, - &format!("equal expressions as operands to `{}`", ast_util::binop_to_string(op.node))); + &format!("equal expressions as operands to `{}`", op.node.as_str())); } } } diff --git a/src/escape.rs b/src/escape.rs index 98500bf62f01..fa235244884a 100644 --- a/src/escape.rs +++ b/src/escape.rs @@ -1,14 +1,14 @@ -use rustc::front::map::Node::{NodeExpr, NodeStmt}; +use rustc::hir::*; +use rustc::hir::intravisit as visit; +use rustc::hir::map::Node::{NodeExpr, NodeStmt}; +use rustc::infer; use rustc::lint::*; use rustc::middle::expr_use_visitor::*; -use rustc::infer; use rustc::middle::mem_categorization::{cmt, Categorization}; use rustc::traits::ProjectionMode; use rustc::ty::adjustment::AutoAdjustment; use rustc::ty; use rustc::util::nodemap::NodeSet; -use rustc_front::hir::*; -use rustc_front::intravisit as visit; use syntax::ast::NodeId; use syntax::codemap::Span; use utils::span_lint; diff --git a/src/eta_reduction.rs b/src/eta_reduction.rs index c080968ef84f..4519acc39de8 100644 --- a/src/eta_reduction.rs +++ b/src/eta_reduction.rs @@ -1,6 +1,6 @@ use rustc::lint::*; use rustc::ty; -use rustc_front::hir::*; +use rustc::hir::*; use utils::{snippet_opt, span_lint_and_then, is_adjusted}; #[allow(missing_copy_implementations)] diff --git a/src/format.rs b/src/format.rs index 300b3d17b393..0a349c98e076 100644 --- a/src/format.rs +++ b/src/format.rs @@ -1,7 +1,7 @@ -use rustc::front::map::Node::NodeItem; +use rustc::hir::map::Node::NodeItem; use rustc::lint::*; use rustc::ty::TypeVariants; -use rustc_front::hir::*; +use rustc::hir::*; use syntax::ast::LitKind; use utils::{DISPLAY_FMT_METHOD_PATH, FMT_ARGUMENTS_NEWV1_PATH, STRING_PATH}; use utils::{is_expn_of, match_path, match_type, span_lint, walk_ptrs_ty}; diff --git a/src/functions.rs b/src/functions.rs index 5ac5aae51a40..ed04473abc3e 100644 --- a/src/functions.rs +++ b/src/functions.rs @@ -1,6 +1,6 @@ use rustc::lint::*; -use rustc_front::hir; -use rustc_front::intravisit; +use rustc::hir; +use rustc::hir::intravisit; use syntax::ast; use syntax::codemap::Span; use utils::span_lint; @@ -45,7 +45,7 @@ impl LintPass for Functions { impl LateLintPass for Functions { fn check_fn(&mut self, cx: &LateContext, _: intravisit::FnKind, decl: &hir::FnDecl, _: &hir::Block, span: Span, nodeid: ast::NodeId) { - use rustc::front::map::Node::*; + use rustc::hir::map::Node::*; if let Some(NodeItem(ref item)) = cx.tcx.map.find(cx.tcx.map.get_parent_node(nodeid)) { match item.node { diff --git a/src/identity_op.rs b/src/identity_op.rs index c25047b87b41..4c1f01b73858 100644 --- a/src/identity_op.rs +++ b/src/identity_op.rs @@ -1,6 +1,6 @@ use consts::{constant_simple, Constant}; use rustc::lint::*; -use rustc_front::hir::*; +use rustc::hir::*; use syntax::codemap::Span; use utils::{span_lint, snippet, in_macro}; use rustc_const_math::ConstInt; diff --git a/src/len_zero.rs b/src/len_zero.rs index 1a097820e1e3..3a376d91c929 100644 --- a/src/len_zero.rs +++ b/src/len_zero.rs @@ -1,7 +1,7 @@ use rustc::lint::*; -use rustc::middle::def_id::DefId; +use rustc::hir::def_id::DefId; use rustc::ty::{self, MethodTraitItemId, ImplOrTraitItemId}; -use rustc_front::hir::*; +use rustc::hir::*; use syntax::ast::{Lit, LitKind, Name}; use syntax::codemap::{Span, Spanned}; use syntax::ptr::P; @@ -111,6 +111,8 @@ fn check_impl_items(cx: &LateContext, item: &Item, impl_items: &[ImplItem]) { if !impl_items.iter().any(|i| is_named_self(i, "is_empty")) { for i in impl_items { if is_named_self(i, "len") { + let ty = cx.tcx.node_id_to_type(item.id); + let s = i.span; span_lint(cx, LEN_WITHOUT_IS_EMPTY, @@ -121,7 +123,7 @@ fn check_impl_items(cx: &LateContext, item: &Item, impl_items: &[ImplItem]) { }, &format!("item `{}` has a `.len(_: &Self)` method, but no `.is_empty(_: &Self)` method. \ Consider adding one", - item.name)); + ty)); return; } } diff --git a/src/lib.rs b/src/lib.rs index 7ab48f462236..1b48c7b3dbbc 100644 --- a/src/lib.rs +++ b/src/lib.rs @@ -19,8 +19,6 @@ fn main() { extern crate syntax; #[macro_use] extern crate rustc; -#[macro_use] -extern crate rustc_front; extern crate toml; diff --git a/src/lifetimes.rs b/src/lifetimes.rs index 72fdba07d32d..ad42a8568e60 100644 --- a/src/lifetimes.rs +++ b/src/lifetimes.rs @@ -1,8 +1,8 @@ use reexport::*; use rustc::lint::*; -use rustc::middle::def::Def; -use rustc_front::hir::*; -use rustc_front::intravisit::{Visitor, walk_ty, walk_ty_param_bound, walk_fn_decl, walk_generics}; +use rustc::hir::def::Def; +use rustc::hir::*; +use rustc::hir::intravisit::{Visitor, walk_ty, walk_ty_param_bound, walk_fn_decl, walk_generics}; use std::collections::{HashSet, HashMap}; use syntax::codemap::Span; use utils::{in_external_macro, span_lint}; diff --git a/src/loops.rs b/src/loops.rs index 20d0fc026d15..4e7e4bf117d8 100644 --- a/src/loops.rs +++ b/src/loops.rs @@ -1,14 +1,14 @@ use reexport::*; -use rustc::front::map::Node::NodeBlock; +use rustc::hir::*; +use rustc::hir::def::Def; +use rustc::hir::intravisit::{Visitor, walk_expr, walk_block, walk_decl}; +use rustc::hir::map::Node::NodeBlock; use rustc::lint::*; use rustc::middle::const_val::ConstVal; -use rustc::middle::def::Def; use rustc::middle::region::CodeExtent; use rustc::ty; use rustc_const_eval::EvalHint::ExprTypeChecked; use rustc_const_eval::eval_const_expr_partial; -use rustc_front::hir::*; -use rustc_front::intravisit::{Visitor, walk_expr, walk_block, walk_decl}; use std::borrow::Cow; use std::collections::HashMap; use syntax::ast; diff --git a/src/map_clone.rs b/src/map_clone.rs index 4eac4dc61138..eeb3aab4655c 100644 --- a/src/map_clone.rs +++ b/src/map_clone.rs @@ -1,5 +1,5 @@ use rustc::lint::*; -use rustc_front::hir::*; +use rustc::hir::*; use utils::{CLONE_PATH, OPTION_PATH}; use utils::{is_adjusted, match_path, match_trait_method, match_type, snippet, span_help_and_lint, walk_ptrs_ty, walk_ptrs_ty_depth}; diff --git a/src/matches.rs b/src/matches.rs index f1499f7fb94f..d82dad5b0653 100644 --- a/src/matches.rs +++ b/src/matches.rs @@ -1,10 +1,10 @@ +use rustc::hir::*; use rustc::lint::*; use rustc::middle::const_val::ConstVal; use rustc::ty; use rustc_const_eval::EvalHint::ExprTypeChecked; use rustc_const_eval::eval_const_expr_partial; use rustc_const_math::ConstInt; -use rustc_front::hir::*; use std::cmp::Ordering; use syntax::ast::LitKind; use syntax::codemap::Span; diff --git a/src/methods.rs b/src/methods.rs index 646cd319a0cd..3fcd472faf51 100644 --- a/src/methods.rs +++ b/src/methods.rs @@ -1,3 +1,4 @@ +use rustc::hir::*; use rustc::lint::*; use rustc::middle::const_val::ConstVal; use rustc::middle::cstore::CrateStore; @@ -5,7 +6,6 @@ use rustc::ty::subst::{Subst, TypeSpace}; use rustc::ty; use rustc_const_eval::EvalHint::ExprTypeChecked; use rustc_const_eval::eval_const_expr_partial; -use rustc_front::hir::*; use std::borrow::Cow; use std::fmt; use syntax::codemap::Span; diff --git a/src/minmax.rs b/src/minmax.rs index 0560bf15604c..67299bac9988 100644 --- a/src/minmax.rs +++ b/src/minmax.rs @@ -1,6 +1,6 @@ use consts::{Constant, constant_simple}; use rustc::lint::*; -use rustc_front::hir::*; +use rustc::hir::*; use std::cmp::{PartialOrd, Ordering}; use syntax::ptr::P; use utils::{match_def_path, span_lint}; diff --git a/src/misc.rs b/src/misc.rs index a6cfec276e55..654e6244c1b6 100644 --- a/src/misc.rs +++ b/src/misc.rs @@ -1,12 +1,11 @@ use reexport::*; +use rustc::hir::*; +use rustc::hir::intravisit::FnKind; use rustc::lint::*; use rustc::middle::const_val::ConstVal; use rustc::ty; use rustc_const_eval::EvalHint::ExprTypeChecked; use rustc_const_eval::eval_const_expr_partial; -use rustc_front::hir::*; -use rustc_front::intravisit::FnKind; -use rustc_front::util::{is_comparison_binop, binop_to_string}; use syntax::codemap::{Span, Spanned, ExpnFormat}; use syntax::ptr::P; use utils::{get_item_name, match_path, snippet, get_parent_expr, span_lint}; @@ -105,7 +104,7 @@ impl LintPass for CmpNan { impl LateLintPass for CmpNan { fn check_expr(&mut self, cx: &LateContext, expr: &Expr) { if let ExprBinary(ref cmp, ref left, ref right) = expr.node { - if is_comparison_binop(cmp.node) { + if cmp.node.is_comparison() { if let ExprPath(_, ref path) = left.node { check_nan(cx, path, expr.span); } @@ -170,7 +169,7 @@ impl LateLintPass for FloatCmp { &format!("{}-comparison of f32 or f64 detected. Consider changing this to `({} - {}).abs() < \ epsilon` for some suitable value of epsilon. \ std::f32::EPSILON and std::f64::EPSILON are available.", - binop_to_string(op), + op.as_str(), snippet(cx, left.span, ".."), snippet(cx, right.span, ".."))); } @@ -217,7 +216,7 @@ impl LintPass for CmpOwned { impl LateLintPass for CmpOwned { fn check_expr(&mut self, cx: &LateContext, expr: &Expr) { if let ExprBinary(ref cmp, ref left, ref right) = expr.node { - if is_comparison_binop(cmp.node) { + if cmp.node.is_comparison() { check_to_owned(cx, left, right, true, cmp.span); check_to_owned(cx, right, left, false, cmp.span) } diff --git a/src/mut_mut.rs b/src/mut_mut.rs index a5ed233241de..65e2c3a46a97 100644 --- a/src/mut_mut.rs +++ b/src/mut_mut.rs @@ -1,6 +1,6 @@ use rustc::lint::*; use rustc::ty::{TypeAndMut, TyRef}; -use rustc_front::hir::*; +use rustc::hir::*; use utils::{in_external_macro, span_lint}; /// **What it does:** This lint checks for instances of `mut mut` references. diff --git a/src/mut_reference.rs b/src/mut_reference.rs index 95ed1092eb55..d74c2c41f237 100644 --- a/src/mut_reference.rs +++ b/src/mut_reference.rs @@ -1,6 +1,6 @@ use rustc::lint::*; use rustc::ty::{TypeAndMut, TypeVariants, MethodCall, TyS}; -use rustc_front::hir::*; +use rustc::hir::*; use syntax::ptr::P; use utils::span_lint; diff --git a/src/mutex_atomic.rs b/src/mutex_atomic.rs index 0593438cfc15..bae1ae38168d 100644 --- a/src/mutex_atomic.rs +++ b/src/mutex_atomic.rs @@ -5,7 +5,7 @@ use rustc::lint::{LintPass, LintArray, LateLintPass, LateContext}; use rustc::ty::subst::ParamSpace; use rustc::ty; -use rustc_front::hir::Expr; +use rustc::hir::Expr; use syntax::ast; use utils::{span_lint, MUTEX_PATH, match_type}; diff --git a/src/needless_bool.rs b/src/needless_bool.rs index ab5a1e26b20c..07da57c684b4 100644 --- a/src/needless_bool.rs +++ b/src/needless_bool.rs @@ -3,7 +3,7 @@ //! This lint is **warn** by default use rustc::lint::*; -use rustc_front::hir::*; +use rustc::hir::*; use syntax::ast::LitKind; use syntax::codemap::Spanned; use utils::{span_lint, span_lint_and_then, snippet, snippet_opt}; diff --git a/src/needless_update.rs b/src/needless_update.rs index d25f66ca4346..d8ae9dc34716 100644 --- a/src/needless_update.rs +++ b/src/needless_update.rs @@ -1,6 +1,6 @@ use rustc::lint::{LateContext, LateLintPass, LintArray, LintPass}; use rustc::ty::TyStruct; -use rustc_front::hir::{Expr, ExprStruct}; +use rustc::hir::{Expr, ExprStruct}; use utils::span_lint; /// **What it does:** This lint warns on needlessly including a base struct on update when all fields are changed anyway. diff --git a/src/new_without_default.rs b/src/new_without_default.rs index 395d69138e13..2bcc345fd601 100644 --- a/src/new_without_default.rs +++ b/src/new_without_default.rs @@ -1,6 +1,6 @@ use rustc::lint::*; -use rustc_front::hir; -use rustc_front::intravisit::FnKind; +use rustc::hir; +use rustc::hir::intravisit::FnKind; use syntax::ast; use syntax::codemap::Span; use utils::{get_trait_def_id, implements_trait, in_external_macro, return_ty, same_tys, span_lint, diff --git a/src/no_effect.rs b/src/no_effect.rs index 59f7be94c237..afb49376b3f8 100644 --- a/src/no_effect.rs +++ b/src/no_effect.rs @@ -1,6 +1,6 @@ use rustc::lint::{LateContext, LateLintPass, LintArray, LintPass}; -use rustc::middle::def::Def; -use rustc_front::hir::{Expr, Expr_, Stmt, StmtSemi}; +use rustc::hir::def::Def; +use rustc::hir::{Expr, Expr_, Stmt, StmtSemi}; use utils::{in_macro, span_lint}; /// **What it does:** This lint checks for statements which have no effect. diff --git a/src/open_options.rs b/src/open_options.rs index e3f61afcf1c8..3c1e69a40ea2 100644 --- a/src/open_options.rs +++ b/src/open_options.rs @@ -1,5 +1,5 @@ use rustc::lint::*; -use rustc_front::hir::{Expr, ExprMethodCall, ExprLit}; +use rustc::hir::{Expr, ExprMethodCall, ExprLit}; use syntax::ast::LitKind; use syntax::codemap::{Span, Spanned}; use utils::{walk_ptrs_ty_depth, match_type, span_lint, OPEN_OPTIONS_PATH}; diff --git a/src/overflow_check_conditional.rs b/src/overflow_check_conditional.rs index 823cb696901a..627028ad462a 100644 --- a/src/overflow_check_conditional.rs +++ b/src/overflow_check_conditional.rs @@ -1,5 +1,5 @@ use rustc::lint::*; -use rustc_front::hir::*; +use rustc::hir::*; use utils::{span_lint}; /// **What it does:** This lint finds classic underflow / overflow checks. diff --git a/src/panic.rs b/src/panic.rs index 8b9bf9f1f197..ab03181c2dd3 100644 --- a/src/panic.rs +++ b/src/panic.rs @@ -1,5 +1,5 @@ use rustc::lint::*; -use rustc_front::hir::*; +use rustc::hir::*; use syntax::ast::LitKind; use utils::{span_lint, is_direct_expn_of, match_path, BEGIN_UNWIND}; diff --git a/src/print.rs b/src/print.rs index ffe20d13ceab..a298d162c058 100644 --- a/src/print.rs +++ b/src/print.rs @@ -1,6 +1,6 @@ -use rustc::front::map::Node::{NodeItem, NodeImplItem}; +use rustc::hir::map::Node::{NodeItem, NodeImplItem}; use rustc::lint::*; -use rustc_front::hir::*; +use rustc::hir::*; use utils::{FMT_ARGUMENTV1_NEW_PATH, DEBUG_FMT_METHOD_PATH, IO_PRINT_PATH}; use utils::{is_expn_of, match_path, span_lint}; diff --git a/src/ptr_arg.rs b/src/ptr_arg.rs index 6498db66e139..8720424da86f 100644 --- a/src/ptr_arg.rs +++ b/src/ptr_arg.rs @@ -1,9 +1,9 @@ //! Checks for usage of `&Vec[_]` and `&String`. -use rustc::front::map::NodeItem; +use rustc::hir::map::NodeItem; use rustc::lint::*; use rustc::ty; -use rustc_front::hir::*; +use rustc::hir::*; use syntax::ast::NodeId; use utils::{STRING_PATH, VEC_PATH}; use utils::{span_lint, match_type}; diff --git a/src/ranges.rs b/src/ranges.rs index 23bd3d1103ce..c2555da1d0b8 100644 --- a/src/ranges.rs +++ b/src/ranges.rs @@ -1,5 +1,5 @@ use rustc::lint::*; -use rustc_front::hir::*; +use rustc::hir::*; use syntax::codemap::Spanned; use utils::{is_integer_literal, match_type, snippet, span_lint, unsugar_range, UnsugaredRange}; diff --git a/src/regex.rs b/src/regex.rs index 46ee7776d66d..f24639312ed8 100644 --- a/src/regex.rs +++ b/src/regex.rs @@ -1,15 +1,14 @@ use regex_syntax; +use rustc::hir::*; use rustc::lint::*; use rustc::middle::const_val::ConstVal; use rustc_const_eval::EvalHint::ExprTypeChecked; use rustc_const_eval::eval_const_expr_partial; -use rustc_front::hir::*; use std::collections::HashSet; use std::error::Error; use syntax::ast::{LitKind, NodeId}; use syntax::codemap::{Span, BytePos}; use syntax::parse::token::InternedString; - use utils::{is_expn_of, match_path, match_type, REGEX_NEW_PATH, span_lint, span_help_and_lint}; /// **What it does:** This lint checks `Regex::new(_)` invocations for correct regex syntax. diff --git a/src/shadow.rs b/src/shadow.rs index baf5c9b8872c..928d447974a3 100644 --- a/src/shadow.rs +++ b/src/shadow.rs @@ -1,8 +1,8 @@ use reexport::*; use rustc::lint::*; -use rustc::middle::def::Def; -use rustc_front::hir::*; -use rustc_front::intravisit::{Visitor, FnKind}; +use rustc::hir::def::Def; +use rustc::hir::*; +use rustc::hir::intravisit::{Visitor, FnKind}; use std::ops::Deref; use syntax::codemap::Span; use utils::{is_from_for_desugar, in_external_macro, snippet, span_lint, span_note_and_lint, DiagnosticWrapper}; diff --git a/src/strings.rs b/src/strings.rs index 9f68175b2024..da1456671fdf 100644 --- a/src/strings.rs +++ b/src/strings.rs @@ -4,7 +4,7 @@ //! disable the subsumed lint unless it has a higher level use rustc::lint::*; -use rustc_front::hir::*; +use rustc::hir::*; use syntax::codemap::Spanned; use utils::STRING_PATH; use utils::SpanlessEq; diff --git a/src/swap.rs b/src/swap.rs index 6d7212233fbb..29db0da5cf9a 100644 --- a/src/swap.rs +++ b/src/swap.rs @@ -1,5 +1,5 @@ use rustc::lint::*; -use rustc_front::hir::*; +use rustc::hir::*; use syntax::codemap::mk_sp; use utils::{differing_macro_contexts, snippet_opt, span_lint_and_then, SpanlessEq}; diff --git a/src/temporary_assignment.rs b/src/temporary_assignment.rs index c945fd7148e7..447964104588 100644 --- a/src/temporary_assignment.rs +++ b/src/temporary_assignment.rs @@ -1,5 +1,5 @@ use rustc::lint::{LateContext, LateLintPass, LintArray, LintPass}; -use rustc_front::hir::{Expr, ExprAssign, ExprField, ExprStruct, ExprTup, ExprTupField}; +use rustc::hir::{Expr, ExprAssign, ExprField, ExprStruct, ExprTup, ExprTupField}; use utils::is_adjusted; use utils::span_lint; diff --git a/src/transmute.rs b/src/transmute.rs index ef049ba4a6db..41b92ca61138 100644 --- a/src/transmute.rs +++ b/src/transmute.rs @@ -1,7 +1,7 @@ use rustc::lint::*; use rustc::ty::TypeVariants::{TyRawPtr, TyRef}; use rustc::ty; -use rustc_front::hir::*; +use rustc::hir::*; use utils::TRANSMUTE_PATH; use utils::{match_def_path, snippet_opt, span_lint, span_lint_and_then}; diff --git a/src/types.rs b/src/types.rs index cc618453132f..281af90736b2 100644 --- a/src/types.rs +++ b/src/types.rs @@ -1,10 +1,8 @@ use reexport::*; +use rustc::hir::*; +use rustc::hir::intravisit::{FnKind, Visitor, walk_ty}; use rustc::lint::*; -use rustc::middle::def; use rustc::ty; -use rustc_front::hir::*; -use rustc_front::intravisit::{FnKind, Visitor, walk_ty}; -use rustc_front::util::{is_comparison_binop, binop_to_string}; use std::cmp::Ordering; use syntax::ast::{IntTy, UintTy, FloatTy}; use syntax::codemap::Span; @@ -162,7 +160,7 @@ 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(vec![]) && is_comparison_binop(op) { + if *sty == ty::TyTuple(vec![]) && op.is_comparison() { let result = match op { BiEq | BiLe | BiGe => "true", _ => "false", @@ -171,7 +169,7 @@ impl LateLintPass for UnitCmp { UNIT_CMP, expr.span, &format!("{}-comparison of unit values detected. This will always be {}", - binop_to_string(op), + op.as_str(), result)); } } diff --git a/src/unicode.rs b/src/unicode.rs index 0f21822ea08f..26521017ee52 100644 --- a/src/unicode.rs +++ b/src/unicode.rs @@ -1,5 +1,5 @@ use rustc::lint::*; -use rustc_front::hir::*; +use rustc::hir::*; use syntax::ast::LitKind; use syntax::codemap::Span; use unicode_normalization::UnicodeNormalization; diff --git a/src/unused_label.rs b/src/unused_label.rs index f2ecad7cc821..f6ff3c3d4b4e 100644 --- a/src/unused_label.rs +++ b/src/unused_label.rs @@ -1,6 +1,6 @@ use rustc::lint::*; -use rustc_front::hir; -use rustc_front::intravisit::{FnKind, Visitor, walk_expr, walk_fn}; +use rustc::hir; +use rustc::hir::intravisit::{FnKind, Visitor, walk_expr, walk_fn}; use std::collections::HashMap; use syntax::ast; use syntax::codemap::Span; diff --git a/src/utils/comparisons.rs b/src/utils/comparisons.rs index a9181b35b385..b890a363fb7f 100644 --- a/src/utils/comparisons.rs +++ b/src/utils/comparisons.rs @@ -1,4 +1,4 @@ -use rustc_front::hir::{BinOp_, Expr}; +use rustc::hir::{BinOp_, Expr}; #[derive(PartialEq, Eq, Debug, Copy, Clone)] pub enum Rel { diff --git a/src/utils/hir.rs b/src/utils/hir.rs index 0659e26d0f27..f6fa21769413 100644 --- a/src/utils/hir.rs +++ b/src/utils/hir.rs @@ -1,6 +1,6 @@ use consts::constant; use rustc::lint::*; -use rustc_front::hir::*; +use rustc::hir::*; use std::hash::{Hash, Hasher, SipHasher}; use syntax::ast::Name; use syntax::ptr::P; diff --git a/src/utils/mod.rs b/src/utils/mod.rs index 7607ef31486b..6d2fd14f533d 100644 --- a/src/utils/mod.rs +++ b/src/utils/mod.rs @@ -1,15 +1,15 @@ use reexport::*; -use rustc::front::map::Node; +use rustc::hir::*; +use rustc::hir::def_id::DefId; +use rustc::hir::map::Node; +use rustc::infer; use rustc::lint::{LintContext, LateContext, Level, Lint}; -use rustc::middle::def_id::DefId; -use rustc::traits; +use rustc::middle::cstore; +use rustc::session::Session; use rustc::traits::ProjectionMode; -use rustc::middle::{cstore, def}; -use rustc::infer; -use rustc::ty; +use rustc::traits; use rustc::ty::subst::Subst; -use rustc::session::Session; -use rustc_front::hir::*; +use rustc::ty; use std::borrow::Cow; use std::mem; use std::ops::{Deref, DerefMut}; @@ -56,7 +56,7 @@ pub const RANGE_TO_PATH: [&'static str; 3] = ["std", "ops", "RangeTo"]; pub const REGEX_NEW_PATH: [&'static str; 3] = ["regex", "Regex", "new"]; pub const RESULT_PATH: [&'static str; 3] = ["core", "result", "Result"]; pub const STRING_PATH: [&'static str; 3] = ["collections", "string", "String"]; -pub const TRANSMUTE_PATH: [&'static str; 3] = ["core", "intrinsics", "transmute"]; +pub const TRANSMUTE_PATH: [&'static str; 4] = ["core", "intrinsics", "", "transmute"]; pub const VEC_FROM_ELEM_PATH: [&'static str; 3] = ["std", "vec", "from_elem"]; pub const VEC_PATH: [&'static str; 3] = ["collections", "vec", "Vec"]; pub const BOX_PATH: [&'static str; 3] = ["std", "boxed", "Box"]; @@ -157,13 +157,22 @@ pub fn in_external_macro(cx: &T, span: Span) -> bool { /// match_def_path(cx, id, &["core", "option", "Option"]) /// ``` pub fn match_def_path(cx: &LateContext, def_id: DefId, path: &[&str]) -> bool { - cx.tcx.with_path(def_id, |iter| { - let mut len = 0; + let krate = &cx.tcx.crate_name(def_id.krate); + if krate != &path[0] { + return false; + } - iter.inspect(|_| len += 1) - .zip(path) - .all(|(nm, p)| nm.name().as_str() == *p) && len == path.len() - }) + let path = &path[1..]; + let other = cx.tcx.def_path(def_id).data; + + if other.len() != path.len() { + return false; + } + + other.into_iter() + .map(|e| e.data) + .zip(path) + .all(|(nm, p)| nm.as_interned_str() == *p) } /// Check if type is struct or enum type with given def path. diff --git a/src/vec.rs b/src/vec.rs index 412ebf396dd3..d27a3320d96c 100644 --- a/src/vec.rs +++ b/src/vec.rs @@ -1,6 +1,6 @@ use rustc::lint::*; use rustc::ty::TypeVariants; -use rustc_front::hir::*; +use rustc::hir::*; use syntax::codemap::Span; use syntax::ptr::P; use utils::VEC_FROM_ELEM_PATH; diff --git a/src/zero_div_zero.rs b/src/zero_div_zero.rs index f58b0e695a91..902d84d4dd32 100644 --- a/src/zero_div_zero.rs +++ b/src/zero_div_zero.rs @@ -1,6 +1,6 @@ use consts::{Constant, constant_simple, FloatWidth}; use rustc::lint::*; -use rustc_front::hir::*; +use rustc::hir::*; use utils::span_help_and_lint; /// `ZeroDivZeroPass` is a pass that checks for a binary expression that consists diff --git a/tests/compile-fail/transmute.rs b/tests/compile-fail/transmute.rs index cd86281d8f24..ad97410cf655 100644 --- a/tests/compile-fail/transmute.rs +++ b/tests/compile-fail/transmute.rs @@ -6,6 +6,10 @@ extern crate core; use std::mem::transmute as my_transmute; use std::vec::Vec as MyVec; +fn my_int() -> usize { + 42 +} + fn my_vec() -> MyVec { vec![] } @@ -86,22 +90,22 @@ fn useless() { #[deny(crosspointer_transmute)] fn crosspointer() { - let mut vec: Vec = vec![]; - let vec_const_ptr: *const Vec = &vec as *const Vec; - let vec_mut_ptr: *mut Vec = &mut vec as *mut Vec; + let mut int: usize = 0; + let int_const_ptr: *const usize = &int as *const usize; + let int_mut_ptr: *mut usize = &mut int as *mut usize; unsafe { - let _: Vec = core::intrinsics::transmute(vec_const_ptr); - //~^ ERROR transmute from a type (`*const std::vec::Vec`) to the type that it points to (`std::vec::Vec`) + let _: usize = core::intrinsics::transmute(int_const_ptr); + //~^ ERROR transmute from a type (`*const usize`) to the type that it points to (`usize`) - let _: Vec = core::intrinsics::transmute(vec_mut_ptr); - //~^ ERROR transmute from a type (`*mut std::vec::Vec`) to the type that it points to (`std::vec::Vec`) + let _: usize = core::intrinsics::transmute(int_mut_ptr); + //~^ ERROR transmute from a type (`*mut usize`) to the type that it points to (`usize`) - let _: *const Vec = core::intrinsics::transmute(my_vec()); - //~^ ERROR transmute from a type (`std::vec::Vec`) to a pointer to that type (`*const std::vec::Vec`) + let _: *const usize = core::intrinsics::transmute(my_int()); + //~^ ERROR transmute from a type (`usize`) to a pointer to that type (`*const usize`) - let _: *mut Vec = core::intrinsics::transmute(my_vec()); - //~^ ERROR transmute from a type (`std::vec::Vec`) to a pointer to that type (`*mut std::vec::Vec`) + let _: *mut usize = core::intrinsics::transmute(my_int()); + //~^ ERROR transmute from a type (`usize`) to a pointer to that type (`*mut usize`) } } diff --git a/tests/consts.rs b/tests/consts.rs index b7b2f6a3f835..4b3aba3f6bed 100644 --- a/tests/consts.rs +++ b/tests/consts.rs @@ -5,12 +5,11 @@ extern crate clippy; extern crate rustc; extern crate rustc_const_eval; extern crate rustc_const_math; -extern crate rustc_front; extern crate syntax; use clippy::consts::{constant_simple, Constant, FloatWidth}; use rustc_const_math::ConstInt; -use rustc_front::hir::*; +use rustc::hir::*; use syntax::ast::{LitIntType, LitKind, StrStyle}; use syntax::codemap::{Spanned, COMMAND_LINE_SP}; use syntax::parse::token::InternedString;