Skip to content

Commit 4c41a22

Browse files
committed
Auto merge of #7476 - flip1995:rustup, r=flip1995
Rustup r? `@ghost` Out of cycle sync for 2 ICE fixes #7470 #7471 #7473 changelog: none
2 parents f467750 + 21abb5d commit 4c41a22

11 files changed

+26
-36
lines changed

clippy_lints/src/escape.rs

+3-6
Original file line numberDiff line numberDiff line change
@@ -11,7 +11,7 @@ use rustc_span::source_map::Span;
1111
use rustc_span::symbol::kw;
1212
use rustc_target::abi::LayoutOf;
1313
use rustc_target::spec::abi::Abi;
14-
use rustc_typeck::expr_use_visitor::{ConsumeMode, Delegate, ExprUseVisitor, PlaceBase, PlaceWithHirId};
14+
use rustc_typeck::expr_use_visitor::{Delegate, ExprUseVisitor, PlaceBase, PlaceWithHirId};
1515

1616
#[derive(Copy, Clone)]
1717
pub struct BoxedLocal {
@@ -133,13 +133,10 @@ fn is_argument(map: rustc_middle::hir::map::Map<'_>, id: HirId) -> bool {
133133
}
134134

135135
impl<'a, 'tcx> Delegate<'tcx> for EscapeDelegate<'a, 'tcx> {
136-
fn consume(&mut self, cmt: &PlaceWithHirId<'tcx>, _: HirId, mode: ConsumeMode) {
136+
fn consume(&mut self, cmt: &PlaceWithHirId<'tcx>, _: HirId) {
137137
if cmt.place.projections.is_empty() {
138138
if let PlaceBase::Local(lid) = cmt.place.base {
139-
if let ConsumeMode::Move = mode {
140-
// moved out or in. clearly can't be localized
141-
self.set.remove(&lid);
142-
}
139+
self.set.remove(&lid);
143140
let map = &self.cx.tcx.hir();
144141
if let Some(Node::Binding(_)) = map.find(cmt.hir_id) {
145142
if self.set.contains(&lid) {

clippy_lints/src/lib.rs

-1
Original file line numberDiff line numberDiff line change
@@ -2106,7 +2106,6 @@ pub fn register_plugins(store: &mut rustc_lint::LintStore, sess: &Session, conf:
21062106
store.register_early_pass(move || box disallowed_script_idents::DisallowedScriptIdents::new(&scripts));
21072107
store.register_late_pass(|| box strlen_on_c_strings::StrlenOnCStrings);
21082108
store.register_late_pass(move || box self_named_constructor::SelfNamedConstructor);
2109-
21102109
}
21112110

21122111
#[rustfmt::skip]

clippy_lints/src/loops/mut_range_bound.rs

+2-2
Original file line numberDiff line numberDiff line change
@@ -7,7 +7,7 @@ use rustc_infer::infer::TyCtxtInferExt;
77
use rustc_lint::LateContext;
88
use rustc_middle::{mir::FakeReadCause, ty};
99
use rustc_span::source_map::Span;
10-
use rustc_typeck::expr_use_visitor::{ConsumeMode, Delegate, ExprUseVisitor, PlaceBase, PlaceWithHirId};
10+
use rustc_typeck::expr_use_visitor::{Delegate, ExprUseVisitor, PlaceBase, PlaceWithHirId};
1111

1212
pub(super) fn check(cx: &LateContext<'_>, arg: &Expr<'_>, body: &Expr<'_>) {
1313
if let Some(higher::Range {
@@ -82,7 +82,7 @@ struct MutatePairDelegate<'a, 'tcx> {
8282
}
8383

8484
impl<'tcx> Delegate<'tcx> for MutatePairDelegate<'_, 'tcx> {
85-
fn consume(&mut self, _: &PlaceWithHirId<'tcx>, _: HirId, _: ConsumeMode) {}
85+
fn consume(&mut self, _: &PlaceWithHirId<'tcx>, _: HirId) {}
8686

8787
fn borrow(&mut self, cmt: &PlaceWithHirId<'tcx>, diag_expr_id: HirId, bk: ty::BorrowKind) {
8888
if let ty::BorrowKind::MutBorrow = bk {

clippy_lints/src/manual_unwrap_or.rs

+2-2
Original file line numberDiff line numberDiff line change
@@ -61,13 +61,13 @@ fn lint_manual_unwrap_or<'tcx>(cx: &LateContext<'tcx>, expr: &'tcx Expr<'tcx>) {
6161
if let Some((idx, or_arm)) = arms.iter().enumerate().find(|(_, arm)| {
6262
match arm.pat.kind {
6363
PatKind::Path(ref qpath) => is_lang_ctor(cx, qpath, OptionNone),
64-
PatKind::TupleStruct(ref qpath, &[pat], _) =>
64+
PatKind::TupleStruct(ref qpath, [pat], _) =>
6565
matches!(pat.kind, PatKind::Wild) && is_lang_ctor(cx, qpath, ResultErr),
6666
_ => false,
6767
}
6868
});
6969
let unwrap_arm = &arms[1 - idx];
70-
if let PatKind::TupleStruct(ref qpath, &[unwrap_pat], _) = unwrap_arm.pat.kind;
70+
if let PatKind::TupleStruct(ref qpath, [unwrap_pat], _) = unwrap_arm.pat.kind;
7171
if is_lang_ctor(cx, qpath, OptionSome) || is_lang_ctor(cx, qpath, ResultOk);
7272
if let PatKind::Binding(_, binding_hir_id, ..) = unwrap_pat.kind;
7373
if path_to_local_id(unwrap_arm.body, binding_hir_id);

clippy_lints/src/matches.rs

+3-3
Original file line numberDiff line numberDiff line change
@@ -625,7 +625,7 @@ impl<'tcx> LateLintPass<'tcx> for Matches {
625625
if let PatKind::TupleStruct(
626626
QPath::Resolved(None, variant_name), args, _) = arms[0].pat.kind;
627627
if args.len() == 1;
628-
if let PatKind::Binding(_, arg, ..) = strip_pat_refs(args[0]).kind;
628+
if let PatKind::Binding(_, arg, ..) = strip_pat_refs(&args[0]).kind;
629629
let body = remove_blocks(arms[0].body);
630630
if path_to_local_id(body, arg);
631631

@@ -721,7 +721,7 @@ fn check_single_match_single_pattern(
721721
expr: &Expr<'_>,
722722
els: Option<&Expr<'_>>,
723723
) {
724-
if is_wild(&arms[1].pat) {
724+
if is_wild(arms[1].pat) {
725725
report_single_match_single_pattern(cx, ex, arms, expr, els);
726726
}
727727
}
@@ -1287,7 +1287,7 @@ fn find_matches_sugg(cx: &LateContext<'_>, ex: &Expr<'_>, arms: &[Arm<'_>], expr
12871287
if let Some((b1_arm, b0_arms)) = arms.split_last();
12881288
if let Some(b0) = find_bool_lit(&b0_arms[0].body.kind, desugared);
12891289
if let Some(b1) = find_bool_lit(&b1_arm.body.kind, desugared);
1290-
if is_wild(&b1_arm.pat);
1290+
if is_wild(b1_arm.pat);
12911291
if b0 != b1;
12921292
let if_guard = &b0_arms[0].guard;
12931293
if if_guard.is_none() || b0_arms.len() == 1;

clippy_lints/src/needless_pass_by_value.rs

+2-4
Original file line numberDiff line numberDiff line change
@@ -326,10 +326,8 @@ impl MovedVariablesCtxt {
326326
}
327327

328328
impl<'tcx> euv::Delegate<'tcx> for MovedVariablesCtxt {
329-
fn consume(&mut self, cmt: &euv::PlaceWithHirId<'tcx>, _: HirId, mode: euv::ConsumeMode) {
330-
if let euv::ConsumeMode::Move = mode {
331-
self.move_common(cmt);
332-
}
329+
fn consume(&mut self, cmt: &euv::PlaceWithHirId<'tcx>, _: HirId) {
330+
self.move_common(cmt);
333331
}
334332

335333
fn borrow(&mut self, _: &euv::PlaceWithHirId<'tcx>, _: HirId, _: ty::BorrowKind) {}

clippy_lints/src/option_if_let_else.rs

+1-1
Original file line numberDiff line numberDiff line change
@@ -132,7 +132,7 @@ fn detect_option_if_let_else<'tcx>(
132132
if !is_else_clause(cx.tcx, expr);
133133
if arms.len() == 2;
134134
if !is_result_ok(cx, cond_expr); // Don't lint on Result::ok because a different lint does it already
135-
if let PatKind::TupleStruct(struct_qpath, &[inner_pat], _) = &arms[0].pat.kind;
135+
if let PatKind::TupleStruct(struct_qpath, [inner_pat], _) = &arms[0].pat.kind;
136136
if is_lang_ctor(cx, struct_qpath, OptionSome);
137137
if let PatKind::Binding(bind_annotation, _, id, _) = &inner_pat.kind;
138138
if !contains_return_break_continue_macro(arms[0].body);

clippy_lints/src/pattern_type_mismatch.rs

+1-1
Original file line numberDiff line numberDiff line change
@@ -258,7 +258,7 @@ fn get_variant<'a>(adt_def: &'a AdtDef, qpath: &QPath<'_>) -> Option<&'a Variant
258258

259259
fn find_first_mismatch_in_tuple<'tcx, I>(
260260
cx: &LateContext<'tcx>,
261-
pats: &[&Pat<'_>],
261+
pats: &[Pat<'_>],
262262
ty_iter_src: I,
263263
) -> Option<(Span, Mutability, Level)>
264264
where

clippy_utils/src/lib.rs

+9-13
Original file line numberDiff line numberDiff line change
@@ -255,7 +255,7 @@ pub fn in_macro(span: Span) -> bool {
255255
}
256256

257257
/// Checks if given pattern is a wildcard (`_`)
258-
pub fn is_wild<'tcx>(pat: &impl std::ops::Deref<Target = Pat<'tcx>>) -> bool {
258+
pub fn is_wild(pat: &Pat<'_>) -> bool {
259259
matches!(pat.kind, PatKind::Wild)
260260
}
261261

@@ -1019,8 +1019,8 @@ pub fn is_refutable(cx: &LateContext<'_>, pat: &Pat<'_>) -> bool {
10191019
)
10201020
}
10211021

1022-
fn are_refutable<'a, I: Iterator<Item = &'a Pat<'a>>>(cx: &LateContext<'_>, mut i: I) -> bool {
1023-
i.any(|pat| is_refutable(cx, pat))
1022+
fn are_refutable<'a, I: IntoIterator<Item = &'a Pat<'a>>>(cx: &LateContext<'_>, i: I) -> bool {
1023+
i.into_iter().any(|pat| is_refutable(cx, pat))
10241024
}
10251025

10261026
match pat.kind {
@@ -1031,24 +1031,20 @@ pub fn is_refutable(cx: &LateContext<'_>, pat: &Pat<'_>) -> bool {
10311031
PatKind::Path(ref qpath) => is_enum_variant(cx, qpath, pat.hir_id),
10321032
PatKind::Or(pats) => {
10331033
// TODO: should be the honest check, that pats is exhaustive set
1034-
are_refutable(cx, pats.iter().map(|pat| &**pat))
1034+
are_refutable(cx, pats)
10351035
},
1036-
PatKind::Tuple(pats, _) => are_refutable(cx, pats.iter().map(|pat| &**pat)),
1036+
PatKind::Tuple(pats, _) => are_refutable(cx, pats),
10371037
PatKind::Struct(ref qpath, fields, _) => {
10381038
is_enum_variant(cx, qpath, pat.hir_id) || are_refutable(cx, fields.iter().map(|field| &*field.pat))
10391039
},
1040-
PatKind::TupleStruct(ref qpath, pats, _) => {
1041-
is_enum_variant(cx, qpath, pat.hir_id) || are_refutable(cx, pats.iter().map(|pat| &**pat))
1042-
},
1043-
PatKind::Slice(head, ref middle, tail) => {
1040+
PatKind::TupleStruct(ref qpath, pats, _) => is_enum_variant(cx, qpath, pat.hir_id) || are_refutable(cx, pats),
1041+
PatKind::Slice(head, middle, tail) => {
10441042
match &cx.typeck_results().node_type(pat.hir_id).kind() {
10451043
rustc_ty::Slice(..) => {
10461044
// [..] is the only irrefutable slice pattern.
10471045
!head.is_empty() || middle.is_none() || !tail.is_empty()
10481046
},
1049-
rustc_ty::Array(..) => {
1050-
are_refutable(cx, head.iter().chain(middle).chain(tail.iter()).map(|pat| &**pat))
1051-
},
1047+
rustc_ty::Array(..) => are_refutable(cx, head.iter().chain(middle).chain(tail.iter())),
10521048
_ => {
10531049
// unreachable!()
10541050
true
@@ -1062,7 +1058,7 @@ pub fn is_refutable(cx: &LateContext<'_>, pat: &Pat<'_>) -> bool {
10621058
/// the function once on the given pattern.
10631059
pub fn recurse_or_patterns<'tcx, F: FnMut(&'tcx Pat<'tcx>)>(pat: &'tcx Pat<'tcx>, mut f: F) {
10641060
if let PatKind::Or(pats) = pat.kind {
1065-
pats.iter().copied().for_each(f);
1061+
pats.iter().for_each(f);
10661062
} else {
10671063
f(pat);
10681064
}

clippy_utils/src/usage.rs

+2-2
Original file line numberDiff line numberDiff line change
@@ -10,7 +10,7 @@ use rustc_lint::LateContext;
1010
use rustc_middle::hir::map::Map;
1111
use rustc_middle::mir::FakeReadCause;
1212
use rustc_middle::ty;
13-
use rustc_typeck::expr_use_visitor::{ConsumeMode, Delegate, ExprUseVisitor, PlaceBase, PlaceWithHirId};
13+
use rustc_typeck::expr_use_visitor::{Delegate, ExprUseVisitor, PlaceBase, PlaceWithHirId};
1414

1515
/// Returns a set of mutated local variable IDs, or `None` if mutations could not be determined.
1616
pub fn mutated_variables<'tcx>(expr: &'tcx Expr<'_>, cx: &LateContext<'tcx>) -> Option<HirIdSet> {
@@ -67,7 +67,7 @@ impl<'tcx> MutVarsDelegate {
6767
}
6868

6969
impl<'tcx> Delegate<'tcx> for MutVarsDelegate {
70-
fn consume(&mut self, _: &PlaceWithHirId<'tcx>, _: HirId, _: ConsumeMode) {}
70+
fn consume(&mut self, _: &PlaceWithHirId<'tcx>, _: HirId) {}
7171

7272
fn borrow(&mut self, cmt: &PlaceWithHirId<'tcx>, _: HirId, bk: ty::BorrowKind) {
7373
if let ty::BorrowKind::MutBorrow = bk {

rust-toolchain

+1-1
Original file line numberDiff line numberDiff line change
@@ -1,3 +1,3 @@
11
[toolchain]
2-
channel = "nightly-2021-07-15"
2+
channel = "nightly-2021-07-19"
33
components = ["llvm-tools-preview", "rustc-dev", "rust-src"]

0 commit comments

Comments
 (0)