Dogfood new trivially_copy_pass_by_ref lint

This commit is contained in:
Wim Looman 2018-05-31 20:15:48 +02:00 committed by Wim Looman
parent 700ece5648
commit 621fdcc3bc
15 changed files with 91 additions and 91 deletions

View file

@ -71,14 +71,14 @@ impl<'a, 'tcx> LateLintPass<'a, 'tcx> for Pass {
fn check_lit(cx: &LateContext, lit: &Lit, e: &Expr) {
match lit.node {
LitKind::Float(ref s, FloatTy::F32) => check_known_consts(cx, e, s, "f32"),
LitKind::Float(ref s, FloatTy::F64) => check_known_consts(cx, e, s, "f64"),
LitKind::FloatUnsuffixed(ref s) => check_known_consts(cx, e, s, "f{32, 64}"),
LitKind::Float(s, FloatTy::F32) => check_known_consts(cx, e, s, "f32"),
LitKind::Float(s, FloatTy::F64) => check_known_consts(cx, e, s, "f64"),
LitKind::FloatUnsuffixed(s) => check_known_consts(cx, e, s, "f{32, 64}"),
_ => (),
}
}
fn check_known_consts(cx: &LateContext, e: &Expr, s: &symbol::Symbol, module: &str) {
fn check_known_consts(cx: &LateContext, e: &Expr, s: symbol::Symbol, module: &str) {
let s = s.as_str();
if s.parse::<f64>().is_ok() {
for &(constant, name, min_digits) in KNOWN_CONSTS {

View file

@ -151,7 +151,7 @@ impl<'a, 'tcx> LateLintPass<'a, 'tcx> for AttrPass {
fn check_item(&mut self, cx: &LateContext<'a, 'tcx>, item: &'tcx Item) {
if is_relevant_item(cx.tcx, item) {
check_attrs(cx, item.span, &item.name, &item.attrs)
check_attrs(cx, item.span, item.name, &item.attrs)
}
match item.node {
ItemExternCrate(_) | ItemUse(_, _) => {
@ -195,13 +195,13 @@ impl<'a, 'tcx> LateLintPass<'a, 'tcx> for AttrPass {
fn check_impl_item(&mut self, cx: &LateContext<'a, 'tcx>, item: &'tcx ImplItem) {
if is_relevant_impl(cx.tcx, item) {
check_attrs(cx, item.span, &item.name, &item.attrs)
check_attrs(cx, item.span, item.name, &item.attrs)
}
}
fn check_trait_item(&mut self, cx: &LateContext<'a, 'tcx>, item: &'tcx TraitItem) {
if is_relevant_trait(cx.tcx, item) {
check_attrs(cx, item.span, &item.name, &item.attrs)
check_attrs(cx, item.span, item.name, &item.attrs)
}
}
}
@ -260,7 +260,7 @@ fn is_relevant_expr(tcx: TyCtxt, tables: &ty::TypeckTables, expr: &Expr) -> bool
}
}
fn check_attrs(cx: &LateContext, span: Span, name: &Name, attrs: &[Attribute]) {
fn check_attrs(cx: &LateContext, span: Span, name: Name, attrs: &[Attribute]) {
if in_macro(span) {
return;
}

View file

@ -112,9 +112,9 @@ impl<'a, 'tcx> LateLintPass<'a, 'tcx> for BitMask {
if let ExprBinary(ref cmp, ref left, ref right) = e.node {
if cmp.node.is_comparison() {
if let Some(cmp_opt) = fetch_int_literal(cx, right) {
check_compare(cx, left, cmp.node, cmp_opt, &e.span)
check_compare(cx, left, cmp.node, cmp_opt, e.span)
} else if let Some(cmp_val) = fetch_int_literal(cx, left) {
check_compare(cx, right, invert_cmp(cmp.node), cmp_val, &e.span)
check_compare(cx, right, invert_cmp(cmp.node), cmp_val, e.span)
}
}
}
@ -156,7 +156,7 @@ fn invert_cmp(cmp: BinOp_) -> BinOp_ {
}
fn check_compare(cx: &LateContext, bit_op: &Expr, cmp_op: BinOp_, cmp_value: u128, span: &Span) {
fn check_compare(cx: &LateContext, bit_op: &Expr, cmp_op: BinOp_, cmp_value: u128, span: Span) {
if let ExprBinary(ref op, ref left, ref right) = bit_op.node {
if op.node != BiBitAnd && op.node != BiBitOr {
return;
@ -167,7 +167,7 @@ fn check_compare(cx: &LateContext, bit_op: &Expr, cmp_op: BinOp_, cmp_value: u12
}
}
fn check_bit_mask(cx: &LateContext, bit_op: BinOp_, cmp_op: BinOp_, mask_value: u128, cmp_value: u128, span: &Span) {
fn check_bit_mask(cx: &LateContext, bit_op: BinOp_, cmp_op: BinOp_, mask_value: u128, cmp_value: u128, span: Span) {
match cmp_op {
BiEq | BiNe => match bit_op {
BiBitAnd => if mask_value & cmp_value != cmp_value {
@ -175,7 +175,7 @@ fn check_bit_mask(cx: &LateContext, bit_op: BinOp_, cmp_op: BinOp_, mask_value:
span_lint(
cx,
BAD_BIT_MASK,
*span,
span,
&format!(
"incompatible bit mask: `_ & {}` can never be equal to `{}`",
mask_value,
@ -184,13 +184,13 @@ fn check_bit_mask(cx: &LateContext, bit_op: BinOp_, cmp_op: BinOp_, mask_value:
);
}
} else if mask_value == 0 {
span_lint(cx, BAD_BIT_MASK, *span, "&-masking with zero");
span_lint(cx, BAD_BIT_MASK, span, "&-masking with zero");
},
BiBitOr => if mask_value | cmp_value != cmp_value {
span_lint(
cx,
BAD_BIT_MASK,
*span,
span,
&format!(
"incompatible bit mask: `_ | {}` can never be equal to `{}`",
mask_value,
@ -205,7 +205,7 @@ fn check_bit_mask(cx: &LateContext, bit_op: BinOp_, cmp_op: BinOp_, mask_value:
span_lint(
cx,
BAD_BIT_MASK,
*span,
span,
&format!(
"incompatible bit mask: `_ & {}` will always be lower than `{}`",
mask_value,
@ -213,13 +213,13 @@ fn check_bit_mask(cx: &LateContext, bit_op: BinOp_, cmp_op: BinOp_, mask_value:
),
);
} else if mask_value == 0 {
span_lint(cx, BAD_BIT_MASK, *span, "&-masking with zero");
span_lint(cx, BAD_BIT_MASK, span, "&-masking with zero");
},
BiBitOr => if mask_value >= cmp_value {
span_lint(
cx,
BAD_BIT_MASK,
*span,
span,
&format!(
"incompatible bit mask: `_ | {}` will never be lower than `{}`",
mask_value,
@ -227,9 +227,9 @@ fn check_bit_mask(cx: &LateContext, bit_op: BinOp_, cmp_op: BinOp_, mask_value:
),
);
} else {
check_ineffective_lt(cx, *span, mask_value, cmp_value, "|");
check_ineffective_lt(cx, span, mask_value, cmp_value, "|");
},
BiBitXor => check_ineffective_lt(cx, *span, mask_value, cmp_value, "^"),
BiBitXor => check_ineffective_lt(cx, span, mask_value, cmp_value, "^"),
_ => (),
},
BiLe | BiGt => match bit_op {
@ -237,7 +237,7 @@ fn check_bit_mask(cx: &LateContext, bit_op: BinOp_, cmp_op: BinOp_, mask_value:
span_lint(
cx,
BAD_BIT_MASK,
*span,
span,
&format!(
"incompatible bit mask: `_ & {}` will never be higher than `{}`",
mask_value,
@ -245,13 +245,13 @@ fn check_bit_mask(cx: &LateContext, bit_op: BinOp_, cmp_op: BinOp_, mask_value:
),
);
} else if mask_value == 0 {
span_lint(cx, BAD_BIT_MASK, *span, "&-masking with zero");
span_lint(cx, BAD_BIT_MASK, span, "&-masking with zero");
},
BiBitOr => if mask_value > cmp_value {
span_lint(
cx,
BAD_BIT_MASK,
*span,
span,
&format!(
"incompatible bit mask: `_ | {}` will always be higher than `{}`",
mask_value,
@ -259,9 +259,9 @@ fn check_bit_mask(cx: &LateContext, bit_op: BinOp_, cmp_op: BinOp_, mask_value:
),
);
} else {
check_ineffective_gt(cx, *span, mask_value, cmp_value, "|");
check_ineffective_gt(cx, span, mask_value, cmp_value, "|");
},
BiBitXor => check_ineffective_gt(cx, *span, mask_value, cmp_value, "^"),
BiBitXor => check_ineffective_gt(cx, span, mask_value, cmp_value, "^"),
_ => (),
},
_ => (),

View file

@ -52,7 +52,7 @@ impl LintPass for EqOp {
impl<'a, 'tcx> LateLintPass<'a, 'tcx> for EqOp {
fn check_expr(&mut self, cx: &LateContext<'a, 'tcx>, e: &'tcx Expr) {
if let ExprBinary(ref op, ref left, ref right) = e.node {
if let ExprBinary(op, ref left, ref right) = e.node {
if in_macro(e.span) {
return;
}
@ -157,7 +157,7 @@ impl<'a, 'tcx> LateLintPass<'a, 'tcx> for EqOp {
}
fn is_valid_operator(op: &BinOp) -> bool {
fn is_valid_operator(op: BinOp) -> bool {
match op.node {
BiSub | BiDiv | BiEq | BiLt | BiLe | BiGt | BiGe | BiNe | BiAnd | BiOr | BiBitXor | BiBitAnd | BiBitOr => true,
_ => false,

View file

@ -46,9 +46,9 @@ impl<'a, 'tcx> LateLintPass<'a, 'tcx> for ExcessivePrecision {
fn check_expr(&mut self, cx: &LateContext<'a, 'tcx>, expr: &'tcx hir::Expr) {
if_chain! {
let ty = cx.tables.expr_ty(expr);
if let TypeVariants::TyFloat(ref fty) = ty.sty;
if let TypeVariants::TyFloat(fty) = ty.sty;
if let hir::ExprLit(ref lit) = expr.node;
if let LitKind::Float(ref sym, _) | LitKind::FloatUnsuffixed(ref sym) = lit.node;
if let LitKind::Float(sym, _) | LitKind::FloatUnsuffixed(sym) = lit.node;
if let Some(sugg) = self.check(sym, fty);
then {
span_lint_and_sugg(
@ -66,7 +66,7 @@ impl<'a, 'tcx> LateLintPass<'a, 'tcx> for ExcessivePrecision {
impl ExcessivePrecision {
// None if nothing to lint, Some(suggestion) if lint neccessary
fn check(&self, sym: &Symbol, fty: &FloatTy) -> Option<String> {
fn check(&self, sym: Symbol, fty: FloatTy) -> Option<String> {
let max = max_digits(fty);
let sym_str = sym.as_str();
if dot_zero_exclusion(&sym_str) {
@ -79,7 +79,7 @@ impl ExcessivePrecision {
let digits = count_digits(&sym_str);
if digits > max as usize {
let formatter = FloatFormat::new(&sym_str);
let sr = match *fty {
let sr = match fty {
FloatTy::F32 => sym_str.parse::<f32>().map(|f| formatter.format(f)),
FloatTy::F64 => sym_str.parse::<f64>().map(|f| formatter.format(f)),
};
@ -115,7 +115,7 @@ fn dot_zero_exclusion(s: &str) -> bool {
}
}
fn max_digits(fty: &FloatTy) -> u32 {
fn max_digits(fty: FloatTy) -> u32 {
match fty {
FloatTy::F32 => f32::DIGITS,
FloatTy::F64 => f64::DIGITS,

View file

@ -126,7 +126,7 @@ impl<'a, 'tcx> LateLintPass<'a, 'tcx> for Functions {
}
impl<'a, 'tcx> Functions {
fn check_arg_number(&self, cx: &LateContext, decl: &hir::FnDecl, span: Span) {
fn check_arg_number(self, cx: &LateContext, decl: &hir::FnDecl, span: Span) {
let args = decl.inputs.len() as u64;
if args > self.threshold {
span_lint(
@ -139,7 +139,7 @@ impl<'a, 'tcx> Functions {
}
fn check_raw_ptr(
&self,
self,
cx: &LateContext<'a, 'tcx>,
unsafety: hir::Unsafety,
decl: &'tcx hir::FnDecl,

View file

@ -38,12 +38,12 @@ impl LintPass for Pass {
impl<'a, 'tcx> LateLintPass<'a, 'tcx> for Pass {
fn check_trait_item(&mut self, cx: &LateContext<'a, 'tcx>, item: &'tcx TraitItem) {
if let TraitItemKind::Method(_, TraitMethod::Required(_)) = item.node {
check_attrs(cx, &item.name, &item.attrs);
check_attrs(cx, item.name, &item.attrs);
}
}
}
fn check_attrs(cx: &LateContext, name: &Name, attrs: &[Attribute]) {
fn check_attrs(cx: &LateContext, name: Name, attrs: &[Attribute]) {
for attr in attrs {
if attr.name() != "inline" {
continue;

View file

@ -227,12 +227,12 @@ enum WarningType {
}
impl WarningType {
pub fn display(&self, grouping_hint: &str, cx: &EarlyContext, span: &syntax_pos::Span) {
match *self {
pub fn display(&self, grouping_hint: &str, cx: &EarlyContext, span: syntax_pos::Span) {
match self {
WarningType::UnreadableLiteral => span_lint_and_sugg(
cx,
UNREADABLE_LITERAL,
*span,
span,
"long literal lacking separators",
"consider",
grouping_hint.to_owned(),
@ -240,7 +240,7 @@ impl WarningType {
WarningType::LargeDigitGroups => span_lint_and_sugg(
cx,
LARGE_DIGIT_GROUPS,
*span,
span,
"digit groups should be smaller",
"consider",
grouping_hint.to_owned(),
@ -248,7 +248,7 @@ impl WarningType {
WarningType::InconsistentDigitGrouping => span_lint_and_sugg(
cx,
INCONSISTENT_DIGIT_GROUPING,
*span,
span,
"digits grouped inconsistently by underscores",
"consider",
grouping_hint.to_owned(),
@ -256,7 +256,7 @@ impl WarningType {
WarningType::DecimalRepresentation => span_lint_and_sugg(
cx,
DECIMAL_LITERAL_REPRESENTATION,
*span,
span,
"integer literal has a better hexadecimal representation",
"consider",
grouping_hint.to_owned(),
@ -291,7 +291,7 @@ impl EarlyLintPass for LiteralDigitGrouping {
}
impl LiteralDigitGrouping {
fn check_lit(&self, cx: &EarlyContext, lit: &Lit) {
fn check_lit(self, cx: &EarlyContext, lit: &Lit) {
match lit.node {
LitKind::Int(..) => {
// Lint integral literals.
@ -302,7 +302,7 @@ impl LiteralDigitGrouping {
then {
let digit_info = DigitInfo::new(&src, false);
let _ = Self::do_lint(digit_info.digits).map_err(|warning_type| {
warning_type.display(&digit_info.grouping_hint(), cx, &lit.span)
warning_type.display(&digit_info.grouping_hint(), cx, lit.span)
});
}
}
@ -337,15 +337,15 @@ impl LiteralDigitGrouping {
if !consistent {
WarningType::InconsistentDigitGrouping.display(&digit_info.grouping_hint(),
cx,
&lit.span);
lit.span);
}
})
.map_err(|warning_type| warning_type.display(&digit_info.grouping_hint(),
cx,
&lit.span));
lit.span));
}
})
.map_err(|warning_type| warning_type.display(&digit_info.grouping_hint(), cx, &lit.span));
.map_err(|warning_type| warning_type.display(&digit_info.grouping_hint(), cx, lit.span));
}
}
},
@ -436,7 +436,7 @@ impl LiteralRepresentation {
threshold,
}
}
fn check_lit(&self, cx: &EarlyContext, lit: &Lit) {
fn check_lit(self, cx: &EarlyContext, lit: &Lit) {
// Lint integral literals.
if_chain! {
if let LitKind::Int(..) = lit.node;
@ -457,7 +457,7 @@ impl LiteralRepresentation {
let hex = format!("{:#X}", val);
let digit_info = DigitInfo::new(&hex[..], false);
let _ = Self::do_lint(digit_info.digits).map_err(|warning_type| {
warning_type.display(&digit_info.grouping_hint(), cx, &lit.span)
warning_type.display(&digit_info.grouping_hint(), cx, lit.span)
});
}
}

View file

@ -412,7 +412,7 @@ impl<'a, 'tcx> LateLintPass<'a, 'tcx> for Pass {
// check for never_loop
match expr.node {
ExprWhile(_, ref block, _) | ExprLoop(ref block, _, _) => {
match never_loop_block(block, &expr.id) {
match never_loop_block(block, expr.id) {
NeverLoopResult::AlwaysBreak =>
span_lint(cx, NEVER_LOOP, expr.span, "this loop never actually loops"),
NeverLoopResult::MayContinueMainLoop | NeverLoopResult::Otherwise => (),
@ -575,7 +575,7 @@ fn combine_branches(b1: NeverLoopResult, b2: NeverLoopResult) -> NeverLoopResult
}
}
fn never_loop_block(block: &Block, main_loop_id: &NodeId) -> NeverLoopResult {
fn never_loop_block(block: &Block, main_loop_id: NodeId) -> NeverLoopResult {
let stmts = block.stmts.iter().map(stmt_to_expr);
let expr = once(block.expr.as_ref().map(|p| &**p));
let mut iter = stmts.chain(expr).filter_map(|e| e);
@ -596,7 +596,7 @@ fn decl_to_expr(decl: &Decl) -> Option<&Expr> {
}
}
fn never_loop_expr(expr: &Expr, main_loop_id: &NodeId) -> NeverLoopResult {
fn never_loop_expr(expr: &Expr, main_loop_id: NodeId) -> NeverLoopResult {
match expr.node {
ExprBox(ref e) |
ExprUnary(_, ref e) |
@ -643,7 +643,7 @@ fn never_loop_expr(expr: &Expr, main_loop_id: &NodeId) -> NeverLoopResult {
ExprAgain(d) => {
let id = d.target_id
.expect("target id can only be missing in the presence of compilation errors");
if id == *main_loop_id {
if id == main_loop_id {
NeverLoopResult::MayContinueMainLoop
} else {
NeverLoopResult::AlwaysBreak
@ -668,17 +668,17 @@ fn never_loop_expr(expr: &Expr, main_loop_id: &NodeId) -> NeverLoopResult {
}
}
fn never_loop_expr_seq<'a, T: Iterator<Item=&'a Expr>>(es: &mut T, main_loop_id: &NodeId) -> NeverLoopResult {
fn never_loop_expr_seq<'a, T: Iterator<Item=&'a Expr>>(es: &mut T, main_loop_id: NodeId) -> NeverLoopResult {
es.map(|e| never_loop_expr(e, main_loop_id))
.fold(NeverLoopResult::Otherwise, combine_seq)
}
fn never_loop_expr_all<'a, T: Iterator<Item=&'a Expr>>(es: &mut T, main_loop_id: &NodeId) -> NeverLoopResult {
fn never_loop_expr_all<'a, T: Iterator<Item=&'a Expr>>(es: &mut T, main_loop_id: NodeId) -> NeverLoopResult {
es.map(|e| never_loop_expr(e, main_loop_id))
.fold(NeverLoopResult::Otherwise, combine_both)
}
fn never_loop_expr_branch<'a, T: Iterator<Item=&'a Expr>>(e: &mut T, main_loop_id: &NodeId) -> NeverLoopResult {
fn never_loop_expr_branch<'a, T: Iterator<Item=&'a Expr>>(e: &mut T, main_loop_id: NodeId) -> NeverLoopResult {
e.map(|e| never_loop_expr(e, main_loop_id))
.fold(NeverLoopResult::AlwaysBreak, combine_branches)
}
@ -1032,7 +1032,7 @@ fn check_for_loop_range<'a, 'tcx>(
};
let take = if let Some(end) = *end {
if is_len_call(end, &indexed) {
if is_len_call(end, indexed) {
"".to_owned()
} else {
match limits {
@ -1096,14 +1096,14 @@ fn check_for_loop_range<'a, 'tcx>(
}
}
fn is_len_call(expr: &Expr, var: &Name) -> bool {
fn is_len_call(expr: &Expr, var: Name) -> bool {
if_chain! {
if let ExprMethodCall(ref method, _, ref len_args) = expr.node;
if len_args.len() == 1;
if method.name == "len";
if let ExprPath(QPath::Resolved(_, ref path)) = len_args[0].node;
if path.segments.len() == 1;
if path.segments[0].name == *var;
if path.segments[0].name == var;
then {
return true;
}

View file

@ -2079,8 +2079,8 @@ impl SelfKind {
}
}
fn description(&self) -> &'static str {
match *self {
fn description(self) -> &'static str {
match self {
SelfKind::Value => "self by value",
SelfKind::Ref => "self by reference",
SelfKind::RefMut => "self by mutable reference",
@ -2164,13 +2164,13 @@ enum OutType {
}
impl OutType {
fn matches(&self, ty: &hir::FunctionRetTy) -> bool {
fn matches(self, ty: &hir::FunctionRetTy) -> bool {
match (self, ty) {
(&OutType::Unit, &hir::DefaultReturn(_)) => true,
(&OutType::Unit, &hir::Return(ref ty)) if ty.node == hir::TyTup(vec![].into()) => true,
(&OutType::Bool, &hir::Return(ref ty)) if is_bool(ty) => true,
(&OutType::Any, &hir::Return(ref ty)) if ty.node != hir::TyTup(vec![].into()) => true,
(&OutType::Ref, &hir::Return(ref ty)) => matches!(ty.node, hir::TyRptr(_, _)),
(OutType::Unit, &hir::DefaultReturn(_)) => true,
(OutType::Unit, &hir::Return(ref ty)) if ty.node == hir::TyTup(vec![].into()) => true,
(OutType::Bool, &hir::Return(ref ty)) if is_bool(ty) => true,
(OutType::Any, &hir::Return(ref ty)) if ty.node != hir::TyTup(vec![].into()) => true,
(OutType::Ref, &hir::Return(ref ty)) => matches!(ty.node, hir::TyRptr(_, _)),
_ => false,
}
}

View file

@ -349,7 +349,7 @@ impl EarlyLintPass for MiscEarly {
}
impl MiscEarly {
fn check_lit(&self, cx: &EarlyContext, lit: &Lit) {
fn check_lit(self, cx: &EarlyContext, lit: &Lit) {
if_chain! {
if let LitKind::Int(value, ..) = lit.node;
if let Some(src) = snippet_opt(cx, lit.span);

View file

@ -92,7 +92,7 @@ impl<'a, 'tcx> LateLintPass<'a, 'tcx> for SuspiciousImpl {
if let Some(impl_trait) = check_binop(
cx,
expr,
&binop.node,
binop.node,
&["Add", "Sub", "Mul", "Div"],
&[BiAdd, BiSub, BiMul, BiDiv],
) {
@ -110,7 +110,7 @@ impl<'a, 'tcx> LateLintPass<'a, 'tcx> for SuspiciousImpl {
if let Some(impl_trait) = check_binop(
cx,
expr,
&binop.node,
binop.node,
&[
"AddAssign",
"SubAssign",
@ -144,7 +144,7 @@ impl<'a, 'tcx> LateLintPass<'a, 'tcx> for SuspiciousImpl {
fn check_binop<'a>(
cx: &LateContext,
expr: &hir::Expr,
binop: &hir::BinOp_,
binop: hir::BinOp_,
traits: &[&'a str],
expected_ops: &[hir::BinOp_],
) -> Option<&'a str> {
@ -169,7 +169,7 @@ fn check_binop<'a>(
if let hir::map::Node::NodeItem(item) = cx.tcx.hir.get(parent_impl);
if let hir::Item_::ItemImpl(_, _, _, _, Some(ref trait_ref), _, _) = item.node;
if let Some(idx) = trait_ids.iter().position(|&tid| tid == trait_ref.path.def.def_id());
if *binop != expected_ops[idx];
if binop != expected_ops[idx];
then{
return Some(traits[idx])
}

View file

@ -1606,12 +1606,12 @@ fn node_as_const_fullint<'a, 'tcx>(cx: &LateContext<'a, 'tcx>, expr: &'tcx Expr)
}
}
fn err_upcast_comparison(cx: &LateContext, span: &Span, expr: &Expr, always: bool) {
fn err_upcast_comparison(cx: &LateContext, span: Span, expr: &Expr, always: bool) {
if let ExprCast(ref cast_val, _) = expr.node {
span_lint(
cx,
INVALID_UPCAST_COMPARISONS,
*span,
span,
&format!(
"because of the numeric bounds on `{}` prior to casting, this expression is always {}",
snippet(cx, cast_val.span, "the expression"),
@ -1623,7 +1623,7 @@ fn err_upcast_comparison(cx: &LateContext, span: &Span, expr: &Expr, always: boo
fn upcast_comparison_bounds_err<'a, 'tcx>(
cx: &LateContext<'a, 'tcx>,
span: &Span,
span: Span,
rel: comparisons::Rel,
lhs_bounds: Option<(FullInt, FullInt)>,
lhs: &'tcx Expr,
@ -1684,8 +1684,8 @@ impl<'a, 'tcx> LateLintPass<'a, 'tcx> for InvalidUpcastComparisons {
let lhs_bounds = numeric_cast_precast_bounds(cx, normalized_lhs);
let rhs_bounds = numeric_cast_precast_bounds(cx, normalized_rhs);
upcast_comparison_bounds_err(cx, &expr.span, rel, lhs_bounds, normalized_lhs, normalized_rhs, false);
upcast_comparison_bounds_err(cx, &expr.span, rel, rhs_bounds, normalized_rhs, normalized_lhs, true);
upcast_comparison_bounds_err(cx, expr.span, rel, lhs_bounds, normalized_lhs, normalized_rhs, false);
upcast_comparison_bounds_err(cx, expr.span, rel, rhs_bounds, normalized_rhs, normalized_lhs, true);
}
}
}

View file

@ -36,12 +36,12 @@ impl LintPass for UnsafeNameRemoval {
impl EarlyLintPass for UnsafeNameRemoval {
fn check_item(&mut self, cx: &EarlyContext, item: &Item) {
if let ItemKind::Use(ref use_tree) = item.node {
check_use_tree(use_tree, cx, &item.span);
check_use_tree(use_tree, cx, item.span);
}
}
}
fn check_use_tree(use_tree: &UseTree, cx: &EarlyContext, span: &Span) {
fn check_use_tree(use_tree: &UseTree, cx: &EarlyContext, span: Span) {
match use_tree.kind {
UseTreeKind::Simple(Some(new_name)) => {
let old_name = use_tree
@ -62,14 +62,14 @@ fn check_use_tree(use_tree: &UseTree, cx: &EarlyContext, span: &Span) {
}
}
fn unsafe_to_safe_check(old_name: Ident, new_name: Ident, cx: &EarlyContext, span: &Span) {
fn unsafe_to_safe_check(old_name: Ident, new_name: Ident, cx: &EarlyContext, span: Span) {
let old_str = old_name.name.as_str();
let new_str = new_name.name.as_str();
if contains_unsafe(&old_str) && !contains_unsafe(&new_str) {
span_lint(
cx,
UNSAFE_REMOVED_FROM_NAME,
*span,
span,
&format!("removed \"unsafe\" from the name of `{}` in use as `{}`", old_str, new_str),
);
}

View file

@ -349,7 +349,7 @@ impl<'a, 'tcx: 'a> SpanlessHash<'a, 'tcx> {
let c: fn(_) -> _ = ExprAgain;
c.hash(&mut self.s);
if let Some(i) = i.label {
self.hash_name(&i.name);
self.hash_name(i.name);
}
},
ExprYield(ref e) => {
@ -386,7 +386,7 @@ impl<'a, 'tcx: 'a> SpanlessHash<'a, 'tcx> {
let c: fn(_, _) -> _ = ExprBreak;
c.hash(&mut self.s);
if let Some(i) = i.label {
self.hash_name(&i.name);
self.hash_name(i.name);
}
if let Some(ref j) = *j {
self.hash_expr(&*j);
@ -419,7 +419,7 @@ impl<'a, 'tcx: 'a> SpanlessHash<'a, 'tcx> {
let c: fn(_, _) -> _ = ExprField;
c.hash(&mut self.s);
self.hash_expr(e);
self.hash_name(&f.name);
self.hash_name(f.name);
},
ExprIndex(ref a, ref i) => {
let c: fn(_, _) -> _ = ExprIndex;
@ -450,7 +450,7 @@ impl<'a, 'tcx: 'a> SpanlessHash<'a, 'tcx> {
c.hash(&mut self.s);
self.hash_block(b);
if let Some(i) = *i {
self.hash_name(&i.name);
self.hash_name(i.name);
}
},
ExprMatch(ref e, ref arms, ref s) => {
@ -471,7 +471,7 @@ impl<'a, 'tcx: 'a> SpanlessHash<'a, 'tcx> {
ExprMethodCall(ref path, ref _tys, ref args) => {
let c: fn(_, _, _) -> _ = ExprMethodCall;
c.hash(&mut self.s);
self.hash_name(&path.name);
self.hash_name(path.name);
self.hash_exprs(args);
},
ExprRepeat(ref e, ref l_id) => {
@ -502,7 +502,7 @@ impl<'a, 'tcx: 'a> SpanlessHash<'a, 'tcx> {
self.hash_qpath(path);
for f in fields {
self.hash_name(&f.ident.name);
self.hash_name(f.ident.name);
self.hash_expr(&f.expr);
}
@ -541,7 +541,7 @@ impl<'a, 'tcx: 'a> SpanlessHash<'a, 'tcx> {
self.hash_expr(cond);
self.hash_block(b);
if let Some(l) = l {
self.hash_name(&l.name);
self.hash_name(l.name);
}
},
}
@ -553,7 +553,7 @@ impl<'a, 'tcx: 'a> SpanlessHash<'a, 'tcx> {
}
}
pub fn hash_name(&mut self, n: &Name) {
pub fn hash_name(&mut self, n: Name) {
n.as_str().hash(&mut self.s);
}
@ -563,7 +563,7 @@ impl<'a, 'tcx: 'a> SpanlessHash<'a, 'tcx> {
self.hash_path(path);
},
QPath::TypeRelative(_, ref path) => {
self.hash_name(&path.name);
self.hash_name(path.name);
},
}
// self.cx.tables.qpath_def(p, id).hash(&mut self.s);
@ -572,7 +572,7 @@ impl<'a, 'tcx: 'a> SpanlessHash<'a, 'tcx> {
pub fn hash_path(&mut self, p: &Path) {
p.is_global().hash(&mut self.s);
for p in &p.segments {
self.hash_name(&p.name);
self.hash_name(p.name);
}
}