Skip to content

Commit 1d33469

Browse files
committed
Auto merge of rust-lang#11157 - flip1995:rustup, r=flip1995
Rustup r? `@ghost` changelog: none
2 parents bafde54 + 753c30f commit 1d33469

File tree

92 files changed

+503
-474
lines changed

Some content is hidden

Large Commits have some content hidden by default. Use the searchbox below for content that may be hidden.

92 files changed

+503
-474
lines changed

Cargo.toml

+1-1
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
11
[package]
22
name = "clippy"
3-
version = "0.1.72"
3+
version = "0.1.73"
44
description = "A bunch of helpful lints to avoid common pitfalls in Rust"
55
repository = "https://github.com/rust-lang/rust-clippy"
66
readme = "README.md"

clippy_dev/src/setup/intellij.rs

+1-1
Original file line numberDiff line numberDiff line change
@@ -37,7 +37,7 @@ impl ClippyProjectInfo {
3737

3838
pub fn setup_rustc_src(rustc_path: &str) {
3939
let Ok(rustc_source_dir) = check_and_get_rustc_dir(rustc_path) else {
40-
return
40+
return;
4141
};
4242

4343
for project in CLIPPY_PROJECTS {

clippy_dev/src/update_lints.rs

+4-1
Original file line numberDiff line numberDiff line change
@@ -340,7 +340,10 @@ pub fn deprecate(name: &str, reason: Option<&String>) {
340340
let name_upper = name.to_uppercase();
341341

342342
let (mut lints, deprecated_lints, renamed_lints) = gather_all();
343-
let Some(lint) = lints.iter().find(|l| l.name == name_lower) else { eprintln!("error: failed to find lint `{name}`"); return; };
343+
let Some(lint) = lints.iter().find(|l| l.name == name_lower) else {
344+
eprintln!("error: failed to find lint `{name}`");
345+
return;
346+
};
344347

345348
let mod_path = {
346349
let mut mod_path = PathBuf::from(format!("clippy_lints/src/{}", lint.module));

clippy_lints/Cargo.toml

+1-1
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
11
[package]
22
name = "clippy_lints"
3-
version = "0.1.72"
3+
version = "0.1.73"
44
description = "A bunch of helpful lints to avoid common pitfalls in Rust"
55
repository = "https://github.com/rust-lang/rust-clippy"
66
readme = "README.md"

clippy_lints/src/assertions_on_constants.rs

+9-3
Original file line numberDiff line numberDiff line change
@@ -31,14 +31,20 @@ declare_lint_pass!(AssertionsOnConstants => [ASSERTIONS_ON_CONSTANTS]);
3131

3232
impl<'tcx> LateLintPass<'tcx> for AssertionsOnConstants {
3333
fn check_expr(&mut self, cx: &LateContext<'tcx>, e: &'tcx Expr<'_>) {
34-
let Some(macro_call) = root_macro_call_first_node(cx, e) else { return };
34+
let Some(macro_call) = root_macro_call_first_node(cx, e) else {
35+
return;
36+
};
3537
let is_debug = match cx.tcx.get_diagnostic_name(macro_call.def_id) {
3638
Some(sym::debug_assert_macro) => true,
3739
Some(sym::assert_macro) => false,
3840
_ => return,
3941
};
40-
let Some((condition, panic_expn)) = find_assert_args(cx, e, macro_call.expn) else { return };
41-
let Some(Constant::Bool(val)) = constant(cx, cx.typeck_results(), condition) else { return };
42+
let Some((condition, panic_expn)) = find_assert_args(cx, e, macro_call.expn) else {
43+
return;
44+
};
45+
let Some(Constant::Bool(val)) = constant(cx, cx.typeck_results(), condition) else {
46+
return;
47+
};
4248
if val {
4349
span_lint_and_help(
4450
cx,

clippy_lints/src/bool_assert_comparison.rs

+10-4
Original file line numberDiff line numberDiff line change
@@ -61,7 +61,7 @@ fn is_impl_not_trait_with_bool_out<'tcx>(cx: &LateContext<'tcx>, ty: Ty<'tcx>) -
6161
)
6262
})
6363
.map_or(false, |assoc_item| {
64-
let proj = cx.tcx.mk_projection(assoc_item.def_id, cx.tcx.mk_substs_trait(ty, []));
64+
let proj = Ty::new_projection(cx.tcx, assoc_item.def_id, cx.tcx.mk_substs_trait(ty, []));
6565
let nty = cx.tcx.normalize_erasing_regions(cx.param_env, proj);
6666

6767
nty.is_bool()
@@ -70,14 +70,18 @@ fn is_impl_not_trait_with_bool_out<'tcx>(cx: &LateContext<'tcx>, ty: Ty<'tcx>) -
7070

7171
impl<'tcx> LateLintPass<'tcx> for BoolAssertComparison {
7272
fn check_expr(&mut self, cx: &LateContext<'tcx>, expr: &'tcx Expr<'_>) {
73-
let Some(macro_call) = root_macro_call_first_node(cx, expr) else { return };
73+
let Some(macro_call) = root_macro_call_first_node(cx, expr) else {
74+
return;
75+
};
7476
let macro_name = cx.tcx.item_name(macro_call.def_id);
7577
let eq_macro = match macro_name.as_str() {
7678
"assert_eq" | "debug_assert_eq" => true,
7779
"assert_ne" | "debug_assert_ne" => false,
7880
_ => return,
7981
};
80-
let Some ((a, b, _)) = find_assert_eq_args(cx, expr, macro_call.expn) else { return };
82+
let Some((a, b, _)) = find_assert_eq_args(cx, expr, macro_call.expn) else {
83+
return;
84+
};
8185

8286
let a_span = a.span.source_callsite();
8387
let b_span = b.span.source_callsite();
@@ -126,7 +130,9 @@ impl<'tcx> LateLintPass<'tcx> for BoolAssertComparison {
126130
let mut suggestions = vec![(name_span, non_eq_mac.to_string()), (lit_span, String::new())];
127131

128132
if bool_value ^ eq_macro {
129-
let Some(sugg) = Sugg::hir_opt(cx, non_lit_expr) else { return };
133+
let Some(sugg) = Sugg::hir_opt(cx, non_lit_expr) else {
134+
return;
135+
};
130136
suggestions.push((non_lit_expr.span, (!sugg).to_string()));
131137
}
132138

clippy_lints/src/dbg_macro.rs

+3-1
Original file line numberDiff line numberDiff line change
@@ -71,7 +71,9 @@ impl DbgMacro {
7171

7272
impl LateLintPass<'_> for DbgMacro {
7373
fn check_expr(&mut self, cx: &LateContext<'_>, expr: &Expr<'_>) {
74-
let Some(macro_call) = root_macro_call_first_node(cx, expr) else { return };
74+
let Some(macro_call) = root_macro_call_first_node(cx, expr) else {
75+
return;
76+
};
7577
if cx.tcx.is_diagnostic_item(sym::dbg_macro, macro_call.def_id) {
7678
// allows `dbg!` in test code if allow-dbg-in-test is set to true in clippy.toml
7779
if self.allow_dbg_in_tests

clippy_lints/src/declared_lints.rs

-1
Original file line numberDiff line numberDiff line change
@@ -171,7 +171,6 @@ pub(crate) static LINTS: &[&crate::LintInfo] = &[
171171
crate::float_literal::LOSSY_FLOAT_LITERAL_INFO,
172172
crate::floating_point_arithmetic::IMPRECISE_FLOPS_INFO,
173173
crate::floating_point_arithmetic::SUBOPTIMAL_FLOPS_INFO,
174-
crate::fn_null_check::FN_NULL_CHECK_INFO,
175174
crate::format::USELESS_FORMAT_INFO,
176175
crate::format_args::FORMAT_IN_FORMAT_ARGS_INFO,
177176
crate::format_args::TO_STRING_IN_FORMAT_ARGS_INFO,

clippy_lints/src/dereference.rs

+3-1
Original file line numberDiff line numberDiff line change
@@ -1129,7 +1129,9 @@ fn needless_borrow_impl_arg_position<'tcx>(
11291129
let destruct_trait_def_id = cx.tcx.lang_items().destruct_trait();
11301130
let sized_trait_def_id = cx.tcx.lang_items().sized_trait();
11311131

1132-
let Some(callee_def_id) = fn_def_id(cx, parent) else { return Position::Other(precedence) };
1132+
let Some(callee_def_id) = fn_def_id(cx, parent) else {
1133+
return Position::Other(precedence);
1134+
};
11331135
let fn_sig = cx.tcx.fn_sig(callee_def_id).subst_identity().skip_binder();
11341136
let substs_with_expr_ty = cx
11351137
.typeck_results()

clippy_lints/src/derivable_impls.rs

+2-2
Original file line numberDiff line numberDiff line change
@@ -8,7 +8,7 @@ use rustc_hir::{
88
self as hir, Body, Expr, ExprKind, GenericArg, Impl, ImplItemKind, Item, ItemKind, Node, PathSegment, QPath, TyKind,
99
};
1010
use rustc_lint::{LateContext, LateLintPass};
11-
use rustc_middle::ty::adjustment::{Adjust, PointerCast};
11+
use rustc_middle::ty::adjustment::{Adjust, PointerCoercion};
1212
use rustc_middle::ty::{self, Adt, AdtDef, SubstsRef, Ty, TypeckResults};
1313
use rustc_session::{declare_tool_lint, impl_lint_pass};
1414
use rustc_span::sym;
@@ -115,7 +115,7 @@ fn check_struct<'tcx>(
115115
let is_default_without_adjusts = |expr| {
116116
is_default_equivalent(cx, expr)
117117
&& typeck_results.expr_adjustments(expr).iter().all(|adj| {
118-
!matches!(adj.kind, Adjust::Pointer(PointerCast::Unsize)
118+
!matches!(adj.kind, Adjust::Pointer(PointerCoercion::Unsize)
119119
if contains_trait_object(adj.target))
120120
})
121121
};

clippy_lints/src/derive.rs

+6-4
Original file line numberDiff line numberDiff line change
@@ -333,7 +333,9 @@ fn check_copy_clone<'tcx>(cx: &LateContext<'tcx>, item: &Item<'_>, trait_ref: &h
333333
Some(id) if trait_ref.trait_def_id() == Some(id) => id,
334334
_ => return,
335335
};
336-
let Some(copy_id) = cx.tcx.lang_items().copy_trait() else { return };
336+
let Some(copy_id) = cx.tcx.lang_items().copy_trait() else {
337+
return;
338+
};
337339
let (ty_adt, ty_subs) = match *ty.kind() {
338340
// Unions can't derive clone.
339341
ty::Adt(adt, subs) if !adt.is_union() => (adt, subs),
@@ -344,9 +346,9 @@ fn check_copy_clone<'tcx>(cx: &LateContext<'tcx>, item: &Item<'_>, trait_ref: &h
344346
if !is_copy(cx, ty) {
345347
if ty_subs.non_erasable_generics().next().is_some() {
346348
let has_copy_impl = cx.tcx.all_local_trait_impls(()).get(&copy_id).map_or(false, |impls| {
347-
impls
348-
.iter()
349-
.any(|&id| matches!(cx.tcx.type_of(id).subst_identity().kind(), ty::Adt(adt, _) if ty_adt.did() == adt.did()))
349+
impls.iter().any(|&id| {
350+
matches!(cx.tcx.type_of(id).subst_identity().kind(), ty::Adt(adt, _) if ty_adt.did() == adt.did())
351+
})
350352
});
351353
if !has_copy_impl {
352354
return;

clippy_lints/src/disallowed_methods.rs

+1-1
Original file line numberDiff line numberDiff line change
@@ -94,7 +94,7 @@ impl<'tcx> LateLintPass<'tcx> for DisallowedMethods {
9494
path_def_id(cx, expr)
9595
};
9696
let Some(def_id) = uncalled_path.or_else(|| fn_def_id(cx, expr)) else {
97-
return
97+
return;
9898
};
9999
let conf = match self.disallowed.get(&def_id) {
100100
Some(&index) => &self.conf_disallowed[index],

clippy_lints/src/doc.rs

+9-3
Original file line numberDiff line numberDiff line change
@@ -294,7 +294,9 @@ impl<'tcx> LateLintPass<'tcx> for DocMarkdown {
294294

295295
fn check_item(&mut self, cx: &LateContext<'tcx>, item: &'tcx hir::Item<'_>) {
296296
let attrs = cx.tcx.hir().attrs(item.hir_id());
297-
let Some(headers) = check_attrs(cx, &self.valid_idents, attrs) else { return };
297+
let Some(headers) = check_attrs(cx, &self.valid_idents, attrs) else {
298+
return;
299+
};
298300
match item.kind {
299301
hir::ItemKind::Fn(ref sig, _, body_id) => {
300302
if !(is_entrypoint_fn(cx, item.owner_id.to_def_id()) || in_external_macro(cx.tcx.sess, item.span)) {
@@ -338,7 +340,9 @@ impl<'tcx> LateLintPass<'tcx> for DocMarkdown {
338340

339341
fn check_trait_item(&mut self, cx: &LateContext<'tcx>, item: &'tcx hir::TraitItem<'_>) {
340342
let attrs = cx.tcx.hir().attrs(item.hir_id());
341-
let Some(headers) = check_attrs(cx, &self.valid_idents, attrs) else { return };
343+
let Some(headers) = check_attrs(cx, &self.valid_idents, attrs) else {
344+
return;
345+
};
342346
if let hir::TraitItemKind::Fn(ref sig, ..) = item.kind {
343347
if !in_external_macro(cx.tcx.sess, item.span) {
344348
lint_for_missing_headers(cx, item.owner_id, sig, headers, None, None);
@@ -348,7 +352,9 @@ impl<'tcx> LateLintPass<'tcx> for DocMarkdown {
348352

349353
fn check_impl_item(&mut self, cx: &LateContext<'tcx>, item: &'tcx hir::ImplItem<'_>) {
350354
let attrs = cx.tcx.hir().attrs(item.hir_id());
351-
let Some(headers) = check_attrs(cx, &self.valid_idents, attrs) else { return };
355+
let Some(headers) = check_attrs(cx, &self.valid_idents, attrs) else {
356+
return;
357+
};
352358
if self.in_trait_impl || in_external_macro(cx.tcx.sess, item.span) {
353359
return;
354360
}

clippy_lints/src/entry.rs

+9-4
Original file line numberDiff line numberDiff line change
@@ -65,16 +65,21 @@ impl<'tcx> LateLintPass<'tcx> for HashMapPass {
6565
return;
6666
}
6767

68-
let Some(higher::If { cond: cond_expr, then: then_expr, r#else: else_expr }) = higher::If::hir(expr) else {
69-
return
68+
let Some(higher::If {
69+
cond: cond_expr,
70+
then: then_expr,
71+
r#else: else_expr,
72+
}) = higher::If::hir(expr)
73+
else {
74+
return;
7075
};
7176

7277
let Some((map_ty, contains_expr)) = try_parse_contains(cx, cond_expr) else {
73-
return
78+
return;
7479
};
7580

7681
let Some(then_search) = find_insert_calls(cx, &contains_expr, then_expr) else {
77-
return
82+
return;
7883
};
7984

8085
let mut app = Applicability::MachineApplicable;

clippy_lints/src/fn_null_check.rs

-102
This file was deleted.

clippy_lints/src/format.rs

+3-1
Original file line numberDiff line numberDiff line change
@@ -43,7 +43,9 @@ declare_lint_pass!(UselessFormat => [USELESS_FORMAT]);
4343

4444
impl<'tcx> LateLintPass<'tcx> for UselessFormat {
4545
fn check_expr(&mut self, cx: &LateContext<'tcx>, expr: &'tcx Expr<'_>) {
46-
let Some(macro_call) = root_macro_call_first_node(cx, expr) else { return };
46+
let Some(macro_call) = root_macro_call_first_node(cx, expr) else {
47+
return;
48+
};
4749
if !cx.tcx.is_diagnostic_item(sym::format_macro, macro_call.def_id) {
4850
return;
4951
}

clippy_lints/src/format_args.rs

+3-1
Original file line numberDiff line numberDiff line change
@@ -186,7 +186,9 @@ impl FormatArgs {
186186

187187
impl<'tcx> LateLintPass<'tcx> for FormatArgs {
188188
fn check_expr(&mut self, cx: &LateContext<'tcx>, expr: &'tcx Expr<'tcx>) {
189-
let Some(macro_call) = root_macro_call_first_node(cx, expr) else { return };
189+
let Some(macro_call) = root_macro_call_first_node(cx, expr) else {
190+
return;
191+
};
190192
if !is_format_macro(cx, macro_call.def_id) {
191193
return;
192194
}

clippy_lints/src/format_impl.rs

+3-1
Original file line numberDiff line numberDiff line change
@@ -127,7 +127,9 @@ impl<'tcx> LateLintPass<'tcx> for FormatImpl {
127127
}
128128

129129
fn check_expr(&mut self, cx: &LateContext<'tcx>, expr: &'tcx Expr<'_>) {
130-
let Some(format_trait_impl) = self.format_trait_impl else { return };
130+
let Some(format_trait_impl) = self.format_trait_impl else {
131+
return;
132+
};
131133

132134
if format_trait_impl.name == sym::Display {
133135
check_to_string_in_display(cx, expr);

clippy_lints/src/from_over_into.rs

+6-2
Original file line numberDiff line numberDiff line change
@@ -164,10 +164,14 @@ fn convert_to_from(
164164
return None;
165165
}
166166
let impl_item = cx.tcx.hir().impl_item(impl_item_ref.id);
167-
let ImplItemKind::Fn(ref sig, body_id) = impl_item.kind else { return None };
167+
let ImplItemKind::Fn(ref sig, body_id) = impl_item.kind else {
168+
return None;
169+
};
168170
let body = cx.tcx.hir().body(body_id);
169171
let [input] = body.params else { return None };
170-
let PatKind::Binding(.., self_ident, None) = input.pat.kind else { return None };
172+
let PatKind::Binding(.., self_ident, None) = input.pat.kind else {
173+
return None;
174+
};
171175

172176
let from = snippet_opt(cx, self_ty.span)?;
173177
let into = snippet_opt(cx, target_ty.span)?;

0 commit comments

Comments
 (0)