about summary refs log tree commit diff
diff options
context:
space:
mode:
authorbors <bors@rust-lang.org>2021-02-02 14:52:53 +0000
committerbors <bors@rust-lang.org>2021-02-02 14:52:53 +0000
commitb81f5811f96fe750ab28c15219d1b0dba6b1dc90 (patch)
treede4308cb542bc90db1f8bfb1bdc1d28b6478b4ab
parenta3ed564c130ec3f19e933a9ea31faca5a717ce91 (diff)
parentd5b760ba62b40dd770c09e704b8a3af64c1fd058 (diff)
downloadrust-b81f5811f96fe750ab28c15219d1b0dba6b1dc90.tar.gz
rust-b81f5811f96fe750ab28c15219d1b0dba6b1dc90.zip
Auto merge of #80843 - Mark-Simulacrum:fmt-bump, r=petrochenkov
Bump rustfmt version
-rw-r--r--compiler/rustc_ast_lowering/src/lib.rs4
-rw-r--r--compiler/rustc_builtin_macros/src/deriving/generic/mod.rs2
-rw-r--r--compiler/rustc_errors/src/diagnostic_builder.rs2
-rw-r--r--compiler/rustc_errors/src/snippet.rs15
-rw-r--r--compiler/rustc_hir/src/hir.rs8
-rw-r--r--compiler/rustc_infer/src/infer/error_reporting/nice_region_error/trait_impl_difference.rs7
-rw-r--r--compiler/rustc_middle/src/hir/map/mod.rs6
-rw-r--r--compiler/rustc_middle/src/mir/mod.rs6
-rw-r--r--compiler/rustc_middle/src/ty/diagnostics.rs18
-rw-r--r--compiler/rustc_middle/src/ty/error.rs11
-rw-r--r--compiler/rustc_middle/src/ty/sty.rs10
-rw-r--r--compiler/rustc_mir_build/src/build/expr/as_place.rs86
-rw-r--r--compiler/rustc_mir_build/src/build/expr/as_rvalue.rs56
-rw-r--r--compiler/rustc_mir_build/src/build/expr/into.rs20
-rw-r--r--compiler/rustc_mir_build/src/build/matches/mod.rs14
-rw-r--r--compiler/rustc_mir_build/src/build/matches/util.rs4
-rw-r--r--compiler/rustc_mir_build/src/build/mod.rs7
-rw-r--r--compiler/rustc_mir_build/src/build/scope.rs11
-rw-r--r--compiler/rustc_parse/src/parser/nonterminal.rs17
-rw-r--r--compiler/rustc_passes/src/stability.rs3
-rw-r--r--compiler/rustc_resolve/src/late/diagnostics.rs26
-rw-r--r--compiler/rustc_target/src/abi/call/mod.rs2
-rw-r--r--compiler/rustc_trait_selection/src/traits/error_reporting/mod.rs9
-rw-r--r--compiler/rustc_trait_selection/src/traits/error_reporting/suggestions.rs6
-rw-r--r--compiler/rustc_typeck/src/astconv/generics.rs15
-rw-r--r--compiler/rustc_typeck/src/check/fn_ctxt/_impl.rs11
-rw-r--r--library/core/src/default.rs6
-rw-r--r--rustfmt.toml2
-rw-r--r--src/bootstrap/bin/main.rs2
-rw-r--r--src/stage0.txt2
30 files changed, 224 insertions, 164 deletions
diff --git a/compiler/rustc_ast_lowering/src/lib.rs b/compiler/rustc_ast_lowering/src/lib.rs
index 8f2e49e299c..ac76b42c57d 100644
--- a/compiler/rustc_ast_lowering/src/lib.rs
+++ b/compiler/rustc_ast_lowering/src/lib.rs
@@ -506,7 +506,9 @@ impl<'a, 'hir> LoweringContext<'a, 'hir> {
                         let count = generics
                             .params
                             .iter()
-                            .filter(|param| matches!(param.kind, ast::GenericParamKind::Lifetime { .. }))
+                            .filter(|param| {
+                                matches!(param.kind, ast::GenericParamKind::Lifetime { .. })
+                            })
                             .count();
                         self.lctx.type_def_lifetime_params.insert(def_id.to_def_id(), count);
                     }
diff --git a/compiler/rustc_builtin_macros/src/deriving/generic/mod.rs b/compiler/rustc_builtin_macros/src/deriving/generic/mod.rs
index e78d1368b35..fa3c958c9fe 100644
--- a/compiler/rustc_builtin_macros/src/deriving/generic/mod.rs
+++ b/compiler/rustc_builtin_macros/src/deriving/generic/mod.rs
@@ -598,7 +598,7 @@ impl<'a> TraitDef<'a> {
 
             let mut ty_params = params
                 .iter()
-                .filter(|param| matches!(param.kind,  ast::GenericParamKind::Type{..}))
+                .filter(|param| matches!(param.kind, ast::GenericParamKind::Type { .. }))
                 .peekable();
 
             if ty_params.peek().is_some() {
diff --git a/compiler/rustc_errors/src/diagnostic_builder.rs b/compiler/rustc_errors/src/diagnostic_builder.rs
index 37902dddff4..c09cce21bf2 100644
--- a/compiler/rustc_errors/src/diagnostic_builder.rs
+++ b/compiler/rustc_errors/src/diagnostic_builder.rs
@@ -36,7 +36,7 @@ macro_rules! forward_inner_docs {
     ($e:expr => $i:item) => {
         #[doc = $e]
         $i
-    }
+    };
 }
 
 /// In general, the `DiagnosticBuilder` uses deref to allow access to
diff --git a/compiler/rustc_errors/src/snippet.rs b/compiler/rustc_errors/src/snippet.rs
index dbb2523f286..acb88e57db5 100644
--- a/compiler/rustc_errors/src/snippet.rs
+++ b/compiler/rustc_errors/src/snippet.rs
@@ -122,11 +122,13 @@ impl Annotation {
     }
 
     pub fn is_multiline(&self) -> bool {
-        matches!(self.annotation_type,
+        matches!(
+            self.annotation_type,
             AnnotationType::Multiline(_)
-            | AnnotationType::MultilineStart(_)
-            | AnnotationType::MultilineLine(_)
-            | AnnotationType::MultilineEnd(_))
+                | AnnotationType::MultilineStart(_)
+                | AnnotationType::MultilineLine(_)
+                | AnnotationType::MultilineEnd(_)
+        )
     }
 
     pub fn len(&self) -> usize {
@@ -158,7 +160,10 @@ impl Annotation {
 
     pub fn takes_space(&self) -> bool {
         // Multiline annotations always have to keep vertical space.
-        matches!(self.annotation_type, AnnotationType::MultilineStart(_) | AnnotationType::MultilineEnd(_))
+        matches!(
+            self.annotation_type,
+            AnnotationType::MultilineStart(_) | AnnotationType::MultilineEnd(_)
+        )
     }
 }
 
diff --git a/compiler/rustc_hir/src/hir.rs b/compiler/rustc_hir/src/hir.rs
index 35170fa7c1d..1c16dc02667 100644
--- a/compiler/rustc_hir/src/hir.rs
+++ b/compiler/rustc_hir/src/hir.rs
@@ -1543,10 +1543,10 @@ pub fn is_range_literal(expr: &Expr<'_>) -> bool {
             **qpath,
             QPath::LangItem(
                 LangItem::Range
-                | LangItem::RangeTo
-                | LangItem::RangeFrom
-                | LangItem::RangeFull
-                | LangItem::RangeToInclusive,
+                    | LangItem::RangeTo
+                    | LangItem::RangeFrom
+                    | LangItem::RangeFull
+                    | LangItem::RangeToInclusive,
                 _,
             )
         ),
diff --git a/compiler/rustc_infer/src/infer/error_reporting/nice_region_error/trait_impl_difference.rs b/compiler/rustc_infer/src/infer/error_reporting/nice_region_error/trait_impl_difference.rs
index 0958afa0308..61c8113d052 100644
--- a/compiler/rustc_infer/src/infer/error_reporting/nice_region_error/trait_impl_difference.rs
+++ b/compiler/rustc_infer/src/infer/error_reporting/nice_region_error/trait_impl_difference.rs
@@ -132,7 +132,12 @@ impl Visitor<'tcx> for TypeParamSpanVisitor<'tcx> {
                 [segment]
                     if segment
                         .res
-                        .map(|res| matches!(res, Res::SelfTy(_, _) | Res::Def(hir::def::DefKind::TyParam, _)))
+                        .map(|res| {
+                            matches!(
+                                res,
+                                Res::SelfTy(_, _) | Res::Def(hir::def::DefKind::TyParam, _)
+                            )
+                        })
                         .unwrap_or(false) =>
                 {
                     self.types.push(path.span);
diff --git a/compiler/rustc_middle/src/hir/map/mod.rs b/compiler/rustc_middle/src/hir/map/mod.rs
index 412d5b5082b..ee12c0e786d 100644
--- a/compiler/rustc_middle/src/hir/map/mod.rs
+++ b/compiler/rustc_middle/src/hir/map/mod.rs
@@ -569,9 +569,9 @@ impl<'hir> Map<'hir> {
             self.find(self.get_parent_node(id)),
             Some(
                 Node::Item(_)
-                | Node::TraitItem(_)
-                | Node::ImplItem(_)
-                | Node::Expr(Expr { kind: ExprKind::Closure(..), .. }),
+                    | Node::TraitItem(_)
+                    | Node::ImplItem(_)
+                    | Node::Expr(Expr { kind: ExprKind::Closure(..), .. }),
             )
         )
     }
diff --git a/compiler/rustc_middle/src/mir/mod.rs b/compiler/rustc_middle/src/mir/mod.rs
index cd2bea86ea1..718e81c84ed 100644
--- a/compiler/rustc_middle/src/mir/mod.rs
+++ b/compiler/rustc_middle/src/mir/mod.rs
@@ -962,8 +962,7 @@ impl<'tcx> LocalDecl<'tcx> {
                     opt_ty_info: _,
                     opt_match_place: _,
                     pat_span: _,
-                })
-                | BindingForm::ImplicitSelf(ImplicitSelfKind::Imm),
+                }) | BindingForm::ImplicitSelf(ImplicitSelfKind::Imm),
             )))
         )
     }
@@ -980,8 +979,7 @@ impl<'tcx> LocalDecl<'tcx> {
                     opt_ty_info: _,
                     opt_match_place: _,
                     pat_span: _,
-                })
-                | BindingForm::ImplicitSelf(_),
+                }) | BindingForm::ImplicitSelf(_),
             )))
         )
     }
diff --git a/compiler/rustc_middle/src/ty/diagnostics.rs b/compiler/rustc_middle/src/ty/diagnostics.rs
index e386d973ee4..4a131a4ec05 100644
--- a/compiler/rustc_middle/src/ty/diagnostics.rs
+++ b/compiler/rustc_middle/src/ty/diagnostics.rs
@@ -12,13 +12,17 @@ impl<'tcx> TyS<'tcx> {
     pub fn is_primitive_ty(&self) -> bool {
         matches!(
             self.kind(),
-            Bool | Char | Str | Int(_) | Uint(_) | Float(_)
-            | Infer(
-                InferTy::IntVar(_)
-                | InferTy::FloatVar(_)
-                | InferTy::FreshIntTy(_)
-                | InferTy::FreshFloatTy(_)
-            )
+            Bool | Char
+                | Str
+                | Int(_)
+                | Uint(_)
+                | Float(_)
+                | Infer(
+                    InferTy::IntVar(_)
+                        | InferTy::FloatVar(_)
+                        | InferTy::FreshIntTy(_)
+                        | InferTy::FreshFloatTy(_)
+                )
         )
     }
 
diff --git a/compiler/rustc_middle/src/ty/error.rs b/compiler/rustc_middle/src/ty/error.rs
index c211f07bed8..1669c59d7f1 100644
--- a/compiler/rustc_middle/src/ty/error.rs
+++ b/compiler/rustc_middle/src/ty/error.rs
@@ -646,11 +646,14 @@ impl<T> Trait<T> for X {
         let current_method_ident = body_owner.and_then(|n| n.ident()).map(|i| i.name);
 
         // We don't want to suggest calling an assoc fn in a scope where that isn't feasible.
-        let callable_scope = matches!(body_owner, Some(
+        let callable_scope = matches!(
+            body_owner,
+            Some(
                 hir::Node::Item(hir::Item { kind: hir::ItemKind::Fn(..), .. })
-                | hir::Node::TraitItem(hir::TraitItem { kind: hir::TraitItemKind::Fn(..), .. })
-                | hir::Node::ImplItem(hir::ImplItem { kind: hir::ImplItemKind::Fn(..), .. }),
-            ));
+                    | hir::Node::TraitItem(hir::TraitItem { kind: hir::TraitItemKind::Fn(..), .. })
+                    | hir::Node::ImplItem(hir::ImplItem { kind: hir::ImplItemKind::Fn(..), .. }),
+            )
+        );
         let impl_comparison = matches!(
             cause_code,
             ObligationCauseCode::CompareImplMethodObligation { .. }
diff --git a/compiler/rustc_middle/src/ty/sty.rs b/compiler/rustc_middle/src/ty/sty.rs
index 9cec0eb5be3..6b4f08d9f93 100644
--- a/compiler/rustc_middle/src/ty/sty.rs
+++ b/compiler/rustc_middle/src/ty/sty.rs
@@ -1871,8 +1871,14 @@ impl<'tcx> TyS<'tcx> {
     pub fn is_scalar(&self) -> bool {
         matches!(
             self.kind(),
-            Bool | Char | Int(_) | Float(_) | Uint(_) | FnDef(..) | FnPtr(_) | RawPtr(_)
-            | Infer(IntVar(_) | FloatVar(_))
+            Bool | Char
+                | Int(_)
+                | Float(_)
+                | Uint(_)
+                | FnDef(..)
+                | FnPtr(_)
+                | RawPtr(_)
+                | Infer(IntVar(_) | FloatVar(_))
         )
     }
 
diff --git a/compiler/rustc_mir_build/src/build/expr/as_place.rs b/compiler/rustc_mir_build/src/build/expr/as_place.rs
index 2503360b1e4..3308a243a3a 100644
--- a/compiler/rustc_mir_build/src/build/expr/as_place.rs
+++ b/compiler/rustc_mir_build/src/build/expr/as_place.rs
@@ -6,8 +6,8 @@ use crate::build::{BlockAnd, BlockAndExtension, Builder};
 use crate::thir::*;
 use rustc_hir::def_id::DefId;
 use rustc_hir::HirId;
-use rustc_middle::middle::region;
 use rustc_middle::hir::place::ProjectionKind as HirProjectionKind;
+use rustc_middle::middle::region;
 use rustc_middle::mir::AssertKind::BoundsCheck;
 use rustc_middle::mir::*;
 use rustc_middle::ty::{self, CanonicalUserTypeAnnotation, Ty, TyCtxt, Variance};
@@ -57,7 +57,8 @@ crate enum PlaceBase {
         /// DefId of the closure
         closure_def_id: DefId,
         /// The trait closure implements, `Fn`, `FnMut`, `FnOnce`
-        closure_kind: ty::ClosureKind },
+        closure_kind: ty::ClosureKind,
+    },
 }
 
 /// `PlaceBuilder` is used to create places during MIR construction. It allows you to "build up" a
@@ -81,8 +82,7 @@ crate struct PlaceBuilder<'tcx> {
 fn convert_to_hir_projections_and_truncate_for_capture<'tcx>(
     mir_projections: &[PlaceElem<'tcx>],
 ) -> Vec<HirProjectionKind> {
-
-    let mut hir_projections  = Vec::new();
+    let mut hir_projections = Vec::new();
 
     for mir_projection in mir_projections {
         let hir_projection = match mir_projection {
@@ -91,20 +91,20 @@ fn convert_to_hir_projections_and_truncate_for_capture<'tcx>(
                 // We will never encouter this for multivariant enums,
                 // read the comment for `Downcast`.
                 HirProjectionKind::Field(field.index() as u32, VariantIdx::new(0))
-            },
+            }
             ProjectionElem::Downcast(..) => {
                 // This projections exist only for enums that have
                 // multiple variants. Since such enums that are captured
                 // completely, we can stop here.
-                break
-            },
+                break;
+            }
             ProjectionElem::Index(..)
             | ProjectionElem::ConstantIndex { .. }
             | ProjectionElem::Subslice { .. } => {
                 // We don't capture array-access projections.
                 // We can stop here as arrays are captured completely.
-                break
-            },
+                break;
+            }
         };
 
         hir_projections.push(hir_projection);
@@ -181,9 +181,9 @@ fn find_capture_matching_projections<'a, 'tcx>(
     // If an ancestor is found, `idx` is the index within the list of captured places
     // for root variable `var_hir_id` and `capture` is the `ty::CapturedPlace` itself.
     let (idx, capture) = root_variable_min_captures.iter().enumerate().find(|(_, capture)| {
-            let possible_ancestor_proj_kinds =
-                capture.place.projections.iter().map(|proj| proj.kind).collect();
-            is_ancestor_or_same_capture(&possible_ancestor_proj_kinds, &hir_projections)
+        let possible_ancestor_proj_kinds =
+            capture.place.projections.iter().map(|proj| proj.kind).collect();
+        is_ancestor_or_same_capture(&possible_ancestor_proj_kinds, &hir_projections)
     })?;
 
     // Convert index to be from the presepective of the entire closure_min_captures map
@@ -213,35 +213,34 @@ fn to_upvars_resolved_place_builder<'a, 'tcx>(
                 ty::ClosureKind::FnOnce => {}
             }
 
-            let (capture_index, capture) =
-                if let Some(capture_details) = find_capture_matching_projections(
+            let (capture_index, capture) = if let Some(capture_details) =
+                find_capture_matching_projections(
                     typeck_results,
                     var_hir_id,
                     closure_def_id,
                     &from_builder.projection,
                 ) {
-                    capture_details
-                } else {
-                    if !tcx.features().capture_disjoint_fields {
-                        bug!(
-                            "No associated capture found for {:?}[{:#?}] even though \
+                capture_details
+            } else {
+                if !tcx.features().capture_disjoint_fields {
+                    bug!(
+                        "No associated capture found for {:?}[{:#?}] even though \
                             capture_disjoint_fields isn't enabled",
-                            var_hir_id,
-                            from_builder.projection
-                        )
-                    } else {
-                        // FIXME(project-rfc-2229#24): Handle this case properly
-                        debug!(
-                            "No associated capture found for {:?}[{:#?}]",
-                            var_hir_id,
-                            from_builder.projection,
-                        );
-                    }
-                    return Err(var_hir_id);
-                };
+                        var_hir_id,
+                        from_builder.projection
+                    )
+                } else {
+                    // FIXME(project-rfc-2229#24): Handle this case properly
+                    debug!(
+                        "No associated capture found for {:?}[{:#?}]",
+                        var_hir_id, from_builder.projection,
+                    );
+                }
+                return Err(var_hir_id);
+            };
 
-            let closure_ty =
-                typeck_results.node_type(tcx.hir().local_def_id_to_hir_id(closure_def_id.expect_local()));
+            let closure_ty = typeck_results
+                .node_type(tcx.hir().local_def_id_to_hir_id(closure_def_id.expect_local()));
 
             let substs = match closure_ty.kind() {
                 ty::Closure(_, substs) => ty::UpvarSubsts::Closure(substs),
@@ -256,7 +255,8 @@ fn to_upvars_resolved_place_builder<'a, 'tcx>(
             // we know that the capture exists and is the `capture_index`-th capture.
             let var_ty = substs.tupled_upvars_ty().tuple_element_ty(capture_index).unwrap();
 
-            upvar_resolved_place_builder = upvar_resolved_place_builder.field(Field::new(capture_index), var_ty);
+            upvar_resolved_place_builder =
+                upvar_resolved_place_builder.field(Field::new(capture_index), var_ty);
 
             // If the variable is captured via ByRef(Immutable/Mutable) Borrow,
             // we need to deref it
@@ -270,8 +270,9 @@ fn to_upvars_resolved_place_builder<'a, 'tcx>(
 
             // We used some of the projections to build the capture itself,
             // now we apply the remaining to the upvar resolved place.
-            upvar_resolved_place_builder.projection.extend(
-                curr_projections.drain(next_projection..));
+            upvar_resolved_place_builder
+                .projection
+                .extend(curr_projections.drain(next_projection..));
 
             Ok(upvar_resolved_place_builder)
         }
@@ -356,7 +357,11 @@ impl<'a, 'tcx> Builder<'a, 'tcx> {
 
     /// This is used when constructing a compound `Place`, so that we can avoid creating
     /// intermediate `Place` values until we know the full set of projections.
-    crate fn as_place_builder<M>(&mut self, block: BasicBlock, expr: M) -> BlockAnd<PlaceBuilder<'tcx>>
+    crate fn as_place_builder<M>(
+        &mut self,
+        block: BasicBlock,
+        expr: M,
+    ) -> BlockAnd<PlaceBuilder<'tcx>>
     where
         M: Mirror<'tcx, Output = Expr<'tcx>>,
     {
@@ -627,7 +632,8 @@ impl<'a, 'tcx> Builder<'a, 'tcx> {
         if is_outermost_index {
             self.read_fake_borrows(block, fake_borrow_temps, source_info)
         } else {
-            base_place = base_place.expect_upvars_resolved(self.hir.tcx(), self.hir.typeck_results());
+            base_place =
+                base_place.expect_upvars_resolved(self.hir.tcx(), self.hir.typeck_results());
             self.add_fake_borrows_of_base(
                 &base_place,
                 block,
@@ -679,7 +685,7 @@ impl<'a, 'tcx> Builder<'a, 'tcx> {
         let tcx = self.hir.tcx();
         let local = match base_place.base {
             PlaceBase::Local(local) => local,
-            PlaceBase::Upvar { .. } => bug!("Expected PlacseBase::Local found Upvar")
+            PlaceBase::Upvar { .. } => bug!("Expected PlacseBase::Local found Upvar"),
         };
 
         let place_ty = Place::ty_from(local, &base_place.projection, &self.local_decls, tcx);
diff --git a/compiler/rustc_mir_build/src/build/expr/as_rvalue.rs b/compiler/rustc_mir_build/src/build/expr/as_rvalue.rs
index 55bdbcfc5b9..c95fc969797 100644
--- a/compiler/rustc_mir_build/src/build/expr/as_rvalue.rs
+++ b/compiler/rustc_mir_build/src/build/expr/as_rvalue.rs
@@ -2,9 +2,9 @@
 
 use rustc_index::vec::Idx;
 
+use crate::build::expr::as_place::PlaceBase;
 use crate::build::expr::category::{Category, RvalueFunc};
 use crate::build::{BlockAnd, BlockAndExtension, Builder};
-use crate::build::expr::as_place::PlaceBase;
 use crate::thir::*;
 use rustc_middle::middle::region;
 use rustc_middle::mir::AssertKind;
@@ -274,7 +274,10 @@ impl<'a, 'tcx> Builder<'a, 'tcx> {
             | ExprKind::ValueTypeAscription { .. } => {
                 // these do not have corresponding `Rvalue` variants,
                 // so make an operand and then return that
-                debug_assert!(!matches!(Category::of(&expr.kind), Some(Category::Rvalue(RvalueFunc::AsRvalue))));
+                debug_assert!(!matches!(
+                    Category::of(&expr.kind),
+                    Some(Category::Rvalue(RvalueFunc::AsRvalue))
+                ));
                 let operand = unpack!(block = this.as_operand(block, scope, expr));
                 block.and(Rvalue::Use(operand))
             }
@@ -401,34 +404,39 @@ impl<'a, 'tcx> Builder<'a, 'tcx> {
             // We are capturing a path that starts off a local variable in the parent.
             // The mutability of the current capture is same as the mutability
             // of the local declaration in the parent.
-            PlaceBase::Local(local) =>  this.local_decls[local].mutability,
+            PlaceBase::Local(local) => this.local_decls[local].mutability,
             // Parent is a closure and we are capturing a path that is captured
             // by the parent itself. The mutability of the current capture
             // is same as that of the capture in the parent closure.
             PlaceBase::Upvar { .. } => {
-                let enclosing_upvars_resolved = arg_place_builder.clone().into_place(
-                    this.hir.tcx(),
-                    this.hir.typeck_results());
+                let enclosing_upvars_resolved =
+                    arg_place_builder.clone().into_place(this.hir.tcx(), this.hir.typeck_results());
 
                 match enclosing_upvars_resolved.as_ref() {
-                    PlaceRef { local, projection: &[ProjectionElem::Field(upvar_index, _), ..] }
+                    PlaceRef {
+                        local,
+                        projection: &[ProjectionElem::Field(upvar_index, _), ..],
+                    }
                     | PlaceRef {
                         local,
-                        projection: &[ProjectionElem::Deref, ProjectionElem::Field(upvar_index, _), ..] } => {
-                            // Not in a closure
-                            debug_assert!(
-                                local == Local::new(1),
-                                "Expected local to be Local(1), found {:?}",
-                                local
-                            );
-                            // Not in a closure
-                            debug_assert!(
-                                this.upvar_mutbls.len() > upvar_index.index(),
-                                "Unexpected capture place, upvar_mutbls={:#?}, upvar_index={:?}",
-                                this.upvar_mutbls, upvar_index
-                            );
-                            this.upvar_mutbls[upvar_index.index()]
-                        }
+                        projection:
+                            &[ProjectionElem::Deref, ProjectionElem::Field(upvar_index, _), ..],
+                    } => {
+                        // Not in a closure
+                        debug_assert!(
+                            local == Local::new(1),
+                            "Expected local to be Local(1), found {:?}",
+                            local
+                        );
+                        // Not in a closure
+                        debug_assert!(
+                            this.upvar_mutbls.len() > upvar_index.index(),
+                            "Unexpected capture place, upvar_mutbls={:#?}, upvar_index={:?}",
+                            this.upvar_mutbls,
+                            upvar_index
+                        );
+                        this.upvar_mutbls[upvar_index.index()]
+                    }
                     _ => bug!("Unexpected capture place"),
                 }
             }
@@ -439,9 +447,7 @@ impl<'a, 'tcx> Builder<'a, 'tcx> {
             Mutability::Mut => BorrowKind::Mut { allow_two_phase_borrow: false },
         };
 
-        let arg_place = arg_place_builder.into_place(
-                    this.hir.tcx(),
-                    this.hir.typeck_results());
+        let arg_place = arg_place_builder.into_place(this.hir.tcx(), this.hir.typeck_results());
 
         this.cfg.push_assign(
             block,
diff --git a/compiler/rustc_mir_build/src/build/expr/into.rs b/compiler/rustc_mir_build/src/build/expr/into.rs
index 32c01f2c733..18ebf334404 100644
--- a/compiler/rustc_mir_build/src/build/expr/into.rs
+++ b/compiler/rustc_mir_build/src/build/expr/into.rs
@@ -10,7 +10,7 @@ use rustc_data_structures::stack::ensure_sufficient_stack;
 use rustc_hir as hir;
 use rustc_middle::middle::region;
 use rustc_middle::mir::*;
-use rustc_middle::ty::{CanonicalUserTypeAnnotation};
+use rustc_middle::ty::CanonicalUserTypeAnnotation;
 
 use std::slice;
 
@@ -38,7 +38,8 @@ impl<'a, 'tcx> Builder<'a, 'tcx> {
         let expr_span = expr.span;
         let source_info = this.source_info(expr_span);
 
-        let expr_is_block_or_scope = matches!(expr.kind, ExprKind::Block { .. } | ExprKind::Scope { .. });
+        let expr_is_block_or_scope =
+            matches!(expr.kind, ExprKind::Block { .. } | ExprKind::Scope { .. });
 
         let schedule_drop = move |this: &mut Self| {
             if let Some(drop_scope) = scope {
@@ -68,7 +69,9 @@ impl<'a, 'tcx> Builder<'a, 'tcx> {
                 this.match_expr(destination, scope, expr_span, block, scrutinee, arms)
             }
             ExprKind::If { cond, then, else_opt } => {
-                let place = unpack!(block = this.as_temp(block, Some(this.local_scope()), cond, Mutability::Mut));
+                let place = unpack!(
+                    block = this.as_temp(block, Some(this.local_scope()), cond, Mutability::Mut)
+                );
                 let operand = Operand::Move(Place::from(place));
 
                 let mut then_block = this.cfg.start_new_block();
@@ -100,14 +103,17 @@ impl<'a, 'tcx> Builder<'a, 'tcx> {
                 );
 
                 join_block.unit()
-            },
+            }
             ExprKind::NeverToAny { source } => {
                 let source = this.hir.mirror(source);
-                let is_call = matches!(source.kind, ExprKind::Call { .. } | ExprKind::InlineAsm { .. });
+                let is_call =
+                    matches!(source.kind, ExprKind::Call { .. } | ExprKind::InlineAsm { .. });
 
                 // (#66975) Source could be a const of type `!`, so has to
                 // exist in the generated MIR.
-                unpack!(block = this.as_temp(block, Some(this.local_scope()), source, Mutability::Mut,));
+                unpack!(
+                    block = this.as_temp(block, Some(this.local_scope()), source, Mutability::Mut,)
+                );
 
                 // This is an optimization. If the expression was a call then we already have an
                 // unreachable block. Don't bother to terminate it and create a new one.
@@ -313,7 +319,7 @@ impl<'a, 'tcx> Builder<'a, 'tcx> {
                                         .field(n, ty)
                                         .into_place(this.hir.tcx(), this.hir.typeck_results()),
                                 )
-                            },
+                            }
                         })
                         .collect()
                 } else {
diff --git a/compiler/rustc_mir_build/src/build/matches/mod.rs b/compiler/rustc_mir_build/src/build/matches/mod.rs
index 90fcee075b5..205ba0d2579 100644
--- a/compiler/rustc_mir_build/src/build/matches/mod.rs
+++ b/compiler/rustc_mir_build/src/build/matches/mod.rs
@@ -1692,15 +1692,21 @@ impl<'a, 'tcx> Builder<'a, 'tcx> {
                     let e = self.hir.mirror(e.clone());
                     let source_info = self.source_info(e.span);
                     (e.span, self.test_bool(block, e, source_info))
-                },
+                }
                 Guard::IfLet(pat, scrutinee) => {
                     let scrutinee_span = scrutinee.span();
-                    let scrutinee_place = unpack!(block = self.lower_scrutinee(block, scrutinee.clone(), scrutinee_span));
+                    let scrutinee_place = unpack!(
+                        block = self.lower_scrutinee(block, scrutinee.clone(), scrutinee_span)
+                    );
                     let mut guard_candidate = Candidate::new(scrutinee_place, &pat, false);
                     let wildcard = Pat::wildcard_from_ty(pat.ty);
                     let mut otherwise_candidate = Candidate::new(scrutinee_place, &wildcard, false);
-                    let fake_borrow_temps =
-                        self.lower_match_tree(block, pat.span, false, &mut [&mut guard_candidate, &mut otherwise_candidate]);
+                    let fake_borrow_temps = self.lower_match_tree(
+                        block,
+                        pat.span,
+                        false,
+                        &mut [&mut guard_candidate, &mut otherwise_candidate],
+                    );
                     self.declare_bindings(
                         None,
                         pat.span.to(arm_span.unwrap()),
diff --git a/compiler/rustc_mir_build/src/build/matches/util.rs b/compiler/rustc_mir_build/src/build/matches/util.rs
index 4ef88c25cad..db1f678a5c6 100644
--- a/compiler/rustc_mir_build/src/build/matches/util.rs
+++ b/compiler/rustc_mir_build/src/build/matches/util.rs
@@ -32,9 +32,7 @@ impl<'a, 'tcx> Builder<'a, 'tcx> {
     ) {
         let tcx = self.hir.tcx();
         let (min_length, exact_size) = match place.ty(&self.local_decls, tcx).ty.kind() {
-            ty::Array(_, length) => {
-                (length.eval_usize(tcx, self.hir.param_env), true)
-            }
+            ty::Array(_, length) => (length.eval_usize(tcx, self.hir.param_env), true),
             _ => ((prefix.len() + suffix.len()).try_into().unwrap(), false),
         };
 
diff --git a/compiler/rustc_mir_build/src/build/mod.rs b/compiler/rustc_mir_build/src/build/mod.rs
index e4891eb5a3c..8c1f73f4235 100644
--- a/compiler/rustc_mir_build/src/build/mod.rs
+++ b/compiler/rustc_mir_build/src/build/mod.rs
@@ -838,9 +838,8 @@ impl<'a, 'tcx> Builder<'a, 'tcx> {
                 _ => span_bug!(self.fn_span, "upvars with non-closure env ty {:?}", closure_ty),
             };
             let capture_tys = upvar_substs.upvar_tys();
-            let captures_with_tys = hir_typeck_results
-                .closure_min_captures_flattened(fn_def_id)
-                .zip(capture_tys);
+            let captures_with_tys =
+                hir_typeck_results.closure_min_captures_flattened(fn_def_id).zip(capture_tys);
 
             self.upvar_mutbls = captures_with_tys
                 .enumerate()
@@ -848,7 +847,7 @@ impl<'a, 'tcx> Builder<'a, 'tcx> {
                     let capture = captured_place.info.capture_kind;
                     let var_id = match captured_place.place.base {
                         HirPlaceBase::Upvar(upvar_id) => upvar_id.var_path.hir_id,
-                        _ => bug!("Expected an upvar")
+                        _ => bug!("Expected an upvar"),
                     };
 
                     let mutability = captured_place.mutability;
diff --git a/compiler/rustc_mir_build/src/build/scope.rs b/compiler/rustc_mir_build/src/build/scope.rs
index 62d2212d109..cbc20c6153a 100644
--- a/compiler/rustc_mir_build/src/build/scope.rs
+++ b/compiler/rustc_mir_build/src/build/scope.rs
@@ -931,10 +931,7 @@ impl<'a, 'tcx> Builder<'a, 'tcx> {
         let local_scope = self.local_scope();
         let scope = self.scopes.scopes.last_mut().unwrap();
 
-        assert_eq!(
-            scope.region_scope, local_scope,
-            "local scope is not the topmost scope!",
-        );
+        assert_eq!(scope.region_scope, local_scope, "local scope is not the topmost scope!",);
 
         // look for moves of a local variable, like `MOVE(_X)`
         let locals_moved = operands
@@ -1046,9 +1043,9 @@ impl<'a, 'tcx> Builder<'a, 'tcx> {
             matches!(
                 self.cfg.block_data(start).terminator().kind,
                 TerminatorKind::Assert { .. }
-                | TerminatorKind::Call {..}
-                | TerminatorKind::DropAndReplace { .. }
-                | TerminatorKind::FalseUnwind { .. }
+                    | TerminatorKind::Call { .. }
+                    | TerminatorKind::DropAndReplace { .. }
+                    | TerminatorKind::FalseUnwind { .. }
             ),
             "diverge_from called on block with terminator that cannot unwind."
         );
diff --git a/compiler/rustc_parse/src/parser/nonterminal.rs b/compiler/rustc_parse/src/parser/nonterminal.rs
index 012b76d3d18..6e25209f090 100644
--- a/compiler/rustc_parse/src/parser/nonterminal.rs
+++ b/compiler/rustc_parse/src/parser/nonterminal.rs
@@ -41,13 +41,16 @@ impl<'a> Parser<'a> {
             },
             NonterminalKind::Block => match token.kind {
                 token::OpenDelim(token::Brace) => true,
-                token::Interpolated(ref nt) => !matches!(**nt, token::NtItem(_)
-                    | token::NtPat(_)
-                    | token::NtTy(_)
-                    | token::NtIdent(..)
-                    | token::NtMeta(_)
-                    | token::NtPath(_)
-                    | token::NtVis(_)),
+                token::Interpolated(ref nt) => !matches!(
+                    **nt,
+                    token::NtItem(_)
+                        | token::NtPat(_)
+                        | token::NtTy(_)
+                        | token::NtIdent(..)
+                        | token::NtMeta(_)
+                        | token::NtPath(_)
+                        | token::NtVis(_)
+                ),
                 _ => false,
             },
             NonterminalKind::Path | NonterminalKind::Meta => match token.kind {
diff --git a/compiler/rustc_passes/src/stability.rs b/compiler/rustc_passes/src/stability.rs
index b70cec25dfb..e1d03e35048 100644
--- a/compiler/rustc_passes/src/stability.rs
+++ b/compiler/rustc_passes/src/stability.rs
@@ -553,7 +553,8 @@ impl<'tcx> Visitor<'tcx> for MissingStabilityAnnotations<'tcx> {
         // optional. They inherit stability from their parents when unannotated.
         if !matches!(
             i.kind,
-            hir::ItemKind::Impl(hir::Impl { of_trait: None, .. }) | hir::ItemKind::ForeignMod { .. }
+            hir::ItemKind::Impl(hir::Impl { of_trait: None, .. })
+                | hir::ItemKind::ForeignMod { .. }
         ) {
             self.check_missing_stability(i.hir_id, i.span);
         }
diff --git a/compiler/rustc_resolve/src/late/diagnostics.rs b/compiler/rustc_resolve/src/late/diagnostics.rs
index bed7a350ea8..9c90388d24a 100644
--- a/compiler/rustc_resolve/src/late/diagnostics.rs
+++ b/compiler/rustc_resolve/src/late/diagnostics.rs
@@ -1659,12 +1659,15 @@ impl<'tcx> LifetimeContext<'_, 'tcx> {
             match missing {
                 MissingLifetimeSpot::Generics(generics) => {
                     let (span, sugg) = if let Some(param) = generics.params.iter().find(|p| {
-                        !matches!(p.kind, hir::GenericParamKind::Type {
-                            synthetic: Some(hir::SyntheticTyParamKind::ImplTrait),
-                            ..
-                        } | hir::GenericParamKind::Lifetime {
-                            kind: hir::LifetimeParamKind::Elided,
-                        })
+                        !matches!(
+                            p.kind,
+                            hir::GenericParamKind::Type {
+                                synthetic: Some(hir::SyntheticTyParamKind::ImplTrait),
+                                ..
+                            } | hir::GenericParamKind::Lifetime {
+                                kind: hir::LifetimeParamKind::Elided,
+                            }
+                        )
                     }) {
                         (param.span.shrink_to_lo(), format!("{}, ", lifetime_ref))
                     } else {
@@ -1844,10 +1847,13 @@ impl<'tcx> LifetimeContext<'_, 'tcx> {
                         msg = "consider introducing a named lifetime parameter".to_string();
                         should_break = true;
                         if let Some(param) = generics.params.iter().find(|p| {
-                            !matches!(p.kind, hir::GenericParamKind::Type {
-                                synthetic: Some(hir::SyntheticTyParamKind::ImplTrait),
-                                ..
-                            })
+                            !matches!(
+                                p.kind,
+                                hir::GenericParamKind::Type {
+                                    synthetic: Some(hir::SyntheticTyParamKind::ImplTrait),
+                                    ..
+                                }
+                            )
                         }) {
                             (param.span.shrink_to_lo(), "'a, ".to_string())
                         } else {
diff --git a/compiler/rustc_target/src/abi/call/mod.rs b/compiler/rustc_target/src/abi/call/mod.rs
index ce8e56b1949..cb37a4b231b 100644
--- a/compiler/rustc_target/src/abi/call/mod.rs
+++ b/compiler/rustc_target/src/abi/call/mod.rs
@@ -526,7 +526,7 @@ impl<'a, Ty> ArgAbi<'a, Ty> {
     }
 
     pub fn is_indirect(&self) -> bool {
-        matches!(self.mode, PassMode::Indirect {..})
+        matches!(self.mode, PassMode::Indirect { .. })
     }
 
     pub fn is_sized_indirect(&self) -> bool {
diff --git a/compiler/rustc_trait_selection/src/traits/error_reporting/mod.rs b/compiler/rustc_trait_selection/src/traits/error_reporting/mod.rs
index a42a05c5f02..d3b3403ac3e 100644
--- a/compiler/rustc_trait_selection/src/traits/error_reporting/mod.rs
+++ b/compiler/rustc_trait_selection/src/traits/error_reporting/mod.rs
@@ -1190,9 +1190,12 @@ impl<'a, 'tcx> InferCtxtPrivExt<'tcx> for InferCtxt<'a, 'tcx> {
                     normalized_ty, data.ty
                 );
 
-                let is_normalized_ty_expected = !matches!(obligation.cause.code, ObligationCauseCode::ItemObligation(_)
-                    | ObligationCauseCode::BindingObligation(_, _)
-                    | ObligationCauseCode::ObjectCastObligation(_));
+                let is_normalized_ty_expected = !matches!(
+                    obligation.cause.code,
+                    ObligationCauseCode::ItemObligation(_)
+                        | ObligationCauseCode::BindingObligation(_, _)
+                        | ObligationCauseCode::ObjectCastObligation(_)
+                );
 
                 if let Err(error) = self.at(&obligation.cause, obligation.param_env).eq_exp(
                     is_normalized_ty_expected,
diff --git a/compiler/rustc_trait_selection/src/traits/error_reporting/suggestions.rs b/compiler/rustc_trait_selection/src/traits/error_reporting/suggestions.rs
index 690591930de..21828006164 100644
--- a/compiler/rustc_trait_selection/src/traits/error_reporting/suggestions.rs
+++ b/compiler/rustc_trait_selection/src/traits/error_reporting/suggestions.rs
@@ -290,9 +290,9 @@ fn suggest_restriction(
             generics
                 .params
                 .iter()
-                .filter(
-                    |p| !matches!(p.kind, hir::GenericParamKind::Type { synthetic: Some(_), ..}),
-                )
+                .filter(|p| {
+                    !matches!(p.kind, hir::GenericParamKind::Type { synthetic: Some(_), .. })
+                })
                 .next(),
             super_traits,
         ) {
diff --git a/compiler/rustc_typeck/src/astconv/generics.rs b/compiler/rustc_typeck/src/astconv/generics.rs
index 0797c956362..67e37ca8d8e 100644
--- a/compiler/rustc_typeck/src/astconv/generics.rs
+++ b/compiler/rustc_typeck/src/astconv/generics.rs
@@ -496,14 +496,15 @@ impl<'o, 'tcx> dyn AstConv<'tcx> + 'o {
     ) -> bool {
         let explicit = !seg.infer_args;
         let impl_trait = generics.params.iter().any(|param| {
-            matches!(param.kind, ty::GenericParamDefKind::Type {
-                synthetic:
-                    Some(
-                        hir::SyntheticTyParamKind::ImplTrait
-                        | hir::SyntheticTyParamKind::FromAttr,
+            matches!(
+                param.kind,
+                ty::GenericParamDefKind::Type {
+                    synthetic: Some(
+                        hir::SyntheticTyParamKind::ImplTrait | hir::SyntheticTyParamKind::FromAttr,
                     ),
-                ..
-            })
+                    ..
+                }
+            )
         });
 
         if explicit && impl_trait {
diff --git a/compiler/rustc_typeck/src/check/fn_ctxt/_impl.rs b/compiler/rustc_typeck/src/check/fn_ctxt/_impl.rs
index ed48a0bc801..bc1a07801ae 100644
--- a/compiler/rustc_typeck/src/check/fn_ctxt/_impl.rs
+++ b/compiler/rustc_typeck/src/check/fn_ctxt/_impl.rs
@@ -274,10 +274,13 @@ impl<'a, 'tcx> FnCtxt<'a, 'tcx> {
         }
 
         let autoborrow_mut = adj.iter().any(|adj| {
-            matches!(adj, &Adjustment {
-                kind: Adjust::Borrow(AutoBorrow::Ref(_, AutoBorrowMutability::Mut { .. })),
-                ..
-            })
+            matches!(
+                adj,
+                &Adjustment {
+                    kind: Adjust::Borrow(AutoBorrow::Ref(_, AutoBorrowMutability::Mut { .. })),
+                    ..
+                }
+            )
         });
 
         match self.typeck_results.borrow_mut().adjustments_mut().entry(expr.hir_id) {
diff --git a/library/core/src/default.rs b/library/core/src/default.rs
index 9a8d65cd4e0..28ec3279459 100644
--- a/library/core/src/default.rs
+++ b/library/core/src/default.rs
@@ -173,9 +173,11 @@ macro_rules! default_impl {
         impl Default for $t {
             #[inline]
             #[doc = $doc]
-            fn default() -> $t { $v }
+            fn default() -> $t {
+                $v
+            }
         }
-    }
+    };
 }
 
 default_impl! { (), (), "Returns the default value of `()`" }
diff --git a/rustfmt.toml b/rustfmt.toml
index 45cce186c09..af807aa6f73 100644
--- a/rustfmt.toml
+++ b/rustfmt.toml
@@ -6,7 +6,7 @@ merge_derives = false
 # by default we ignore everything in the repository
 # tidy only checks files which are not ignored, each entry follows gitignore style
 ignore = [
-    "build",
+    "/build/",
     "/vendor/",
 
     # tests for now are not formatted, as they are sometimes pretty-printing constrained
diff --git a/src/bootstrap/bin/main.rs b/src/bootstrap/bin/main.rs
index 07e582d4d29..a32a4a7fe56 100644
--- a/src/bootstrap/bin/main.rs
+++ b/src/bootstrap/bin/main.rs
@@ -15,7 +15,7 @@ fn main() {
 
     // check_version warnings are not printed during setup
     let changelog_suggestion =
-        if matches!(config.cmd, Subcommand::Setup {..}) { None } else { check_version(&config) };
+        if matches!(config.cmd, Subcommand::Setup { .. }) { None } else { check_version(&config) };
 
     // NOTE: Since `./configure` generates a `config.toml`, distro maintainers will see the
     // changelog warning, not the `x.py setup` message.
diff --git a/src/stage0.txt b/src/stage0.txt
index e853b9b4e41..d3c76eb282a 100644
--- a/src/stage0.txt
+++ b/src/stage0.txt
@@ -19,7 +19,7 @@ rustc: beta
 # bootstrapping issues with use of new syntax in this repo. If you're looking at
 # the beta/stable branch, this key should be omitted, as we don't want to depend
 # on rustfmt from nightly there.
-rustfmt: nightly-2020-11-19
+rustfmt: nightly-2021-01-28
 
 # When making a stable release the process currently looks like:
 #