Skip to content

Commit

Permalink
re-format with new rustfmt
Browse files Browse the repository at this point in the history
  • Loading branch information
Mark-Simulacrum committed Nov 30, 2021
1 parent b221c87 commit 971c549
Show file tree
Hide file tree
Showing 15 changed files with 111 additions and 81 deletions.
6 changes: 4 additions & 2 deletions compiler/rustc_attr/src/builtin.rs
Expand Up @@ -519,8 +519,10 @@ pub fn eval_condition(
[NestedMetaItem::Literal(Lit { kind: LitKind::Str(sym, ..), span, .. })] => {
(sym, span)
}
[NestedMetaItem::Literal(Lit { span, .. })
| NestedMetaItem::MetaItem(MetaItem { span, .. })] => {
[
NestedMetaItem::Literal(Lit { span, .. })
| NestedMetaItem::MetaItem(MetaItem { span, .. }),
] => {
sess.span_diagnostic
.struct_span_err(*span, "expected a version literal")
.emit();
Expand Down
4 changes: 1 addition & 3 deletions compiler/rustc_borrowck/src/diagnostics/conflict_errors.rs
Expand Up @@ -977,9 +977,7 @@ impl<'cx, 'tcx> MirBorrowckCtxt<'cx, 'tcx> {
Some(ref name),
BorrowExplanation::MustBeValidFor {
category:
category
@
(ConstraintCategory::Return(_)
category @ (ConstraintCategory::Return(_)
| ConstraintCategory::CallArgument
| ConstraintCategory::OpaqueType),
from_closure: false,
Expand Down
31 changes: 21 additions & 10 deletions compiler/rustc_borrowck/src/diagnostics/mutability_errors.rs
Expand Up @@ -165,10 +165,13 @@ impl<'a, 'tcx> MirBorrowckCtxt<'a, 'tcx> {
PlaceRef {
local: _,
projection:
[.., ProjectionElem::Index(_)
| ProjectionElem::ConstantIndex { .. }
| ProjectionElem::Subslice { .. }
| ProjectionElem::Downcast(..)],
[
..,
ProjectionElem::Index(_)
| ProjectionElem::ConstantIndex { .. }
| ProjectionElem::Subslice { .. }
| ProjectionElem::Downcast(..),
],
} => bug!("Unexpected immutable place."),
}

Expand Down Expand Up @@ -217,7 +220,12 @@ impl<'a, 'tcx> MirBorrowckCtxt<'a, 'tcx> {
PlaceRef {
local,
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));

Expand Down Expand Up @@ -763,11 +771,14 @@ impl<'a, 'tcx> MirBorrowckCtxt<'a, 'tcx> {
kind:
Call(
_,
[Expr {
kind: MethodCall(path_segment, ..),
hir_id,
..
}, ..],
[
Expr {
kind: MethodCall(path_segment, ..),
hir_id,
..
},
..,
],
),
..
},
Expand Down
32 changes: 18 additions & 14 deletions compiler/rustc_borrowck/src/diagnostics/region_name.rs
Expand Up @@ -769,20 +769,24 @@ impl<'tcx> MirBorrowckCtxt<'_, 'tcx> {
let opaque_ty = hir.item(id);
if let hir::ItemKind::OpaqueTy(hir::OpaqueTy {
bounds:
[hir::GenericBound::LangItemTrait(
hir::LangItem::Future,
_,
_,
hir::GenericArgs {
bindings:
[hir::TypeBinding {
ident: Ident { name: sym::Output, .. },
kind: hir::TypeBindingKind::Equality { ty },
..
}],
..
},
)],
[
hir::GenericBound::LangItemTrait(
hir::LangItem::Future,
_,
_,
hir::GenericArgs {
bindings:
[
hir::TypeBinding {
ident: Ident { name: sym::Output, .. },
kind: hir::TypeBindingKind::Equality { ty },
..
},
],
..
},
),
],
..
}) = opaque_ty.kind
{
Expand Down
6 changes: 2 additions & 4 deletions compiler/rustc_codegen_llvm/src/debuginfo/metadata.rs
Expand Up @@ -1525,14 +1525,12 @@ fn generator_layout_and_saved_local_names(
// Deref of the `Pin<&mut Self>` state argument.
mir::ProjectionElem::Field(..),
mir::ProjectionElem::Deref,

// Field of a variant of the state.
mir::ProjectionElem::Downcast(_, variant),
mir::ProjectionElem::Field(field, _),
] => {
let name = &mut generator_saved_local_names[
generator_layout.variant_fields[variant][field]
];
let name = &mut generator_saved_local_names
[generator_layout.variant_fields[variant][field]];
if name.is_none() {
name.replace(var.name);
}
Expand Down
4 changes: 1 addition & 3 deletions compiler/rustc_expand/src/mbe/macro_parser.rs
Expand Up @@ -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,
// we pop the stack to backtrack out of the descent.
seq
@
(TokenTree::Delimited(..)
seq @ (TokenTree::Delimited(..)
| TokenTree::Token(Token { kind: DocComment(..), .. })) => {
let lower_elts = mem::replace(&mut item.top_elts, Tt(seq));
let idx = item.idx;
Expand Down
29 changes: 19 additions & 10 deletions compiler/rustc_expand/src/parse/tests.rs
Expand Up @@ -65,24 +65,33 @@ fn string_to_tts_macro() {
let tts: &[TokenTree] = &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<_>>();
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<_>>();
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),
}
let tts = &second_tts.trees().collect::<Vec<_>>();
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),
}
}
Expand Down
6 changes: 5 additions & 1 deletion compiler/rustc_middle/src/ty/context.rs
Expand Up @@ -1111,7 +1111,11 @@ impl<'tcx> TyCtxt<'tcx> {
};
debug!("layout_scalar_valid_range: attr={:?}", attr);
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()
{
Bound::Included(a)
Expand Down
19 changes: 11 additions & 8 deletions compiler/rustc_middle/src/ty/sty.rs
Expand Up @@ -356,14 +356,17 @@ impl<'tcx> ClosureSubsts<'tcx> {
/// The ordering assumed here must match that used by `ClosureSubsts::new` above.
fn split(self) -> ClosureSubstsParts<'tcx, GenericArg<'tcx>> {
match self.substs[..] {
[ref parent_substs @ .., closure_kind_ty, closure_sig_as_fn_ptr_ty, tupled_upvars_ty] => {
ClosureSubstsParts {
parent_substs,
closure_kind_ty,
closure_sig_as_fn_ptr_ty,
tupled_upvars_ty,
}
}
[
ref parent_substs @ ..,
closure_kind_ty,
closure_sig_as_fn_ptr_ty,
tupled_upvars_ty,
] => ClosureSubstsParts {
parent_substs,
closure_kind_ty,
closure_sig_as_fn_ptr_ty,
tupled_upvars_ty,
},
_ => bug!("closure substs missing synthetics"),
}
}
Expand Down
Expand Up @@ -2026,9 +2026,7 @@ impl<'a, 'tcx> InferCtxtPrivExt<'tcx> for InferCtxt<'a, 'tcx> {
debug!("maybe_suggest_unsized_generics: param={:?}", param);
match node {
hir::Node::Item(
item
@
hir::Item {
item @ hir::Item {
// Only suggest indirection for uses of type parameters in ADTs.
kind:
hir::ItemKind::Enum(..) | hir::ItemKind::Struct(..) | hir::ItemKind::Union(..),
Expand Down
6 changes: 4 additions & 2 deletions compiler/rustc_typeck/src/check/coercion.rs
Expand Up @@ -1126,8 +1126,10 @@ impl<'a, 'tcx> FnCtxt<'a, 'tcx> {
for expr in exprs {
let expr = expr.as_coercion_site();
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() {
ty::Ref(_, _, mt_orig) => {
let mutbl_adj: hir::Mutability = mutbl_adj.into();
Expand Down
26 changes: 16 additions & 10 deletions compiler/rustc_typeck/src/check/fn_ctxt/_impl.rs
Expand Up @@ -304,20 +304,26 @@ impl<'a, 'tcx> FnCtxt<'a, 'tcx> {
// is a valid NeverToAny adjustment, because it can't
// be reached.
(&[Adjustment { kind: Adjust::NeverToAny, .. }], _) => return,
(&[
Adjustment { kind: Adjust::Deref(_), .. },
Adjustment { kind: Adjust::Borrow(AutoBorrow::Ref(..)), .. },
], &[
Adjustment { kind: Adjust::Deref(_), .. },
.. // Any following adjustments are allowed.
]) => {
(
&[
Adjustment { kind: Adjust::Deref(_), .. },
Adjustment { kind: Adjust::Borrow(AutoBorrow::Ref(..)), .. },
],
&[
Adjustment { kind: Adjust::Deref(_), .. },
.., // Any following adjustments are allowed.
],
) => {
// A reborrow has no effect before a dereference.
}
// FIXME: currently we never try to compose autoderefs
// and ReifyFnPointer/UnsafeFnPointer, but we could.
_ =>
bug!("while adjusting {:?}, can't compose {:?} and {:?}",
expr, entry.get(), adj)
_ => bug!(
"while adjusting {:?}, can't compose {:?} and {:?}",
expr,
entry.get(),
adj
),
};
*entry.get_mut() = adj;
}
Expand Down
7 changes: 5 additions & 2 deletions compiler/rustc_typeck/src/check/place_op.rs
Expand Up @@ -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 let [.., Adjustment { kind: Adjust::Borrow(AutoBorrow::Ref(..)), .. }, Adjustment { kind: Adjust::Pointer(PointerCast::Unsize), ref mut target }] =
adjustments[..]
if let [
..,
Adjustment { kind: Adjust::Borrow(AutoBorrow::Ref(..)), .. },
Adjustment { kind: Adjust::Pointer(PointerCast::Unsize), ref mut target },
] = adjustments[..]
{
*target = method.sig.inputs()[0];
}
Expand Down
8 changes: 2 additions & 6 deletions compiler/rustc_typeck/src/check/upvar.rs
Expand Up @@ -687,15 +687,11 @@ impl<'a, 'tcx> FnCtxt<'a, 'tcx> {
r
),
(
l
@
(ProjectionKind::Index
l @ (ProjectionKind::Index
| ProjectionKind::Subslice
| ProjectionKind::Deref
| ProjectionKind::Field(..)),
r
@
(ProjectionKind::Index
r @ (ProjectionKind::Index
| ProjectionKind::Subslice
| ProjectionKind::Deref
| ProjectionKind::Field(..)),
Expand Down
4 changes: 1 addition & 3 deletions src/librustdoc/clean/utils.rs
Expand Up @@ -395,9 +395,7 @@ crate fn register_res(cx: &mut DocContext<'_>, res: Res) -> DefId {
let (did, kind) = match res {
// These should be added to the cache using `record_extern_fqn`.
Res::Def(
kind
@
(AssocTy | AssocFn | AssocConst | Variant | Fn | TyAlias | Enum | Trait | Struct
kind @ (AssocTy | AssocFn | AssocConst | Variant | Fn | TyAlias | Enum | Trait | Struct
| Union | Mod | ForeignTy | Const | Static | Macro(..) | TraitAlias),
i,
) => (i, kind.into()),
Expand Down

0 comments on commit 971c549

Please sign in to comment.