Revert "Fixed for loop problem, corrected all occurences that got linted"
This reverts commit 6626295fbc
.
This commit is contained in:
parent
6626295fbc
commit
cd6748749a
@ -61,7 +61,7 @@ impl<'tcx> LateLintPass<'tcx> for AssertionsOnConstants {
|
||||
&format!("`assert!(false, {})` should probably be replaced", panic_message),
|
||||
None,
|
||||
&format!("use `panic!({})` or `unreachable!({})`", panic_message, panic_message),
|
||||
);
|
||||
)
|
||||
};
|
||||
|
||||
if let Some(debug_assert_span) = is_expn_of(e.span, "debug_assert") {
|
||||
|
@ -277,7 +277,7 @@ impl<'tcx> LateLintPass<'tcx> for Attributes {
|
||||
|
||||
fn check_item(&mut self, cx: &LateContext<'tcx>, item: &'tcx Item<'_>) {
|
||||
if is_relevant_item(cx, item) {
|
||||
check_attrs(cx, item.span, item.ident.name, &item.attrs);
|
||||
check_attrs(cx, item.span, item.ident.name, &item.attrs)
|
||||
}
|
||||
match item.kind {
|
||||
ItemKind::ExternCrate(..) | ItemKind::Use(..) => {
|
||||
@ -353,13 +353,13 @@ impl<'tcx> LateLintPass<'tcx> for Attributes {
|
||||
|
||||
fn check_impl_item(&mut self, cx: &LateContext<'tcx>, item: &'tcx ImplItem<'_>) {
|
||||
if is_relevant_impl(cx, item) {
|
||||
check_attrs(cx, item.span, item.ident.name, &item.attrs);
|
||||
check_attrs(cx, item.span, item.ident.name, &item.attrs)
|
||||
}
|
||||
}
|
||||
|
||||
fn check_trait_item(&mut self, cx: &LateContext<'tcx>, item: &'tcx TraitItem<'_>) {
|
||||
if is_relevant_trait(cx, item) {
|
||||
check_attrs(cx, item.span, item.ident.name, &item.attrs);
|
||||
check_attrs(cx, item.span, item.ident.name, &item.attrs)
|
||||
}
|
||||
}
|
||||
}
|
||||
|
@ -115,9 +115,9 @@ impl<'tcx> LateLintPass<'tcx> for BitMask {
|
||||
if let ExprKind::Binary(cmp, left, right) = &e.kind {
|
||||
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)
|
||||
}
|
||||
}
|
||||
}
|
||||
@ -171,7 +171,7 @@ fn check_compare(cx: &LateContext<'_>, bit_op: &Expr<'_>, cmp_op: BinOpKind, cmp
|
||||
}
|
||||
fetch_int_literal(cx, right)
|
||||
.or_else(|| fetch_int_literal(cx, left))
|
||||
.map_or((), |mask| check_bit_mask(cx, op.node, cmp_op, mask, cmp_value, span));
|
||||
.map_or((), |mask| check_bit_mask(cx, op.node, cmp_op, mask, cmp_value, span))
|
||||
}
|
||||
}
|
||||
|
||||
|
@ -66,7 +66,7 @@ impl<'tcx> LateLintPass<'tcx> for NonminimalBool {
|
||||
_: Span,
|
||||
_: HirId,
|
||||
) {
|
||||
NonminimalBoolVisitor { cx }.visit_body(body);
|
||||
NonminimalBoolVisitor { cx }.visit_body(body)
|
||||
}
|
||||
}
|
||||
|
||||
@ -184,7 +184,7 @@ impl<'a, 'tcx, 'v> SuggestContext<'a, 'tcx, 'v> {
|
||||
Term(n) => {
|
||||
let terminal = self.terminals[n as usize];
|
||||
if let Some(str) = simplify_not(self.cx, terminal) {
|
||||
self.output.push_str(&str);
|
||||
self.output.push_str(&str)
|
||||
} else {
|
||||
self.output.push('!');
|
||||
let snip = snippet_opt(self.cx, terminal.span)?;
|
||||
@ -452,7 +452,7 @@ impl<'a, 'tcx> Visitor<'tcx> for NonminimalBoolVisitor<'a, 'tcx> {
|
||||
}
|
||||
match &e.kind {
|
||||
ExprKind::Binary(binop, _, _) if binop.node == BinOpKind::Or || binop.node == BinOpKind::And => {
|
||||
self.bool_expr(e);
|
||||
self.bool_expr(e)
|
||||
},
|
||||
ExprKind::Unary(UnOp::UnNot, inner) => {
|
||||
if self.cx.typeck_results().node_types()[inner.hir_id].is_bool() {
|
||||
|
@ -92,7 +92,7 @@ declare_lint_pass!(CollapsibleIf => [COLLAPSIBLE_IF, COLLAPSIBLE_ELSE_IF]);
|
||||
impl EarlyLintPass for CollapsibleIf {
|
||||
fn check_expr(&mut self, cx: &EarlyContext<'_>, expr: &ast::Expr) {
|
||||
if !expr.span.from_expansion() {
|
||||
check_if(cx, expr);
|
||||
check_if(cx, expr)
|
||||
}
|
||||
}
|
||||
}
|
||||
|
@ -118,7 +118,7 @@ impl<'tcx> LateLintPass<'tcx> for ComparisonChain {
|
||||
"`if` chain can be rewritten with `match`",
|
||||
None,
|
||||
"Consider rewriting the `if` chain to use `cmp` and `match`.",
|
||||
);
|
||||
)
|
||||
}
|
||||
}
|
||||
|
||||
|
@ -156,7 +156,7 @@ impl<'tcx> LateLintPass<'tcx> for EqOp {
|
||||
vec![(left.span, lsnip), (right.span, rsnip)],
|
||||
);
|
||||
},
|
||||
);
|
||||
)
|
||||
} else if lcpy
|
||||
&& !rcpy
|
||||
&& implements_trait(cx, lty, trait_id, &[cx.typeck_results().expr_ty(right).into()])
|
||||
@ -175,7 +175,7 @@ impl<'tcx> LateLintPass<'tcx> for EqOp {
|
||||
Applicability::MaybeIncorrect, // FIXME #2597
|
||||
);
|
||||
},
|
||||
);
|
||||
)
|
||||
} else if !lcpy
|
||||
&& rcpy
|
||||
&& implements_trait(cx, cx.typeck_results().expr_ty(left), trait_id, &[rty.into()])
|
||||
@ -194,7 +194,7 @@ impl<'tcx> LateLintPass<'tcx> for EqOp {
|
||||
Applicability::MaybeIncorrect, // FIXME #2597
|
||||
);
|
||||
},
|
||||
);
|
||||
)
|
||||
}
|
||||
},
|
||||
// &foo == bar
|
||||
@ -218,7 +218,7 @@ impl<'tcx> LateLintPass<'tcx> for EqOp {
|
||||
Applicability::MaybeIncorrect, // FIXME #2597
|
||||
);
|
||||
},
|
||||
);
|
||||
)
|
||||
}
|
||||
},
|
||||
// foo == &bar
|
||||
@ -236,7 +236,7 @@ impl<'tcx> LateLintPass<'tcx> for EqOp {
|
||||
rsnip,
|
||||
Applicability::MaybeIncorrect, // FIXME #2597
|
||||
);
|
||||
});
|
||||
})
|
||||
}
|
||||
},
|
||||
_ => {},
|
||||
|
@ -74,7 +74,7 @@ impl<'tcx> LateLintPass<'tcx> for EtaReduction {
|
||||
match expr.kind {
|
||||
ExprKind::Call(_, args) | ExprKind::MethodCall(_, _, args, _) => {
|
||||
for arg in args {
|
||||
check_closure(cx, arg);
|
||||
check_closure(cx, arg)
|
||||
}
|
||||
},
|
||||
_ => (),
|
||||
|
@ -116,7 +116,7 @@ impl<'a, 'tcx> DivergenceVisitor<'a, 'tcx> {
|
||||
self.visit_expr(e);
|
||||
for arm in arms {
|
||||
if let Some(Guard::If(if_expr)) = arm.guard {
|
||||
self.visit_expr(if_expr);
|
||||
self.visit_expr(if_expr)
|
||||
}
|
||||
// make sure top level arm expressions aren't linted
|
||||
self.maybe_walk_expr(&*arm.body);
|
||||
|
@ -270,7 +270,7 @@ impl<'tcx> LateLintPass<'tcx> for Functions {
|
||||
_,
|
||||
)
|
||||
| intravisit::FnKind::ItemFn(_, _, hir::FnHeader { abi: Abi::Rust, .. }, _, _) => {
|
||||
self.check_arg_number(cx, decl, span.with_hi(decl.output.span().hi()));
|
||||
self.check_arg_number(cx, decl, span.with_hi(decl.output.span().hi()))
|
||||
},
|
||||
_ => {},
|
||||
}
|
||||
@ -434,7 +434,7 @@ impl<'tcx> Functions {
|
||||
TOO_MANY_LINES,
|
||||
span,
|
||||
&format!("this function has too many lines ({}/{})", line_count, self.max_lines),
|
||||
);
|
||||
)
|
||||
}
|
||||
}
|
||||
|
||||
@ -707,7 +707,7 @@ impl<'a, 'tcx> intravisit::Visitor<'tcx> for StaticMutVisitor<'a, 'tcx> {
|
||||
}
|
||||
},
|
||||
Assign(ref target, ..) | AssignOp(_, ref target, _) | AddrOf(_, hir::Mutability::Mut, ref target) => {
|
||||
self.mutates_static |= is_mutated_static(self.cx, target);
|
||||
self.mutates_static |= is_mutated_static(self.cx, target)
|
||||
},
|
||||
_ => {},
|
||||
}
|
||||
|
@ -101,7 +101,7 @@ impl<'tcx> LateLintPass<'tcx> for FutureNotSend {
|
||||
));
|
||||
}
|
||||
}
|
||||
});
|
||||
})
|
||||
},
|
||||
);
|
||||
}
|
||||
|
@ -53,7 +53,7 @@ impl<'tcx> LateLintPass<'tcx> for InfiniteIter {
|
||||
return;
|
||||
},
|
||||
};
|
||||
span_lint(cx, lint, expr.span, msg);
|
||||
span_lint(cx, lint, expr.span, msg)
|
||||
}
|
||||
}
|
||||
|
||||
|
@ -85,8 +85,8 @@ impl<'tcx> LateLintPass<'tcx> for MultipleInherentImpl {
|
||||
|diag| {
|
||||
diag.span_note(*initial_span, "first implementation here");
|
||||
},
|
||||
);
|
||||
});
|
||||
)
|
||||
})
|
||||
}
|
||||
}
|
||||
}
|
||||
|
@ -256,9 +256,9 @@ fn check_cmp(cx: &LateContext<'_>, span: Span, method: &Expr<'_>, lit: &Expr<'_>
|
||||
}
|
||||
}
|
||||
|
||||
check_len(cx, span, method_path.ident.name, args, &lit.node, op, compare_to);
|
||||
check_len(cx, span, method_path.ident.name, args, &lit.node, op, compare_to)
|
||||
} else {
|
||||
check_empty_expr(cx, span, method, lit, op);
|
||||
check_empty_expr(cx, span, method, lit, op)
|
||||
}
|
||||
}
|
||||
|
||||
|
@ -143,7 +143,7 @@ impl<'tcx> LateLintPass<'tcx> for LetUnderscore {
|
||||
None,
|
||||
"consider using an underscore-prefixed named \
|
||||
binding or dropping explicitly with `std::mem::drop`"
|
||||
);
|
||||
)
|
||||
} else if implements_drop {
|
||||
span_lint_and_help(
|
||||
cx,
|
||||
@ -153,7 +153,7 @@ impl<'tcx> LateLintPass<'tcx> for LetUnderscore {
|
||||
None,
|
||||
"consider using an underscore-prefixed named \
|
||||
binding or dropping explicitly with `std::mem::drop`"
|
||||
);
|
||||
)
|
||||
} else if is_must_use_ty(cx, cx.typeck_results().expr_ty(init)) {
|
||||
span_lint_and_help(
|
||||
cx,
|
||||
@ -162,7 +162,7 @@ impl<'tcx> LateLintPass<'tcx> for LetUnderscore {
|
||||
"non-binding let on an expression with `#[must_use]` type",
|
||||
None,
|
||||
"consider explicitly using expression value"
|
||||
);
|
||||
)
|
||||
} else if is_must_use_func_call(cx, init) {
|
||||
span_lint_and_help(
|
||||
cx,
|
||||
@ -171,7 +171,7 @@ impl<'tcx> LateLintPass<'tcx> for LetUnderscore {
|
||||
"non-binding let on a result of a `#[must_use]` function",
|
||||
None,
|
||||
"consider explicitly using function result"
|
||||
);
|
||||
)
|
||||
}
|
||||
}
|
||||
}
|
||||
|
@ -205,7 +205,7 @@ fn could_use_elision<'tcx>(
|
||||
output_visitor.visit_ty(ty);
|
||||
}
|
||||
for lt in named_generics {
|
||||
input_visitor.visit_generic_param(lt);
|
||||
input_visitor.visit_generic_param(lt)
|
||||
}
|
||||
|
||||
if input_visitor.abort() || output_visitor.abort() {
|
||||
@ -460,7 +460,7 @@ impl<'tcx> Visitor<'tcx> for LifetimeChecker {
|
||||
// `'b` in `'a: 'b` is useless unless used elsewhere in
|
||||
// a non-lifetime bound
|
||||
if let GenericParamKind::Type { .. } = param.kind {
|
||||
walk_generic_param(self, param);
|
||||
walk_generic_param(self, param)
|
||||
}
|
||||
}
|
||||
fn nested_visit_map(&mut self) -> NestedVisitorMap<Self::Map> {
|
||||
|
@ -229,7 +229,7 @@ impl EarlyLintPass for LiteralDigitGrouping {
|
||||
}
|
||||
|
||||
if let ExprKind::Lit(ref lit) = expr.kind {
|
||||
self.check_lit(cx, lit);
|
||||
self.check_lit(cx, lit)
|
||||
}
|
||||
}
|
||||
}
|
||||
@ -292,7 +292,7 @@ impl LiteralDigitGrouping {
|
||||
}
|
||||
};
|
||||
if should_warn {
|
||||
warning_type.display(num_lit.format(), cx, lit.span);
|
||||
warning_type.display(num_lit.format(), cx, lit.span)
|
||||
}
|
||||
}
|
||||
}
|
||||
@ -422,7 +422,7 @@ impl EarlyLintPass for DecimalLiteralRepresentation {
|
||||
}
|
||||
|
||||
if let ExprKind::Lit(ref lit) = expr.kind {
|
||||
self.check_lit(cx, lit);
|
||||
self.check_lit(cx, lit)
|
||||
}
|
||||
}
|
||||
}
|
||||
@ -444,7 +444,7 @@ impl DecimalLiteralRepresentation {
|
||||
let hex = format!("{:#X}", val);
|
||||
let num_lit = NumericLiteral::new(&hex, num_lit.suffix, false);
|
||||
let _ = Self::do_lint(num_lit.integer).map_err(|warning_type| {
|
||||
warning_type.display(num_lit.format(), cx, lit.span);
|
||||
warning_type.display(num_lit.format(), cx, lit.span)
|
||||
});
|
||||
}
|
||||
}
|
||||
|
@ -1426,7 +1426,7 @@ fn detect_same_item_push<'tcx>(
|
||||
"try using vec![{};SIZE] or {}.resize(NEW_SIZE, {})",
|
||||
item_str, vec_str, item_str
|
||||
),
|
||||
);
|
||||
)
|
||||
}
|
||||
|
||||
if !matches!(pat.kind, PatKind::Wild) {
|
||||
@ -1714,7 +1714,7 @@ fn lint_iter_method(cx: &LateContext<'_>, args: &[Expr<'_>], arg: &Expr<'_>, met
|
||||
"to write this more concisely, try",
|
||||
format!("&{}{}", muta, object),
|
||||
applicability,
|
||||
);
|
||||
)
|
||||
}
|
||||
|
||||
fn check_for_loop_arg(cx: &LateContext<'_>, pat: &Pat<'_>, arg: &Expr<'_>, expr: &Expr<'_>) {
|
||||
@ -1753,7 +1753,7 @@ fn check_for_loop_arg(cx: &LateContext<'_>, pat: &Pat<'_>, arg: &Expr<'_>, expr:
|
||||
},
|
||||
);
|
||||
if TyS::same_type(receiver_ty_adjusted, ref_receiver_ty) {
|
||||
lint_iter_method(cx, args, arg, method_name);
|
||||
lint_iter_method(cx, args, arg, method_name)
|
||||
}
|
||||
}
|
||||
} else if method_name == "next" && match_trait_method(cx, arg, &paths::ITERATOR) {
|
||||
@ -2075,10 +2075,10 @@ impl<'tcx> Delegate<'tcx> for MutatePairDelegate<'_, 'tcx> {
|
||||
if let ty::BorrowKind::MutBorrow = bk {
|
||||
if let PlaceBase::Local(id) = cmt.place.base {
|
||||
if Some(id) == self.hir_id_low {
|
||||
self.span_low = Some(self.cx.tcx.hir().span(diag_expr_id));
|
||||
self.span_low = Some(self.cx.tcx.hir().span(diag_expr_id))
|
||||
}
|
||||
if Some(id) == self.hir_id_high {
|
||||
self.span_high = Some(self.cx.tcx.hir().span(diag_expr_id));
|
||||
self.span_high = Some(self.cx.tcx.hir().span(diag_expr_id))
|
||||
}
|
||||
}
|
||||
}
|
||||
@ -2087,10 +2087,10 @@ impl<'tcx> Delegate<'tcx> for MutatePairDelegate<'_, 'tcx> {
|
||||
fn mutate(&mut self, cmt: &PlaceWithHirId<'tcx>, diag_expr_id: HirId) {
|
||||
if let PlaceBase::Local(id) = cmt.place.base {
|
||||
if Some(id) == self.hir_id_low {
|
||||
self.span_low = Some(self.cx.tcx.hir().span(diag_expr_id));
|
||||
self.span_low = Some(self.cx.tcx.hir().span(diag_expr_id))
|
||||
}
|
||||
if Some(id) == self.hir_id_high {
|
||||
self.span_high = Some(self.cx.tcx.hir().span(diag_expr_id));
|
||||
self.span_high = Some(self.cx.tcx.hir().span(diag_expr_id))
|
||||
}
|
||||
}
|
||||
}
|
||||
@ -2543,10 +2543,10 @@ impl<'a, 'tcx> Visitor<'tcx> for IncrementVisitor<'a, 'tcx> {
|
||||
}
|
||||
},
|
||||
ExprKind::Assign(ref lhs, _, _) if lhs.hir_id == expr.hir_id => {
|
||||
*state = IncrementVisitorVarState::DontWarn;
|
||||
*state = IncrementVisitorVarState::DontWarn
|
||||
},
|
||||
ExprKind::AddrOf(BorrowKind::Ref, mutability, _) if mutability == Mutability::Mut => {
|
||||
*state = IncrementVisitorVarState::DontWarn;
|
||||
*state = IncrementVisitorVarState::DontWarn
|
||||
},
|
||||
_ => (),
|
||||
}
|
||||
@ -2670,7 +2670,7 @@ impl<'a, 'tcx> Visitor<'tcx> for InitializeVisitor<'a, 'tcx> {
|
||||
}
|
||||
},
|
||||
ExprKind::AddrOf(BorrowKind::Ref, mutability, _) if mutability == Mutability::Mut => {
|
||||
self.state = InitializeVisitorState::DontWarn;
|
||||
self.state = InitializeVisitorState::DontWarn
|
||||
},
|
||||
_ => (),
|
||||
}
|
||||
@ -2815,7 +2815,7 @@ impl<'tcx> Visitor<'tcx> for LoopNestVisitor {
|
||||
return;
|
||||
}
|
||||
}
|
||||
walk_pat(self, pat);
|
||||
walk_pat(self, pat)
|
||||
}
|
||||
|
||||
fn nested_visit_map(&mut self) -> NestedVisitorMap<Self::Map> {
|
||||
|
@ -206,9 +206,9 @@ impl<'tcx> LateLintPass<'tcx> for MacroUseImports {
|
||||
let mut suggestions = vec![];
|
||||
for ((root, span), path) in used {
|
||||
if path.len() == 1 {
|
||||
suggestions.push((span, format!("{}::{}", root, path[0])));
|
||||
suggestions.push((span, format!("{}::{}", root, path[0])))
|
||||
} else {
|
||||
suggestions.push((span, format!("{}::{{{}}}", root, path.join(", "))));
|
||||
suggestions.push((span, format!("{}::{{{}}}", root, path.join(", "))))
|
||||
}
|
||||
}
|
||||
|
||||
@ -225,7 +225,7 @@ impl<'tcx> LateLintPass<'tcx> for MacroUseImports {
|
||||
"remove the attribute and import the macro directly, try",
|
||||
help,
|
||||
Applicability::MaybeIncorrect,
|
||||
);
|
||||
)
|
||||
}
|
||||
}
|
||||
}
|
||||
|
@ -126,7 +126,7 @@ impl<'tcx> LateLintPass<'tcx> for ManualStrip {
|
||||
kind_word,
|
||||
snippet(cx, pattern.span, "..")))]
|
||||
.into_iter().chain(strippings.into_iter().map(|span| (span, "<stripped>".into()))),
|
||||
);
|
||||
)
|
||||
});
|
||||
}
|
||||
}
|
||||
|
@ -122,7 +122,7 @@ fn lint_needless_cloning(cx: &LateContext<'_>, root: Span, receiver: Span) {
|
||||
"remove the `map` call",
|
||||
String::new(),
|
||||
Applicability::MachineApplicable,
|
||||
);
|
||||
)
|
||||
}
|
||||
|
||||
fn lint(cx: &LateContext<'_>, replace: Span, root: Span, copied: bool) {
|
||||
@ -139,7 +139,7 @@ fn lint(cx: &LateContext<'_>, replace: Span, root: Span, copied: bool) {
|
||||
snippet_with_applicability(cx, root, "..", &mut applicability)
|
||||
),
|
||||
applicability,
|
||||
);
|
||||
)
|
||||
} else {
|
||||
span_lint_and_sugg(
|
||||
cx,
|
||||
@ -152,6 +152,6 @@ fn lint(cx: &LateContext<'_>, replace: Span, root: Span, copied: bool) {
|
||||
snippet_with_applicability(cx, root, "..", &mut applicability)
|
||||
),
|
||||
applicability,
|
||||
);
|
||||
)
|
||||
}
|
||||
}
|
||||
|
@ -1046,7 +1046,7 @@ fn check_wild_enum_match(cx: &LateContext<'_>, ex: &Expr<'_>, arms: &[Arm<'_>])
|
||||
"try this",
|
||||
suggestion[0].clone(),
|
||||
Applicability::MaybeIncorrect,
|
||||
);
|
||||
)
|
||||
};
|
||||
|
||||
span_lint_and_sugg(
|
||||
@ -1057,7 +1057,7 @@ fn check_wild_enum_match(cx: &LateContext<'_>, ex: &Expr<'_>, arms: &[Arm<'_>])
|
||||
"try this",
|
||||
suggestion.join(" | "),
|
||||
Applicability::MaybeIncorrect,
|
||||
);
|
||||
)
|
||||
}
|
||||
}
|
||||
|
||||
@ -1156,7 +1156,7 @@ fn check_match_as_ref(cx: &LateContext<'_>, ex: &Expr<'_>, arms: &[Arm<'_>], exp
|
||||
cast,
|
||||
),
|
||||
applicability,
|
||||
);
|
||||
)
|
||||
}
|
||||
}
|
||||
}
|
||||
|
@ -151,7 +151,7 @@ pub(crate) trait BindInsteadOfMap {
|
||||
.into_iter()
|
||||
.map(|(span1, span2)| (span1, snippet(cx, span2, "_").into())),
|
||||
),
|
||||
);
|
||||
)
|
||||
});
|
||||
}
|
||||
can_sugg
|
||||
|
@ -1582,10 +1582,10 @@ impl<'tcx> LateLintPass<'tcx> for Methods {
|
||||
["flatten", "map"] => lint_map_flatten(cx, expr, arg_lists[1]),
|
||||
["is_some", "find"] => lint_search_is_some(cx, expr, "find", arg_lists[1], arg_lists[0], method_spans[1]),
|
||||
["is_some", "position"] => {
|
||||
lint_search_is_some(cx, expr, "position", arg_lists[1], arg_lists[0], method_spans[1]);
|
||||
lint_search_is_some(cx, expr, "position", arg_lists[1], arg_lists[0], method_spans[1])
|
||||
},
|
||||
["is_some", "rposition"] => {
|
||||
lint_search_is_some(cx, expr, "rposition", arg_lists[1], arg_lists[0], method_spans[1]);
|
||||
lint_search_is_some(cx, expr, "rposition", arg_lists[1], arg_lists[0], method_spans[1])
|
||||
},
|
||||
["extend", ..] => lint_extend(cx, expr, arg_lists[0]),
|
||||
["nth", "iter"] => lint_iter_nth(cx, expr, &arg_lists, false),
|
||||
@ -1601,17 +1601,17 @@ impl<'tcx> LateLintPass<'tcx> for Methods {
|
||||
["count", "map"] => lint_suspicious_map(cx, expr),
|
||||
["assume_init"] => lint_maybe_uninit(cx, &arg_lists[0][0], expr),
|
||||
["unwrap_or", arith @ ("checked_add" | "checked_sub" | "checked_mul")] => {
|
||||
manual_saturating_arithmetic::lint(cx, expr, &arg_lists, &arith["checked_".len()..]);
|
||||
manual_saturating_arithmetic::lint(cx, expr, &arg_lists, &arith["checked_".len()..])
|
||||
},
|
||||
["add" | "offset" | "sub" | "wrapping_offset" | "wrapping_add" | "wrapping_sub"] => {
|
||||
check_pointer_offset(cx, expr, arg_lists[0]);
|
||||
check_pointer_offset(cx, expr, arg_lists[0])
|
||||
},
|
||||
["is_file", ..] => lint_filetype_is_file(cx, expr, arg_lists[0]),
|
||||
["map", "as_ref"] => {
|
||||
lint_option_as_ref_deref(cx, expr, arg_lists[1], arg_lists[0], false, self.msrv.as_ref());
|
||||
lint_option_as_ref_deref(cx, expr, arg_lists[1], arg_lists[0], false, self.msrv.as_ref())
|
||||
},
|
||||
["map", "as_mut"] => {
|
||||
lint_option_as_ref_deref(cx, expr, arg_lists[1], arg_lists[0], true, self.msrv.as_ref());
|
||||
lint_option_as_ref_deref(cx, expr, arg_lists[1], arg_lists[0], true, self.msrv.as_ref())
|
||||
},
|
||||
["unwrap_or_else", ..] => unnecessary_lazy_eval::lint(cx, expr, arg_lists[0], "unwrap_or"),
|
||||
["get_or_insert_with", ..] => unnecessary_lazy_eval::lint(cx, expr, arg_lists[0], "get_or_insert"),
|
||||
@ -2446,16 +2446,16 @@ fn lint_unnecessary_fold(cx: &LateContext<'_>, expr: &hir::Expr<'_>, fold_args:
|
||||
if let hir::ExprKind::Lit(ref lit) = fold_args[1].kind {
|
||||
match lit.node {
|
||||
ast::LitKind::Bool(false) => {
|
||||
check_fold_with_op(cx, expr, fold_args, fold_span, hir::BinOpKind::Or, "any", true);
|
||||
check_fold_with_op(cx, expr, fold_args, fold_span, hir::BinOpKind::Or, "any", true)
|
||||
},
|
||||
ast::LitKind::Bool(true) => {
|
||||
check_fold_with_op(cx, expr, fold_args, fold_span, hir::BinOpKind::And, "all", true);
|
||||
check_fold_with_op(cx, expr, fold_args, fold_span, hir::BinOpKind::And, "all", true)
|
||||
},
|
||||
ast::LitKind::Int(0, _) => {
|
||||
check_fold_with_op(cx, expr, fold_args, fold_span, hir::BinOpKind::Add, "sum", false);
|
||||
check_fold_with_op(cx, expr, fold_args, fold_span, hir::BinOpKind::Add, "sum", false)
|
||||
},
|
||||
ast::LitKind::Int(1, _) => {
|
||||
check_fold_with_op(cx, expr, fold_args, fold_span, hir::BinOpKind::Mul, "product", false);
|
||||
check_fold_with_op(cx, expr, fold_args, fold_span, hir::BinOpKind::Mul, "product", false)
|
||||
},
|
||||
_ => (),
|
||||
}
|
||||
|
@ -47,7 +47,7 @@ impl<'tcx> LateLintPass<'tcx> for UnnecessaryMutPassed {
|
||||
let def_id = cx.typeck_results().type_dependent_def_id(e.hir_id).unwrap();
|
||||
let substs = cx.typeck_results().node_substs(e.hir_id);
|
||||
let method_type = cx.tcx.type_of(def_id).subst(cx.tcx, substs);
|
||||
check_arguments(cx, arguments, method_type, &path.ident.as_str(), "method");
|
||||
check_arguments(cx, arguments, method_type, &path.ident.as_str(), "method")
|
||||
},
|
||||
_ => (),
|
||||
}
|
||||
|
@ -106,7 +106,7 @@ impl<'a, 'tcx> Visitor<'tcx> for MutArgVisitor<'a, 'tcx> {
|
||||
_ if !self.found => self.expr_span = Some(expr.span),
|
||||
_ => return,
|
||||
}
|
||||
walk_expr(self, expr);
|
||||
walk_expr(self, expr)
|
||||
}
|
||||
|
||||
fn nested_visit_map(&mut self) -> NestedVisitorMap<Self::Map> {
|
||||
|
@ -120,7 +120,7 @@ impl EarlyLintPass for NeedlessArbitrarySelfType {
|
||||
match &p.ty.kind {
|
||||
TyKind::Path(None, path) => {
|
||||
if let PatKind::Ident(BindingMode::ByValue(mutbl), _, _) = p.pat.kind {
|
||||
check_param_inner(cx, path, p.span.to(p.ty.span), &Mode::Value, mutbl);
|
||||
check_param_inner(cx, path, p.span.to(p.ty.span), &Mode::Value, mutbl)
|
||||
}
|
||||
},
|
||||
TyKind::Rptr(lifetime, mut_ty) => {
|
||||
|
@ -80,7 +80,7 @@ impl<'tcx> LateLintPass<'tcx> for NeedlessBool {
|
||||
}
|
||||
|
||||
if parent_node_is_if_expr(&e, &cx) {
|
||||
snip = snip.blockify();
|
||||
snip = snip.blockify()
|
||||
}
|
||||
|
||||
span_lint_and_sugg(
|
||||
@ -142,7 +142,7 @@ impl<'tcx> LateLintPass<'tcx> for BoolComparison {
|
||||
|h: Sugg<'_>| !h,
|
||||
"equality checks against false can be replaced by a negation",
|
||||
));
|
||||
check_comparison(cx, e, true_case, false_case, true_case, false_case, ignore_no_literal);
|
||||
check_comparison(cx, e, true_case, false_case, true_case, false_case, ignore_no_literal)
|
||||
},
|
||||
BinOpKind::Ne => {
|
||||
let true_case = Some((
|
||||
@ -150,7 +150,7 @@ impl<'tcx> LateLintPass<'tcx> for BoolComparison {
|
||||
"inequality checks against true can be replaced by a negation",
|
||||
));
|
||||
let false_case = Some((|h| h, "inequality checks against false are unnecessary"));
|
||||
check_comparison(cx, e, true_case, false_case, true_case, false_case, ignore_no_literal);
|
||||
check_comparison(cx, e, true_case, false_case, true_case, false_case, ignore_no_literal)
|
||||
},
|
||||
BinOpKind::Lt => check_comparison(
|
||||
cx,
|
||||
@ -249,22 +249,22 @@ fn check_comparison<'a, 'tcx>(
|
||||
snippet_with_applicability(cx, expression_info.right_span, "..", &mut applicability)
|
||||
),
|
||||
applicability,
|
||||
);
|
||||
)
|
||||
}
|
||||
}
|
||||
|
||||
match (fetch_bool_expr(left_side), fetch_bool_expr(right_side)) {
|
||||
(Bool(true), Other) => left_true.map_or((), |(h, m)| {
|
||||
suggest_bool_comparison(cx, e, right_side, applicability, m, h);
|
||||
suggest_bool_comparison(cx, e, right_side, applicability, m, h)
|
||||
}),
|
||||
(Other, Bool(true)) => right_true.map_or((), |(h, m)| {
|
||||
suggest_bool_comparison(cx, e, left_side, applicability, m, h);
|
||||
suggest_bool_comparison(cx, e, left_side, applicability, m, h)
|
||||
}),
|
||||
(Bool(false), Other) => left_false.map_or((), |(h, m)| {
|
||||
suggest_bool_comparison(cx, e, right_side, applicability, m, h);
|
||||
suggest_bool_comparison(cx, e, right_side, applicability, m, h)
|
||||
}),
|
||||
(Other, Bool(false)) => right_false.map_or((), |(h, m)| {
|
||||
suggest_bool_comparison(cx, e, left_side, applicability, m, h);
|
||||
suggest_bool_comparison(cx, e, left_side, applicability, m, h)
|
||||
}),
|
||||
(Other, Other) => no_literal.map_or((), |(h, m)| {
|
||||
let left_side = Sugg::hir_with_applicability(cx, left_side, "..", &mut applicability);
|
||||
@ -277,7 +277,7 @@ fn check_comparison<'a, 'tcx>(
|
||||
"try simplifying it as shown",
|
||||
h(left_side, right_side).to_string(),
|
||||
applicability,
|
||||
);
|
||||
)
|
||||
}),
|
||||
_ => (),
|
||||
}
|
||||
|
@ -83,7 +83,7 @@ impl<'tcx> LateLintPass<'tcx> for NoNegCompOpForPartialOrd {
|
||||
types produces code that is hard to read and refactor, please \
|
||||
consider using the `partial_cmp` method instead, to make it \
|
||||
clear that the two values could be incomparable"
|
||||
);
|
||||
)
|
||||
}
|
||||
}
|
||||
}
|
||||
|
@ -125,7 +125,7 @@ fn check_open_options(cx: &LateContext<'_>, options: &[(OpenOption, Argument)],
|
||||
"the method `create` is called more than once",
|
||||
);
|
||||
} else {
|
||||
create = true;
|
||||
create = true
|
||||
}
|
||||
create_arg = create_arg || (arg == Argument::True);
|
||||
},
|
||||
@ -138,7 +138,7 @@ fn check_open_options(cx: &LateContext<'_>, options: &[(OpenOption, Argument)],
|
||||
"the method `append` is called more than once",
|
||||
);
|
||||
} else {
|
||||
append = true;
|
||||
append = true
|
||||
}
|
||||
append_arg = append_arg || (arg == Argument::True);
|
||||
},
|
||||
@ -151,7 +151,7 @@ fn check_open_options(cx: &LateContext<'_>, options: &[(OpenOption, Argument)],
|
||||
"the method `truncate` is called more than once",
|
||||
);
|
||||
} else {
|
||||
truncate = true;
|
||||
truncate = true
|
||||
}
|
||||
truncate_arg = truncate_arg || (arg == Argument::True);
|
||||
},
|
||||
@ -164,7 +164,7 @@ fn check_open_options(cx: &LateContext<'_>, options: &[(OpenOption, Argument)],
|
||||
"the method `read` is called more than once",
|
||||
);
|
||||
} else {
|
||||
read = true;
|
||||
read = true
|
||||
}
|
||||
read_arg = read_arg || (arg == Argument::True);
|
||||
},
|
||||
@ -177,7 +177,7 @@ fn check_open_options(cx: &LateContext<'_>, options: &[(OpenOption, Argument)],
|
||||
"the method `write` is called more than once",
|
||||
);
|
||||
} else {
|
||||
write = true;
|
||||
write = true
|
||||
}
|
||||
write_arg = write_arg || (arg == Argument::True);
|
||||
},
|
||||
|
@ -88,7 +88,7 @@ impl QuestionMark {
|
||||
"replace it with",
|
||||
replacement_str,
|
||||
applicability,
|
||||
);
|
||||
)
|
||||
}
|
||||
}
|
||||
}
|
||||
|
@ -56,7 +56,7 @@ impl<'ast> ast_visit::Visitor<'ast> for ReturnVisitor {
|
||||
self.found_return = true;
|
||||
}
|
||||
|
||||
ast_visit::walk_expr(self, ex);
|
||||
ast_visit::walk_expr(self, ex)
|
||||
}
|
||||
}
|
||||
|
||||
|
@ -60,7 +60,7 @@ impl<'tcx> LateLintPass<'tcx> for RedundantPubCrate {
|
||||
Applicability::MachineApplicable,
|
||||
);
|
||||
},
|
||||
);
|
||||
)
|
||||
}
|
||||
}
|
||||
}
|
||||
|
@ -139,7 +139,7 @@ impl<'tcx> LateLintPass<'tcx> for Return {
|
||||
} else {
|
||||
RetReplacement::Empty
|
||||
};
|
||||
check_final_expr(cx, &body.value, Some(body.value.span), replacement);
|
||||
check_final_expr(cx, &body.value, Some(body.value.span), replacement)
|
||||
},
|
||||
FnKind::ItemFn(..) | FnKind::Method(..) => {
|
||||
if let ExprKind::Block(ref block, _) = body.value.kind {
|
||||
@ -239,7 +239,7 @@ fn emit_return_lint(cx: &LateContext<'_>, ret_span: Span, inner_span: Option<Spa
|
||||
if let Some(snippet) = snippet_opt(cx, inner_span) {
|
||||
diag.span_suggestion(ret_span, "remove `return`", snippet, Applicability::MachineApplicable);
|
||||
}
|
||||
});
|
||||
})
|
||||
},
|
||||
None => match replacement {
|
||||
RetReplacement::Empty => {
|
||||
|
@ -1,7 +1,7 @@
|
||||
use crate::utils::{in_macro, span_lint_and_sugg, sugg};
|
||||
use crate::utils::{in_macro, span_lint_and_then, sugg};
|
||||
use if_chain::if_chain;
|
||||
use rustc_errors::Applicability;
|
||||
use rustc_hir::{Block, ExprKind};
|
||||
use rustc_hir::*;
|
||||
use rustc_lint::{LateContext, LateLintPass};
|
||||
use rustc_session::{declare_lint_pass, declare_tool_lint};
|
||||
|
||||
@ -42,25 +42,31 @@ impl LateLintPass<'_> for SemicolonIfNothingReturned {
|
||||
if let Some(expr) = block.expr;
|
||||
let t_expr = cx.typeck_results().expr_ty(expr);
|
||||
if t_expr.is_unit();
|
||||
if let Ok(snippet) = cx.tcx.sess.source_map().span_to_snippet(expr.span.source_callsite());
|
||||
if !snippet.ends_with('}');
|
||||
then {
|
||||
// filter out the desugared `for` loop
|
||||
if let ExprKind::DropTemps(..) = &expr.kind {
|
||||
return;
|
||||
match expr.kind {
|
||||
ExprKind::Loop(..) |
|
||||
ExprKind::Match(..) |
|
||||
ExprKind::Block(..) |
|
||||
ExprKind::If(..) if !in_macro(expr.span) => return,
|
||||
_ => (),
|
||||
}
|
||||
|
||||
let sugg = sugg::Sugg::hir(cx, &expr, "..");
|
||||
let suggestion = format!("{0};", sugg);
|
||||
span_lint_and_sugg(
|
||||
span_lint_and_then(
|
||||
cx,
|
||||
SEMICOLON_IF_NOTHING_RETURNED,
|
||||
expr.span,
|
||||
"Consider adding a `;` to the last statement for consistent formatting",
|
||||
"add a `;` here",
|
||||
suggestion,
|
||||
Applicability::MaybeIncorrect,
|
||||
);
|
||||
"add `;` to terminate block",
|
||||
| diag | {
|
||||
diag.span_suggestion(
|
||||
expr.span,
|
||||
"add `;`",
|
||||
suggestion,
|
||||
Applicability::MaybeIncorrect,
|
||||
);
|
||||
}
|
||||
)
|
||||
}
|
||||
}
|
||||
}
|
||||
|
@ -118,7 +118,7 @@ fn check_fn<'tcx>(cx: &LateContext<'tcx>, decl: &'tcx FnDecl<'_>, body: &'tcx Bo
|
||||
let mut bindings = Vec::with_capacity(decl.inputs.len());
|
||||
for arg in iter_input_pats(decl, body) {
|
||||
if let PatKind::Binding(.., ident, _) = arg.pat.kind {
|
||||
bindings.push((ident.name, ident.span));
|
||||
bindings.push((ident.name, ident.span))
|
||||
}
|
||||
}
|
||||
check_expr(cx, &body.value, &mut bindings);
|
||||
@ -154,7 +154,7 @@ fn check_local<'tcx>(cx: &LateContext<'tcx>, local: &'tcx Local<'_>, bindings: &
|
||||
..
|
||||
} = *local;
|
||||
if let Some(ref t) = *ty {
|
||||
check_ty(cx, t, bindings);
|
||||
check_ty(cx, t, bindings)
|
||||
}
|
||||
if let Some(ref o) = *init {
|
||||
check_expr(cx, o, bindings);
|
||||
@ -330,7 +330,7 @@ fn check_expr<'tcx>(cx: &LateContext<'tcx>, expr: &'tcx Expr<'_>, bindings: &mut
|
||||
// ExprKind::MethodCall
|
||||
ExprKind::Array(v) | ExprKind::Tup(v) => {
|
||||
for e in v {
|
||||
check_expr(cx, e, bindings);
|
||||
check_expr(cx, e, bindings)
|
||||
}
|
||||
},
|
||||
ExprKind::If(ref cond, ref then, ref otherwise) => {
|
||||
@ -371,11 +371,11 @@ fn check_ty<'tcx>(cx: &LateContext<'tcx>, ty: &'tcx Ty<'_>, bindings: &mut Vec<(
|
||||
check_expr(cx, &cx.tcx.hir().body(anon_const.body).value, bindings);
|
||||
},
|
||||
TyKind::Ptr(MutTy { ty: ref mty, .. }) | TyKind::Rptr(_, MutTy { ty: ref mty, .. }) => {
|
||||
check_ty(cx, mty, bindings);
|
||||
check_ty(cx, mty, bindings)
|
||||
},
|
||||
TyKind::Tup(tup) => {
|
||||
for t in tup {
|
||||
check_ty(cx, t, bindings);
|
||||
check_ty(cx, t, bindings)
|
||||
}
|
||||
},
|
||||
TyKind::Typeof(ref anon_const) => check_expr(cx, &cx.tcx.hir().body(anon_const.body).value, bindings),
|
||||
|
@ -306,7 +306,7 @@ impl<'a, 'tcx> Visitor<'tcx> for VectorInitializationVisitor<'a, 'tcx> {
|
||||
fn visit_block(&mut self, block: &'tcx Block<'_>) {
|
||||
if self.initialization_found {
|
||||
if let Some(ref s) = block.stmts.get(0) {
|
||||
self.visit_stmt(s);
|
||||
self.visit_stmt(s)
|
||||
}
|
||||
|
||||
self.initialization_found = false;
|
||||
|
@ -265,7 +265,7 @@ fn emit_suggestion(cx: &EarlyContext<'_>, span: Span, sugg: String, applicabilit
|
||||
"I think you meant",
|
||||
sugg,
|
||||
applicability,
|
||||
);
|
||||
)
|
||||
}
|
||||
|
||||
fn ident_swap_sugg(
|
||||
@ -476,7 +476,7 @@ impl Add for IdentLocation {
|
||||
|
||||
impl AddAssign for IdentLocation {
|
||||
fn add_assign(&mut self, other: Self) {
|
||||
*self = *self + other;
|
||||
*self = *self + other
|
||||
}
|
||||
}
|
||||
|
||||
@ -507,7 +507,7 @@ impl Add for IdentDifference {
|
||||
|
||||
impl AddAssign for IdentDifference {
|
||||
fn add_assign(&mut self, other: Self) {
|
||||
*self = *self + other;
|
||||
*self = *self + other
|
||||
}
|
||||
}
|
||||
|
||||
|
@ -463,7 +463,7 @@ impl<'tcx> LateLintPass<'tcx> for Transmute {
|
||||
Applicability::Unspecified,
|
||||
);
|
||||
},
|
||||
);
|
||||
)
|
||||
},
|
||||
(ty::Ref(_, ty_from, from_mutbl), ty::Ref(_, ty_to, to_mutbl)) => {
|
||||
if_chain! {
|
||||
@ -519,7 +519,7 @@ impl<'tcx> LateLintPass<'tcx> for Transmute {
|
||||
Applicability::Unspecified,
|
||||
);
|
||||
},
|
||||
);
|
||||
)
|
||||
}
|
||||
}
|
||||
}
|
||||
@ -552,7 +552,7 @@ impl<'tcx> LateLintPass<'tcx> for Transmute {
|
||||
Applicability::Unspecified,
|
||||
);
|
||||
},
|
||||
);
|
||||
)
|
||||
},
|
||||
(ty::Int(_) | ty::Uint(_), ty::Float(_)) if !const_context => span_lint_and_then(
|
||||
cx,
|
||||
|
@ -630,7 +630,7 @@ impl Types {
|
||||
TyKind::Rptr(ref lt, ref mut_ty) => self.check_ty_rptr(cx, hir_ty, is_local, lt, mut_ty),
|
||||
// recurse
|
||||
TyKind::Slice(ref ty) | TyKind::Array(ref ty, _) | TyKind::Ptr(MutTy { ref ty, .. }) => {
|
||||
self.check_ty(cx, ty, is_local);
|
||||
self.check_ty(cx, ty, is_local)
|
||||
},
|
||||
TyKind::Tup(tys) => {
|
||||
for ty in tys {
|
||||
@ -2436,7 +2436,7 @@ fn upcast_comparison_bounds_err<'tcx>(
|
||||
},
|
||||
Rel::Eq | Rel::Ne => unreachable!(),
|
||||
} {
|
||||
err_upcast_comparison(cx, span, lhs, true);
|
||||
err_upcast_comparison(cx, span, lhs, true)
|
||||
} else if match rel {
|
||||
Rel::Lt => {
|
||||
if invert {
|
||||
@ -2454,7 +2454,7 @@ fn upcast_comparison_bounds_err<'tcx>(
|
||||
},
|
||||
Rel::Eq | Rel::Ne => unreachable!(),
|
||||
} {
|
||||
err_upcast_comparison(cx, span, lhs, false);
|
||||
err_upcast_comparison(cx, span, lhs, false)
|
||||
}
|
||||
}
|
||||
}
|
||||
|
@ -69,7 +69,7 @@ impl LateLintPass<'_> for Unicode {
|
||||
fn check_expr(&mut self, cx: &LateContext<'_>, expr: &'_ Expr<'_>) {
|
||||
if let ExprKind::Lit(ref lit) = expr.kind {
|
||||
if let LitKind::Str(_, _) = lit.node {
|
||||
check_str(cx, lit.span, expr.hir_id);
|
||||
check_str(cx, lit.span, expr.hir_id)
|
||||
}
|
||||
}
|
||||
}
|
||||
@ -80,7 +80,7 @@ fn escape<T: Iterator<Item = char>>(s: T) -> String {
|
||||
for c in s {
|
||||
if c as u32 > 0x7F {
|
||||
for d in c.escape_unicode() {
|
||||
result.push(d);
|
||||
result.push(d)
|
||||
}
|
||||
} else {
|
||||
result.push(c);
|
||||
|
@ -94,7 +94,7 @@ impl<'a, 'tcx> Visitor<'tcx> for UnusedSelfVisitor<'a, 'tcx> {
|
||||
return;
|
||||
}
|
||||
if let Res::Local(hir_id) = &path.res {
|
||||
self.uses_self = self.self_hir_id == hir_id;
|
||||
self.uses_self = self.self_hir_id == hir_id
|
||||
}
|
||||
walk_path(self, path);
|
||||
}
|
||||
|
@ -69,7 +69,7 @@ fn check_ident(cx: &EarlyContext<'_>, ident: &Ident) {
|
||||
"consider making the acronym lowercase, except the initial letter",
|
||||
corrected,
|
||||
Applicability::MaybeIncorrect,
|
||||
);
|
||||
)
|
||||
}
|
||||
}
|
||||
|
||||
|
@ -103,7 +103,7 @@ impl<'a, 'tcx> Visitor<'tcx> for SemanticUseSelfVisitor<'a, 'tcx> {
|
||||
}
|
||||
}
|
||||
|
||||
walk_ty(self, hir_ty);
|
||||
walk_ty(self, hir_ty)
|
||||
}
|
||||
|
||||
fn nested_visit_map(&mut self) -> NestedVisitorMap<Self::Map> {
|
||||
|
@ -115,7 +115,7 @@ fn parse_attrs<F: FnMut(u64)>(sess: &Session, attrs: &[ast::Attribute], name: &'
|
||||
for attr in get_attr(sess, attrs, name) {
|
||||
if let Some(ref value) = attr.value_str() {
|
||||
if let Ok(value) = FromStr::from_str(&value.as_str()) {
|
||||
f(value);
|
||||
f(value)
|
||||
} else {
|
||||
sess.span_err(attr.span, "not a number");
|
||||
}
|
||||
|
@ -293,7 +293,7 @@ impl<'tcx> Visitor<'tcx> for PrintVisitor {
|
||||
LitKind::Str(ref text, _) => {
|
||||
let str_pat = self.next("s");
|
||||
println!(" if let LitKind::Str(ref {}, _) = {}.node;", str_pat, lit_pat);
|
||||
println!(" if {}.as_str() == {:?}", str_pat, &*text.as_str());
|
||||
println!(" if {}.as_str() == {:?}", str_pat, &*text.as_str())
|
||||
},
|
||||
}
|
||||
},
|
||||
|
@ -211,7 +211,7 @@ pub fn multispan_sugg<I>(diag: &mut DiagnosticBuilder<'_>, help_msg: &str, sugg:
|
||||
where
|
||||
I: IntoIterator<Item = (Span, String)>,
|
||||
{
|
||||
multispan_sugg_with_applicability(diag, help_msg, Applicability::Unspecified, sugg);
|
||||
multispan_sugg_with_applicability(diag, help_msg, Applicability::Unspecified, sugg)
|
||||
}
|
||||
|
||||
pub fn multispan_sugg_with_applicability<I>(
|
||||
|
@ -464,7 +464,7 @@ pub fn method_chain_args<'a>(expr: &'a Expr<'_>, methods: &[&str]) -> Option<Vec
|
||||
return None;
|
||||
}
|
||||
matched.push(&**args); // build up `matched` backwards
|
||||
current = &args[0]; // go to parent expression
|
||||
current = &args[0] // go to parent expression
|
||||
} else {
|
||||
return None;
|
||||
}
|
||||
|
@ -656,7 +656,7 @@ impl<T: LintContext> DiagnosticBuilderExt<T> for rustc_errors::DiagnosticBuilder
|
||||
|
||||
if let Some(non_whitespace_offset) = non_whitespace_offset {
|
||||
remove_span = remove_span
|
||||
.with_hi(remove_span.hi() + BytePos(non_whitespace_offset.try_into().expect("offset too large")));
|
||||
.with_hi(remove_span.hi() + BytePos(non_whitespace_offset.try_into().expect("offset too large")))
|
||||
}
|
||||
}
|
||||
|
||||
|
@ -60,7 +60,7 @@ impl<'tcx> MutVarsDelegate {
|
||||
//FIXME: This causes false negatives. We can't get the `NodeId` from
|
||||
//`Categorization::Upvar(_)`. So we search for any `Upvar`s in the
|
||||
//`while`-body, not just the ones in the condition.
|
||||
self.skip = true;
|
||||
self.skip = true
|
||||
},
|
||||
_ => {},
|
||||
}
|
||||
@ -72,12 +72,12 @@ impl<'tcx> Delegate<'tcx> for MutVarsDelegate {
|
||||
|
||||
fn borrow(&mut self, cmt: &PlaceWithHirId<'tcx>, _: HirId, bk: ty::BorrowKind) {
|
||||
if let ty::BorrowKind::MutBorrow = bk {
|
||||
self.update(&cmt);
|
||||
self.update(&cmt)
|
||||
}
|
||||
}
|
||||
|
||||
fn mutate(&mut self, cmt: &PlaceWithHirId<'tcx>, _: HirId) {
|
||||
self.update(&cmt);
|
||||
self.update(&cmt)
|
||||
}
|
||||
}
|
||||
|
||||
|
@ -87,7 +87,7 @@ where
|
||||
}
|
||||
|
||||
fn visit_stmt(&mut self, stmt: &'hir hir::Stmt<'_>) {
|
||||
intravisit::walk_stmt(&mut *self.inside_stmt(true), stmt);
|
||||
intravisit::walk_stmt(&mut *self.inside_stmt(true), stmt)
|
||||
}
|
||||
|
||||
fn visit_expr(&mut self, expr: &'hir hir::Expr<'_>) {
|
||||
|
@ -52,7 +52,7 @@ impl<'tcx> LateLintPass<'tcx> for VerboseFileReads {
|
||||
"use of `File::read_to_string`",
|
||||
None,
|
||||
"consider using `fs::read_to_string` instead",
|
||||
);
|
||||
)
|
||||
}
|
||||
}
|
||||
}
|
||||
|
@ -298,7 +298,7 @@ impl EarlyLintPass for Write {
|
||||
Applicability::MachineApplicable,
|
||||
);
|
||||
},
|
||||
);
|
||||
)
|
||||
}
|
||||
}
|
||||
} else if mac.path == sym!(writeln) {
|
||||
|
@ -46,10 +46,3 @@ fn foobar(x: i32) {
|
||||
y = x + 1;
|
||||
}
|
||||
}
|
||||
|
||||
fn loop_test(x: i32) {
|
||||
let y: i32;
|
||||
for &ext in &["stdout", "stderr", "fixed"] {
|
||||
println!("{}", ext);
|
||||
}
|
||||
}
|
||||
|
@ -1,4 +1,4 @@
|
||||
error: Consider adding a `;` to the last statement for consistent formatting
|
||||
error: add `;` to terminate block
|
||||
--> $DIR/semicolon_if_nothing_returned.rs:8:5
|
||||
|
|
||||
LL | println!("Hello")
|
||||
@ -7,17 +7,17 @@ LL | println!("Hello")
|
||||
= note: `-D clippy::semicolon-if-nothing-returned` implied by `-D warnings`
|
||||
= note: this error originates in a macro (in Nightly builds, run with -Z macro-backtrace for more info)
|
||||
|
||||
error: Consider adding a `;` to the last statement for consistent formatting
|
||||
error: add `;` to terminate block
|
||||
--> $DIR/semicolon_if_nothing_returned.rs:12:5
|
||||
|
|
||||
LL | get_unit()
|
||||
| ^^^^^^^^^^ help: add a `;` here: `get_unit();`
|
||||
| ^^^^^^^^^^ help: add `;`: `get_unit();`
|
||||
|
||||
error: Consider adding a `;` to the last statement for consistent formatting
|
||||
error: add `;` to terminate block
|
||||
--> $DIR/semicolon_if_nothing_returned.rs:17:5
|
||||
|
|
||||
LL | y = x + 1
|
||||
| ^^^^^^^^^ help: add a `;` here: `y = x + 1;`
|
||||
| ^^^^^^^^^ help: add `;`: `y = x + 1;`
|
||||
|
||||
error: aborting due to 3 previous errors
|
||||
|
||||
|
Loading…
Reference in New Issue
Block a user