Skip to content

Commit 1d168b3

Browse files
authored
Merge branch 'rust-lang:master' into clear-with-drain
2 parents d56c941 + 5ed64d4 commit 1d168b3

File tree

67 files changed

+715
-321
lines changed

Some content is hidden

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

67 files changed

+715
-321
lines changed

.cargo/config.toml

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -11,3 +11,6 @@ target-dir = "target"
1111

1212
[unstable]
1313
binary-dep-depinfo = true
14+
15+
[profile.dev]
16+
split-debuginfo = "unpacked"

.github/workflows/clippy_bors.yml

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -180,6 +180,8 @@ jobs:
180180

181181
# Run
182182
- name: Build Integration Test
183+
env:
184+
CARGO_PROFILE_DEV_SPLIT_DEBUGINFO: off
183185
run: cargo test --test integration --features integration --no-run
184186

185187
# Upload

CHANGELOG.md

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -4988,6 +4988,7 @@ Released 2018-09-13
49884988
[`unnecessary_safety_doc`]: https://rust-lang.github.io/rust-clippy/master/index.html#unnecessary_safety_doc
49894989
[`unnecessary_self_imports`]: https://rust-lang.github.io/rust-clippy/master/index.html#unnecessary_self_imports
49904990
[`unnecessary_sort_by`]: https://rust-lang.github.io/rust-clippy/master/index.html#unnecessary_sort_by
4991+
[`unnecessary_struct_initialization`]: https://rust-lang.github.io/rust-clippy/master/index.html#unnecessary_struct_initialization
49914992
[`unnecessary_to_owned`]: https://rust-lang.github.io/rust-clippy/master/index.html#unnecessary_to_owned
49924993
[`unnecessary_unwrap`]: https://rust-lang.github.io/rust-clippy/master/index.html#unnecessary_unwrap
49934994
[`unnecessary_wraps`]: https://rust-lang.github.io/rust-clippy/master/index.html#unnecessary_wraps

COPYRIGHT

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,11 @@
1+
// REUSE-IgnoreStart
2+
13
Copyright 2014-2022 The Rust Project Developers
24

35
Licensed under the Apache License, Version 2.0 <LICENSE-APACHE or
46
http://www.apache.org/licenses/LICENSE-2.0> or the MIT license
57
<LICENSE-MIT or http://opensource.org/licenses/MIT>, at your
68
option. All files in the project carrying such notice may not be
79
copied, modified, or distributed except according to those terms.
10+
11+
// REUSE-IgnoreEnd

README.md

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -275,10 +275,14 @@ If you want to contribute to Clippy, you can find more information in [CONTRIBUT
275275

276276
## License
277277

278+
<!-- REUSE-IgnoreStart -->
279+
278280
Copyright 2014-2022 The Rust Project Developers
279281

280282
Licensed under the Apache License, Version 2.0 <LICENSE-APACHE or
281283
[https://www.apache.org/licenses/LICENSE-2.0](https://www.apache.org/licenses/LICENSE-2.0)> or the MIT license
282284
<LICENSE-MIT or [https://opensource.org/licenses/MIT](https://opensource.org/licenses/MIT)>, at your
283285
option. Files in the project may not be
284286
copied, modified, or distributed except according to those terms.
287+
288+
<!-- REUSE-IgnoreEnd -->

book/src/development/adding_lints.md

Lines changed: 10 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -18,6 +18,7 @@ because that's clearly a non-descriptive name.
1818
- [Cargo lints](#cargo-lints)
1919
- [Rustfix tests](#rustfix-tests)
2020
- [Testing manually](#testing-manually)
21+
- [Running directly](#running-directly)
2122
- [Lint declaration](#lint-declaration)
2223
- [Lint registration](#lint-registration)
2324
- [Lint passes](#lint-passes)
@@ -186,6 +187,15 @@ cargo dev lint input.rs
186187
from the working copy root. With tests in place, let's have a look at
187188
implementing our lint now.
188189

190+
## Running directly
191+
192+
While it's easier to just use `cargo dev lint`, it might be desirable to get
193+
`target/release/cargo-clippy` and `target/release/clippy-driver` to work as well in some cases.
194+
By default, they don't work because clippy dynamically links rustc. To help them find rustc,
195+
add the path printed by`rustc --print target-libdir` (ran inside this workspace so that the rustc version matches)
196+
to your library search path.
197+
On linux, this can be done by setting the `LD_LIBRARY_PATH` environment variable to that path.
198+
189199
## Lint declaration
190200

191201
Let's start by opening the new file created in the `clippy_lints` crate at

clippy_lints/src/booleans.rs

Lines changed: 13 additions & 12 deletions
Original file line numberDiff line numberDiff line change
@@ -495,18 +495,19 @@ struct NotSimplificationVisitor<'a, 'tcx> {
495495

496496
impl<'a, 'tcx> Visitor<'tcx> for NotSimplificationVisitor<'a, 'tcx> {
497497
fn visit_expr(&mut self, expr: &'tcx Expr<'_>) {
498-
if let ExprKind::Unary(UnOp::Not, inner) = &expr.kind {
499-
if let Some(suggestion) = simplify_not(self.cx, inner) {
500-
span_lint_and_sugg(
501-
self.cx,
502-
NONMINIMAL_BOOL,
503-
expr.span,
504-
"this boolean expression can be simplified",
505-
"try",
506-
suggestion,
507-
Applicability::MachineApplicable,
508-
);
509-
}
498+
if let ExprKind::Unary(UnOp::Not, inner) = &expr.kind &&
499+
!inner.span.from_expansion() &&
500+
let Some(suggestion) = simplify_not(self.cx, inner)
501+
{
502+
span_lint_and_sugg(
503+
self.cx,
504+
NONMINIMAL_BOOL,
505+
expr.span,
506+
"this boolean expression can be simplified",
507+
"try",
508+
suggestion,
509+
Applicability::MachineApplicable,
510+
);
510511
}
511512

512513
walk_expr(self, expr);

clippy_lints/src/casts/cast_possible_truncation.rs

Lines changed: 29 additions & 13 deletions
Original file line numberDiff line numberDiff line change
@@ -2,8 +2,9 @@ use clippy_utils::consts::{constant, Constant};
22
use clippy_utils::diagnostics::{span_lint, span_lint_and_then};
33
use clippy_utils::expr_or_init;
44
use clippy_utils::source::snippet;
5+
use clippy_utils::sugg::Sugg;
56
use clippy_utils::ty::{get_discriminant_value, is_isize_or_usize};
6-
use rustc_errors::{Applicability, SuggestionStyle};
7+
use rustc_errors::{Applicability, Diagnostic, SuggestionStyle};
78
use rustc_hir::def::{DefKind, Res};
89
use rustc_hir::{BinOpKind, Expr, ExprKind};
910
use rustc_lint::LateContext;
@@ -163,19 +164,34 @@ pub(super) fn check(
163164
_ => return,
164165
};
165166

166-
let name_of_cast_from = snippet(cx, cast_expr.span, "..");
167-
let cast_to_snip = snippet(cx, cast_to_span, "..");
168-
let suggestion = format!("{cast_to_snip}::try_from({name_of_cast_from})");
169-
170167
span_lint_and_then(cx, CAST_POSSIBLE_TRUNCATION, expr.span, &msg, |diag| {
171168
diag.help("if this is intentional allow the lint with `#[allow(clippy::cast_possible_truncation)]` ...");
172-
diag.span_suggestion_with_style(
173-
expr.span,
174-
"... or use `try_from` and handle the error accordingly",
175-
suggestion,
176-
Applicability::Unspecified,
177-
// always show the suggestion in a separate line
178-
SuggestionStyle::ShowAlways,
179-
);
169+
if !cast_from.is_floating_point() {
170+
offer_suggestion(cx, expr, cast_expr, cast_to_span, diag);
171+
}
180172
});
181173
}
174+
175+
fn offer_suggestion(
176+
cx: &LateContext<'_>,
177+
expr: &Expr<'_>,
178+
cast_expr: &Expr<'_>,
179+
cast_to_span: Span,
180+
diag: &mut Diagnostic,
181+
) {
182+
let cast_to_snip = snippet(cx, cast_to_span, "..");
183+
let suggestion = if cast_to_snip == "_" {
184+
format!("{}.try_into()", Sugg::hir(cx, cast_expr, "..").maybe_par())
185+
} else {
186+
format!("{cast_to_snip}::try_from({})", Sugg::hir(cx, cast_expr, ".."))
187+
};
188+
189+
diag.span_suggestion_with_style(
190+
expr.span,
191+
"... or use `try_from` and handle the error accordingly",
192+
suggestion,
193+
Applicability::Unspecified,
194+
// always show the suggestion in a separate line
195+
SuggestionStyle::ShowAlways,
196+
);
197+
}

clippy_lints/src/cognitive_complexity.rs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -143,7 +143,7 @@ impl<'tcx> LateLintPass<'tcx> for CognitiveComplexity {
143143
span: Span,
144144
def_id: LocalDefId,
145145
) {
146-
if !cx.tcx.has_attr(def_id.to_def_id(), sym::test) {
146+
if !cx.tcx.has_attr(def_id, sym::test) {
147147
let expr = if is_async_fn(kind) {
148148
match get_async_fn_body(cx.tcx, body) {
149149
Some(b) => b,

clippy_lints/src/declared_lints.rs

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -619,6 +619,7 @@ pub(crate) static LINTS: &[&crate::LintInfo] = &[
619619
crate::unnamed_address::VTABLE_ADDRESS_COMPARISONS_INFO,
620620
crate::unnecessary_owned_empty_strings::UNNECESSARY_OWNED_EMPTY_STRINGS_INFO,
621621
crate::unnecessary_self_imports::UNNECESSARY_SELF_IMPORTS_INFO,
622+
crate::unnecessary_struct_initialization::UNNECESSARY_STRUCT_INITIALIZATION_INFO,
622623
crate::unnecessary_wraps::UNNECESSARY_WRAPS_INFO,
623624
crate::unnested_or_patterns::UNNESTED_OR_PATTERNS_INFO,
624625
crate::unsafe_removed_from_name::UNSAFE_REMOVED_FROM_NAME_INFO,

clippy_lints/src/derivable_impls.rs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -181,7 +181,7 @@ impl<'tcx> LateLintPass<'tcx> for DerivableImpls {
181181
self_ty,
182182
..
183183
}) = item.kind;
184-
if !cx.tcx.has_attr(item.owner_id.to_def_id(), sym::automatically_derived);
184+
if !cx.tcx.has_attr(item.owner_id, sym::automatically_derived);
185185
if !item.span.from_expansion();
186186
if let Some(def_id) = trait_ref.trait_def_id();
187187
if cx.tcx.is_diagnostic_item(sym::Default, def_id);

clippy_lints/src/derive.rs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -212,7 +212,7 @@ impl<'tcx> LateLintPass<'tcx> for Derive {
212212
}) = item.kind
213213
{
214214
let ty = cx.tcx.type_of(item.owner_id).subst_identity();
215-
let is_automatically_derived = cx.tcx.has_attr(item.owner_id.to_def_id(), sym::automatically_derived);
215+
let is_automatically_derived = cx.tcx.has_attr(item.owner_id, sym::automatically_derived);
216216

217217
check_hash_peq(cx, item.span, trait_ref, ty, is_automatically_derived);
218218
check_ord_partial_ord(cx, item.span, trait_ref, ty, is_automatically_derived);

clippy_lints/src/disallowed_script_idents.rs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -32,7 +32,7 @@ declare_clippy_lint! {
3232
/// ### Example
3333
/// ```rust
3434
/// // Assuming that `clippy.toml` contains the following line:
35-
/// // allowed-locales = ["Latin", "Cyrillic"]
35+
/// // allowed-scripts = ["Latin", "Cyrillic"]
3636
/// let counter = 10; // OK, latin is allowed.
3737
/// let счётчик = 10; // OK, cyrillic is allowed.
3838
/// let zähler = 10; // OK, it's still latin.

clippy_lints/src/functions/must_use.rs

Lines changed: 6 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -22,13 +22,13 @@ use super::{DOUBLE_MUST_USE, MUST_USE_CANDIDATE, MUST_USE_UNIT};
2222

2323
pub(super) fn check_item<'tcx>(cx: &LateContext<'tcx>, item: &'tcx hir::Item<'_>) {
2424
let attrs = cx.tcx.hir().attrs(item.hir_id());
25-
let attr = cx.tcx.get_attr(item.owner_id.to_def_id(), sym::must_use);
25+
let attr = cx.tcx.get_attr(item.owner_id, sym::must_use);
2626
if let hir::ItemKind::Fn(ref sig, _generics, ref body_id) = item.kind {
2727
let is_public = cx.effective_visibilities.is_exported(item.owner_id.def_id);
2828
let fn_header_span = item.span.with_hi(sig.decl.output.span().hi());
2929
if let Some(attr) = attr {
3030
check_needless_must_use(cx, sig.decl, item.owner_id, item.span, fn_header_span, attr);
31-
} else if is_public && !is_proc_macro(cx.sess(), attrs) && !attrs.iter().any(|a| a.has_name(sym::no_mangle)) {
31+
} else if is_public && !is_proc_macro(attrs) && !attrs.iter().any(|a| a.has_name(sym::no_mangle)) {
3232
check_must_use_candidate(
3333
cx,
3434
sig.decl,
@@ -47,13 +47,10 @@ pub(super) fn check_impl_item<'tcx>(cx: &LateContext<'tcx>, item: &'tcx hir::Imp
4747
let is_public = cx.effective_visibilities.is_exported(item.owner_id.def_id);
4848
let fn_header_span = item.span.with_hi(sig.decl.output.span().hi());
4949
let attrs = cx.tcx.hir().attrs(item.hir_id());
50-
let attr = cx.tcx.get_attr(item.owner_id.to_def_id(), sym::must_use);
50+
let attr = cx.tcx.get_attr(item.owner_id, sym::must_use);
5151
if let Some(attr) = attr {
5252
check_needless_must_use(cx, sig.decl, item.owner_id, item.span, fn_header_span, attr);
53-
} else if is_public
54-
&& !is_proc_macro(cx.sess(), attrs)
55-
&& trait_ref_of_method(cx, item.owner_id.def_id).is_none()
56-
{
53+
} else if is_public && !is_proc_macro(attrs) && trait_ref_of_method(cx, item.owner_id.def_id).is_none() {
5754
check_must_use_candidate(
5855
cx,
5956
sig.decl,
@@ -73,12 +70,12 @@ pub(super) fn check_trait_item<'tcx>(cx: &LateContext<'tcx>, item: &'tcx hir::Tr
7370
let fn_header_span = item.span.with_hi(sig.decl.output.span().hi());
7471

7572
let attrs = cx.tcx.hir().attrs(item.hir_id());
76-
let attr = cx.tcx.get_attr(item.owner_id.to_def_id(), sym::must_use);
73+
let attr = cx.tcx.get_attr(item.owner_id, sym::must_use);
7774
if let Some(attr) = attr {
7875
check_needless_must_use(cx, sig.decl, item.owner_id, item.span, fn_header_span, attr);
7976
} else if let hir::TraitFn::Provided(eid) = *eid {
8077
let body = cx.tcx.hir().body(eid);
81-
if attr.is_none() && is_public && !is_proc_macro(cx.sess(), attrs) {
78+
if attr.is_none() && is_public && !is_proc_macro(attrs) {
8279
check_must_use_candidate(
8380
cx,
8481
sig.decl,

clippy_lints/src/future_not_send.rs

Lines changed: 4 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -9,7 +9,7 @@ use rustc_session::{declare_lint_pass, declare_tool_lint};
99
use rustc_span::def_id::LocalDefId;
1010
use rustc_span::{sym, Span};
1111
use rustc_trait_selection::traits::error_reporting::suggestions::TypeErrCtxtExt;
12-
use rustc_trait_selection::traits::{self, FulfillmentError};
12+
use rustc_trait_selection::traits::{self, FulfillmentError, ObligationCtxt};
1313

1414
declare_clippy_lint! {
1515
/// ### What it does
@@ -79,8 +79,10 @@ impl<'tcx> LateLintPass<'tcx> for FutureNotSend {
7979
let send_trait = cx.tcx.get_diagnostic_item(sym::Send).unwrap();
8080
let span = decl.output.span();
8181
let infcx = cx.tcx.infer_ctxt().build();
82+
let ocx = ObligationCtxt::new(&infcx);
8283
let cause = traits::ObligationCause::misc(span, fn_def_id);
83-
let send_errors = traits::fully_solve_bound(&infcx, cause, cx.param_env, ret_ty, send_trait);
84+
ocx.register_bound(cause, cx.param_env, ret_ty, send_trait);
85+
let send_errors = ocx.select_all_or_error();
8486
if !send_errors.is_empty() {
8587
span_lint_and_then(
8688
cx,

clippy_lints/src/infinite_iter.rs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -167,7 +167,7 @@ fn is_infinite(cx: &LateContext<'_>, expr: &Expr<'_>) -> Finiteness {
167167
Finite
168168
},
169169
ExprKind::Block(block, _) => block.expr.as_ref().map_or(Finite, |e| is_infinite(cx, e)),
170-
ExprKind::Box(e) | ExprKind::AddrOf(BorrowKind::Ref, _, e) => is_infinite(cx, e),
170+
ExprKind::AddrOf(BorrowKind::Ref, _, e) => is_infinite(cx, e),
171171
ExprKind::Call(path, _) => {
172172
if let ExprKind::Path(ref qpath) = path.kind {
173173
cx.qpath_res(qpath, path.hir_id)

clippy_lints/src/lib.rs

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -302,6 +302,7 @@ mod unit_types;
302302
mod unnamed_address;
303303
mod unnecessary_owned_empty_strings;
304304
mod unnecessary_self_imports;
305+
mod unnecessary_struct_initialization;
305306
mod unnecessary_wraps;
306307
mod unnested_or_patterns;
307308
mod unsafe_removed_from_name;
@@ -938,6 +939,7 @@ pub fn register_plugins(store: &mut rustc_lint::LintStore, sess: &Session, conf:
938939
store.register_late_pass(|_| Box::new(let_with_type_underscore::UnderscoreTyped));
939940
store.register_late_pass(|_| Box::new(allow_attributes::AllowAttribute));
940941
store.register_late_pass(move |_| Box::new(manual_main_separator_str::ManualMainSeparatorStr::new(msrv())));
942+
store.register_late_pass(|_| Box::new(unnecessary_struct_initialization::UnnecessaryStruct));
941943
// add lints here, do not remove this comment, it's used in `new_lint`
942944
}
943945

clippy_lints/src/loops/never_loop.rs

Lines changed: 1 addition & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -124,8 +124,7 @@ fn stmt_to_expr<'tcx>(stmt: &Stmt<'tcx>) -> Option<(&'tcx Expr<'tcx>, Option<&'t
124124
#[allow(clippy::too_many_lines)]
125125
fn never_loop_expr(expr: &Expr<'_>, ignore_ids: &mut Vec<HirId>, main_loop_id: HirId) -> NeverLoopResult {
126126
match expr.kind {
127-
ExprKind::Box(e)
128-
| ExprKind::Unary(_, e)
127+
ExprKind::Unary(_, e)
129128
| ExprKind::Cast(e, _)
130129
| ExprKind::Type(e, _)
131130
| ExprKind::Field(e, _)

clippy_lints/src/manual_async_fn.rs

Lines changed: 1 addition & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,4 @@
11
use clippy_utils::diagnostics::span_lint_and_then;
2-
use clippy_utils::match_function_call_with_def_id;
32
use clippy_utils::source::{position_before_rarrow, snippet_block, snippet_opt};
43
use if_chain::if_chain;
54
use rustc_errors::Applicability;
@@ -184,16 +183,10 @@ fn captures_all_lifetimes(inputs: &[Ty<'_>], output_lifetimes: &[LifetimeName])
184183
fn desugared_async_block<'tcx>(cx: &LateContext<'tcx>, block: &'tcx Block<'tcx>) -> Option<&'tcx Body<'tcx>> {
185184
if_chain! {
186185
if let Some(block_expr) = block.expr;
187-
if let Some(args) = cx
188-
.tcx
189-
.lang_items()
190-
.identity_future_fn()
191-
.and_then(|def_id| match_function_call_with_def_id(cx, block_expr, def_id));
192-
if args.len() == 1;
193186
if let Expr {
194187
kind: ExprKind::Closure(&Closure { body, .. }),
195188
..
196-
} = args[0];
189+
} = block_expr;
197190
let closure_body = cx.tcx.hir().body(body);
198191
if closure_body.generator_kind == Some(GeneratorKind::Async(AsyncGeneratorKind::Block));
199192
then {

clippy_lints/src/matches/significant_drop_in_scrutinee.rs

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -321,7 +321,6 @@ impl<'a, 'tcx> Visitor<'tcx> for SigDropHelper<'a, 'tcx> {
321321
self.has_significant_drop = true;
322322
}
323323
}
324-
ExprKind::Box(..) |
325324
ExprKind::Array(..) |
326325
ExprKind::Call(..) |
327326
ExprKind::Unary(..) |

clippy_lints/src/methods/unnecessary_sort_by.rs

Lines changed: 0 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -33,10 +33,6 @@ struct SortByKeyDetection {
3333
/// contains a and the other replaces it with b)
3434
fn mirrored_exprs(a_expr: &Expr<'_>, a_ident: &Ident, b_expr: &Expr<'_>, b_ident: &Ident) -> bool {
3535
match (&a_expr.kind, &b_expr.kind) {
36-
// Two boxes with mirrored contents
37-
(ExprKind::Box(left_expr), ExprKind::Box(right_expr)) => {
38-
mirrored_exprs(left_expr, a_ident, right_expr, b_ident)
39-
},
4036
// Two arrays with mirrored contents
4137
(ExprKind::Array(left_exprs), ExprKind::Array(right_exprs)) => {
4238
iter::zip(*left_exprs, *right_exprs).all(|(left, right)| mirrored_exprs(left, a_ident, right, b_ident))

clippy_lints/src/methods/unnecessary_to_owned.rs

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -369,10 +369,10 @@ fn can_change_type<'a>(cx: &LateContext<'a>, mut expr: &'a Expr<'a>, mut ty: Ty<
369369
Node::Item(item) => {
370370
if let ItemKind::Fn(_, _, body_id) = &item.kind
371371
&& let output_ty = return_ty(cx, item.owner_id)
372-
&& Inherited::build(cx.tcx, item.owner_id.def_id).enter(|inherited| {
373-
let fn_ctxt = FnCtxt::new(inherited, cx.param_env, item.owner_id.def_id);
374-
fn_ctxt.can_coerce(ty, output_ty)
375-
}) {
372+
&& let inherited = Inherited::new(cx.tcx, item.owner_id.def_id)
373+
&& let fn_ctxt = FnCtxt::new(&inherited, cx.param_env, item.owner_id.def_id)
374+
&& fn_ctxt.can_coerce(ty, output_ty)
375+
{
376376
if has_lifetime(output_ty) && has_lifetime(ty) {
377377
return false;
378378
}

clippy_lints/src/no_effect.rs

Lines changed: 2 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -127,8 +127,7 @@ fn has_no_effect(cx: &LateContext<'_>, expr: &Expr<'_>) -> bool {
127127
| ExprKind::Type(inner, _)
128128
| ExprKind::Unary(_, inner)
129129
| ExprKind::Field(inner, _)
130-
| ExprKind::AddrOf(_, _, inner)
131-
| ExprKind::Box(inner) => has_no_effect(cx, inner),
130+
| ExprKind::AddrOf(_, _, inner) => has_no_effect(cx, inner),
132131
ExprKind::Struct(_, fields, ref base) => {
133132
!has_drop(cx, cx.typeck_results().expr_ty(expr))
134133
&& fields.iter().all(|field| has_no_effect(cx, field.expr))
@@ -234,8 +233,7 @@ fn reduce_expression<'a>(cx: &LateContext<'_>, expr: &'a Expr<'a>) -> Option<Vec
234233
| ExprKind::Type(inner, _)
235234
| ExprKind::Unary(_, inner)
236235
| ExprKind::Field(inner, _)
237-
| ExprKind::AddrOf(_, _, inner)
238-
| ExprKind::Box(inner) => reduce_expression(cx, inner).or_else(|| Some(vec![inner])),
236+
| ExprKind::AddrOf(_, _, inner) => reduce_expression(cx, inner).or_else(|| Some(vec![inner])),
239237
ExprKind::Struct(_, fields, ref base) => {
240238
if has_drop(cx, cx.typeck_results().expr_ty(expr)) {
241239
None

clippy_lints/src/partialeq_ne_impl.rs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -36,7 +36,7 @@ impl<'tcx> LateLintPass<'tcx> for PartialEqNeImpl {
3636
fn check_item(&mut self, cx: &LateContext<'tcx>, item: &'tcx Item<'_>) {
3737
if_chain! {
3838
if let ItemKind::Impl(Impl { of_trait: Some(ref trait_ref), items: impl_items, .. }) = item.kind;
39-
if !cx.tcx.has_attr(item.owner_id.to_def_id(), sym::automatically_derived);
39+
if !cx.tcx.has_attr(item.owner_id, sym::automatically_derived);
4040
if let Some(eq_trait) = cx.tcx.lang_items().eq_trait();
4141
if trait_ref.path.res.def_id() == eq_trait;
4242
then {

0 commit comments

Comments
 (0)