Rustup to 1.9.0-nightly (bf5da36f1 2016-04-06)

This commit is contained in:
mcarton 2016-04-07 17:46:48 +02:00
parent c1c935db46
commit c24ba91123
60 changed files with 136 additions and 130 deletions

View file

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

View file

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

View file

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

View file

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

View file

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

View file

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

View file

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

View file

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

View file

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

View file

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

View file

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

View file

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

View file

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

View file

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

View file

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

View file

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

View file

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

View file

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

View file

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

View file

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

View file

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

View file

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

View file

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

View file

@ -19,8 +19,6 @@ fn main() {
extern crate syntax;
#[macro_use]
extern crate rustc;
#[macro_use]
extern crate rustc_front;
extern crate toml;

View file

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

View file

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

View file

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

View file

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

View file

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

View file

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

View file

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

View file

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

View file

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

View file

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

View file

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

View file

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

View file

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

View file

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

View file

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

View file

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

View file

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

View file

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

View file

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

View file

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

View file

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

View file

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

View file

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

View file

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

View file

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

View file

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

View file

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

View file

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

View file

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

View file

@ -1,4 +1,4 @@
use rustc_front::hir::{BinOp_, Expr};
use rustc::hir::{BinOp_, Expr};
#[derive(PartialEq, Eq, Debug, Copy, Clone)]
pub enum Rel {

View file

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

View file

@ -1,15 +1,15 @@
use reexport::*;
use rustc::front::map::Node;
use rustc::lint::{LintContext, LateContext, Level, Lint};
use rustc::middle::def_id::DefId;
use rustc::traits;
use rustc::traits::ProjectionMode;
use rustc::middle::{cstore, def};
use rustc::hir::*;
use rustc::hir::def_id::DefId;
use rustc::hir::map::Node;
use rustc::infer;
use rustc::ty;
use rustc::ty::subst::Subst;
use rustc::lint::{LintContext, LateContext, Level, Lint};
use rustc::middle::cstore;
use rustc::session::Session;
use rustc_front::hir::*;
use rustc::traits::ProjectionMode;
use rustc::traits;
use rustc::ty::subst::Subst;
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<T: LintContext>(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)
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.name().as_str() == *p) && len == path.len()
})
.all(|(nm, p)| nm.as_interned_str() == *p)
}
/// Check if type is struct or enum type with given def path.

View file

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

View file

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

View file

@ -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<i32> {
vec![]
}
@ -86,22 +90,22 @@ fn useless() {
#[deny(crosspointer_transmute)]
fn crosspointer() {
let mut vec: Vec<i32> = vec![];
let vec_const_ptr: *const Vec<i32> = &vec as *const Vec<i32>;
let vec_mut_ptr: *mut Vec<i32> = &mut vec as *mut Vec<i32>;
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<i32> = core::intrinsics::transmute(vec_const_ptr);
//~^ ERROR transmute from a type (`*const std::vec::Vec<i32>`) to the type that it points to (`std::vec::Vec<i32>`)
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<i32> = core::intrinsics::transmute(vec_mut_ptr);
//~^ ERROR transmute from a type (`*mut std::vec::Vec<i32>`) to the type that it points to (`std::vec::Vec<i32>`)
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<i32> = core::intrinsics::transmute(my_vec());
//~^ ERROR transmute from a type (`std::vec::Vec<i32>`) to a pointer to that type (`*const std::vec::Vec<i32>`)
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<i32> = core::intrinsics::transmute(my_vec());
//~^ ERROR transmute from a type (`std::vec::Vec<i32>`) to a pointer to that type (`*mut std::vec::Vec<i32>`)
let _: *mut usize = core::intrinsics::transmute(my_int());
//~^ ERROR transmute from a type (`usize`) to a pointer to that type (`*mut usize`)
}
}

View file

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