Skip to content

Commit 4911ab1

Browse files
committed
Auto merge of #6482 - flip1995:rustup, r=flip1995
Rustup r? `@ghost` changelog: none
2 parents 12a35ab + 53d6e0c commit 4911ab1

File tree

8 files changed

+35
-8
lines changed

8 files changed

+35
-8
lines changed

clippy_lints/src/await_holding_invalid.rs

+5-1
Original file line numberDiff line numberDiff line change
@@ -99,7 +99,11 @@ impl LateLintPass<'_> for AwaitHolding {
9999
};
100100
let def_id = cx.tcx.hir().body_owner_def_id(body_id);
101101
let typeck_results = cx.tcx.typeck(def_id);
102-
check_interior_types(cx, &typeck_results.generator_interior_types, body.value.span);
102+
check_interior_types(
103+
cx,
104+
&typeck_results.generator_interior_types.as_ref().skip_binder(),
105+
body.value.span,
106+
);
103107
}
104108
}
105109
}

clippy_lints/src/shadow.rs

+4
Original file line numberDiff line numberDiff line change
@@ -342,6 +342,10 @@ fn check_expr<'tcx>(cx: &LateContext<'tcx>, expr: &'tcx Expr<'_>, bindings: &mut
342342
if let Some(ref guard) = arm.guard {
343343
match guard {
344344
Guard::If(if_expr) => check_expr(cx, if_expr, bindings),
345+
Guard::IfLet(guard_pat, guard_expr) => {
346+
check_pat(cx, guard_pat, Some(*guard_expr), guard_pat.span, bindings);
347+
check_expr(cx, guard_expr, bindings);
348+
},
345349
}
346350
}
347351
check_expr(cx, &arm.body, bindings);

clippy_lints/src/utils/author.rs

+13
Original file line numberDiff line numberDiff line change
@@ -372,6 +372,18 @@ impl<'tcx> Visitor<'tcx> for PrintVisitor {
372372
self.current = if_expr_pat;
373373
self.visit_expr(if_expr);
374374
},
375+
hir::Guard::IfLet(ref if_let_pat, ref if_let_expr) => {
376+
let if_let_pat_pat = self.next("pat");
377+
let if_let_expr_pat = self.next("expr");
378+
println!(
379+
" if let Guard::IfLet(ref {}, ref {}) = {};",
380+
if_let_pat_pat, if_let_expr_pat, guard_pat
381+
);
382+
self.current = if_let_expr_pat;
383+
self.visit_expr(if_let_expr);
384+
self.current = if_let_pat_pat;
385+
self.visit_pat(if_let_pat);
386+
},
375387
}
376388
}
377389
self.current = format!("{}[{}].pat", arms_pat, i);
@@ -730,6 +742,7 @@ fn desugaring_name(des: hir::MatchSource) -> String {
730742
"MatchSource::IfLetDesugar {{ contains_else_clause: {} }}",
731743
contains_else_clause
732744
),
745+
hir::MatchSource::IfLetGuardDesugar => "MatchSource::IfLetGuardDesugar".to_string(),
733746
hir::MatchSource::IfDesugar { contains_else_clause } => format!(
734747
"MatchSource::IfDesugar {{ contains_else_clause: {} }}",
735748
contains_else_clause

clippy_lints/src/utils/hir_utils.rs

+3-1
Original file line numberDiff line numberDiff line change
@@ -169,6 +169,8 @@ impl<'a, 'tcx> SpanlessEq<'a, 'tcx> {
169169
fn eq_guard(&mut self, left: &Guard<'_>, right: &Guard<'_>) -> bool {
170170
match (left, right) {
171171
(Guard::If(l), Guard::If(r)) => self.eq_expr(l, r),
172+
(Guard::IfLet(lp, le), Guard::IfLet(rp, re)) => self.eq_pat(lp, rp) && self.eq_expr(le, re),
173+
_ => false,
172174
}
173175
}
174176

@@ -669,7 +671,7 @@ impl<'a, 'tcx> SpanlessHash<'a, 'tcx> {
669671

670672
pub fn hash_guard(&mut self, g: &Guard<'_>) {
671673
match g {
672-
Guard::If(ref expr) => {
674+
Guard::If(ref expr) | Guard::IfLet(_, ref expr) => {
673675
self.hash_expr(expr);
674676
},
675677
}

clippy_lints/src/utils/inspector.rs

+5
Original file line numberDiff line numberDiff line change
@@ -560,5 +560,10 @@ fn print_guard(cx: &LateContext<'_>, guard: &hir::Guard<'_>, indent: usize) {
560560
println!("{}If", ind);
561561
print_expr(cx, expr, indent + 1);
562562
},
563+
hir::Guard::IfLet(pat, expr) => {
564+
println!("{}IfLet", ind);
565+
print_pat(cx, pat, indent + 1);
566+
print_expr(cx, expr, indent + 1);
567+
},
563568
}
564569
}

clippy_lints/src/utils/mod.rs

+2-2
Original file line numberDiff line numberDiff line change
@@ -1480,8 +1480,8 @@ pub fn is_must_use_ty<'tcx>(cx: &LateContext<'tcx>, ty: Ty<'tcx>) -> bool {
14801480
false
14811481
},
14821482
ty::Dynamic(binder, _) => {
1483-
for predicate in binder.skip_binder().iter() {
1484-
if let ty::ExistentialPredicate::Trait(ref trait_ref) = predicate {
1483+
for predicate in binder.iter() {
1484+
if let ty::ExistentialPredicate::Trait(ref trait_ref) = predicate.skip_binder() {
14851485
if must_use_attr(&cx.tcx.get_attrs(trait_ref.def_id)).is_some() {
14861486
return true;
14871487
}

rust-toolchain

+1-1
Original file line numberDiff line numberDiff line change
@@ -1,3 +1,3 @@
11
[toolchain]
2-
channel = "nightly-2020-12-14"
2+
channel = "nightly-2020-12-20"
33
components = ["llvm-tools-preview", "rustc-dev", "rust-src", "rustfmt"]

tests/ui/crashes/used_underscore_binding_macro.rs

+2-3
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,6 @@
1-
#![allow(clippy::useless_attribute)] //issue #2910
1+
// edition:2018
22

3-
#[macro_use]
4-
extern crate serde_derive;
3+
use serde::Deserialize;
54

65
/// Tests that we do not lint for unused underscores in a `MacroAttribute`
76
/// expansion

0 commit comments

Comments
 (0)