Skip to content

Commit 14f55fa

Browse files
committed
Merge commit '9e3cd88718cd1912a515d26dbd9c4019fd5a9577' into clippyup
2 parents 5ab0f37 + 9e3cd88 commit 14f55fa

File tree

80 files changed

+2329
-668
lines changed

Some content is hidden

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

80 files changed

+2329
-668
lines changed

src/tools/clippy/.cargo/config

+1
Original file line numberDiff line numberDiff line change
@@ -2,6 +2,7 @@
22
uitest = "test --test compile-test"
33
dev = "run --target-dir clippy_dev/target --package clippy_dev --bin clippy_dev --manifest-path clippy_dev/Cargo.toml --"
44
lintcheck = "run --target-dir lintcheck/target --package lintcheck --bin lintcheck --manifest-path lintcheck/Cargo.toml -- "
5+
collect-metadata = "test --test dogfood --features metadata-collector-lint -- run_metadata_collection_lint --ignored"
56

67
[build]
78
rustflags = ["-Zunstable-options"]

src/tools/clippy/.github/workflows/clippy_bors.yml

+5
Original file line numberDiff line numberDiff line change
@@ -90,6 +90,11 @@ jobs:
9090
- name: Checkout
9191
uses: actions/[email protected]
9292

93+
# FIXME: should not be necessary once 1.24.2 is the default version on the windows runner
94+
- name: Update rustup
95+
run: rustup self update
96+
if: runner.os == 'Windows'
97+
9398
- name: Install toolchain
9499
run: rustup show active-toolchain
95100

src/tools/clippy/CHANGELOG.md

+192-6
Original file line numberDiff line numberDiff line change
@@ -6,11 +6,195 @@ document.
66

77
## Unreleased / In Rust Nightly
88

9-
[6ed6f1e...master](https://github.com/rust-lang/rust-clippy/compare/6ed6f1e...master)
9+
[7c7683c...master](https://github.com/rust-lang/rust-clippy/compare/7c7683c...master)
10+
11+
## Rust 1.53
12+
13+
Current beta, release 2021-06-17
14+
15+
[6ed6f1e...7c7683c](https://github.com/rust-lang/rust-clippy/compare/6ed6f1e...7c7683c)
16+
17+
### New Lints
18+
19+
* [`option_filter_map`]
20+
[#6342](https://github.com/rust-lang/rust-clippy/pull/6342)
21+
* [`branches_sharing_code`]
22+
[#6463](https://github.com/rust-lang/rust-clippy/pull/6463)
23+
* [`needless_for_each`]
24+
[#6706](https://github.com/rust-lang/rust-clippy/pull/6706)
25+
* [`if_then_some_else_none`]
26+
[#6859](https://github.com/rust-lang/rust-clippy/pull/6859)
27+
* [`non_octal_unix_permissions`]
28+
[#7001](https://github.com/rust-lang/rust-clippy/pull/7001)
29+
* [`unnecessary_self_imports`]
30+
[#7072](https://github.com/rust-lang/rust-clippy/pull/7072)
31+
* [`bool_assert_comparison`]
32+
[#7083](https://github.com/rust-lang/rust-clippy/pull/7083)
33+
* [`cloned_instead_of_copied`]
34+
[#7098](https://github.com/rust-lang/rust-clippy/pull/7098)
35+
* [`flat_map_option`]
36+
[#7101](https://github.com/rust-lang/rust-clippy/pull/7101)
37+
38+
### Moves and Deprecations
39+
40+
* Deprecate [`filter_map`] lint
41+
[#7059](https://github.com/rust-lang/rust-clippy/pull/7059)
42+
* Move [`transmute_ptr_to_ptr`] to `pedantic`
43+
[#7102](https://github.com/rust-lang/rust-clippy/pull/7102)
44+
45+
### Enhancements
46+
47+
* [`mem_replace_with_default`]: Also lint on common std constructors
48+
[#6820](https://github.com/rust-lang/rust-clippy/pull/6820)
49+
* [`wrong_self_convention`]: Also lint on `to_*_mut` methods
50+
[#6828](https://github.com/rust-lang/rust-clippy/pull/6828)
51+
* [`wildcard_enum_match_arm`], [`match_wildcard_for_single_variants`]:
52+
[#6863](https://github.com/rust-lang/rust-clippy/pull/6863)
53+
* Attempt to find a common path prefix in suggestion
54+
* Don't lint on `Option` and `Result`
55+
* Consider `Self` prefix
56+
* [`explicit_deref_methods`]: Also lint on chained `deref` calls
57+
[#6865](https://github.com/rust-lang/rust-clippy/pull/6865)
58+
* [`or_fun_call`]: Also lint on `unsafe` blocks
59+
[#6928](https://github.com/rust-lang/rust-clippy/pull/6928)
60+
* [`vec_box`], [`linkedlist`], [`option_option`]: Also lint in `const` and
61+
`static` items [#6938](https://github.com/rust-lang/rust-clippy/pull/6938)
62+
* [`search_is_some`]: Also check for `is_none`
63+
[#6942](https://github.com/rust-lang/rust-clippy/pull/6942)
64+
* [`string_lit_as_bytes`]: Also lint on `into_bytes`
65+
[#6959](https://github.com/rust-lang/rust-clippy/pull/6959)
66+
* [`len_without_is_empty`]: Also lint if function signatures of `len` and
67+
`is_empty` don't match
68+
[#6980](https://github.com/rust-lang/rust-clippy/pull/6980)
69+
* [`redundant_pattern_matching`]: Also lint if the pattern is a `&` pattern
70+
[#6991](https://github.com/rust-lang/rust-clippy/pull/6991)
71+
* [`clone_on_copy`]: Also lint on chained method calls taking `self` by value
72+
[#7000](https://github.com/rust-lang/rust-clippy/pull/7000)
73+
* [`missing_panics_doc`]: Also lint on `assert_eq!` and `assert_ne!`
74+
[#7029](https://github.com/rust-lang/rust-clippy/pull/7029)
75+
* [`needless_return`]: Also lint in `async` functions
76+
[#7067](https://github.com/rust-lang/rust-clippy/pull/7067)
77+
* [`unused_io_amount`]: Also lint on expressions like `_.read().ok()?`
78+
[#7100](https://github.com/rust-lang/rust-clippy/pull/7100)
79+
* [`iter_cloned_collect`]: Also lint on large arrays, since const-generics are
80+
now stable [#7138](https://github.com/rust-lang/rust-clippy/pull/7138)
81+
82+
### False Positive Fixes
83+
84+
* [`upper_case_acronyms`]: No longer lints on public items
85+
[#6805](https://github.com/rust-lang/rust-clippy/pull/6805)
86+
* [`suspicious_map`]: No longer lints when side effects may occur inside the
87+
`map` call [#6831](https://github.com/rust-lang/rust-clippy/pull/6831)
88+
* [`manual_map`], [`manual_unwrap_or`]: No longer lints in `const` functions
89+
[#6917](https://github.com/rust-lang/rust-clippy/pull/6917)
90+
* [`wrong_self_convention`]: Now respects `Copy` types
91+
[#6924](https://github.com/rust-lang/rust-clippy/pull/6924)
92+
* [`needless_question_mark`]: No longer lints if the `?` and the `Some(..)` come
93+
from different macro contexts [#6935](https://github.com/rust-lang/rust-clippy/pull/6935)
94+
* [`map_entry`]: Better detect if the entry API can be used
95+
[#6937](https://github.com/rust-lang/rust-clippy/pull/6937)
96+
* [`or_fun_call`]: No longer lints on some `len` function calls
97+
[#6950](https://github.com/rust-lang/rust-clippy/pull/6950)
98+
* [`new_ret_no_self`]: No longer lints when `Self` is returned with different
99+
generic arguments [#6952](https://github.com/rust-lang/rust-clippy/pull/6952)
100+
* [`upper_case_acronyms`]: No longer lints on public items
101+
[#6981](https://github.com/rust-lang/rust-clippy/pull/6981)
102+
* [`explicit_into_iter_loop`]: Only lint when `into_iter` is an implementation
103+
of `IntoIterator` [#6982](https://github.com/rust-lang/rust-clippy/pull/6982)
104+
* [`expl_impl_clone_on_copy`]: Take generic constraints into account before
105+
suggesting to use `derive` instead
106+
[#6993](https://github.com/rust-lang/rust-clippy/pull/6993)
107+
* [`missing_panics_doc`]: No longer lints when only debug-assertions are used
108+
[#6996](https://github.com/rust-lang/rust-clippy/pull/6996)
109+
* [`clone_on_copy`]: Only lint when using the `Clone` trait
110+
[#7000](https://github.com/rust-lang/rust-clippy/pull/7000)
111+
* [`wrong_self_convention`]: No longer lints inside a trait implementation
112+
[#7002](https://github.com/rust-lang/rust-clippy/pull/7002)
113+
* [`redundant_clone`]: No longer lints when the cloned value is modified while
114+
the clone is in use
115+
[#7011](https://github.com/rust-lang/rust-clippy/pull/7011)
116+
* [`same_item_push`]: No longer lints if the `Vec` is used in the loop body
117+
[#7018](https://github.com/rust-lang/rust-clippy/pull/7018)
118+
* [`cargo_common_metadata`]: Remove author requirement
119+
[#7026](https://github.com/rust-lang/rust-clippy/pull/7026)
120+
* [`panic_in_result_fn`]: No longer lints on `debug_assert` family
121+
[#7060](https://github.com/rust-lang/rust-clippy/pull/7060)
122+
* [`panic`]: No longer wrongfully lints on `debug_assert` with message
123+
[#7063](https://github.com/rust-lang/rust-clippy/pull/7063)
124+
* [`wrong_self_convention`]: No longer lints in trait implementations where no
125+
`self` is involved [#7064](https://github.com/rust-lang/rust-clippy/pull/7064)
126+
* [`missing_const_for_fn`]: No longer lints when unstable `const` function is
127+
involved [#7076](https://github.com/rust-lang/rust-clippy/pull/7076)
128+
* [`suspicious_else_formatting`]: Allow Allman style braces
129+
[#7087](https://github.com/rust-lang/rust-clippy/pull/7087)
130+
* [`inconsistent_struct_constructor`]: No longer lints in macros
131+
[#7097](https://github.com/rust-lang/rust-clippy/pull/7097)
132+
* [`single_component_path_imports`]: No longer lints on macro re-exports
133+
[#7120](https://github.com/rust-lang/rust-clippy/pull/7120)
134+
135+
### Suggestion Fixes/Improvements
136+
137+
* [`redundant_pattern_matching`]: Add a note when applying this lint would
138+
change the drop order
139+
[#6568](https://github.com/rust-lang/rust-clippy/pull/6568)
140+
* [`write_literal`], [`print_literal`]: Add auto-applicable suggestion
141+
[#6821](https://github.com/rust-lang/rust-clippy/pull/6821)
142+
* [`manual_map`]: Fix suggestion for complex `if let ... else` chains
143+
[#6856](https://github.com/rust-lang/rust-clippy/pull/6856)
144+
* [`inconsistent_struct_constructor`]: Make lint description and message clearer
145+
[#6892](https://github.com/rust-lang/rust-clippy/pull/6892)
146+
* [`map_entry`]: Now suggests `or_insert`, `insert_with` or `match _.entry(_)`
147+
as appropriate [#6937](https://github.com/rust-lang/rust-clippy/pull/6937)
148+
* [`manual_flatten`]: Suggest to insert `copied` if necessary
149+
[#6962](https://github.com/rust-lang/rust-clippy/pull/6962)
150+
* [`redundant_slicing`]: Fix suggestion when a re-borrow might be required or
151+
when the value is from a macro call
152+
[#6975](https://github.com/rust-lang/rust-clippy/pull/6975)
153+
* [`match_wildcard_for_single_variants`]: Fix suggestion for hidden variant
154+
[#6988](https://github.com/rust-lang/rust-clippy/pull/6988)
155+
* [`clone_on_copy`]: Correct suggestion when the cloned value is a macro call
156+
[#7000](https://github.com/rust-lang/rust-clippy/pull/7000)
157+
* [`manual_map`]: Fix suggestion at the end of an if chain
158+
[#7004](https://github.com/rust-lang/rust-clippy/pull/7004)
159+
* Fix needless parenthesis output in multiple lint suggestions
160+
[#7013](https://github.com/rust-lang/rust-clippy/pull/7013)
161+
* [`needless_collect`]: Better explanation in the lint message
162+
[#7020](https://github.com/rust-lang/rust-clippy/pull/7020)
163+
* [`useless_vec`]: Now considers mutability
164+
[#7036](https://github.com/rust-lang/rust-clippy/pull/7036)
165+
* [`useless_format`]: Wrap the content in braces if necessary
166+
[#7092](https://github.com/rust-lang/rust-clippy/pull/7092)
167+
* [`single_match`]: Don't suggest an equality check for types which don't
168+
implement `PartialEq`
169+
[#7093](https://github.com/rust-lang/rust-clippy/pull/7093)
170+
* [`from_over_into`]: Mention type in help message
171+
[#7099](https://github.com/rust-lang/rust-clippy/pull/7099)
172+
* [`manual_unwrap_or`]: Fix invalid code suggestion due to a macro call
173+
[#7136](https://github.com/rust-lang/rust-clippy/pull/7136)
174+
175+
### ICE Fixes
176+
177+
* [`macro_use_imports`]
178+
[#7022](https://github.com/rust-lang/rust-clippy/pull/7022)
179+
* [`missing_panics_doc`]
180+
[#7034](https://github.com/rust-lang/rust-clippy/pull/7034)
181+
* [`tabs_in_doc_comments`]
182+
[#7039](https://github.com/rust-lang/rust-clippy/pull/7039)
183+
* [`missing_const_for_fn`]
184+
[#7128](https://github.com/rust-lang/rust-clippy/pull/7128)
185+
186+
### Others
187+
188+
* [Clippy's lint
189+
list](https://rust-lang.github.io/rust-clippy/master/index.html) now supports
190+
themes [#7030](https://github.com/rust-lang/rust-clippy/pull/7030)
191+
* Lints that were uplifted to `rustc` now mention the new `rustc` name in the
192+
deprecation warning
193+
[#7056](https://github.com/rust-lang/rust-clippy/pull/7056)
10194

11195
## Rust 1.52
12196

13-
Current beta, release 2021-05-06
197+
Current stable, released 2021-05-06
14198

15199
[3e41797...6ed6f1e](https://github.com/rust-lang/rust-clippy/compare/3e41797...6ed6f1e)
16200

@@ -99,7 +283,7 @@ Current beta, release 2021-05-06
99283
[#6682](https://github.com/rust-lang/rust-clippy/pull/6682)
100284
* [`unit_arg`]: No longer lints on unit arguments when they come from a path expression.
101285
[#6601](https://github.com/rust-lang/rust-clippy/pull/6601)
102-
* [`cargo_common_metadata`]: No longer lints if
286+
* [`cargo_common_metadata`]: No longer lints if
103287
[`publish = false`](https://doc.rust-lang.org/cargo/reference/manifest.html#the-publish-field)
104288
is defined in the manifest
105289
[#6650](https://github.com/rust-lang/rust-clippy/pull/6650)
@@ -124,11 +308,11 @@ Current beta, release 2021-05-06
124308

125309
* [`useless_format`]: Improved the documentation example
126310
[#6854](https://github.com/rust-lang/rust-clippy/pull/6854)
127-
* Clippy's [`README.md`]: Includes a new subsection on running Clippy as a rustc wrapper
311+
* Clippy's [`README.md`]: Includes a new subsection on running Clippy as a rustc wrapper
128312
[#6782](https://github.com/rust-lang/rust-clippy/pull/6782)
129313

130314
### Others
131-
* Running `cargo clippy` after `cargo check` now works as expected
315+
* Running `cargo clippy` after `cargo check` now works as expected
132316
(`cargo clippy` and `cargo check` no longer shares the same build cache)
133317
[#6687](https://github.com/rust-lang/rust-clippy/pull/6687)
134318
* Cargo now re-runs Clippy if arguments after `--` provided to `cargo clippy` are changed.
@@ -145,7 +329,7 @@ Current beta, release 2021-05-06
145329

146330
## Rust 1.51
147331

148-
Current stable, released 2021-03-25
332+
Released 2021-03-25
149333

150334
[4911ab1...3e41797](https://github.com/rust-lang/rust-clippy/compare/4911ab1...3e41797)
151335

@@ -2365,6 +2549,7 @@ Released 2018-09-13
23652549
[`mutex_integer`]: https://rust-lang.github.io/rust-clippy/master/index.html#mutex_integer
23662550
[`naive_bytecount`]: https://rust-lang.github.io/rust-clippy/master/index.html#naive_bytecount
23672551
[`needless_arbitrary_self_type`]: https://rust-lang.github.io/rust-clippy/master/index.html#needless_arbitrary_self_type
2552+
[`needless_bitwise_bool`]: https://rust-lang.github.io/rust-clippy/master/index.html#needless_bitwise_bool
23682553
[`needless_bool`]: https://rust-lang.github.io/rust-clippy/master/index.html#needless_bool
23692554
[`needless_borrow`]: https://rust-lang.github.io/rust-clippy/master/index.html#needless_borrow
23702555
[`needless_borrowed_reference`]: https://rust-lang.github.io/rust-clippy/master/index.html#needless_borrowed_reference
@@ -2538,6 +2723,7 @@ Released 2018-09-13
25382723
[`unsound_collection_transmute`]: https://rust-lang.github.io/rust-clippy/master/index.html#unsound_collection_transmute
25392724
[`unstable_as_mut_slice`]: https://rust-lang.github.io/rust-clippy/master/index.html#unstable_as_mut_slice
25402725
[`unstable_as_slice`]: https://rust-lang.github.io/rust-clippy/master/index.html#unstable_as_slice
2726+
[`unused_async`]: https://rust-lang.github.io/rust-clippy/master/index.html#unused_async
25412727
[`unused_collect`]: https://rust-lang.github.io/rust-clippy/master/index.html#unused_collect
25422728
[`unused_io_amount`]: https://rust-lang.github.io/rust-clippy/master/index.html#unused_io_amount
25432729
[`unused_self`]: https://rust-lang.github.io/rust-clippy/master/index.html#unused_self

src/tools/clippy/Cargo.toml

+1-1
Original file line numberDiff line numberDiff line change
@@ -49,7 +49,7 @@ rustc-workspace-hack = "1.0.0"
4949
rustc_tools_util = { version = "0.2.0", path = "rustc_tools_util" }
5050

5151
[features]
52-
deny-warnings = []
52+
deny-warnings = ["clippy_lints/deny-warnings"]
5353
integration = ["tempfile"]
5454
internal-lints = ["clippy_lints/internal-lints"]
5555
metadata-collector-lint = ["internal-lints", "clippy_lints/metadata-collector-lint"]

src/tools/clippy/clippy_dev/src/lib.rs

+3-1
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,7 @@
1-
#![cfg_attr(feature = "deny-warnings", deny(warnings))]
21
#![feature(once_cell)]
2+
#![cfg_attr(feature = "deny-warnings", deny(warnings))]
3+
// warn on lints, that are included in `rust-lang/rust`s bootstrap
4+
#![warn(rust_2018_idioms, unused_lifetimes)]
35

46
use itertools::Itertools;
57
use regex::Regex;

src/tools/clippy/clippy_dev/src/main.rs

+2
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,6 @@
11
#![cfg_attr(feature = "deny-warnings", deny(warnings))]
2+
// warn on lints, that are included in `rust-lang/rust`s bootstrap
3+
#![warn(rust_2018_idioms, unused_lifetimes)]
24

35
use clap::{App, Arg, ArgMatches, SubCommand};
46
use clippy_dev::{bless, fmt, ide_setup, new_lint, serve, stderr_length_check, update_lints};

src/tools/clippy/clippy_lints/Cargo.toml

+1-1
Original file line numberDiff line numberDiff line change
@@ -30,7 +30,7 @@ rustc-semver = "1.1.0"
3030
url = { version = "2.1.0", features = ["serde"] }
3131

3232
[features]
33-
deny-warnings = []
33+
deny-warnings = ["clippy_utils/deny-warnings"]
3434
# build clippy with internal lints enabled, off by default
3535
internal-lints = ["clippy_utils/internal-lints"]
3636
metadata-collector-lint = ["serde_json", "clippy_utils/metadata-collector-lint"]

src/tools/clippy/clippy_lints/src/deprecated_lints.rs

+9-2
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,13 @@
1+
/// This struct fakes the `Lint` declaration that is usually created by `declare_lint!`. This
2+
/// enables the simple extraction of the metadata without changing the current deprecation
3+
/// declaration.
4+
pub struct ClippyDeprecatedLint;
5+
16
macro_rules! declare_deprecated_lint {
2-
(pub $name: ident, $_reason: expr) => {
3-
declare_lint!(pub $name, Allow, "deprecated lint")
7+
{ $(#[$attr:meta])* pub $name: ident, $_reason: expr} => {
8+
$(#[$attr])*
9+
#[allow(dead_code)]
10+
pub static $name: ClippyDeprecatedLint = ClippyDeprecatedLint {};
411
}
512
}
613

src/tools/clippy/clippy_lints/src/derive.rs

+6-10
Original file line numberDiff line numberDiff line change
@@ -12,7 +12,7 @@ use rustc_lint::{LateContext, LateLintPass};
1212
use rustc_middle::hir::map::Map;
1313
use rustc_middle::ty::{self, Ty};
1414
use rustc_session::{declare_lint_pass, declare_tool_lint};
15-
use rustc_span::{source_map::Span};
15+
use rustc_span::source_map::Span;
1616

1717
declare_clippy_lint! {
1818
/// **What it does:** Checks for deriving `Hash` but implementing `PartialEq`
@@ -310,15 +310,11 @@ fn check_copy_clone<'tcx>(cx: &LateContext<'tcx>, item: &Item<'_>, trait_ref: &T
310310
// there's a Copy impl for any instance of the adt.
311311
if !is_copy(cx, ty) {
312312
if ty_subs.non_erasable_generics().next().is_some() {
313-
let has_copy_impl = cx
314-
.tcx
315-
.all_local_trait_impls(())
316-
.get(&copy_id)
317-
.map_or(false, |impls| {
318-
impls
319-
.iter()
320-
.any(|&id| matches!(cx.tcx.type_of(id).kind(), ty::Adt(adt, _) if ty_adt.did == adt.did))
321-
});
313+
let has_copy_impl = cx.tcx.all_local_trait_impls(()).get(&copy_id).map_or(false, |impls| {
314+
impls
315+
.iter()
316+
.any(|&id| matches!(cx.tcx.type_of(id).kind(), ty::Adt(adt, _) if ty_adt.did == adt.did))
317+
});
322318
if !has_copy_impl {
323319
return;
324320
}

src/tools/clippy/clippy_lints/src/doc.rs

+1-1
Original file line numberDiff line numberDiff line change
@@ -383,7 +383,7 @@ pub fn strip_doc_comment_decoration(doc: &str, comment_kind: CommentKind, span:
383383
let mut no_stars = String::with_capacity(doc.len());
384384
for line in doc.lines() {
385385
let mut chars = line.chars();
386-
while let Some(c) = chars.next() {
386+
for c in &mut chars {
387387
if c.is_whitespace() {
388388
no_stars.push(c);
389389
} else {

src/tools/clippy/clippy_lints/src/floating_point_arithmetic.rs

+1-11
Original file line numberDiff line numberDiff line change
@@ -323,7 +323,7 @@ fn check_powi(cx: &LateContext<'_>, expr: &Expr<'_>, args: &[Expr<'_>]) {
323323
cx,
324324
SUBOPTIMAL_FLOPS,
325325
parent.span,
326-
"square can be computed more efficiently",
326+
"multiply and add expressions can be calculated more efficiently and accurately",
327327
"consider using",
328328
format!(
329329
"{}.mul_add({}, {})",
@@ -337,16 +337,6 @@ fn check_powi(cx: &LateContext<'_>, expr: &Expr<'_>, args: &[Expr<'_>]) {
337337
return;
338338
}
339339
}
340-
341-
span_lint_and_sugg(
342-
cx,
343-
SUBOPTIMAL_FLOPS,
344-
expr.span,
345-
"square can be computed more efficiently",
346-
"consider using",
347-
format!("{} * {}", Sugg::hir(cx, &args[0], ".."), Sugg::hir(cx, &args[0], "..")),
348-
Applicability::MachineApplicable,
349-
);
350340
}
351341
}
352342
}

src/tools/clippy/clippy_lints/src/implicit_return.rs

+5-1
Original file line numberDiff line numberDiff line change
@@ -147,7 +147,11 @@ fn lint_implicit_returns(
147147
visit_break_exprs(block, |break_expr, dest, sub_expr| {
148148
if dest.target_id.ok() == Some(expr.hir_id) {
149149
if call_site_span.is_none() && break_expr.span.ctxt() == ctxt {
150-
lint_break(cx, break_expr.span, sub_expr.unwrap().span);
150+
// At this point sub_expr can be `None` in async functions which either diverge, or return the
151+
// unit type.
152+
if let Some(sub_expr) = sub_expr {
153+
lint_break(cx, break_expr.span, sub_expr.span);
154+
}
151155
} else {
152156
// the break expression is from a macro call, add a return to the loop
153157
add_return = true;

0 commit comments

Comments
 (0)