From eca185438b52ae4645f5aa78b6076adeec49707d Mon Sep 17 00:00:00 2001 From: Manish Goregaokar Date: Thu, 3 Sep 2015 20:12:17 +0530 Subject: [PATCH] Update rust to 0efb9dab8c7c07fa28e9df0eccc5c07ea3c17fbb (HIR+lints, Thu Sep 3 18:59:56 2015 +0530) fixes #294 --- src/approx_const.rs | 2 +- src/attrs.rs | 6 +++--- src/bit_mask.rs | 4 ++-- src/collapsible_if.rs | 2 +- src/consts.rs | 2 +- src/eq_op.rs | 4 ++-- src/eta_reduction.rs | 2 +- src/identity_op.rs | 2 +- src/len_zero.rs | 2 +- src/lib.rs | 6 ++++++ src/lifetimes.rs | 7 ++++--- src/loops.rs | 5 +++-- src/matches.rs | 5 ++--- src/methods.rs | 2 +- src/misc.rs | 9 +++++---- src/mut_mut.rs | 2 +- src/needless_bool.rs | 2 +- src/precedence.rs | 2 +- src/ptr_arg.rs | 2 +- src/ranges.rs | 2 +- src/returns.rs | 8 ++++---- src/shadow.rs | 11 +++++------ src/strings.rs | 2 +- src/types.rs | 22 +++++++++++----------- src/unicode.rs | 2 +- src/utils.rs | 5 +++-- tests/consts.rs | 3 ++- 27 files changed, 66 insertions(+), 57 deletions(-) diff --git a/src/approx_const.rs b/src/approx_const.rs index d307c7dd056..a132bc90361 100644 --- a/src/approx_const.rs +++ b/src/approx_const.rs @@ -1,5 +1,5 @@ use rustc::lint::*; -use syntax::ast::*; +use rustc_front::hir::*; use syntax::codemap::Span; use std::f64::consts as f64; diff --git a/src/attrs.rs b/src/attrs.rs index ad021f28a4d..05362c706f0 100644 --- a/src/attrs.rs +++ b/src/attrs.rs @@ -1,7 +1,8 @@ //! checks for attributes use rustc::lint::*; -use syntax::ast::*; +use rustc_front::hir::*; +use reexport::*; use syntax::codemap::ExpnInfo; use utils::{in_macro, match_path, span_lint}; @@ -68,7 +69,6 @@ fn is_relevant_block(block: &Block) -> bool { StmtExpr(ref expr, _) | StmtSemi(ref expr, _) => { return is_relevant_expr(expr); } - _ => () } } block.expr.as_ref().map_or(false, |e| is_relevant_expr(e)) @@ -79,7 +79,7 @@ fn is_relevant_expr(expr: &Expr) -> bool { ExprBlock(ref block) => is_relevant_block(block), ExprRet(Some(ref e)) | ExprParen(ref e) => is_relevant_expr(e), - ExprRet(None) | ExprBreak(_) | ExprMac(_) => false, + ExprRet(None) | ExprBreak(_) => false, ExprCall(ref path_expr, _) => { if let ExprPath(_, ref path) = path_expr.node { !match_path(path, &["std", "rt", "begin_unwind"]) diff --git a/src/bit_mask.rs b/src/bit_mask.rs index 465b772da5c..b1b8a735455 100644 --- a/src/bit_mask.rs +++ b/src/bit_mask.rs @@ -1,8 +1,8 @@ use rustc::lint::*; use rustc::middle::const_eval::lookup_const_by_id; use rustc::middle::def::*; -use syntax::ast::*; -use syntax::ast_util::is_comparison_binop; +use rustc_front::hir::*; +use rustc_front::util::is_comparison_binop; use syntax::codemap::Span; use utils::span_lint; diff --git a/src/collapsible_if.rs b/src/collapsible_if.rs index e0b25b7283b..9301aafbace 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 syntax::ast::*; +use rustc_front::hir::*; use syntax::codemap::{Spanned, ExpnInfo}; use utils::{in_macro, span_help_and_lint, snippet, snippet_block}; diff --git a/src/consts.rs b/src/consts.rs index 29b96146db2..a8a446a703f 100644 --- a/src/consts.rs +++ b/src/consts.rs @@ -4,7 +4,7 @@ use rustc::lint::Context; use rustc::middle::const_eval::lookup_const_by_id; use rustc::middle::def::PathResolution; use rustc::middle::def::Def::*; -use syntax::ast::*; +use rustc_front::hir::*; use syntax::ptr::P; use std::cmp::PartialOrd; use std::cmp::Ordering::{self, Greater, Less, Equal}; diff --git a/src/eq_op.rs b/src/eq_op.rs index 3b4f47b5562..c5953201436 100644 --- a/src/eq_op.rs +++ b/src/eq_op.rs @@ -1,6 +1,6 @@ use rustc::lint::*; -use syntax::ast::*; -use syntax::ast_util as ast_util; +use rustc_front::hir::*; +use rustc_front::util as ast_util; use syntax::ptr::P; use consts::constant; diff --git a/src/eta_reduction.rs b/src/eta_reduction.rs index da2149f0539..f3359ad0c37 100644 --- a/src/eta_reduction.rs +++ b/src/eta_reduction.rs @@ -1,5 +1,5 @@ use rustc::lint::*; -use syntax::ast::*; +use rustc_front::hir::*; use rustc::middle::ty; use utils::{snippet, span_lint}; diff --git a/src/identity_op.rs b/src/identity_op.rs index bcdd527e407..0225c9b4d69 100644 --- a/src/identity_op.rs +++ b/src/identity_op.rs @@ -1,5 +1,5 @@ use rustc::lint::*; -use syntax::ast::*; +use rustc_front::hir::*; use syntax::codemap::Span; use consts::{constant, is_negative}; diff --git a/src/len_zero.rs b/src/len_zero.rs index 068568cb392..c30a98d8537 100644 --- a/src/len_zero.rs +++ b/src/len_zero.rs @@ -1,5 +1,5 @@ use rustc::lint::*; -use syntax::ast::*; +use rustc_front::hir::*; use syntax::ptr::P; use syntax::codemap::{Span, Spanned}; use rustc::middle::def_id::DefId; diff --git a/src/lib.rs b/src/lib.rs index e51732818ba..e0556972a7d 100755 --- a/src/lib.rs +++ b/src/lib.rs @@ -7,6 +7,8 @@ extern crate syntax; #[macro_use] extern crate rustc; +#[macro_use] +extern crate rustc_front; // Only for the compile time checking of paths extern crate core; @@ -42,6 +44,10 @@ pub mod ranges; pub mod matches; pub mod precedence; +mod reexport { + pub use syntax::ast::{Name, Ident, NodeId}; +} + #[plugin_registrar] pub fn plugin_registrar(reg: &mut Registry) { reg.register_lint_pass(box types::TypePass as LintPassObject); diff --git a/src/lifetimes.rs b/src/lifetimes.rs index de7a39fdb3b..dccad1ffbe7 100644 --- a/src/lifetimes.rs +++ b/src/lifetimes.rs @@ -1,7 +1,8 @@ -use syntax::ast::*; +use rustc_front::hir::*; +use reexport::*; use rustc::lint::*; use syntax::codemap::Span; -use syntax::visit::{Visitor, walk_ty, walk_ty_param_bound}; +use rustc_front::visit::{Visitor, walk_ty, walk_ty_param_bound}; use std::collections::HashSet; use utils::{in_external_macro, span_lint}; @@ -152,7 +153,7 @@ fn unique_lifetimes(lts: &[RefLt]) -> usize { lts.iter().collect::>().len() } -/// A visitor usable for syntax::visit::walk_ty(). +/// A visitor usable for rustc_front::visit::walk_ty(). struct RefVisitor(Vec); impl RefVisitor { diff --git a/src/loops.rs b/src/loops.rs index 3e1e669ea48..d40eca8c0f3 100644 --- a/src/loops.rs +++ b/src/loops.rs @@ -1,6 +1,7 @@ use rustc::lint::*; -use syntax::ast::*; -use syntax::visit::{Visitor, walk_expr}; +use rustc_front::hir::*; +use reexport::*; +use rustc_front::visit::{Visitor, walk_expr}; use rustc::middle::ty; use std::collections::HashSet; diff --git a/src/matches.rs b/src/matches.rs index fdc3ca5e907..5947469cd90 100644 --- a/src/matches.rs +++ b/src/matches.rs @@ -1,6 +1,5 @@ use rustc::lint::*; -use syntax::ast; -use syntax::ast::*; +use rustc_front::hir::*; use utils::{snippet, span_lint, span_help_and_lint, in_external_macro, expr_block}; @@ -20,7 +19,7 @@ impl LintPass for MatchPass { } fn check_expr(&mut self, cx: &Context, expr: &Expr) { - if let ExprMatch(ref ex, ref arms, ast::MatchSource::Normal) = expr.node { + if let ExprMatch(ref ex, ref arms, MatchSource::Normal) = expr.node { // check preconditions for SINGLE_MATCH // only two arms if arms.len() == 2 && diff --git a/src/methods.rs b/src/methods.rs index c6f0b1c2e59..25435274313 100644 --- a/src/methods.rs +++ b/src/methods.rs @@ -1,4 +1,4 @@ -use syntax::ast::*; +use rustc_front::hir::*; use rustc::lint::*; use rustc::middle::ty; use rustc::middle::subst::Subst; diff --git a/src/misc.rs b/src/misc.rs index 1376bf41b38..eb3a93941be 100644 --- a/src/misc.rs +++ b/src/misc.rs @@ -1,10 +1,11 @@ use rustc::lint::*; use syntax::ptr::P; -use syntax::ast::*; -use syntax::ast_util::{is_comparison_binop, binop_to_string}; +use rustc_front::hir::*; +use reexport::*; +use rustc_front::util::{is_comparison_binop, binop_to_string}; use syntax::codemap::{Span, Spanned}; -use syntax::visit::FnKind; -use rustc::ast_map::Node::*; +use rustc_front::visit::FnKind; +use rustc::front::map::Node::*; use rustc::middle::ty; use utils::{match_path, snippet, span_lint, walk_ptrs_ty}; diff --git a/src/mut_mut.rs b/src/mut_mut.rs index fbcb70e17d3..236d9b6a5a2 100644 --- a/src/mut_mut.rs +++ b/src/mut_mut.rs @@ -1,5 +1,5 @@ use rustc::lint::*; -use syntax::ast::*; +use rustc_front::hir::*; use syntax::codemap::ExpnInfo; use rustc::middle::ty::{TypeAndMut, TyRef}; diff --git a/src/needless_bool.rs b/src/needless_bool.rs index 0fe52c44189..0e8276bfafa 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 syntax::ast::*; +use rustc_front::hir::*; use utils::{span_lint, snippet}; diff --git a/src/precedence.rs b/src/precedence.rs index 1d89adf9df8..31c28146e1e 100644 --- a/src/precedence.rs +++ b/src/precedence.rs @@ -1,5 +1,5 @@ use rustc::lint::*; -use syntax::ast::*; +use rustc_front::hir::*; use syntax::codemap::Spanned; use utils::span_lint; diff --git a/src/ptr_arg.rs b/src/ptr_arg.rs index bcbd8dad68a..b0d9757e6c5 100644 --- a/src/ptr_arg.rs +++ b/src/ptr_arg.rs @@ -3,7 +3,7 @@ //! This lint is **warn** by default use rustc::lint::*; -use syntax::ast::*; +use rustc_front::hir::*; use rustc::middle::ty; use utils::{span_lint, match_type}; diff --git a/src/ranges.rs b/src/ranges.rs index 914b4daa6be..197afaf1163 100644 --- a/src/ranges.rs +++ b/src/ranges.rs @@ -1,5 +1,5 @@ use rustc::lint::{Context, LintArray, LintPass}; -use syntax::ast::*; +use rustc_front::hir::*; use syntax::codemap::Spanned; use utils::match_type; diff --git a/src/returns.rs b/src/returns.rs index 29749b29435..ea75cf562bf 100644 --- a/src/returns.rs +++ b/src/returns.rs @@ -1,7 +1,8 @@ use rustc::lint::*; -use syntax::ast::*; +use rustc_front::hir::*; +use reexport::*; use syntax::codemap::{Span, Spanned}; -use syntax::visit::FnKind; +use rustc_front::visit::FnKind; use utils::{span_lint, snippet, match_path, in_external_macro}; @@ -42,8 +43,7 @@ impl ReturnPass { // an if/if let expr, check both exprs // note, if without else is going to be a type checking error anyways // (except for unit type functions) so we don't match it - ExprIf(_, ref ifblock, Some(ref elsexpr)) | - ExprIfLet(_, _, ref ifblock, Some(ref elsexpr)) => { + ExprIf(_, ref ifblock, Some(ref elsexpr)) => { self.check_block_return(cx, ifblock); self.check_final_expr(cx, elsexpr); } diff --git a/src/shadow.rs b/src/shadow.rs index 7f555d4be85..aaa2c91a036 100644 --- a/src/shadow.rs +++ b/src/shadow.rs @@ -1,7 +1,8 @@ use std::ops::Deref; -use syntax::ast::*; +use rustc_front::hir::*; +use reexport::*; use syntax::codemap::Span; -use syntax::visit::FnKind; +use rustc_front::visit::FnKind; use rustc::lint::{Context, LintArray, LintPass}; use rustc::middle::def::Def::{DefVariant, DefStruct}; @@ -47,8 +48,7 @@ fn check_block(cx: &Context, block: &Block, bindings: &mut Vec) { match stmt.node { StmtDecl(ref decl, _) => check_decl(cx, decl, bindings), StmtExpr(ref e, _) | StmtSemi(ref e, _) => - check_expr(cx, e, bindings), - _ => () + check_expr(cx, e, bindings) } } if let Some(ref o) = block.expr { check_expr(cx, o, bindings); } @@ -320,8 +320,7 @@ fn contains_block_self(name: Name, block: &Block) -> bool { } }, StmtExpr(ref e, _) | StmtSemi(ref e, _) => - if contains_self(name, e) { return true }, - _ => () + if contains_self(name, e) { return true } } } if let Some(ref e) = block.expr { contains_self(name, e) } else { false } diff --git a/src/strings.rs b/src/strings.rs index fc8a2d238bb..3c9c1086a12 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 syntax::ast::*; +use rustc_front::hir::*; use syntax::codemap::Spanned; use eq_op::is_exp_equal; diff --git a/src/types.rs b/src/types.rs index 4a3c183462d..9fa63f1986c 100644 --- a/src/types.rs +++ b/src/types.rs @@ -1,9 +1,9 @@ use rustc::lint::*; -use syntax::ast; -use syntax::ast::*; -use syntax::ast_util::{is_comparison_binop, binop_to_string}; +use rustc_front::hir::*; +use reexport::*; +use rustc_front::util::{is_comparison_binop, binop_to_string}; use syntax::codemap::Span; -use syntax::visit::{FnKind, Visitor, walk_ty}; +use rustc_front::visit::{FnKind, Visitor, walk_ty}; use rustc::middle::ty; use utils::{match_type, snippet, span_lint, span_help_and_lint, in_external_macro}; @@ -24,7 +24,7 @@ impl LintPass for TypePass { lint_array!(BOX_VEC, LINKEDLIST) } - fn check_ty(&mut self, cx: &Context, ast_ty: &ast::Ty) { + fn check_ty(&mut self, cx: &Context, ast_ty: &Ty) { if let Some(ty) = cx.tcx.ast_ty_to_ty_cache.borrow().get(&ast_ty.id) { if let ty::TyBox(ref inner) = ty.sty { if match_type(cx, inner, &VEC_PATH) { @@ -126,7 +126,7 @@ fn int_ty_to_nbits(typ: &ty::TyS) -> usize { fn is_isize_or_usize(typ: &ty::TyS) -> bool { match typ.sty { - ty::TyInt(ast::TyIs) | ty::TyUint(ast::TyUs) => true, + ty::TyInt(TyIs) | ty::TyUint(TyUs) => true, _ => false } } @@ -211,7 +211,7 @@ impl LintPass for CastPass { match (cast_from.is_integral(), cast_to.is_integral()) { (true, false) => { let from_nbits = int_ty_to_nbits(cast_from); - let to_nbits = if let ty::TyFloat(ast::TyF32) = cast_to.sty {32} else {64}; + let to_nbits = if let ty::TyFloat(TyF32) = cast_to.sty {32} else {64}; if is_isize_or_usize(cast_from) || from_nbits >= to_nbits { span_precision_loss_lint(cx, expr, cast_from, to_nbits == 64); } @@ -235,8 +235,8 @@ impl LintPass for CastPass { check_truncation_and_wrapping(cx, expr, cast_from, cast_to); } (false, false) => { - if let (&ty::TyFloat(ast::TyF64), - &ty::TyFloat(ast::TyF32)) = (&cast_from.sty, &cast_to.sty) { + if let (&ty::TyFloat(TyF64), + &ty::TyFloat(TyF32)) = (&cast_from.sty, &cast_to.sty) { span_lint(cx, CAST_POSSIBLE_TRUNCATION, expr.span, "casting f64 to f32 may truncate the value"); @@ -320,7 +320,7 @@ fn check_fndecl(cx: &Context, decl: &FnDecl) { } } -fn check_type(cx: &Context, ty: &ast::Ty) { +fn check_type(cx: &Context, ty: &Ty) { if in_external_macro(cx, ty.span) { return; } let score = { let mut visitor = TypeComplexityVisitor { score: 0, nest: 1 }; @@ -343,7 +343,7 @@ struct TypeComplexityVisitor { } impl<'v> Visitor<'v> for TypeComplexityVisitor { - fn visit_ty(&mut self, ty: &'v ast::Ty) { + fn visit_ty(&mut self, ty: &'v Ty) { let (add_score, sub_nest) = match ty.node { // _, &x and *x have only small overhead; don't mess with nesting level TyInfer | diff --git a/src/unicode.rs b/src/unicode.rs index 8a64f612666..a993da1782a 100644 --- a/src/unicode.rs +++ b/src/unicode.rs @@ -1,5 +1,5 @@ use rustc::lint::*; -use syntax::ast::*; +use rustc_front::hir::*; use syntax::codemap::{BytePos, Span}; use utils::span_lint; diff --git a/src/utils.rs b/src/utils.rs index 2f9b86964c2..860ad85aab9 100644 --- a/src/utils.rs +++ b/src/utils.rs @@ -1,7 +1,8 @@ use rustc::lint::*; -use syntax::ast::*; +use rustc_front::hir::*; +use reexport::*; use syntax::codemap::{ExpnInfo, Span, ExpnFormat}; -use rustc::ast_map::Node::NodeExpr; +use rustc::front::map::Node::NodeExpr; use rustc::middle::def_id::DefId; use rustc::middle::ty; use std::borrow::Cow; diff --git a/tests/consts.rs b/tests/consts.rs index 55270cc6b51..7aa42545074 100755 --- a/tests/consts.rs +++ b/tests/consts.rs @@ -4,8 +4,9 @@ extern crate clippy; extern crate syntax; extern crate rustc; +extern crate rustc_front; -use syntax::ast::*; +use rustc_front::hir::*; use syntax::parse::token::InternedString; use syntax::ptr::P; use syntax::codemap::{Spanned, COMMAND_LINE_SP};