Skip to content

Commit b312ad7

Browse files
committed
Auto merge of #8856 - xFrednet:rustup, r=Manishearth,Alexendoo
Rustup `@rust-lang/clippy,` `@Jarcho,` `@dswij,` `@Alexendoo.` Could someone review this? It should be pretty straight forward since it's just a sync. I think it's also fine if either one of `@Jarcho,` `@dswij,` `@Alexendoo` approves this, as these are usually not reviewed. I just want to make sure that I didn't break something obvious 🙃 It should be enough to look at the merge commit 🙃 changelog: none changelog: move [`significant_drop_in_scrutinee`] to `suspicious`
2 parents f26f117 + 7842dbc commit b312ad7

Some content is hidden

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

43 files changed

+1538
-136
lines changed

CHANGELOG.md

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -3715,6 +3715,7 @@ Released 2018-09-13
37153715
[`short_circuit_statement`]: https://rust-lang.github.io/rust-clippy/master/index.html#short_circuit_statement
37163716
[`should_assert_eq`]: https://rust-lang.github.io/rust-clippy/master/index.html#should_assert_eq
37173717
[`should_implement_trait`]: https://rust-lang.github.io/rust-clippy/master/index.html#should_implement_trait
3718+
[`significant_drop_in_scrutinee`]: https://rust-lang.github.io/rust-clippy/master/index.html#significant_drop_in_scrutinee
37183719
[`similar_names`]: https://rust-lang.github.io/rust-clippy/master/index.html#similar_names
37193720
[`single_char_add_str`]: https://rust-lang.github.io/rust-clippy/master/index.html#single_char_add_str
37203721
[`single_char_lifetime_names`]: https://rust-lang.github.io/rust-clippy/master/index.html#single_char_lifetime_names

Cargo.toml

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
11
[package]
22
name = "clippy"
3-
version = "0.1.62"
3+
version = "0.1.63"
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/Cargo.toml

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
11
[package]
22
name = "clippy_lints"
3-
version = "0.1.62"
3+
version = "0.1.63"
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/collapsible_match.rs

Lines changed: 5 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -5,7 +5,7 @@ use clippy_utils::{is_lang_ctor, is_unit_expr, path_to_local, peel_blocks_with_s
55
use if_chain::if_chain;
66
use rustc_errors::MultiSpan;
77
use rustc_hir::LangItem::OptionNone;
8-
use rustc_hir::{Arm, Expr, Guard, HirId, Pat, PatKind};
8+
use rustc_hir::{Arm, Expr, Guard, HirId, Let, Pat, PatKind};
99
use rustc_lint::{LateContext, LateLintPass};
1010
use rustc_session::{declare_lint_pass, declare_tool_lint};
1111
use rustc_span::Span;
@@ -109,7 +109,10 @@ fn check_arm<'tcx>(
109109
(Some(a), Some(b)) => SpanlessEq::new(cx).eq_expr(a, b),
110110
};
111111
// the binding must not be used in the if guard
112-
if outer_guard.map_or(true, |(Guard::If(e) | Guard::IfLet(_, e))| !is_local_used(cx, *e, binding_id));
112+
if outer_guard.map_or(
113+
true,
114+
|(Guard::If(e) | Guard::IfLet(Let { init: e, .. }))| !is_local_used(cx, *e, binding_id)
115+
);
113116
// ...or anywhere in the inner expression
114117
if match inner {
115118
IfLetOrMatch::IfLet(_, _, body, els) => {

clippy_lints/src/derivable_impls.rs

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,5 @@
11
use clippy_utils::diagnostics::span_lint_and_help;
2-
use clippy_utils::{is_automatically_derived, is_default_equivalent, peel_blocks};
2+
use clippy_utils::{is_default_equivalent, peel_blocks};
33
use rustc_hir::{
44
def::{DefKind, Res},
55
Body, Expr, ExprKind, GenericArg, Impl, ImplItemKind, Item, ItemKind, Node, PathSegment, QPath, TyKind,
@@ -71,8 +71,7 @@ impl<'tcx> LateLintPass<'tcx> for DerivableImpls {
7171
self_ty,
7272
..
7373
}) = item.kind;
74-
if let attrs = cx.tcx.hir().attrs(item.hir_id());
75-
if !is_automatically_derived(attrs);
74+
if !cx.tcx.has_attr(item.def_id.to_def_id(), sym::automatically_derived);
7675
if !item.span.from_expansion();
7776
if let Some(def_id) = trait_ref.trait_def_id();
7877
if cx.tcx.is_diagnostic_item(sym::Default, def_id);
@@ -81,6 +80,7 @@ impl<'tcx> LateLintPass<'tcx> for DerivableImpls {
8180
if let ImplItemKind::Fn(_, b) = &impl_item.kind;
8281
if let Body { value: func_expr, .. } = cx.tcx.hir().body(*b);
8382
if let Some(adt_def) = cx.tcx.type_of(item.def_id).ty_adt_def();
83+
if let attrs = cx.tcx.hir().attrs(item.hir_id());
8484
if !attrs.iter().any(|attr| attr.doc_str().is_some());
8585
if let child_attrs = cx.tcx.hir().attrs(impl_item_hir);
8686
if !child_attrs.iter().any(|attr| attr.doc_str().is_some());

clippy_lints/src/derive.rs

Lines changed: 4 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,7 @@
11
use clippy_utils::diagnostics::{span_lint_and_help, span_lint_and_note, span_lint_and_sugg, span_lint_and_then};
22
use clippy_utils::paths;
33
use clippy_utils::ty::{implements_trait, is_copy};
4-
use clippy_utils::{is_automatically_derived, is_lint_allowed, match_def_path};
4+
use clippy_utils::{is_lint_allowed, match_def_path};
55
use if_chain::if_chain;
66
use rustc_errors::Applicability;
77
use rustc_hir::intravisit::{walk_expr, walk_fn, walk_item, FnKind, Visitor};
@@ -205,8 +205,7 @@ impl<'tcx> LateLintPass<'tcx> for Derive {
205205
}) = item.kind
206206
{
207207
let ty = cx.tcx.type_of(item.def_id);
208-
let attrs = cx.tcx.hir().attrs(item.hir_id());
209-
let is_automatically_derived = is_automatically_derived(attrs);
208+
let is_automatically_derived = cx.tcx.has_attr(item.def_id.to_def_id(), sym::automatically_derived);
210209

211210
check_hash_peq(cx, item.span, trait_ref, ty, is_automatically_derived);
212211
check_ord_partial_ord(cx, item.span, trait_ref, ty, is_automatically_derived);
@@ -236,7 +235,7 @@ fn check_hash_peq<'tcx>(
236235
then {
237236
// Look for the PartialEq implementations for `ty`
238237
cx.tcx.for_each_relevant_impl(peq_trait_def_id, ty, |impl_id| {
239-
let peq_is_automatically_derived = is_automatically_derived(cx.tcx.get_attrs(impl_id));
238+
let peq_is_automatically_derived = cx.tcx.has_attr(impl_id, sym::automatically_derived);
240239

241240
if peq_is_automatically_derived == hash_is_automatically_derived {
242241
return;
@@ -290,7 +289,7 @@ fn check_ord_partial_ord<'tcx>(
290289
then {
291290
// Look for the PartialOrd implementations for `ty`
292291
cx.tcx.for_each_relevant_impl(partial_ord_trait_def_id, ty, |impl_id| {
293-
let partial_ord_is_automatically_derived = is_automatically_derived(cx.tcx.get_attrs(impl_id));
292+
let partial_ord_is_automatically_derived = cx.tcx.has_attr(impl_id, sym::automatically_derived);
294293

295294
if partial_ord_is_automatically_derived == ord_is_automatically_derived {
296295
return;

clippy_lints/src/entry.rs

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -11,7 +11,7 @@ use rustc_errors::Applicability;
1111
use rustc_hir::{
1212
hir_id::HirIdSet,
1313
intravisit::{walk_expr, Visitor},
14-
Block, Expr, ExprKind, Guard, HirId, Pat, Stmt, StmtKind, UnOp,
14+
Block, Expr, ExprKind, Guard, HirId, Let, Pat, Stmt, StmtKind, UnOp,
1515
};
1616
use rustc_lint::{LateContext, LateLintPass};
1717
use rustc_session::{declare_lint_pass, declare_tool_lint};
@@ -478,7 +478,7 @@ impl<'tcx> Visitor<'tcx> for InsertSearcher<'_, 'tcx> {
478478
let mut is_map_used = self.is_map_used;
479479
for arm in arms {
480480
self.visit_pat(arm.pat);
481-
if let Some(Guard::If(guard) | Guard::IfLet(_, guard)) = arm.guard {
481+
if let Some(Guard::If(guard) | Guard::IfLet(&Let { init: guard, .. })) = arm.guard {
482482
self.visit_non_tail_expr(guard);
483483
}
484484
is_map_used |= self.visit_cond_arm(arm.body);

clippy_lints/src/eta_reduction.rs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -150,7 +150,7 @@ impl<'tcx> LateLintPass<'tcx> for EtaReduction {
150150
if check_inputs(cx, body.params, args);
151151
let method_def_id = cx.typeck_results().type_dependent_def_id(body.value.hir_id).unwrap();
152152
let substs = cx.typeck_results().node_substs(body.value.hir_id);
153-
let call_ty = cx.tcx.type_of(method_def_id).subst(cx.tcx, substs);
153+
let call_ty = cx.tcx.bound_type_of(method_def_id).subst(cx.tcx, substs);
154154
if check_sig(cx, closure_ty, call_ty);
155155
then {
156156
span_lint_and_then(cx, REDUNDANT_CLOSURE_FOR_METHOD_CALLS, expr.span, "redundant closure", |diag| {

clippy_lints/src/functions/must_use.rs

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -13,13 +13,13 @@ use clippy_utils::attrs::is_proc_macro;
1313
use clippy_utils::diagnostics::{span_lint_and_help, span_lint_and_then};
1414
use clippy_utils::source::snippet_opt;
1515
use clippy_utils::ty::is_must_use_ty;
16-
use clippy_utils::{match_def_path, must_use_attr, return_ty, trait_ref_of_method};
16+
use clippy_utils::{match_def_path, return_ty, trait_ref_of_method};
1717

1818
use super::{DOUBLE_MUST_USE, MUST_USE_CANDIDATE, MUST_USE_UNIT};
1919

2020
pub(super) fn check_item<'tcx>(cx: &LateContext<'tcx>, item: &'tcx hir::Item<'_>) {
2121
let attrs = cx.tcx.hir().attrs(item.hir_id());
22-
let attr = must_use_attr(attrs);
22+
let attr = cx.tcx.get_attr(item.def_id.to_def_id(), sym::must_use);
2323
if let hir::ItemKind::Fn(ref sig, _generics, ref body_id) = item.kind {
2424
let is_public = cx.access_levels.is_exported(item.def_id);
2525
let fn_header_span = item.span.with_hi(sig.decl.output.span().hi());
@@ -44,7 +44,7 @@ pub(super) fn check_impl_item<'tcx>(cx: &LateContext<'tcx>, item: &'tcx hir::Imp
4444
let is_public = cx.access_levels.is_exported(item.def_id);
4545
let fn_header_span = item.span.with_hi(sig.decl.output.span().hi());
4646
let attrs = cx.tcx.hir().attrs(item.hir_id());
47-
let attr = must_use_attr(attrs);
47+
let attr = cx.tcx.get_attr(item.def_id.to_def_id(), sym::must_use);
4848
if let Some(attr) = attr {
4949
check_needless_must_use(cx, sig.decl, item.hir_id(), item.span, fn_header_span, attr);
5050
} else if is_public && !is_proc_macro(cx.sess(), attrs) && trait_ref_of_method(cx, item.def_id).is_none() {
@@ -67,7 +67,7 @@ pub(super) fn check_trait_item<'tcx>(cx: &LateContext<'tcx>, item: &'tcx hir::Tr
6767
let fn_header_span = item.span.with_hi(sig.decl.output.span().hi());
6868

6969
let attrs = cx.tcx.hir().attrs(item.hir_id());
70-
let attr = must_use_attr(attrs);
70+
let attr = cx.tcx.get_attr(item.def_id.to_def_id(), sym::must_use);
7171
if let Some(attr) = attr {
7272
check_needless_must_use(cx, sig.decl, item.hir_id(), item.span, fn_header_span, attr);
7373
} else if let hir::TraitFn::Provided(eid) = *eid {

clippy_lints/src/future_not_send.rs

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -5,7 +5,7 @@ use rustc_hir::{Body, FnDecl, HirId};
55
use rustc_infer::infer::TyCtxtInferExt;
66
use rustc_lint::{LateContext, LateLintPass};
77
use rustc_middle::ty::subst::Subst;
8-
use rustc_middle::ty::{Opaque, PredicateKind::Trait};
8+
use rustc_middle::ty::{EarlyBinder, Opaque, PredicateKind::Trait};
99
use rustc_session::{declare_lint_pass, declare_tool_lint};
1010
use rustc_span::{sym, Span};
1111
use rustc_trait_selection::traits::error_reporting::suggestions::InferCtxtExt;
@@ -67,7 +67,7 @@ impl<'tcx> LateLintPass<'tcx> for FutureNotSend {
6767
let preds = cx.tcx.explicit_item_bounds(id);
6868
let mut is_future = false;
6969
for &(p, _span) in preds {
70-
let p = p.subst(cx.tcx, subst);
70+
let p = EarlyBinder(p).subst(cx.tcx, subst);
7171
if let Some(trait_pred) = p.to_opt_poly_trait_pred() {
7272
if Some(trait_pred.skip_binder().trait_ref.def_id) == cx.tcx.lang_items().future_trait() {
7373
is_future = true;

0 commit comments

Comments
 (0)