Skip to content

Commit

Permalink
Apply unnecessary_semicolon to Clippy sources
Browse files Browse the repository at this point in the history
  • Loading branch information
samueltardieu committed Jan 19, 2025
1 parent 30209f1 commit 285b4b9
Show file tree
Hide file tree
Showing 76 changed files with 88 additions and 88 deletions.
2 changes: 1 addition & 1 deletion clippy_dev/src/setup/intellij.rs
Original file line number Diff line number Diff line change
Expand Up @@ -62,7 +62,7 @@ fn check_and_get_rustc_dir(rustc_path: &str) -> Result<PathBuf, ()> {
eprintln!("error: unable to get the absolute path of rustc ({err})");
return Err(());
},
};
}
}

let path = path.join("compiler");
Expand Down
2 changes: 1 addition & 1 deletion clippy_dev/src/update_lints.rs
Original file line number Diff line number Diff line change
Expand Up @@ -842,7 +842,7 @@ fn try_rename_file(old_name: &Path, new_name: &Path) -> bool {
Ok(file) => drop(file),
Err(e) if matches!(e.kind(), io::ErrorKind::AlreadyExists | io::ErrorKind::NotFound) => return false,
Err(e) => panic_file(e, new_name, "create"),
};
}
match fs::rename(old_name, new_name) {
Ok(()) => true,
Err(e) => {
Expand Down
2 changes: 1 addition & 1 deletion clippy_lints/src/assigning_clones.rs
Original file line number Diff line number Diff line change
Expand Up @@ -257,7 +257,7 @@ fn build_sugg<'tcx>(
// The receiver may have been a value type, so we need to add an `&` to
// be sure the argument to clone_from will be a reference.
arg_sugg = arg_sugg.addr();
};
}

format!("{receiver_sugg}.clone_from({arg_sugg})")
},
Expand Down
2 changes: 1 addition & 1 deletion clippy_lints/src/attrs/mixed_attributes_style.rs
Original file line number Diff line number Diff line change
Expand Up @@ -60,7 +60,7 @@ pub(super) fn check(cx: &EarlyContext<'_>, item_span: Span, attrs: &[Attribute])
}
outer_attr_kind.insert(kind);
},
};
}
}
}

Expand Down
2 changes: 1 addition & 1 deletion clippy_lints/src/casts/cast_possible_wrap.rs
Original file line number Diff line number Diff line change
Expand Up @@ -84,6 +84,6 @@ pub(super) fn check(cx: &LateContext<'_>, expr: &Expr<'_>, cast_from: Ty<'_>, ca
diag
.note("`usize` and `isize` may be as small as 16 bits on some platforms")
.note("for more information see https://doc.rust-lang.org/reference/types/numeric.html#machine-dependent-integer-types");
};
}
});
}
4 changes: 2 additions & 2 deletions clippy_lints/src/casts/cast_sign_loss.rs
Original file line number Diff line number Diff line change
Expand Up @@ -205,7 +205,7 @@ fn expr_muldiv_sign(cx: &LateContext<'_>, expr: &Expr<'_>) -> Sign {
// - uncertain if there are any uncertain values (because they could be negative or positive),
Sign::Uncertain => return Sign::Uncertain,
Sign::ZeroOrPositive => (),
};
}
}

// A mul/div is:
Expand Down Expand Up @@ -236,7 +236,7 @@ fn expr_add_sign(cx: &LateContext<'_>, expr: &Expr<'_>) -> Sign {
// - uncertain if there are any uncertain values (because they could be negative or positive),
Sign::Uncertain => return Sign::Uncertain,
Sign::ZeroOrPositive => positive_count += 1,
};
}
}

// A sum is:
Expand Down
2 changes: 1 addition & 1 deletion clippy_lints/src/checked_conversions.rs
Original file line number Diff line number Diff line change
Expand Up @@ -273,7 +273,7 @@ fn get_types_from_cast<'a>(
},
_ => {},
}
};
}
None
}

Expand Down
2 changes: 1 addition & 1 deletion clippy_lints/src/default_constructed_unit_structs.rs
Original file line number Diff line number Diff line change
Expand Up @@ -80,6 +80,6 @@ impl LateLintPass<'_> for DefaultConstructedUnitStructs {
String::new(),
Applicability::MachineApplicable,
);
};
}
}
}
2 changes: 1 addition & 1 deletion clippy_lints/src/dereference.rs
Original file line number Diff line number Diff line change
Expand Up @@ -331,7 +331,7 @@ impl<'tcx> LateLintPass<'tcx> for Dereferencing<'tcx> {
deref_count += 1;
},
None => break None,
};
}
};

let use_node = use_cx.use_node(cx);
Expand Down
2 changes: 1 addition & 1 deletion clippy_lints/src/enum_clike.rs
Original file line number Diff line number Diff line change
Expand Up @@ -70,7 +70,7 @@ impl<'tcx> LateLintPass<'tcx> for UnportableVariant {
var.span,
"C-like enum variant discriminant is not portable to 32-bit targets",
);
};
}
}
}
}
Expand Down
2 changes: 1 addition & 1 deletion clippy_lints/src/extra_unused_type_parameters.rs
Original file line number Diff line number Diff line change
Expand Up @@ -183,7 +183,7 @@ impl<'cx, 'tcx> TypeWalker<'cx, 'tcx> {
.collect()
};
self.emit_sugg(spans, msg, help);
};
}
}
}

Expand Down
2 changes: 1 addition & 1 deletion clippy_lints/src/functions/impl_trait_in_params.rs
Original file line number Diff line number Diff line change
Expand Up @@ -45,7 +45,7 @@ pub(super) fn check_fn<'tcx>(cx: &LateContext<'_>, kind: &'tcx FnKind<'_>, body:
for param in generics.params {
if param.is_impl_trait() {
report(cx, param, generics);
};
}
}
}
}
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 @@ -160,7 +160,7 @@ fn check_needless_must_use(
&& !is_must_use_ty(cx, future_ty)
{
return;
};
}
}

span_lint_and_help(
Expand Down
2 changes: 1 addition & 1 deletion clippy_lints/src/implicit_saturating_add.rs
Original file line number Diff line number Diff line change
Expand Up @@ -120,7 +120,7 @@ fn get_const<'tcx>(cx: &LateContext<'tcx>, expr: &Expr<'tcx>) -> Option<(u128, B
let ecx = ConstEvalCtxt::new(cx);
if let Some(Constant::Int(c)) = ecx.eval(r) {
return Some((c, op.node, l));
};
}
if let Some(Constant::Int(c)) = ecx.eval(l) {
return Some((c, invert_op(op.node)?, r));
}
Expand Down
2 changes: 1 addition & 1 deletion clippy_lints/src/implicit_saturating_sub.rs
Original file line number Diff line number Diff line change
Expand Up @@ -350,7 +350,7 @@ fn check_with_condition<'tcx>(
if cx.typeck_results().expr_ty(cond_left).is_signed() {
} else {
print_lint_and_sugg(cx, var_name, expr);
};
}
}
},
ExprKind::Path(QPath::TypeRelative(_, name)) => {
Expand Down
2 changes: 1 addition & 1 deletion clippy_lints/src/iter_over_hash_type.rs
Original file line number Diff line number Diff line change
Expand Up @@ -65,6 +65,6 @@ impl LateLintPass<'_> for IterOverHashType {
expr.span,
"iteration over unordered hash-based type",
);
};
}
}
}
2 changes: 1 addition & 1 deletion clippy_lints/src/let_with_type_underscore.rs
Original file line number Diff line number Diff line change
Expand Up @@ -41,6 +41,6 @@ impl<'tcx> LateLintPass<'tcx> for UnderscoreTyped {
Some(ty.span.with_lo(local.pat.span.hi())),
"remove the explicit type `_` declaration",
);
};
}
}
}
2 changes: 1 addition & 1 deletion clippy_lints/src/lifetimes.rs
Original file line number Diff line number Diff line change
Expand Up @@ -784,7 +784,7 @@ fn report_elidable_lifetimes(
|diag| {
if !include_suggestions {
return;
};
}

if let Some(suggestions) = elision_suggestions(cx, generics, elidable_lts, usages) {
diag.multipart_suggestion("elide the lifetimes", suggestions, Applicability::MachineApplicable);
Expand Down
2 changes: 1 addition & 1 deletion clippy_lints/src/literal_representation.rs
Original file line number Diff line number Diff line change
Expand Up @@ -251,7 +251,7 @@ impl LiteralDigitGrouping {
);
if !consistent {
return Err(WarningType::InconsistentDigitGrouping);
};
}
}

Ok(())
Expand Down
4 changes: 2 additions & 2 deletions clippy_lints/src/manual_let_else.rs
Original file line number Diff line number Diff line change
Expand Up @@ -106,7 +106,7 @@ impl<'tcx> QuestionMark {
emit_manual_let_else(cx, stmt.span, match_expr, &ident_map, pat_arm.pat, diverging_arm.body);
},
}
};
}
}
}

Expand Down Expand Up @@ -295,7 +295,7 @@ fn pat_allowed_for_else(cx: &LateContext<'_>, pat: &'_ Pat<'_>, check_types: boo
PatKind::Struct(..) | PatKind::TupleStruct(..) | PatKind::Path(..)
) {
return;
};
}
let ty = typeck_results.pat_ty(pat);
// Option and Result are allowed, everything else isn't.
if !(is_type_diagnostic_item(cx, ty, sym::Option) || is_type_diagnostic_item(cx, ty, sym::Result)) {
Expand Down
2 changes: 1 addition & 1 deletion clippy_lints/src/manual_rem_euclid.rs
Original file line number Diff line number Diff line change
Expand Up @@ -85,7 +85,7 @@ impl<'tcx> LateLintPass<'tcx> for ManualRemEuclid {
}
},
_ => return,
};
}

let mut app = Applicability::MachineApplicable;
let rem_of = snippet_with_context(cx, rem2_lhs.span, ctxt, "_", &mut app).0;
Expand Down
2 changes: 1 addition & 1 deletion clippy_lints/src/manual_strip.rs
Original file line number Diff line number Diff line change
Expand Up @@ -86,7 +86,7 @@ impl<'tcx> LateLintPass<'tcx> for ManualStrip {
let target_res = cx.qpath_res(target_path, target_arg.hir_id);
if target_res == Res::Err {
return;
};
}

if let Res::Local(hir_id) = target_res
&& let Some(used_mutably) = mutated_variables(then, cx)
Expand Down
8 changes: 4 additions & 4 deletions clippy_lints/src/matches/manual_filter.rs
Original file line number Diff line number Diff line change
Expand Up @@ -34,7 +34,7 @@ fn get_cond_expr<'tcx>(
needs_negated: is_none_expr(cx, then_expr), /* if the `then_expr` resolves to `None`, need to negate the
* cond */
});
};
}
None
}

Expand All @@ -45,7 +45,7 @@ fn peels_blocks_incl_unsafe_opt<'a>(expr: &'a Expr<'a>) -> Option<&'a Expr<'a>>
if block.stmts.is_empty() {
return block.expr;
}
};
}
None
}

Expand All @@ -68,14 +68,14 @@ fn is_some_expr(cx: &LateContext<'_>, target: HirId, ctxt: SyntaxContext, expr:
&& is_res_lang_ctor(cx, path_res(cx, callee), OptionSome)
&& path_to_local_id(arg, target);
}
};
}
false
}

fn is_none_expr(cx: &LateContext<'_>, expr: &Expr<'_>) -> bool {
if let Some(inner_expr) = peels_blocks_incl_unsafe_opt(expr) {
return is_res_lang_ctor(cx, path_res(cx, inner_expr), OptionNone);
};
}
false
}

Expand Down
2 changes: 1 addition & 1 deletion clippy_lints/src/matches/manual_utils.rs
Original file line number Diff line number Diff line change
Expand Up @@ -109,7 +109,7 @@ where
}
},
None => return None,
};
}

let mut app = Applicability::MachineApplicable;

Expand Down
2 changes: 1 addition & 1 deletion clippy_lints/src/matches/match_like_matches.rs
Original file line number Diff line number Diff line change
Expand Up @@ -117,7 +117,7 @@ where
if let ty::Ref(..) = cx.typeck_results().expr_ty(ex_inner).kind() {
ex_new = ex_inner;
}
};
}
span_lint_and_sugg(
cx,
MATCH_LIKE_MATCHES_MACRO,
Expand Down
2 changes: 1 addition & 1 deletion clippy_lints/src/matches/match_wild_enum.rs
Original file line number Diff line number Diff line change
Expand Up @@ -170,7 +170,7 @@ pub(crate) fn check(cx: &LateContext<'_>, ex: &Expr<'_>, arms: &[Arm<'_>]) {
);
});
},
};
}
}

enum CommonPrefixSearcher<'a> {
Expand Down
2 changes: 1 addition & 1 deletion clippy_lints/src/matches/try_err.rs
Original file line number Diff line number Diff line change
Expand Up @@ -46,7 +46,7 @@ pub(super) fn check<'tcx>(cx: &LateContext<'tcx>, expr: &'tcx Expr<'_>, scrutine
err_ty = ty;
} else {
return;
};
}

span_lint_and_then(
cx,
Expand Down
2 changes: 1 addition & 1 deletion clippy_lints/src/matches/wild_in_or_pats.rs
Original file line number Diff line number Diff line change
Expand Up @@ -13,7 +13,7 @@ pub(crate) fn check(cx: &LateContext<'_>, expr: &Expr<'_>, arms: &[Arm<'_>]) {
&& has_non_exhaustive_attr(cx.tcx, *adt_def)
{
return;
};
}
for arm in arms {
if let PatKind::Or(fields) = arm.pat.kind {
// look for multiple fields in this arm that contains at least one Wild pattern
Expand Down
2 changes: 1 addition & 1 deletion clippy_lints/src/methods/bytecount.rs
Original file line number Diff line number Diff line change
Expand Up @@ -62,5 +62,5 @@ pub(super) fn check<'tcx>(
),
applicability,
);
};
}
}
2 changes: 1 addition & 1 deletion clippy_lints/src/methods/bytes_count_to_len.rs
Original file line number Diff line number Diff line change
Expand Up @@ -32,5 +32,5 @@ pub(super) fn check<'tcx>(
),
applicability,
);
};
}
}
2 changes: 1 addition & 1 deletion clippy_lints/src/methods/bytes_nth.rs
Original file line number Diff line number Diff line change
Expand Up @@ -46,5 +46,5 @@ pub(super) fn check<'tcx>(cx: &LateContext<'tcx>, expr: &Expr<'_>, recv: &'tcx E
format!("{receiver}.as_bytes().get({n}).copied()"),
applicability,
);
};
}
}
2 changes: 1 addition & 1 deletion clippy_lints/src/methods/cloned_instead_of_copied.rs
Original file line number Diff line number Diff line change
Expand Up @@ -32,7 +32,7 @@ pub fn check(cx: &LateContext<'_>, expr: &Expr<'_>, recv: &Expr<'_>, span: Span,
// &T where T: Copy
ty::Ref(_, ty, _) if is_copy(cx, *ty) => {},
_ => return,
};
}
span_lint_and_sugg(
cx,
CLONED_INSTEAD_OF_COPIED,
Expand Down
2 changes: 1 addition & 1 deletion clippy_lints/src/methods/err_expect.rs
Original file line number Diff line number Diff line change
Expand Up @@ -37,7 +37,7 @@ pub(super) fn check(
"expect_err".to_string(),
Applicability::MachineApplicable,
);
};
}
}

/// Given a `Result<T, E>` type, return its data (`T`).
Expand Down
2 changes: 1 addition & 1 deletion clippy_lints/src/methods/expect_fun_call.rs
Original file line number Diff line number Diff line change
Expand Up @@ -58,7 +58,7 @@ pub(super) fn check<'tcx>(
if ty.is_str() && can_be_static_str(cx, arg) {
return false;
}
};
}
true
}

Expand Down
2 changes: 1 addition & 1 deletion clippy_lints/src/methods/iter_with_drain.rs
Original file line number Diff line number Diff line change
Expand Up @@ -25,5 +25,5 @@ pub(super) fn check(cx: &LateContext<'_>, expr: &Expr<'_>, recv: &Expr<'_>, span
"into_iter()".to_string(),
Applicability::MaybeIncorrect,
);
};
}
}
2 changes: 1 addition & 1 deletion clippy_lints/src/methods/path_ends_with_ext.rs
Original file line number Diff line number Diff line change
Expand Up @@ -37,7 +37,7 @@ pub(super) fn check(
let _ = write!(sugg, r#".extension().is_some_and(|ext| ext == "{path}")"#);
} else {
let _ = write!(sugg, r#".extension().map_or(false, |ext| ext == "{path}")"#);
};
}

span_lint_and_sugg(
cx,
Expand Down
2 changes: 1 addition & 1 deletion clippy_lints/src/methods/unnecessary_iter_cloned.rs
Original file line number Diff line number Diff line change
Expand Up @@ -87,7 +87,7 @@ pub fn check_for_loop_iter(
// skip lint
return true;
}
};
}

// the lint should not be executed if no violation happens
let snippet = if let ExprKind::MethodCall(maybe_iter_method_name, collection, [], _) = receiver.kind
Expand Down
4 changes: 2 additions & 2 deletions clippy_lints/src/misc.rs
Original file line number Diff line number Diff line change
Expand Up @@ -214,7 +214,7 @@ impl<'tcx> LateLintPass<'tcx> for LintPass {
);
},
);
};
}
if let StmtKind::Semi(expr) = stmt.kind
&& let ExprKind::Binary(ref binop, a, b) = expr.kind
&& (binop.node == BinOpKind::And || binop.node == BinOpKind::Or)
Expand All @@ -236,7 +236,7 @@ impl<'tcx> LateLintPass<'tcx> for LintPass {
);
},
);
};
}
}

fn check_expr(&mut self, cx: &LateContext<'tcx>, expr: &'tcx Expr<'_>) {
Expand Down
2 changes: 1 addition & 1 deletion clippy_lints/src/mismatching_type_param_order.rs
Original file line number Diff line number Diff line change
Expand Up @@ -66,7 +66,7 @@ impl<'tcx> LateLintPass<'tcx> for TypeParamMismatch {
}) => impl_params.push((path.segments[0].ident.to_string(), path.span)),
GenericArg::Type(_) => return,
_ => (),
};
}
}

// find the type that the Impl is for
Expand Down
Loading

0 comments on commit 285b4b9

Please sign in to comment.