Auto merge of #6482 - flip1995:rustup, r=flip1995

Rustup

r? `@ghost`

changelog: none
This commit is contained in:
bors 2020-12-20 16:00:11 +00:00
commit 4911ab124c
8 changed files with 35 additions and 8 deletions

View File

@ -99,7 +99,11 @@ impl LateLintPass<'_> for AwaitHolding {
}; };
let def_id = cx.tcx.hir().body_owner_def_id(body_id); let def_id = cx.tcx.hir().body_owner_def_id(body_id);
let typeck_results = cx.tcx.typeck(def_id); let typeck_results = cx.tcx.typeck(def_id);
check_interior_types(cx, &typeck_results.generator_interior_types, body.value.span); check_interior_types(
cx,
&typeck_results.generator_interior_types.as_ref().skip_binder(),
body.value.span,
);
} }
} }
} }

View File

@ -342,6 +342,10 @@ fn check_expr<'tcx>(cx: &LateContext<'tcx>, expr: &'tcx Expr<'_>, bindings: &mut
if let Some(ref guard) = arm.guard { if let Some(ref guard) = arm.guard {
match guard { match guard {
Guard::If(if_expr) => check_expr(cx, if_expr, bindings), Guard::If(if_expr) => check_expr(cx, if_expr, bindings),
Guard::IfLet(guard_pat, guard_expr) => {
check_pat(cx, guard_pat, Some(*guard_expr), guard_pat.span, bindings);
check_expr(cx, guard_expr, bindings);
},
} }
} }
check_expr(cx, &arm.body, bindings); check_expr(cx, &arm.body, bindings);

View File

@ -372,6 +372,18 @@ impl<'tcx> Visitor<'tcx> for PrintVisitor {
self.current = if_expr_pat; self.current = if_expr_pat;
self.visit_expr(if_expr); self.visit_expr(if_expr);
}, },
hir::Guard::IfLet(ref if_let_pat, ref if_let_expr) => {
let if_let_pat_pat = self.next("pat");
let if_let_expr_pat = self.next("expr");
println!(
" if let Guard::IfLet(ref {}, ref {}) = {};",
if_let_pat_pat, if_let_expr_pat, guard_pat
);
self.current = if_let_expr_pat;
self.visit_expr(if_let_expr);
self.current = if_let_pat_pat;
self.visit_pat(if_let_pat);
},
} }
} }
self.current = format!("{}[{}].pat", arms_pat, i); self.current = format!("{}[{}].pat", arms_pat, i);
@ -730,6 +742,7 @@ fn desugaring_name(des: hir::MatchSource) -> String {
"MatchSource::IfLetDesugar {{ contains_else_clause: {} }}", "MatchSource::IfLetDesugar {{ contains_else_clause: {} }}",
contains_else_clause contains_else_clause
), ),
hir::MatchSource::IfLetGuardDesugar => "MatchSource::IfLetGuardDesugar".to_string(),
hir::MatchSource::IfDesugar { contains_else_clause } => format!( hir::MatchSource::IfDesugar { contains_else_clause } => format!(
"MatchSource::IfDesugar {{ contains_else_clause: {} }}", "MatchSource::IfDesugar {{ contains_else_clause: {} }}",
contains_else_clause contains_else_clause

View File

@ -169,6 +169,8 @@ impl<'a, 'tcx> SpanlessEq<'a, 'tcx> {
fn eq_guard(&mut self, left: &Guard<'_>, right: &Guard<'_>) -> bool { fn eq_guard(&mut self, left: &Guard<'_>, right: &Guard<'_>) -> bool {
match (left, right) { match (left, right) {
(Guard::If(l), Guard::If(r)) => self.eq_expr(l, r), (Guard::If(l), Guard::If(r)) => self.eq_expr(l, r),
(Guard::IfLet(lp, le), Guard::IfLet(rp, re)) => self.eq_pat(lp, rp) && self.eq_expr(le, re),
_ => false,
} }
} }
@ -669,7 +671,7 @@ impl<'a, 'tcx> SpanlessHash<'a, 'tcx> {
pub fn hash_guard(&mut self, g: &Guard<'_>) { pub fn hash_guard(&mut self, g: &Guard<'_>) {
match g { match g {
Guard::If(ref expr) => { Guard::If(ref expr) | Guard::IfLet(_, ref expr) => {
self.hash_expr(expr); self.hash_expr(expr);
}, },
} }

View File

@ -560,5 +560,10 @@ fn print_guard(cx: &LateContext<'_>, guard: &hir::Guard<'_>, indent: usize) {
println!("{}If", ind); println!("{}If", ind);
print_expr(cx, expr, indent + 1); print_expr(cx, expr, indent + 1);
}, },
hir::Guard::IfLet(pat, expr) => {
println!("{}IfLet", ind);
print_pat(cx, pat, indent + 1);
print_expr(cx, expr, indent + 1);
},
} }
} }

View File

@ -1480,8 +1480,8 @@ pub fn is_must_use_ty<'tcx>(cx: &LateContext<'tcx>, ty: Ty<'tcx>) -> bool {
false false
}, },
ty::Dynamic(binder, _) => { ty::Dynamic(binder, _) => {
for predicate in binder.skip_binder().iter() { for predicate in binder.iter() {
if let ty::ExistentialPredicate::Trait(ref trait_ref) = predicate { if let ty::ExistentialPredicate::Trait(ref trait_ref) = predicate.skip_binder() {
if must_use_attr(&cx.tcx.get_attrs(trait_ref.def_id)).is_some() { if must_use_attr(&cx.tcx.get_attrs(trait_ref.def_id)).is_some() {
return true; return true;
} }

View File

@ -1,3 +1,3 @@
[toolchain] [toolchain]
channel = "nightly-2020-12-14" channel = "nightly-2020-12-20"
components = ["llvm-tools-preview", "rustc-dev", "rust-src", "rustfmt"] components = ["llvm-tools-preview", "rustc-dev", "rust-src", "rustfmt"]

View File

@ -1,7 +1,6 @@
#![allow(clippy::useless_attribute)] //issue #2910 // edition:2018
#[macro_use] use serde::Deserialize;
extern crate serde_derive;
/// Tests that we do not lint for unused underscores in a `MacroAttribute` /// Tests that we do not lint for unused underscores in a `MacroAttribute`
/// expansion /// expansion