Skip to content

Commit

Permalink
Auto merge of #7268 - mbartlett21:update_semi, r=Manishearth
Browse files Browse the repository at this point in the history
Move `semicolon_if_nothing_returned` to `pedantic`

This moves the `semicolon_if_nothing_returned` lint to `pedantic` category.
I had done #7148, but on the master branch, and Github doesn't seem to let me change that, so here's another PR

changelog: Move [`semicolon_if_nothing_returned`] lint into `pedantic` category.
  • Loading branch information
bors committed May 25, 2021
2 parents a248648 + 0c017ea commit 513c0eb
Show file tree
Hide file tree
Showing 70 changed files with 155 additions and 154 deletions.
2 changes: 1 addition & 1 deletion clippy_lints/src/assertions_on_constants.rs
Original file line number Diff line number Diff line change
Expand Up @@ -63,7 +63,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") {
Expand Down
6 changes: 3 additions & 3 deletions clippy_lints/src/attrs.rs
Original file line number Diff line number Diff line change
Expand Up @@ -273,7 +273,7 @@ impl<'tcx> LateLintPass<'tcx> for Attributes {
fn check_item(&mut self, cx: &LateContext<'tcx>, item: &'tcx Item<'_>) {
let attrs = cx.tcx.hir().attrs(item.hir_id());
if is_relevant_item(cx, item) {
check_attrs(cx, item.span, item.ident.name, attrs)
check_attrs(cx, item.span, item.ident.name, attrs);
}
match item.kind {
ItemKind::ExternCrate(..) | ItemKind::Use(..) => {
Expand Down Expand Up @@ -343,13 +343,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, cx.tcx.hir().attrs(item.hir_id()))
check_attrs(cx, item.span, item.ident.name, cx.tcx.hir().attrs(item.hir_id()));
}
}

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, cx.tcx.hir().attrs(item.hir_id()))
check_attrs(cx, item.span, item.ident.name, cx.tcx.hir().attrs(item.hir_id()));
}
}
}
Expand Down
6 changes: 3 additions & 3 deletions clippy_lints/src/bit_mask.rs
Original file line number Diff line number Diff line change
Expand Up @@ -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);
}
}
}
Expand Down Expand Up @@ -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));
}
}

Expand Down
6 changes: 3 additions & 3 deletions clippy_lints/src/booleans.rs
Original file line number Diff line number Diff line change
Expand Up @@ -66,7 +66,7 @@ impl<'tcx> LateLintPass<'tcx> for NonminimalBool {
_: Span,
_: HirId,
) {
NonminimalBoolVisitor { cx }.visit_body(body)
NonminimalBoolVisitor { cx }.visit_body(body);
}
}

Expand Down Expand Up @@ -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)?;
Expand Down Expand Up @@ -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::Not, inner) => {
if self.cx.typeck_results().node_types()[inner.hir_id].is_bool() {
Expand Down
2 changes: 1 addition & 1 deletion clippy_lints/src/collapsible_if.rs
Original file line number Diff line number Diff line change
Expand Up @@ -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);
}
}
}
Expand Down
2 changes: 1 addition & 1 deletion clippy_lints/src/comparison_chain.rs
Original file line number Diff line number Diff line change
Expand Up @@ -120,7 +120,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`",
)
);
}
}

Expand Down
2 changes: 1 addition & 1 deletion clippy_lints/src/copies.rs
Original file line number Diff line number Diff line change
Expand Up @@ -476,7 +476,7 @@ fn emit_branches_sharing_code_lint(
}

suggestions.push(("end", span, suggestion.to_string()));
add_expr_note = !cx.typeck_results().expr_ty(if_expr).is_unit()
add_expr_note = !cx.typeck_results().expr_ty(if_expr).is_unit();
}

let add_optional_msgs = |diag: &mut DiagnosticBuilder<'_>| {
Expand Down
4 changes: 2 additions & 2 deletions clippy_lints/src/default_numeric_fallback.rs
Original file line number Diff line number Diff line change
Expand Up @@ -181,9 +181,9 @@ impl<'a, 'tcx> Visitor<'tcx> for NumericFallbackVisitor<'a, 'tcx> {
match stmt.kind {
StmtKind::Local(local) => {
if local.ty.is_some() {
self.ty_bounds.push(TyBound::Any)
self.ty_bounds.push(TyBound::Any);
} else {
self.ty_bounds.push(TyBound::Nothing)
self.ty_bounds.push(TyBound::Nothing);
}
},

Expand Down
8 changes: 4 additions & 4 deletions clippy_lints/src/double_comparison.rs
Original file line number Diff line number Diff line change
Expand Up @@ -70,16 +70,16 @@ impl<'tcx> DoubleComparisons {
#[rustfmt::skip]
match (op, lkind, rkind) {
(BinOpKind::Or, BinOpKind::Eq, BinOpKind::Lt) | (BinOpKind::Or, BinOpKind::Lt, BinOpKind::Eq) => {
lint_double_comparison!(<=)
lint_double_comparison!(<=);
},
(BinOpKind::Or, BinOpKind::Eq, BinOpKind::Gt) | (BinOpKind::Or, BinOpKind::Gt, BinOpKind::Eq) => {
lint_double_comparison!(>=)
lint_double_comparison!(>=);
},
(BinOpKind::Or, BinOpKind::Lt, BinOpKind::Gt) | (BinOpKind::Or, BinOpKind::Gt, BinOpKind::Lt) => {
lint_double_comparison!(!=)
lint_double_comparison!(!=);
},
(BinOpKind::And, BinOpKind::Le, BinOpKind::Ge) | (BinOpKind::And, BinOpKind::Ge, BinOpKind::Le) => {
lint_double_comparison!(==)
lint_double_comparison!(==);
},
_ => (),
};
Expand Down
2 changes: 1 addition & 1 deletion clippy_lints/src/entry.rs
Original file line number Diff line number Diff line change
Expand Up @@ -469,7 +469,7 @@ impl<'tcx> Visitor<'tcx> for InsertSearcher<'_, 'tcx> {
let mut is_map_used = self.is_map_used;
for arm in arms {
if let Some(Guard::If(guard) | Guard::IfLet(_, guard)) = arm.guard {
self.visit_non_tail_expr(guard)
self.visit_non_tail_expr(guard);
}
is_map_used |= self.visit_cond_arm(arm.body);
}
Expand Down
12 changes: 6 additions & 6 deletions clippy_lints/src/eq_op.rs
Original file line number Diff line number Diff line change
Expand Up @@ -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()])
Expand All @@ -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()])
Expand All @@ -194,7 +194,7 @@ impl<'tcx> LateLintPass<'tcx> for EqOp {
Applicability::MaybeIncorrect, // FIXME #2597
);
},
)
);
}
},
// &foo == bar
Expand All @@ -218,9 +218,9 @@ impl<'tcx> LateLintPass<'tcx> for EqOp {
Applicability::MaybeIncorrect, // FIXME #2597
);
},
)
);
}
},
},
// foo == &bar
(_, &ExprKind::AddrOf(BorrowKind::Ref, _, r)) => {
let rty = cx.typeck_results().expr_ty(r);
Expand All @@ -236,7 +236,7 @@ impl<'tcx> LateLintPass<'tcx> for EqOp {
rsnip,
Applicability::MaybeIncorrect, // FIXME #2597
);
})
});
}
},
_ => {},
Expand Down
7 changes: 4 additions & 3 deletions clippy_lints/src/eta_reduction.rs
Original file line number Diff line number Diff line change
Expand Up @@ -77,7 +77,7 @@ impl<'tcx> LateLintPass<'tcx> for EtaReduction {
for arg in args {
// skip `foo(macro!())`
if arg.span.ctxt() == expr.span.ctxt() {
check_closure(cx, arg)
check_closure(cx, arg);
}
}
},
Expand Down Expand Up @@ -190,9 +190,10 @@ fn get_ufcs_type_name(cx: &LateContext<'_>, method_def_id: def_id::DefId, self_a
cx.tcx.impl_of_method(method_def_id).and_then(|_| {
//a type may implicitly implement other type's methods (e.g. Deref)
if match_types(expected_type_of_self, actual_type_of_self) {
return Some(get_type_name(cx, actual_type_of_self));
Some(get_type_name(cx, actual_type_of_self))
} else {
None
}
None
})
}

Expand Down
2 changes: 1 addition & 1 deletion clippy_lints/src/eval_order_dependence.rs
Original file line number Diff line number Diff line change
Expand Up @@ -110,7 +110,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);
Expand Down
2 changes: 1 addition & 1 deletion clippy_lints/src/functions/must_use.rs
Original file line number Diff line number Diff line change
Expand Up @@ -240,7 +240,7 @@ impl<'a, 'tcx> intravisit::Visitor<'tcx> for StaticMutVisitor<'a, 'tcx> {
}
},
Assign(target, ..) | AssignOp(_, target, _) | AddrOf(_, hir::Mutability::Mut, target) => {
self.mutates_static |= is_mutated_static(target)
self.mutates_static |= is_mutated_static(target);
},
_ => {},
}
Expand Down
2 changes: 1 addition & 1 deletion clippy_lints/src/functions/too_many_lines.rs
Original file line number Diff line number Diff line change
Expand Up @@ -63,6 +63,6 @@ pub(super) fn check_fn(cx: &LateContext<'_>, span: Span, body: &'tcx hir::Body<'
"this function has too many lines ({}/{})",
line_count, too_many_lines_threshold
),
)
);
}
}
2 changes: 1 addition & 1 deletion clippy_lints/src/future_not_send.rs
Original file line number Diff line number Diff line change
Expand Up @@ -102,7 +102,7 @@ impl<'tcx> LateLintPass<'tcx> for FutureNotSend {
));
}
}
})
});
},
);
}
Expand Down
2 changes: 1 addition & 1 deletion clippy_lints/src/implicit_return.rs
Original file line number Diff line number Diff line change
Expand Up @@ -67,7 +67,7 @@ fn lint_break(cx: &LateContext<'_>, break_span: Span, expr_span: Span) {
"change `break` to `return` as shown",
format!("return {}", snip),
app,
)
);
}

#[derive(Clone, Copy, PartialEq, Eq)]
Expand Down
2 changes: 1 addition & 1 deletion clippy_lints/src/infinite_iter.rs
Original file line number Diff line number Diff line change
Expand Up @@ -54,7 +54,7 @@ impl<'tcx> LateLintPass<'tcx> for InfiniteIter {
return;
},
};
span_lint(cx, lint, expr.span, msg)
span_lint(cx, lint, expr.span, msg);
}
}

Expand Down
4 changes: 2 additions & 2 deletions clippy_lints/src/invalid_upcast_comparisons.rs
Original file line number Diff line number Diff line change
Expand Up @@ -177,7 +177,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 {
Expand All @@ -195,7 +195,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);
}
}
}
Expand Down
4 changes: 2 additions & 2 deletions clippy_lints/src/len_zero.rs
Original file line number Diff line number Diff line change
Expand Up @@ -380,9 +380,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);
}
}

Expand Down
8 changes: 4 additions & 4 deletions clippy_lints/src/let_underscore.rs
Original file line number Diff line number Diff line change
Expand Up @@ -135,7 +135,7 @@ impl<'tcx> LateLintPass<'tcx> for LetUnderscore {
None,
"consider using an underscore-prefixed named \
binding or dropping explicitly with `std::mem::drop`"
)
);
} else if init_ty.needs_drop(cx.tcx, cx.param_env) {
span_lint_and_help(
cx,
Expand All @@ -145,7 +145,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,
Expand All @@ -154,7 +154,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,
Expand All @@ -163,7 +163,7 @@ impl<'tcx> LateLintPass<'tcx> for LetUnderscore {
"non-binding let on a result of a `#[must_use]` function",
None,
"consider explicitly using function result"
)
);
}
}
}
Expand Down
2 changes: 1 addition & 1 deletion clippy_lints/src/lib.rs
Original file line number Diff line number Diff line change
Expand Up @@ -1038,7 +1038,6 @@ pub fn register_plugins(store: &mut rustc_lint::LintStore, sess: &Session, conf:
LintId::of(panic_unimplemented::UNIMPLEMENTED),
LintId::of(panic_unimplemented::UNREACHABLE),
LintId::of(pattern_type_mismatch::PATTERN_TYPE_MISMATCH),
LintId::of(semicolon_if_nothing_returned::SEMICOLON_IF_NOTHING_RETURNED),
LintId::of(shadow::SHADOW_REUSE),
LintId::of(shadow::SHADOW_SAME),
LintId::of(strings::STRING_ADD),
Expand Down Expand Up @@ -1129,6 +1128,7 @@ pub fn register_plugins(store: &mut rustc_lint::LintStore, sess: &Session, conf:
LintId::of(ranges::RANGE_PLUS_ONE),
LintId::of(redundant_else::REDUNDANT_ELSE),
LintId::of(ref_option_ref::REF_OPTION_REF),
LintId::of(semicolon_if_nothing_returned::SEMICOLON_IF_NOTHING_RETURNED),
LintId::of(shadow::SHADOW_UNRELATED),
LintId::of(strings::STRING_ADD_ASSIGN),
LintId::of(trait_bounds::TRAIT_DUPLICATION_IN_BOUNDS),
Expand Down
4 changes: 2 additions & 2 deletions clippy_lints/src/lifetimes.rs
Original file line number Diff line number Diff line change
Expand Up @@ -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() {
Expand Down Expand Up @@ -463,7 +463,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> {
Expand Down
Loading

0 comments on commit 513c0eb

Please sign in to comment.