Update rust to 0efb9dab8c7c07fa28e9df0eccc5c07ea3c17fbb (HIR+lints, Thu Sep 3 18:59:56 2015 +0530)

fixes #294
This commit is contained in:
Manish Goregaokar 2015-09-03 20:12:17 +05:30
parent 5b7ec55fc2
commit eca185438b
27 changed files with 66 additions and 57 deletions

View File

@ -1,5 +1,5 @@
use rustc::lint::*;
use syntax::ast::*;
use rustc_front::hir::*;
use syntax::codemap::Span;
use std::f64::consts as f64;

View File

@ -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"])

View File

@ -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;

View File

@ -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};

View File

@ -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};

View File

@ -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;

View File

@ -1,5 +1,5 @@
use rustc::lint::*;
use syntax::ast::*;
use rustc_front::hir::*;
use rustc::middle::ty;
use utils::{snippet, span_lint};

View File

@ -1,5 +1,5 @@
use rustc::lint::*;
use syntax::ast::*;
use rustc_front::hir::*;
use syntax::codemap::Span;
use consts::{constant, is_negative};

View File

@ -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;

View File

@ -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);

View File

@ -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::<HashSet<_>>().len()
}
/// A visitor usable for syntax::visit::walk_ty().
/// A visitor usable for rustc_front::visit::walk_ty().
struct RefVisitor(Vec<RefLt>);
impl RefVisitor {

View File

@ -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;

View File

@ -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 &&

View File

@ -1,4 +1,4 @@
use syntax::ast::*;
use rustc_front::hir::*;
use rustc::lint::*;
use rustc::middle::ty;
use rustc::middle::subst::Subst;

View File

@ -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};

View File

@ -1,5 +1,5 @@
use rustc::lint::*;
use syntax::ast::*;
use rustc_front::hir::*;
use syntax::codemap::ExpnInfo;
use rustc::middle::ty::{TypeAndMut, TyRef};

View File

@ -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};

View File

@ -1,5 +1,5 @@
use rustc::lint::*;
use syntax::ast::*;
use rustc_front::hir::*;
use syntax::codemap::Spanned;
use utils::span_lint;

View File

@ -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};

View File

@ -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;

View File

@ -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);
}

View File

@ -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<Name>) {
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 }

View File

@ -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;

View File

@ -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 |

View File

@ -1,5 +1,5 @@
use rustc::lint::*;
use syntax::ast::*;
use rustc_front::hir::*;
use syntax::codemap::{BytePos, Span};
use utils::span_lint;

View File

@ -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;

View File

@ -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};