Skip to content

Commit 336456e

Browse files
committed
Auto merge of #9174 - flip1995:rustup, r=<try>
Rustup r? `@ghost` changelog: none
2 parents 0f5a38f + 9178ba1 commit 336456e

File tree

83 files changed

+288
-231
lines changed

Some content is hidden

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

83 files changed

+288
-231
lines changed

book/src/README.md

+1-1
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,7 @@
11
# Clippy
22

33
[![Clippy Test](https://github.com/rust-lang/rust-clippy/workflows/Clippy%20Test/badge.svg?branch=auto&event=push)](https://github.com/rust-lang/rust-clippy/actions?query=workflow%3A%22Clippy+Test%22+event%3Apush+branch%3Aauto)
4-
[![License: MIT OR Apache-2.0](https://img.shields.io/crates/l/clippy.svg)](#license)
4+
[![License: MIT OR Apache-2.0](https://img.shields.io/crates/l/clippy.svg)](https://github.com/rust-lang/rust-clippy#license)
55

66
A collection of lints to catch common mistakes and improve your
77
[Rust](https://github.com/rust-lang/rust) code.

book/src/development/adding_lints.md

+18-15
Original file line numberDiff line numberDiff line change
@@ -13,7 +13,6 @@ because that's clearly a non-descriptive name.
1313
- [Testing](#testing)
1414
- [Cargo lints](#cargo-lints)
1515
- [Rustfix tests](#rustfix-tests)
16-
- [Edition 2018 tests](#edition-2018-tests)
1716
- [Testing manually](#testing-manually)
1817
- [Lint declaration](#lint-declaration)
1918
- [Lint registration](#lint-registration)
@@ -402,9 +401,8 @@ need to ensure that the MSRV configured for the project is >= the MSRV of the
402401
required Rust feature. If multiple features are required, just use the one with
403402
a lower MSRV.
404403

405-
First, add an MSRV alias for the required feature in
406-
[`clippy_utils::msrvs`](/clippy_utils/src/msrvs.rs). This can be accessed later
407-
as `msrvs::STR_STRIP_PREFIX`, for example.
404+
First, add an MSRV alias for the required feature in [`clippy_utils::msrvs`].
405+
This can be accessed later as `msrvs::STR_STRIP_PREFIX`, for example.
408406

409407
```rust
410408
msrv_aliases! {
@@ -468,6 +466,8 @@ define_Conf! {
468466
}
469467
```
470468

469+
[`clippy_utils::msrvs`]: https://doc.rust-lang.org/nightly/nightly-rustc/clippy_utils/msrvs/index.html
470+
471471
## Author lint
472472

473473
If you have trouble implementing your lint, there is also the internal `author`
@@ -583,8 +583,7 @@ the workspace directory. Adding a configuration to a lint can be useful for
583583
thresholds or to constrain some behavior that can be seen as a false positive
584584
for some users. Adding a configuration is done in the following steps:
585585

586-
1. Adding a new configuration entry to
587-
[clippy_lints::utils::conf](/clippy_lints/src/utils/conf.rs) like this:
586+
1. Adding a new configuration entry to [`clippy_lints::utils::conf`] like this:
588587

589588
```rust
590589
/// Lint: LINT_NAME.
@@ -635,9 +634,9 @@ for some users. Adding a configuration is done in the following steps:
635634
```
636635
3. Passing the configuration value to the lint impl struct:
637636

638-
First find the struct construction in the [clippy_lints lib
639-
file](/clippy_lints/src/lib.rs). The configuration value is now cloned or
640-
copied into a local value that is then passed to the impl struct like this:
637+
First find the struct construction in the [`clippy_lints` lib file]. The
638+
configuration value is now cloned or copied into a local value that is then
639+
passed to the impl struct like this:
641640

642641
```rust
643642
// Default generated registration:
@@ -653,12 +652,16 @@ for some users. Adding a configuration is done in the following steps:
653652

654653
4. Adding tests:
655654
1. The default configured value can be tested like any normal lint in
656-
[`tests/ui`](/tests/ui).
657-
2. The configuration itself will be tested separately in
658-
[`tests/ui-toml`](/tests/ui-toml). Simply add a new subfolder with a
659-
fitting name. This folder contains a `clippy.toml` file with the
660-
configuration value and a rust file that should be linted by Clippy. The
661-
test can otherwise be written as usual.
655+
[`tests/ui`].
656+
2. The configuration itself will be tested separately in [`tests/ui-toml`].
657+
Simply add a new subfolder with a fitting name. This folder contains a
658+
`clippy.toml` file with the configuration value and a rust file that
659+
should be linted by Clippy. The test can otherwise be written as usual.
660+
661+
[`clippy_lints::utils::conf`]: https://github.com/rust-lang/rust-clippy/blob/master/clippy_lints/src/utils/conf.rs
662+
[`clippy_lints` lib file]: https://github.com/rust-lang/rust-clippy/blob/master/clippy_lints/src/lib.rs
663+
[`tests/ui`]: https://github.com/rust-lang/rust-clippy/blob/master/tests/ui
664+
[`tests/ui-toml`]: https://github.com/rust-lang/rust-clippy/blob/master/tests/ui-toml
662665

663666
## Cheat Sheet
664667

book/src/development/basics.md

+1-1
Original file line numberDiff line numberDiff line change
@@ -102,7 +102,7 @@ cargo dev dogfood
102102
```
103103

104104
More about intellij command usage and reasons
105-
[here](../CONTRIBUTING.md#intellij-rust)
105+
[here](https://github.com/rust-lang/rust-clippy/blob/master/CONTRIBUTING.md#intellij-rust)
106106

107107
## lintcheck
108108

book/src/development/common_tools_writing_lints.md

+1-1
Original file line numberDiff line numberDiff line change
@@ -276,4 +276,4 @@ functions to deal with macros:
276276
[LateContext]: https://doc.rust-lang.org/nightly/nightly-rustc/rustc_lint/struct.LateContext.html
277277
[TyCtxt]: https://doc.rust-lang.org/nightly/nightly-rustc/rustc_middle/ty/context/struct.TyCtxt.html
278278
[pat_ty]: https://doc.rust-lang.org/nightly/nightly-rustc/rustc_middle/ty/context/struct.TypeckResults.html#method.pat_ty
279-
[paths]: ../clippy_utils/src/paths.rs
279+
[paths]: https://doc.rust-lang.org/nightly/nightly-rustc/clippy_utils/paths/index.html

book/src/usage.md

+1-1
Original file line numberDiff line numberDiff line change
@@ -148,4 +148,4 @@ clippy-driver --edition 2018 -Cpanic=abort foo.rs
148148
> that are not optimized as expected, for example.
149149
150150
[Installation]: installation.md
151-
[CI]: continuous_integration
151+
[CI]: continuous_integration/index.md

clippy_lints/src/blocks_in_if_conditions.rs

+2-2
Original file line numberDiff line numberDiff line change
@@ -6,7 +6,7 @@ use clippy_utils::ty::implements_trait;
66
use if_chain::if_chain;
77
use rustc_errors::Applicability;
88
use rustc_hir::intravisit::{walk_expr, Visitor};
9-
use rustc_hir::{BlockCheckMode, Expr, ExprKind};
9+
use rustc_hir::{BlockCheckMode, Closure, Expr, ExprKind};
1010
use rustc_lint::{LateContext, LateLintPass, LintContext};
1111
use rustc_middle::lint::in_external_macro;
1212
use rustc_session::{declare_lint_pass, declare_tool_lint};
@@ -51,7 +51,7 @@ struct ExVisitor<'a, 'tcx> {
5151

5252
impl<'a, 'tcx> Visitor<'tcx> for ExVisitor<'a, 'tcx> {
5353
fn visit_expr(&mut self, expr: &'tcx Expr<'tcx>) {
54-
if let ExprKind::Closure { body, .. } = expr.kind {
54+
if let ExprKind::Closure(&Closure { body, .. }) = expr.kind {
5555
// do not lint if the closure is called using an iterator (see #1141)
5656
if_chain! {
5757
if let Some(parent) = get_parent_expr(self.cx, expr);

clippy_lints/src/bytecount.rs

+2-2
Original file line numberDiff line numberDiff line change
@@ -5,7 +5,7 @@ use clippy_utils::visitors::is_local_used;
55
use clippy_utils::{path_to_local_id, paths, peel_blocks, peel_ref_operators, strip_pat_refs};
66
use if_chain::if_chain;
77
use rustc_errors::Applicability;
8-
use rustc_hir::{BinOpKind, Expr, ExprKind, PatKind};
8+
use rustc_hir::{BinOpKind, Closure, Expr, ExprKind, PatKind};
99
use rustc_lint::{LateContext, LateLintPass};
1010
use rustc_middle::ty::{self, UintTy};
1111
use rustc_session::{declare_lint_pass, declare_tool_lint};
@@ -51,7 +51,7 @@ impl<'tcx> LateLintPass<'tcx> for ByteCount {
5151
if count.ident.name == sym::count;
5252
if let ExprKind::MethodCall(filter, [filter_recv, filter_arg], _) = count_recv.kind;
5353
if filter.ident.name == sym!(filter);
54-
if let ExprKind::Closure { body, .. } = filter_arg.kind;
54+
if let ExprKind::Closure(&Closure { body, .. }) = filter_arg.kind;
5555
let body = cx.tcx.hir().body(body);
5656
if let [param] = body.params;
5757
if let PatKind::Binding(_, arg_id, _, _) = strip_pat_refs(param.pat).kind;

clippy_lints/src/dereference.rs

+4-4
Original file line numberDiff line numberDiff line change
@@ -8,14 +8,14 @@ use rustc_data_structures::fx::FxIndexMap;
88
use rustc_errors::Applicability;
99
use rustc_hir::intravisit::{walk_ty, Visitor};
1010
use rustc_hir::{
11-
self as hir, BindingAnnotation, Body, BodyId, BorrowKind, Expr, ExprKind, FnRetTy, GenericArg, HirId, ImplItem,
12-
ImplItemKind, Item, ItemKind, Local, MatchSource, Mutability, Node, Pat, PatKind, Path, QPath, TraitItem,
11+
self as hir, BindingAnnotation, Body, BodyId, BorrowKind, Closure, Expr, ExprKind, FnRetTy, GenericArg, HirId,
12+
ImplItem, ImplItemKind, Item, ItemKind, Local, MatchSource, Mutability, Node, Pat, PatKind, Path, QPath, TraitItem,
1313
TraitItemKind, TyKind, UnOp,
1414
};
1515
use rustc_infer::infer::TyCtxtInferExt;
1616
use rustc_lint::{LateContext, LateLintPass};
1717
use rustc_middle::ty::adjustment::{Adjust, Adjustment, AutoBorrow, AutoBorrowMutability};
18-
use rustc_middle::ty::{self, Ty, TyCtxt, TypeFoldable, TypeckResults};
18+
use rustc_middle::ty::{self, Ty, TyCtxt, TypeVisitable, TypeckResults};
1919
use rustc_session::{declare_tool_lint, impl_lint_pass};
2020
use rustc_span::{symbol::sym, Span, Symbol};
2121
use rustc_trait_selection::infer::InferCtxtExt;
@@ -720,7 +720,7 @@ fn walk_parents<'tcx>(cx: &LateContext<'tcx>, e: &'tcx Expr<'_>) -> (Position, &
720720
let owner_id = cx.tcx.hir().body_owner(cx.enclosing_body.unwrap());
721721
Some(
722722
if let Node::Expr(Expr {
723-
kind: ExprKind::Closure { fn_decl, .. },
723+
kind: ExprKind::Closure(&Closure { fn_decl, .. }),
724724
..
725725
}) = cx.tcx.hir().get(owner_id)
726726
{

clippy_lints/src/duplicate_mod.rs

+28-2
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,7 @@
11
use clippy_utils::diagnostics::span_lint_and_help;
22
use rustc_ast::ast::{Crate, Inline, Item, ItemKind, ModKind};
33
use rustc_errors::MultiSpan;
4-
use rustc_lint::{EarlyContext, EarlyLintPass, LintContext};
4+
use rustc_lint::{EarlyContext, EarlyLintPass, Level, LintContext};
55
use rustc_session::{declare_tool_lint, impl_lint_pass};
66
use rustc_span::{FileName, Span};
77
use std::collections::BTreeMap;
@@ -49,6 +49,7 @@ declare_clippy_lint! {
4949
struct Modules {
5050
local_path: PathBuf,
5151
spans: Vec<Span>,
52+
lint_levels: Vec<Level>,
5253
}
5354

5455
#[derive(Default)]
@@ -70,13 +71,38 @@ impl EarlyLintPass for DuplicateMod {
7071
let modules = self.modules.entry(absolute_path).or_insert(Modules {
7172
local_path,
7273
spans: Vec::new(),
74+
lint_levels: Vec::new(),
7375
});
7476
modules.spans.push(item.span_with_attributes());
77+
modules.lint_levels.push(cx.get_lint_level(DUPLICATE_MOD));
7578
}
7679
}
7780

7881
fn check_crate_post(&mut self, cx: &EarlyContext<'_>, _: &Crate) {
79-
for Modules { local_path, spans } in self.modules.values() {
82+
for Modules {
83+
local_path,
84+
spans,
85+
lint_levels,
86+
} in self.modules.values()
87+
{
88+
if spans.len() < 2 {
89+
continue;
90+
}
91+
92+
// At this point the lint would be emitted
93+
assert_eq!(spans.len(), lint_levels.len());
94+
let spans: Vec<_> = spans
95+
.iter()
96+
.zip(lint_levels)
97+
.filter_map(|(span, lvl)| {
98+
if let Some(id) = lvl.get_expectation_id() {
99+
cx.fulfill_expectation(id);
100+
}
101+
102+
(!matches!(lvl, Level::Allow | Level::Expect(_))).then_some(*span)
103+
})
104+
.collect();
105+
80106
if spans.len() < 2 {
81107
continue;
82108
}

clippy_lints/src/escape.rs

+5-11
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,7 @@
11
use clippy_utils::diagnostics::span_lint_hir;
22
use clippy_utils::ty::contains_ty;
33
use rustc_hir::intravisit;
4-
use rustc_hir::{self, AssocItemKind, Body, FnDecl, HirId, HirIdSet, Impl, ItemKind, Node};
4+
use rustc_hir::{self, AssocItemKind, Body, FnDecl, HirId, HirIdSet, Impl, ItemKind, Node, Pat, PatKind};
55
use rustc_infer::infer::TyCtxtInferExt;
66
use rustc_lint::{LateContext, LateLintPass};
77
use rustc_middle::mir::FakeReadCause;
@@ -132,7 +132,10 @@ impl<'tcx> LateLintPass<'tcx> for BoxedLocal {
132132
// TODO: Replace with Map::is_argument(..) when it's fixed
133133
fn is_argument(map: rustc_middle::hir::map::Map<'_>, id: HirId) -> bool {
134134
match map.find(id) {
135-
Some(Node::Binding(_)) => (),
135+
Some(Node::Pat(Pat {
136+
kind: PatKind::Binding(..),
137+
..
138+
})) => (),
136139
_ => return false,
137140
}
138141

@@ -144,15 +147,6 @@ impl<'a, 'tcx> Delegate<'tcx> for EscapeDelegate<'a, 'tcx> {
144147
if cmt.place.projections.is_empty() {
145148
if let PlaceBase::Local(lid) = cmt.place.base {
146149
self.set.remove(&lid);
147-
let map = &self.cx.tcx.hir();
148-
if let Some(Node::Binding(_)) = map.find(cmt.hir_id) {
149-
if self.set.contains(&lid) {
150-
// let y = x where x is known
151-
// remove x, insert y
152-
self.set.insert(cmt.hir_id);
153-
self.set.remove(&lid);
154-
}
155-
}
156150
}
157151
}
158152
}

clippy_lints/src/eta_reduction.rs

+3-3
Original file line numberDiff line numberDiff line change
@@ -7,12 +7,12 @@ use clippy_utils::{higher, is_adjusted, path_to_local, path_to_local_id};
77
use if_chain::if_chain;
88
use rustc_errors::Applicability;
99
use rustc_hir::def_id::DefId;
10-
use rustc_hir::{Expr, ExprKind, Param, PatKind, Unsafety};
10+
use rustc_hir::{Closure, Expr, ExprKind, Param, PatKind, Unsafety};
1111
use rustc_lint::{LateContext, LateLintPass};
1212
use rustc_middle::ty::adjustment::{Adjust, Adjustment, AutoBorrow};
1313
use rustc_middle::ty::binding::BindingMode;
1414
use rustc_middle::ty::subst::Subst;
15-
use rustc_middle::ty::{self, ClosureKind, Ty, TypeFoldable};
15+
use rustc_middle::ty::{self, ClosureKind, Ty, TypeVisitable};
1616
use rustc_session::{declare_lint_pass, declare_tool_lint};
1717
use rustc_span::symbol::sym;
1818

@@ -78,7 +78,7 @@ impl<'tcx> LateLintPass<'tcx> for EtaReduction {
7878
return;
7979
}
8080
let body = match expr.kind {
81-
ExprKind::Closure { body, .. } => cx.tcx.hir().body(body),
81+
ExprKind::Closure(&Closure { body, .. }) => cx.tcx.hir().body(body),
8282
_ => return,
8383
};
8484
if body.value.span.from_expansion() {

clippy_lints/src/excessive_bools.rs

+1-1
Original file line numberDiff line numberDiff line change
@@ -94,7 +94,7 @@ impl ExcessiveBools {
9494

9595
fn check_fn_sig(&self, cx: &EarlyContext<'_>, fn_sig: &FnSig, span: Span) {
9696
match fn_sig.header.ext {
97-
Extern::Implicit | Extern::Explicit(_) => return,
97+
Extern::Implicit(_) | Extern::Explicit(_, _) => return,
9898
Extern::None => (),
9999
}
100100

clippy_lints/src/explicit_write.rs

+1-1
Original file line numberDiff line numberDiff line change
@@ -125,7 +125,7 @@ fn look_in_block<'tcx, 'hir>(cx: &LateContext<'tcx>, kind: &'tcx ExprKind<'hir>)
125125
// Find id of the local that expr_end_of_block resolves to
126126
if let ExprKind::Path(QPath::Resolved(None, expr_path)) = expr_end_of_block.kind;
127127
if let Res::Local(expr_res) = expr_path.res;
128-
if let Some(Node::Binding(res_pat)) = cx.tcx.hir().find(expr_res);
128+
if let Some(Node::Pat(res_pat)) = cx.tcx.hir().find(expr_res);
129129

130130
// Find id of the local we found in the block
131131
if let PatKind::Binding(BindingAnnotation::Unannotated, local_hir_id, _ident, None) = local.pat.kind;

clippy_lints/src/infinite_iter.rs

+2-2
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,7 @@
11
use clippy_utils::diagnostics::span_lint;
22
use clippy_utils::ty::{implements_trait, is_type_diagnostic_item};
33
use clippy_utils::{higher, match_def_path, path_def_id, paths};
4-
use rustc_hir::{BorrowKind, Expr, ExprKind};
4+
use rustc_hir::{BorrowKind, Closure, Expr, ExprKind};
55
use rustc_lint::{LateContext, LateLintPass};
66
use rustc_session::{declare_lint_pass, declare_tool_lint};
77
use rustc_span::symbol::{sym, Symbol};
@@ -159,7 +159,7 @@ fn is_infinite(cx: &LateContext<'_>, expr: &Expr<'_>) -> Finiteness {
159159
}
160160
}
161161
if method.ident.name == sym!(flat_map) && args.len() == 2 {
162-
if let ExprKind::Closure { body, .. } = args[1].kind {
162+
if let ExprKind::Closure(&Closure { body, .. }) = args[1].kind {
163163
let body = cx.tcx.hir().body(body);
164164
return is_infinite(cx, &body.value);
165165
}

clippy_lints/src/inherent_to_string.rs

+2-2
Original file line numberDiff line numberDiff line change
@@ -2,7 +2,7 @@ use clippy_utils::diagnostics::span_lint_and_help;
22
use clippy_utils::ty::{implements_trait, is_type_diagnostic_item};
33
use clippy_utils::{get_trait_def_id, paths, return_ty, trait_ref_of_method};
44
use if_chain::if_chain;
5-
use rustc_hir::{ImplItem, ImplItemKind};
5+
use rustc_hir::{GenericParamKind, ImplItem, ImplItemKind};
66
use rustc_lint::{LateContext, LateLintPass};
77
use rustc_session::{declare_lint_pass, declare_tool_lint};
88
use rustc_span::sym;
@@ -102,7 +102,7 @@ impl<'tcx> LateLintPass<'tcx> for InherentToString {
102102
let decl = &signature.decl;
103103
if decl.implicit_self.has_implicit_self();
104104
if decl.inputs.len() == 1;
105-
if impl_item.generics.params.is_empty();
105+
if impl_item.generics.params.iter().all(|p| matches!(p.kind, GenericParamKind::Lifetime { .. }));
106106

107107
// Check if return type is String
108108
if is_type_diagnostic_item(cx, return_ty(cx, impl_item.hir_id()), sym::String);

clippy_lints/src/lifetimes.rs

+7-3
Original file line numberDiff line numberDiff line change
@@ -9,8 +9,8 @@ use rustc_hir::intravisit::{
99
use rustc_hir::FnRetTy::Return;
1010
use rustc_hir::{
1111
BareFnTy, BodyId, FnDecl, GenericArg, GenericBound, GenericParam, GenericParamKind, Generics, Impl, ImplItem,
12-
ImplItemKind, Item, ItemKind, LangItem, Lifetime, LifetimeName, ParamName, PolyTraitRef, PredicateOrigin,
13-
TraitBoundModifier, TraitFn, TraitItem, TraitItemKind, Ty, TyKind, WherePredicate,
12+
ImplItemKind, Item, ItemKind, LangItem, Lifetime, LifetimeName, LifetimeParamKind, ParamName, PolyTraitRef,
13+
PredicateOrigin, TraitBoundModifier, TraitFn, TraitItem, TraitItemKind, Ty, TyKind, WherePredicate,
1414
};
1515
use rustc_lint::{LateContext, LateLintPass};
1616
use rustc_middle::hir::nested_filter as middle_nested_filter;
@@ -338,7 +338,10 @@ fn could_use_elision<'tcx>(
338338
fn allowed_lts_from(named_generics: &[GenericParam<'_>]) -> FxHashSet<RefLt> {
339339
let mut allowed_lts = FxHashSet::default();
340340
for par in named_generics.iter() {
341-
if let GenericParamKind::Lifetime { .. } = par.kind {
341+
if let GenericParamKind::Lifetime {
342+
kind: LifetimeParamKind::Explicit,
343+
} = par.kind
344+
{
342345
allowed_lts.insert(RefLt::Named(par.name.ident().name));
343346
}
344347
}
@@ -379,6 +382,7 @@ impl<'a, 'tcx> RefVisitor<'a, 'tcx> {
379382
self.lts.push(RefLt::Static);
380383
} else if let LifetimeName::Param(_, ParamName::Fresh) = lt.name {
381384
// Fresh lifetimes generated should be ignored.
385+
self.lts.push(RefLt::Unnamed);
382386
} else if lt.is_elided() {
383387
self.lts.push(RefLt::Unnamed);
384388
} else {

clippy_lints/src/loops/mut_range_bound.rs

+1-1
Original file line numberDiff line numberDiff line change
@@ -43,7 +43,7 @@ fn mut_warn_with_span(cx: &LateContext<'_>, span: Option<Span>) {
4343
fn check_for_mutability(cx: &LateContext<'_>, bound: &Expr<'_>) -> Option<HirId> {
4444
if_chain! {
4545
if let Some(hir_id) = path_to_local(bound);
46-
if let Node::Binding(pat) = cx.tcx.hir().get(hir_id);
46+
if let Node::Pat(pat) = cx.tcx.hir().get(hir_id);
4747
if let PatKind::Binding(BindingAnnotation::Mutable, ..) = pat.kind;
4848
then {
4949
return Some(hir_id);

clippy_lints/src/loops/needless_range_loop.rs

+2-2
Original file line numberDiff line numberDiff line change
@@ -9,7 +9,7 @@ use rustc_ast::ast;
99
use rustc_data_structures::fx::{FxHashMap, FxHashSet};
1010
use rustc_hir::def::{DefKind, Res};
1111
use rustc_hir::intravisit::{walk_expr, Visitor};
12-
use rustc_hir::{BinOpKind, BorrowKind, Expr, ExprKind, HirId, Mutability, Pat, PatKind, QPath};
12+
use rustc_hir::{BinOpKind, BorrowKind, Closure, Expr, ExprKind, HirId, Mutability, Pat, PatKind, QPath};
1313
use rustc_lint::LateContext;
1414
use rustc_middle::middle::region;
1515
use rustc_middle::ty::{self, Ty};
@@ -369,7 +369,7 @@ impl<'a, 'tcx> Visitor<'tcx> for VarVisitor<'a, 'tcx> {
369369
self.visit_expr(expr);
370370
}
371371
},
372-
ExprKind::Closure { body, .. } => {
372+
ExprKind::Closure(&Closure { body, .. }) => {
373373
let body = self.cx.tcx.hir().body(body);
374374
self.visit_expr(&body.value);
375375
},

0 commit comments

Comments
 (0)