Auto merge of #80843 - Mark-Simulacrum:fmt-bump, r=petrochenkov

Bump rustfmt version
This commit is contained in:
bors 2021-02-02 14:52:53 +00:00
commit b81f5811f9
30 changed files with 224 additions and 164 deletions

View File

@ -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);
}

View File

@ -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() {

View File

@ -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

View File

@ -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(_)
)
}
}

View File

@ -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,
_,
)
),

View File

@ -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);

View File

@ -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(..), .. }),
)
)
}

View File

@ -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(_),
)))
)
}

View File

@ -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(_)
)
)
}

View File

@ -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 { .. }

View File

@ -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(_))
)
}

View File

@ -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);

View File

@ -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,

View File

@ -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 {

View File

@ -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()),

View File

@ -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),
};

View File

@ -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;

View File

@ -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."
);

View File

@ -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 {

View File

@ -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);
}

View File

@ -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 {

View File

@ -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 {

View File

@ -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,

View File

@ -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,
) {

View File

@ -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 {

View File

@ -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) {

View File

@ -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 `()`" }

View File

@ -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

View File

@ -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.

View File

@ -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:
#