Skip to content

Rustup #9174

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Merged
merged 39 commits into from
Jul 15, 2022
Merged

Rustup #9174

Show file tree
Hide file tree
Changes from all commits
Commits
Show all changes
39 commits
Select commit Hold shift + click to select a range
09f5df5
Merge commit '0cb0f7636851f9fcc57085cf80197a2ef6db098f' into clippyup
flip1995 Jun 30, 2022
5de8590
Factor out hir::Node::Binding
camsteffen Jun 28, 2022
d5e33d3
Shorten def_span for more items.
cjgillot Feb 13, 2022
053caf8
Rollup merge of #98639 - camsteffen:no-node-binding, r=compiler-errors
Dylan-DPC Jul 2, 2022
ab23b3a
ast: Add span to `Extern`
aDotInTheVoid Jul 2, 2022
5c35569
Relax constrained generics to TypeVisitable
eggyal Jun 17, 2022
490c773
Update TypeVisitor paths
eggyal Jun 17, 2022
f84d9bc
Build the Clippy book as part of x.py doc
flip1995 Jul 3, 2022
e34ee24
fix miri-opt tests
TaKO8Ki Jul 6, 2022
0d443d1
Fix `#[expect]` and `#[allow]` for `clippy::duplicate_mod`
xFrednet Jun 25, 2022
5483a7d
Auto merge of #98827 - aDotInTheVoid:suggest-extern-block, r=nagisa
bors Jul 7, 2022
cac25cd
Move `predecessors` from Body to BasicBlocks
tmiasko Jul 5, 2022
347d999
Shorten span for closures.
cjgillot Jun 27, 2022
6293da2
`UnsafeCell` now has no niches, ever.
oli-obk Jul 7, 2022
4f9933a
Rollup merge of #98507 - xFrednet:rfc-2383-manual-expectation-magic, …
Dylan-DPC Jul 7, 2022
5474f56
Rollup merge of #98930 - tmiasko:pub-basic-blocks, r=oli-obk
Dylan-DPC Jul 7, 2022
3388787
Add test for and fix rust-lang/rust-clippy#9131
anall Jul 7, 2022
bee9da1
Auto merge of #98482 - cjgillot:short-struct-span-closure, r=estebank
bors Jul 8, 2022
1e033a9
Rollup merge of #99026 - anall:buffix/clippy-9131, r=xFrednet
matthiaskrgr Jul 8, 2022
d053a3d
add opt in attribute for stable-in-unstable items
yaahc May 9, 2022
9225ebd
lower let-else in MIR instead
dingxiangfei2009 Jun 2, 2022
af3ba22
move else block into the `Local` struct
dingxiangfei2009 Jul 5, 2022
9d86ce6
add new rval, pull deref early
ouz-a Jun 13, 2022
1c3f62c
Fix clippy build
WaffleLapkin Jun 30, 2022
9e2f689
Rollup merge of #98848 - flip1995:clippy-book, r=jyn514
GuillaumeGomez Jul 13, 2022
dcd2484
Clippy fallout.
cjgillot Jun 4, 2022
9e1af3f
Rollup merge of #98574 - dingxiangfei2009:let-else-thir, r=oli-obk
Dylan-DPC Jul 13, 2022
73a6240
Rollup merge of #99011 - oli-obk:UnsoundCell, r=eddyb
Dylan-DPC Jul 13, 2022
4e3a7bf
Auto merge of #98145 - ouz-a:some_branch, r=oli-obk
bors Jul 13, 2022
5b7a2d5
Auto merge of #99210 - Dylan-DPC:rollup-879cp1t, r=Dylan-DPC
bors Jul 13, 2022
eee0bf4
add array tests, cleanup, tidy, and bless
RalfJung Jun 30, 2022
73f3294
Rename `debugging_opts` to `unstable_opts`
jyn514 Jul 6, 2022
44f25ba
Auto merge of #98975 - jyn514:unstable_opts, r=wesleywiser
bors Jul 14, 2022
5a6fe3f
Rollup merge of #97720 - cjgillot:all-fresh, r=petrochenkov
Dylan-DPC Jul 14, 2022
e275abf
Rollup merge of #98705 - WaffleLapkin:closure_binder, r=cjgillot
Dylan-DPC Jul 14, 2022
c9a78ee
Auto merge of #99231 - Dylan-DPC:rollup-0tl8c0o, r=Dylan-DPC
bors Jul 14, 2022
6dc9746
Auto merge of #95956 - yaahc:stable-in-unstable, r=cjgillot
bors Jul 14, 2022
f074034
Merge remote-tracking branch 'upstream/master' into rustup
flip1995 Jul 15, 2022
9178ba1
Bump nightly version -> 2022-07-15
flip1995 Jul 15, 2022
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
2 changes: 1 addition & 1 deletion book/src/README.md
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
# Clippy

[![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)
[![License: MIT OR Apache-2.0](https://img.shields.io/crates/l/clippy.svg)](#license)
[![License: MIT OR Apache-2.0](https://img.shields.io/crates/l/clippy.svg)](https://github.com/rust-lang/rust-clippy#license)

A collection of lints to catch common mistakes and improve your
[Rust](https://github.com/rust-lang/rust) code.
Expand Down
33 changes: 18 additions & 15 deletions book/src/development/adding_lints.md
Original file line number Diff line number Diff line change
Expand Up @@ -13,7 +13,6 @@ because that's clearly a non-descriptive name.
- [Testing](#testing)
- [Cargo lints](#cargo-lints)
- [Rustfix tests](#rustfix-tests)
- [Edition 2018 tests](#edition-2018-tests)
- [Testing manually](#testing-manually)
- [Lint declaration](#lint-declaration)
- [Lint registration](#lint-registration)
Expand Down Expand Up @@ -402,9 +401,8 @@ need to ensure that the MSRV configured for the project is >= the MSRV of the
required Rust feature. If multiple features are required, just use the one with
a lower MSRV.

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

```rust
msrv_aliases! {
Expand Down Expand Up @@ -468,6 +466,8 @@ define_Conf! {
}
```

[`clippy_utils::msrvs`]: https://doc.rust-lang.org/nightly/nightly-rustc/clippy_utils/msrvs/index.html

## Author lint

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

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

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

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

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

4. Adding tests:
1. The default configured value can be tested like any normal lint in
[`tests/ui`](/tests/ui).
2. The configuration itself will be tested separately in
[`tests/ui-toml`](/tests/ui-toml). Simply add a new subfolder with a
fitting name. This folder contains a `clippy.toml` file with the
configuration value and a rust file that should be linted by Clippy. The
test can otherwise be written as usual.
[`tests/ui`].
2. The configuration itself will be tested separately in [`tests/ui-toml`].
Simply add a new subfolder with a fitting name. This folder contains a
`clippy.toml` file with the configuration value and a rust file that
should be linted by Clippy. The test can otherwise be written as usual.

[`clippy_lints::utils::conf`]: https://github.com/rust-lang/rust-clippy/blob/master/clippy_lints/src/utils/conf.rs
[`clippy_lints` lib file]: https://github.com/rust-lang/rust-clippy/blob/master/clippy_lints/src/lib.rs
[`tests/ui`]: https://github.com/rust-lang/rust-clippy/blob/master/tests/ui
[`tests/ui-toml`]: https://github.com/rust-lang/rust-clippy/blob/master/tests/ui-toml

## Cheat Sheet

Expand Down
2 changes: 1 addition & 1 deletion book/src/development/basics.md
Original file line number Diff line number Diff line change
Expand Up @@ -102,7 +102,7 @@ cargo dev dogfood
```

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

## lintcheck

Expand Down
2 changes: 1 addition & 1 deletion book/src/development/common_tools_writing_lints.md
Original file line number Diff line number Diff line change
Expand Up @@ -276,4 +276,4 @@ functions to deal with macros:
[LateContext]: https://doc.rust-lang.org/nightly/nightly-rustc/rustc_lint/struct.LateContext.html
[TyCtxt]: https://doc.rust-lang.org/nightly/nightly-rustc/rustc_middle/ty/context/struct.TyCtxt.html
[pat_ty]: https://doc.rust-lang.org/nightly/nightly-rustc/rustc_middle/ty/context/struct.TypeckResults.html#method.pat_ty
[paths]: ../clippy_utils/src/paths.rs
[paths]: https://doc.rust-lang.org/nightly/nightly-rustc/clippy_utils/paths/index.html
2 changes: 1 addition & 1 deletion book/src/usage.md
Original file line number Diff line number Diff line change
Expand Up @@ -148,4 +148,4 @@ clippy-driver --edition 2018 -Cpanic=abort foo.rs
> that are not optimized as expected, for example.

[Installation]: installation.md
[CI]: continuous_integration
[CI]: continuous_integration/index.md
4 changes: 2 additions & 2 deletions clippy_lints/src/blocks_in_if_conditions.rs
Original file line number Diff line number Diff line change
Expand Up @@ -6,7 +6,7 @@ use clippy_utils::ty::implements_trait;
use if_chain::if_chain;
use rustc_errors::Applicability;
use rustc_hir::intravisit::{walk_expr, Visitor};
use rustc_hir::{BlockCheckMode, Expr, ExprKind};
use rustc_hir::{BlockCheckMode, Closure, Expr, ExprKind};
use rustc_lint::{LateContext, LateLintPass, LintContext};
use rustc_middle::lint::in_external_macro;
use rustc_session::{declare_lint_pass, declare_tool_lint};
Expand Down Expand Up @@ -51,7 +51,7 @@ struct ExVisitor<'a, 'tcx> {

impl<'a, 'tcx> Visitor<'tcx> for ExVisitor<'a, 'tcx> {
fn visit_expr(&mut self, expr: &'tcx Expr<'tcx>) {
if let ExprKind::Closure { body, .. } = expr.kind {
if let ExprKind::Closure(&Closure { body, .. }) = expr.kind {
// do not lint if the closure is called using an iterator (see #1141)
if_chain! {
if let Some(parent) = get_parent_expr(self.cx, expr);
Expand Down
4 changes: 2 additions & 2 deletions clippy_lints/src/bytecount.rs
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,7 @@ use clippy_utils::visitors::is_local_used;
use clippy_utils::{path_to_local_id, paths, peel_blocks, peel_ref_operators, strip_pat_refs};
use if_chain::if_chain;
use rustc_errors::Applicability;
use rustc_hir::{BinOpKind, Expr, ExprKind, PatKind};
use rustc_hir::{BinOpKind, Closure, Expr, ExprKind, PatKind};
use rustc_lint::{LateContext, LateLintPass};
use rustc_middle::ty::{self, UintTy};
use rustc_session::{declare_lint_pass, declare_tool_lint};
Expand Down Expand Up @@ -51,7 +51,7 @@ impl<'tcx> LateLintPass<'tcx> for ByteCount {
if count.ident.name == sym::count;
if let ExprKind::MethodCall(filter, [filter_recv, filter_arg], _) = count_recv.kind;
if filter.ident.name == sym!(filter);
if let ExprKind::Closure { body, .. } = filter_arg.kind;
if let ExprKind::Closure(&Closure { body, .. }) = filter_arg.kind;
let body = cx.tcx.hir().body(body);
if let [param] = body.params;
if let PatKind::Binding(_, arg_id, _, _) = strip_pat_refs(param.pat).kind;
Expand Down
8 changes: 4 additions & 4 deletions clippy_lints/src/dereference.rs
Original file line number Diff line number Diff line change
Expand Up @@ -8,14 +8,14 @@ use rustc_data_structures::fx::FxIndexMap;
use rustc_errors::Applicability;
use rustc_hir::intravisit::{walk_ty, Visitor};
use rustc_hir::{
self as hir, BindingAnnotation, Body, BodyId, BorrowKind, Expr, ExprKind, FnRetTy, GenericArg, HirId, ImplItem,
ImplItemKind, Item, ItemKind, Local, MatchSource, Mutability, Node, Pat, PatKind, Path, QPath, TraitItem,
self as hir, BindingAnnotation, Body, BodyId, BorrowKind, Closure, Expr, ExprKind, FnRetTy, GenericArg, HirId,
ImplItem, ImplItemKind, Item, ItemKind, Local, MatchSource, Mutability, Node, Pat, PatKind, Path, QPath, TraitItem,
TraitItemKind, TyKind, UnOp,
};
use rustc_infer::infer::TyCtxtInferExt;
use rustc_lint::{LateContext, LateLintPass};
use rustc_middle::ty::adjustment::{Adjust, Adjustment, AutoBorrow, AutoBorrowMutability};
use rustc_middle::ty::{self, Ty, TyCtxt, TypeFoldable, TypeckResults};
use rustc_middle::ty::{self, Ty, TyCtxt, TypeVisitable, TypeckResults};
use rustc_session::{declare_tool_lint, impl_lint_pass};
use rustc_span::{symbol::sym, Span, Symbol};
use rustc_trait_selection::infer::InferCtxtExt;
Expand Down Expand Up @@ -720,7 +720,7 @@ fn walk_parents<'tcx>(cx: &LateContext<'tcx>, e: &'tcx Expr<'_>) -> (Position, &
let owner_id = cx.tcx.hir().body_owner(cx.enclosing_body.unwrap());
Some(
if let Node::Expr(Expr {
kind: ExprKind::Closure { fn_decl, .. },
kind: ExprKind::Closure(&Closure { fn_decl, .. }),
..
}) = cx.tcx.hir().get(owner_id)
{
Expand Down
30 changes: 28 additions & 2 deletions clippy_lints/src/duplicate_mod.rs
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
use clippy_utils::diagnostics::span_lint_and_help;
use rustc_ast::ast::{Crate, Inline, Item, ItemKind, ModKind};
use rustc_errors::MultiSpan;
use rustc_lint::{EarlyContext, EarlyLintPass, LintContext};
use rustc_lint::{EarlyContext, EarlyLintPass, Level, LintContext};
use rustc_session::{declare_tool_lint, impl_lint_pass};
use rustc_span::{FileName, Span};
use std::collections::BTreeMap;
Expand Down Expand Up @@ -49,6 +49,7 @@ declare_clippy_lint! {
struct Modules {
local_path: PathBuf,
spans: Vec<Span>,
lint_levels: Vec<Level>,
}

#[derive(Default)]
Expand All @@ -70,13 +71,38 @@ impl EarlyLintPass for DuplicateMod {
let modules = self.modules.entry(absolute_path).or_insert(Modules {
local_path,
spans: Vec::new(),
lint_levels: Vec::new(),
});
modules.spans.push(item.span_with_attributes());
modules.lint_levels.push(cx.get_lint_level(DUPLICATE_MOD));
}
}

fn check_crate_post(&mut self, cx: &EarlyContext<'_>, _: &Crate) {
for Modules { local_path, spans } in self.modules.values() {
for Modules {
local_path,
spans,
lint_levels,
} in self.modules.values()
{
if spans.len() < 2 {
continue;
}

// At this point the lint would be emitted
assert_eq!(spans.len(), lint_levels.len());
let spans: Vec<_> = spans
.iter()
.zip(lint_levels)
.filter_map(|(span, lvl)| {
if let Some(id) = lvl.get_expectation_id() {
cx.fulfill_expectation(id);
}

(!matches!(lvl, Level::Allow | Level::Expect(_))).then_some(*span)
})
.collect();

if spans.len() < 2 {
continue;
}
Expand Down
16 changes: 5 additions & 11 deletions clippy_lints/src/escape.rs
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
use clippy_utils::diagnostics::span_lint_hir;
use clippy_utils::ty::contains_ty;
use rustc_hir::intravisit;
use rustc_hir::{self, AssocItemKind, Body, FnDecl, HirId, HirIdSet, Impl, ItemKind, Node};
use rustc_hir::{self, AssocItemKind, Body, FnDecl, HirId, HirIdSet, Impl, ItemKind, Node, Pat, PatKind};
use rustc_infer::infer::TyCtxtInferExt;
use rustc_lint::{LateContext, LateLintPass};
use rustc_middle::mir::FakeReadCause;
Expand Down Expand Up @@ -132,7 +132,10 @@ impl<'tcx> LateLintPass<'tcx> for BoxedLocal {
// TODO: Replace with Map::is_argument(..) when it's fixed
fn is_argument(map: rustc_middle::hir::map::Map<'_>, id: HirId) -> bool {
match map.find(id) {
Some(Node::Binding(_)) => (),
Some(Node::Pat(Pat {
kind: PatKind::Binding(..),
..
})) => (),
_ => return false,
}

Expand All @@ -144,15 +147,6 @@ impl<'a, 'tcx> Delegate<'tcx> for EscapeDelegate<'a, 'tcx> {
if cmt.place.projections.is_empty() {
if let PlaceBase::Local(lid) = cmt.place.base {
self.set.remove(&lid);
let map = &self.cx.tcx.hir();
if let Some(Node::Binding(_)) = map.find(cmt.hir_id) {
if self.set.contains(&lid) {
// let y = x where x is known
// remove x, insert y
self.set.insert(cmt.hir_id);
self.set.remove(&lid);
}
}
}
}
}
Expand Down
6 changes: 3 additions & 3 deletions clippy_lints/src/eta_reduction.rs
Original file line number Diff line number Diff line change
Expand Up @@ -7,12 +7,12 @@ use clippy_utils::{higher, is_adjusted, path_to_local, path_to_local_id};
use if_chain::if_chain;
use rustc_errors::Applicability;
use rustc_hir::def_id::DefId;
use rustc_hir::{Expr, ExprKind, Param, PatKind, Unsafety};
use rustc_hir::{Closure, Expr, ExprKind, Param, PatKind, Unsafety};
use rustc_lint::{LateContext, LateLintPass};
use rustc_middle::ty::adjustment::{Adjust, Adjustment, AutoBorrow};
use rustc_middle::ty::binding::BindingMode;
use rustc_middle::ty::subst::Subst;
use rustc_middle::ty::{self, ClosureKind, Ty, TypeFoldable};
use rustc_middle::ty::{self, ClosureKind, Ty, TypeVisitable};
use rustc_session::{declare_lint_pass, declare_tool_lint};
use rustc_span::symbol::sym;

Expand Down Expand Up @@ -78,7 +78,7 @@ impl<'tcx> LateLintPass<'tcx> for EtaReduction {
return;
}
let body = match expr.kind {
ExprKind::Closure { body, .. } => cx.tcx.hir().body(body),
ExprKind::Closure(&Closure { body, .. }) => cx.tcx.hir().body(body),
_ => return,
};
if body.value.span.from_expansion() {
Expand Down
2 changes: 1 addition & 1 deletion clippy_lints/src/excessive_bools.rs
Original file line number Diff line number Diff line change
Expand Up @@ -94,7 +94,7 @@ impl ExcessiveBools {

fn check_fn_sig(&self, cx: &EarlyContext<'_>, fn_sig: &FnSig, span: Span) {
match fn_sig.header.ext {
Extern::Implicit | Extern::Explicit(_) => return,
Extern::Implicit(_) | Extern::Explicit(_, _) => return,
Extern::None => (),
}

Expand Down
2 changes: 1 addition & 1 deletion clippy_lints/src/explicit_write.rs
Original file line number Diff line number Diff line change
Expand Up @@ -125,7 +125,7 @@ fn look_in_block<'tcx, 'hir>(cx: &LateContext<'tcx>, kind: &'tcx ExprKind<'hir>)
// Find id of the local that expr_end_of_block resolves to
if let ExprKind::Path(QPath::Resolved(None, expr_path)) = expr_end_of_block.kind;
if let Res::Local(expr_res) = expr_path.res;
if let Some(Node::Binding(res_pat)) = cx.tcx.hir().find(expr_res);
if let Some(Node::Pat(res_pat)) = cx.tcx.hir().find(expr_res);

// Find id of the local we found in the block
if let PatKind::Binding(BindingAnnotation::Unannotated, local_hir_id, _ident, None) = local.pat.kind;
Expand Down
4 changes: 2 additions & 2 deletions clippy_lints/src/infinite_iter.rs
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
use clippy_utils::diagnostics::span_lint;
use clippy_utils::ty::{implements_trait, is_type_diagnostic_item};
use clippy_utils::{higher, match_def_path, path_def_id, paths};
use rustc_hir::{BorrowKind, Expr, ExprKind};
use rustc_hir::{BorrowKind, Closure, Expr, ExprKind};
use rustc_lint::{LateContext, LateLintPass};
use rustc_session::{declare_lint_pass, declare_tool_lint};
use rustc_span::symbol::{sym, Symbol};
Expand Down Expand Up @@ -159,7 +159,7 @@ fn is_infinite(cx: &LateContext<'_>, expr: &Expr<'_>) -> Finiteness {
}
}
if method.ident.name == sym!(flat_map) && args.len() == 2 {
if let ExprKind::Closure { body, .. } = args[1].kind {
if let ExprKind::Closure(&Closure { body, .. }) = args[1].kind {
let body = cx.tcx.hir().body(body);
return is_infinite(cx, &body.value);
}
Expand Down
4 changes: 2 additions & 2 deletions clippy_lints/src/inherent_to_string.rs
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,7 @@ use clippy_utils::diagnostics::span_lint_and_help;
use clippy_utils::ty::{implements_trait, is_type_diagnostic_item};
use clippy_utils::{get_trait_def_id, paths, return_ty, trait_ref_of_method};
use if_chain::if_chain;
use rustc_hir::{ImplItem, ImplItemKind};
use rustc_hir::{GenericParamKind, ImplItem, ImplItemKind};
use rustc_lint::{LateContext, LateLintPass};
use rustc_session::{declare_lint_pass, declare_tool_lint};
use rustc_span::sym;
Expand Down Expand Up @@ -102,7 +102,7 @@ impl<'tcx> LateLintPass<'tcx> for InherentToString {
let decl = &signature.decl;
if decl.implicit_self.has_implicit_self();
if decl.inputs.len() == 1;
if impl_item.generics.params.is_empty();
if impl_item.generics.params.iter().all(|p| matches!(p.kind, GenericParamKind::Lifetime { .. }));

// Check if return type is String
if is_type_diagnostic_item(cx, return_ty(cx, impl_item.hir_id()), sym::String);
Expand Down
10 changes: 7 additions & 3 deletions clippy_lints/src/lifetimes.rs
Original file line number Diff line number Diff line change
Expand Up @@ -9,8 +9,8 @@ use rustc_hir::intravisit::{
use rustc_hir::FnRetTy::Return;
use rustc_hir::{
BareFnTy, BodyId, FnDecl, GenericArg, GenericBound, GenericParam, GenericParamKind, Generics, Impl, ImplItem,
ImplItemKind, Item, ItemKind, LangItem, Lifetime, LifetimeName, ParamName, PolyTraitRef, PredicateOrigin,
TraitBoundModifier, TraitFn, TraitItem, TraitItemKind, Ty, TyKind, WherePredicate,
ImplItemKind, Item, ItemKind, LangItem, Lifetime, LifetimeName, LifetimeParamKind, ParamName, PolyTraitRef,
PredicateOrigin, TraitBoundModifier, TraitFn, TraitItem, TraitItemKind, Ty, TyKind, WherePredicate,
};
use rustc_lint::{LateContext, LateLintPass};
use rustc_middle::hir::nested_filter as middle_nested_filter;
Expand Down Expand Up @@ -338,7 +338,10 @@ fn could_use_elision<'tcx>(
fn allowed_lts_from(named_generics: &[GenericParam<'_>]) -> FxHashSet<RefLt> {
let mut allowed_lts = FxHashSet::default();
for par in named_generics.iter() {
if let GenericParamKind::Lifetime { .. } = par.kind {
if let GenericParamKind::Lifetime {
kind: LifetimeParamKind::Explicit,
} = par.kind
{
allowed_lts.insert(RefLt::Named(par.name.ident().name));
}
}
Expand Down Expand Up @@ -379,6 +382,7 @@ impl<'a, 'tcx> RefVisitor<'a, 'tcx> {
self.lts.push(RefLt::Static);
} else if let LifetimeName::Param(_, ParamName::Fresh) = lt.name {
// Fresh lifetimes generated should be ignored.
self.lts.push(RefLt::Unnamed);
} else if lt.is_elided() {
self.lts.push(RefLt::Unnamed);
} else {
Expand Down
2 changes: 1 addition & 1 deletion clippy_lints/src/loops/mut_range_bound.rs
Original file line number Diff line number Diff line change
Expand Up @@ -43,7 +43,7 @@ fn mut_warn_with_span(cx: &LateContext<'_>, span: Option<Span>) {
fn check_for_mutability(cx: &LateContext<'_>, bound: &Expr<'_>) -> Option<HirId> {
if_chain! {
if let Some(hir_id) = path_to_local(bound);
if let Node::Binding(pat) = cx.tcx.hir().get(hir_id);
if let Node::Pat(pat) = cx.tcx.hir().get(hir_id);
if let PatKind::Binding(BindingAnnotation::Mutable, ..) = pat.kind;
then {
return Some(hir_id);
Expand Down
4 changes: 2 additions & 2 deletions clippy_lints/src/loops/needless_range_loop.rs
Original file line number Diff line number Diff line change
Expand Up @@ -9,7 +9,7 @@ use rustc_ast::ast;
use rustc_data_structures::fx::{FxHashMap, FxHashSet};
use rustc_hir::def::{DefKind, Res};
use rustc_hir::intravisit::{walk_expr, Visitor};
use rustc_hir::{BinOpKind, BorrowKind, Expr, ExprKind, HirId, Mutability, Pat, PatKind, QPath};
use rustc_hir::{BinOpKind, BorrowKind, Closure, Expr, ExprKind, HirId, Mutability, Pat, PatKind, QPath};
use rustc_lint::LateContext;
use rustc_middle::middle::region;
use rustc_middle::ty::{self, Ty};
Expand Down Expand Up @@ -369,7 +369,7 @@ impl<'a, 'tcx> Visitor<'tcx> for VarVisitor<'a, 'tcx> {
self.visit_expr(expr);
}
},
ExprKind::Closure { body, .. } => {
ExprKind::Closure(&Closure { body, .. }) => {
let body = self.cx.tcx.hir().body(body);
self.visit_expr(&body.value);
},
Expand Down
Loading