1
Fork 0

re-format with new rustfmt

This commit is contained in:
Mark Rousskov 2021-11-30 13:08:41 -05:00
parent b221c877e8
commit 971c549ca3
15 changed files with 111 additions and 81 deletions

View file

@ -519,8 +519,10 @@ pub fn eval_condition(
[NestedMetaItem::Literal(Lit { kind: LitKind::Str(sym, ..), span, .. })] => { [NestedMetaItem::Literal(Lit { kind: LitKind::Str(sym, ..), span, .. })] => {
(sym, span) (sym, span)
} }
[NestedMetaItem::Literal(Lit { span, .. }) [
| NestedMetaItem::MetaItem(MetaItem { span, .. })] => { NestedMetaItem::Literal(Lit { span, .. })
| NestedMetaItem::MetaItem(MetaItem { span, .. }),
] => {
sess.span_diagnostic sess.span_diagnostic
.struct_span_err(*span, "expected a version literal") .struct_span_err(*span, "expected a version literal")
.emit(); .emit();

View file

@ -977,9 +977,7 @@ impl<'cx, 'tcx> MirBorrowckCtxt<'cx, 'tcx> {
Some(ref name), Some(ref name),
BorrowExplanation::MustBeValidFor { BorrowExplanation::MustBeValidFor {
category: category:
category category @ (ConstraintCategory::Return(_)
@
(ConstraintCategory::Return(_)
| ConstraintCategory::CallArgument | ConstraintCategory::CallArgument
| ConstraintCategory::OpaqueType), | ConstraintCategory::OpaqueType),
from_closure: false, from_closure: false,

View file

@ -165,10 +165,13 @@ impl<'a, 'tcx> MirBorrowckCtxt<'a, 'tcx> {
PlaceRef { PlaceRef {
local: _, local: _,
projection: projection:
[.., ProjectionElem::Index(_) [
..,
ProjectionElem::Index(_)
| ProjectionElem::ConstantIndex { .. } | ProjectionElem::ConstantIndex { .. }
| ProjectionElem::Subslice { .. } | ProjectionElem::Subslice { .. }
| ProjectionElem::Downcast(..)], | ProjectionElem::Downcast(..),
],
} => bug!("Unexpected immutable place."), } => bug!("Unexpected immutable place."),
} }
@ -217,7 +220,12 @@ impl<'a, 'tcx> MirBorrowckCtxt<'a, 'tcx> {
PlaceRef { PlaceRef {
local, local,
projection: projection:
[proj_base @ .., ProjectionElem::Deref, ProjectionElem::Field(field, _), ProjectionElem::Deref], [
proj_base @ ..,
ProjectionElem::Deref,
ProjectionElem::Field(field, _),
ProjectionElem::Deref,
],
} => { } => {
err.span_label(span, format!("cannot {ACT}", ACT = act)); err.span_label(span, format!("cannot {ACT}", ACT = act));
@ -763,11 +771,14 @@ impl<'a, 'tcx> MirBorrowckCtxt<'a, 'tcx> {
kind: kind:
Call( Call(
_, _,
[Expr { [
Expr {
kind: MethodCall(path_segment, ..), kind: MethodCall(path_segment, ..),
hir_id, hir_id,
.. ..
}, ..], },
..,
],
), ),
.. ..
}, },

View file

@ -769,20 +769,24 @@ impl<'tcx> MirBorrowckCtxt<'_, 'tcx> {
let opaque_ty = hir.item(id); let opaque_ty = hir.item(id);
if let hir::ItemKind::OpaqueTy(hir::OpaqueTy { if let hir::ItemKind::OpaqueTy(hir::OpaqueTy {
bounds: bounds:
[hir::GenericBound::LangItemTrait( [
hir::GenericBound::LangItemTrait(
hir::LangItem::Future, hir::LangItem::Future,
_, _,
_, _,
hir::GenericArgs { hir::GenericArgs {
bindings: bindings:
[hir::TypeBinding { [
hir::TypeBinding {
ident: Ident { name: sym::Output, .. }, ident: Ident { name: sym::Output, .. },
kind: hir::TypeBindingKind::Equality { ty }, kind: hir::TypeBindingKind::Equality { ty },
.. ..
}], },
],
.. ..
}, },
)], ),
],
.. ..
}) = opaque_ty.kind }) = opaque_ty.kind
{ {

View file

@ -1525,14 +1525,12 @@ fn generator_layout_and_saved_local_names(
// Deref of the `Pin<&mut Self>` state argument. // Deref of the `Pin<&mut Self>` state argument.
mir::ProjectionElem::Field(..), mir::ProjectionElem::Field(..),
mir::ProjectionElem::Deref, mir::ProjectionElem::Deref,
// Field of a variant of the state. // Field of a variant of the state.
mir::ProjectionElem::Downcast(_, variant), mir::ProjectionElem::Downcast(_, variant),
mir::ProjectionElem::Field(field, _), mir::ProjectionElem::Field(field, _),
] => { ] => {
let name = &mut generator_saved_local_names[ let name = &mut generator_saved_local_names
generator_layout.variant_fields[variant][field] [generator_layout.variant_fields[variant][field]];
];
if name.is_none() { if name.is_none() {
name.replace(var.name); name.replace(var.name);
} }

View file

@ -584,9 +584,7 @@ fn inner_parse_loop<'root, 'tt>(
// //
// At the beginning of the loop, if we reach the end of the delimited submatcher, // At the beginning of the loop, if we reach the end of the delimited submatcher,
// we pop the stack to backtrack out of the descent. // we pop the stack to backtrack out of the descent.
seq seq @ (TokenTree::Delimited(..)
@
(TokenTree::Delimited(..)
| TokenTree::Token(Token { kind: DocComment(..), .. })) => { | TokenTree::Token(Token { kind: DocComment(..), .. })) => {
let lower_elts = mem::replace(&mut item.top_elts, Tt(seq)); let lower_elts = mem::replace(&mut item.top_elts, Tt(seq));
let idx = item.idx; let idx = item.idx;

View file

@ -65,24 +65,33 @@ fn string_to_tts_macro() {
let tts: &[TokenTree] = &tts[..]; let tts: &[TokenTree] = &tts[..];
match tts { match tts {
[TokenTree::Token(Token { kind: token::Ident(name_macro_rules, false), .. }), TokenTree::Token(Token { kind: token::Not, .. }), TokenTree::Token(Token { kind: token::Ident(name_zip, false), .. }), TokenTree::Delimited(_, macro_delim, macro_tts)] [
if name_macro_rules == &kw::MacroRules && name_zip.as_str() == "zip" => TokenTree::Token(Token { kind: token::Ident(name_macro_rules, false), .. }),
{ TokenTree::Token(Token { kind: token::Not, .. }),
TokenTree::Token(Token { kind: token::Ident(name_zip, false), .. }),
TokenTree::Delimited(_, macro_delim, macro_tts),
] if name_macro_rules == &kw::MacroRules && name_zip.as_str() == "zip" => {
let tts = &macro_tts.trees().collect::<Vec<_>>(); let tts = &macro_tts.trees().collect::<Vec<_>>();
match &tts[..] { match &tts[..] {
[TokenTree::Delimited(_, first_delim, first_tts), TokenTree::Token(Token { kind: token::FatArrow, .. }), TokenTree::Delimited(_, second_delim, second_tts)] [
if macro_delim == &token::Paren => TokenTree::Delimited(_, first_delim, first_tts),
{ TokenTree::Token(Token { kind: token::FatArrow, .. }),
TokenTree::Delimited(_, second_delim, second_tts),
] if macro_delim == &token::Paren => {
let tts = &first_tts.trees().collect::<Vec<_>>(); let tts = &first_tts.trees().collect::<Vec<_>>();
match &tts[..] { match &tts[..] {
[TokenTree::Token(Token { kind: token::Dollar, .. }), TokenTree::Token(Token { kind: token::Ident(name, false), .. })] [
if first_delim == &token::Paren && name.as_str() == "a" => {} TokenTree::Token(Token { kind: token::Dollar, .. }),
TokenTree::Token(Token { kind: token::Ident(name, false), .. }),
] if first_delim == &token::Paren && name.as_str() == "a" => {}
_ => panic!("value 3: {:?} {:?}", first_delim, first_tts), _ => panic!("value 3: {:?} {:?}", first_delim, first_tts),
} }
let tts = &second_tts.trees().collect::<Vec<_>>(); let tts = &second_tts.trees().collect::<Vec<_>>();
match &tts[..] { match &tts[..] {
[TokenTree::Token(Token { kind: token::Dollar, .. }), TokenTree::Token(Token { kind: token::Ident(name, false), .. })] [
if second_delim == &token::Paren && name.as_str() == "a" => {} TokenTree::Token(Token { kind: token::Dollar, .. }),
TokenTree::Token(Token { kind: token::Ident(name, false), .. }),
] if second_delim == &token::Paren && name.as_str() == "a" => {}
_ => panic!("value 4: {:?} {:?}", second_delim, second_tts), _ => panic!("value 4: {:?} {:?}", second_delim, second_tts),
} }
} }

View file

@ -1111,7 +1111,11 @@ impl<'tcx> TyCtxt<'tcx> {
}; };
debug!("layout_scalar_valid_range: attr={:?}", attr); debug!("layout_scalar_valid_range: attr={:?}", attr);
if let Some( if let Some(
&[ast::NestedMetaItem::Literal(ast::Lit { kind: ast::LitKind::Int(a, _), .. })], &[
ast::NestedMetaItem::Literal(ast::Lit {
kind: ast::LitKind::Int(a, _), ..
}),
],
) = attr.meta_item_list().as_deref() ) = attr.meta_item_list().as_deref()
{ {
Bound::Included(a) Bound::Included(a)

View file

@ -356,14 +356,17 @@ impl<'tcx> ClosureSubsts<'tcx> {
/// The ordering assumed here must match that used by `ClosureSubsts::new` above. /// The ordering assumed here must match that used by `ClosureSubsts::new` above.
fn split(self) -> ClosureSubstsParts<'tcx, GenericArg<'tcx>> { fn split(self) -> ClosureSubstsParts<'tcx, GenericArg<'tcx>> {
match self.substs[..] { match self.substs[..] {
[ref parent_substs @ .., closure_kind_ty, closure_sig_as_fn_ptr_ty, tupled_upvars_ty] => { [
ClosureSubstsParts { ref parent_substs @ ..,
closure_kind_ty,
closure_sig_as_fn_ptr_ty,
tupled_upvars_ty,
] => ClosureSubstsParts {
parent_substs, parent_substs,
closure_kind_ty, closure_kind_ty,
closure_sig_as_fn_ptr_ty, closure_sig_as_fn_ptr_ty,
tupled_upvars_ty, tupled_upvars_ty,
} },
}
_ => bug!("closure substs missing synthetics"), _ => bug!("closure substs missing synthetics"),
} }
} }

View file

@ -2026,9 +2026,7 @@ impl<'a, 'tcx> InferCtxtPrivExt<'tcx> for InferCtxt<'a, 'tcx> {
debug!("maybe_suggest_unsized_generics: param={:?}", param); debug!("maybe_suggest_unsized_generics: param={:?}", param);
match node { match node {
hir::Node::Item( hir::Node::Item(
item item @ hir::Item {
@
hir::Item {
// Only suggest indirection for uses of type parameters in ADTs. // Only suggest indirection for uses of type parameters in ADTs.
kind: kind:
hir::ItemKind::Enum(..) | hir::ItemKind::Struct(..) | hir::ItemKind::Union(..), hir::ItemKind::Enum(..) | hir::ItemKind::Struct(..) | hir::ItemKind::Union(..),

View file

@ -1126,8 +1126,10 @@ impl<'a, 'tcx> FnCtxt<'a, 'tcx> {
for expr in exprs { for expr in exprs {
let expr = expr.as_coercion_site(); let expr = expr.as_coercion_site();
let noop = match self.typeck_results.borrow().expr_adjustments(expr) { let noop = match self.typeck_results.borrow().expr_adjustments(expr) {
&[Adjustment { kind: Adjust::Deref(_), .. }, Adjustment { kind: Adjust::Borrow(AutoBorrow::Ref(_, mutbl_adj)), .. }] => &[
{ Adjustment { kind: Adjust::Deref(_), .. },
Adjustment { kind: Adjust::Borrow(AutoBorrow::Ref(_, mutbl_adj)), .. },
] => {
match *self.node_ty(expr.hir_id).kind() { match *self.node_ty(expr.hir_id).kind() {
ty::Ref(_, _, mt_orig) => { ty::Ref(_, _, mt_orig) => {
let mutbl_adj: hir::Mutability = mutbl_adj.into(); let mutbl_adj: hir::Mutability = mutbl_adj.into();

View file

@ -304,20 +304,26 @@ impl<'a, 'tcx> FnCtxt<'a, 'tcx> {
// is a valid NeverToAny adjustment, because it can't // is a valid NeverToAny adjustment, because it can't
// be reached. // be reached.
(&[Adjustment { kind: Adjust::NeverToAny, .. }], _) => return, (&[Adjustment { kind: Adjust::NeverToAny, .. }], _) => return,
(&[ (
&[
Adjustment { kind: Adjust::Deref(_), .. }, Adjustment { kind: Adjust::Deref(_), .. },
Adjustment { kind: Adjust::Borrow(AutoBorrow::Ref(..)), .. }, Adjustment { kind: Adjust::Borrow(AutoBorrow::Ref(..)), .. },
], &[ ],
&[
Adjustment { kind: Adjust::Deref(_), .. }, Adjustment { kind: Adjust::Deref(_), .. },
.. // Any following adjustments are allowed. .., // Any following adjustments are allowed.
]) => { ],
) => {
// A reborrow has no effect before a dereference. // A reborrow has no effect before a dereference.
} }
// FIXME: currently we never try to compose autoderefs // FIXME: currently we never try to compose autoderefs
// and ReifyFnPointer/UnsafeFnPointer, but we could. // and ReifyFnPointer/UnsafeFnPointer, but we could.
_ => _ => bug!(
bug!("while adjusting {:?}, can't compose {:?} and {:?}", "while adjusting {:?}, can't compose {:?} and {:?}",
expr, entry.get(), adj) expr,
entry.get(),
adj
),
}; };
*entry.get_mut() = adj; *entry.get_mut() = adj;
} }

View file

@ -440,8 +440,11 @@ impl<'a, 'tcx> FnCtxt<'a, 'tcx> {
} }
// If we have an autoref followed by unsizing at the end, fix the unsize target. // If we have an autoref followed by unsizing at the end, fix the unsize target.
if let [.., Adjustment { kind: Adjust::Borrow(AutoBorrow::Ref(..)), .. }, Adjustment { kind: Adjust::Pointer(PointerCast::Unsize), ref mut target }] = if let [
adjustments[..] ..,
Adjustment { kind: Adjust::Borrow(AutoBorrow::Ref(..)), .. },
Adjustment { kind: Adjust::Pointer(PointerCast::Unsize), ref mut target },
] = adjustments[..]
{ {
*target = method.sig.inputs()[0]; *target = method.sig.inputs()[0];
} }

View file

@ -687,15 +687,11 @@ impl<'a, 'tcx> FnCtxt<'a, 'tcx> {
r r
), ),
( (
l l @ (ProjectionKind::Index
@
(ProjectionKind::Index
| ProjectionKind::Subslice | ProjectionKind::Subslice
| ProjectionKind::Deref | ProjectionKind::Deref
| ProjectionKind::Field(..)), | ProjectionKind::Field(..)),
r r @ (ProjectionKind::Index
@
(ProjectionKind::Index
| ProjectionKind::Subslice | ProjectionKind::Subslice
| ProjectionKind::Deref | ProjectionKind::Deref
| ProjectionKind::Field(..)), | ProjectionKind::Field(..)),

View file

@ -395,9 +395,7 @@ crate fn register_res(cx: &mut DocContext<'_>, res: Res) -> DefId {
let (did, kind) = match res { let (did, kind) = match res {
// These should be added to the cache using `record_extern_fqn`. // These should be added to the cache using `record_extern_fqn`.
Res::Def( Res::Def(
kind kind @ (AssocTy | AssocFn | AssocConst | Variant | Fn | TyAlias | Enum | Trait | Struct
@
(AssocTy | AssocFn | AssocConst | Variant | Fn | TyAlias | Enum | Trait | Struct
| Union | Mod | ForeignTy | Const | Static | Macro(..) | TraitAlias), | Union | Mod | ForeignTy | Const | Static | Macro(..) | TraitAlias),
i, i,
) => (i, kind.into()), ) => (i, kind.into()),