Skip to content

Commit 1fcae03

Browse files
committed
Rustfmt
1 parent 3183b44 commit 1fcae03

File tree

287 files changed

+5886
-4606
lines changed

Some content is hidden

Large Commits have some content hidden by default. Use the searchbox below for content that may be hidden.

287 files changed

+5886
-4606
lines changed

compiler/rustc_abi/src/lib.rs

+7-4
Original file line numberDiff line numberDiff line change
@@ -1184,10 +1184,13 @@ impl Scalar {
11841184
#[inline]
11851185
pub fn is_bool(&self) -> bool {
11861186
use Integer::*;
1187-
matches!(self, Scalar::Initialized {
1188-
value: Primitive::Int(I8, false),
1189-
valid_range: WrappingRange { start: 0, end: 1 }
1190-
})
1187+
matches!(
1188+
self,
1189+
Scalar::Initialized {
1190+
value: Primitive::Int(I8, false),
1191+
valid_range: WrappingRange { start: 0, end: 1 }
1192+
}
1193+
)
11911194
}
11921195

11931196
/// Get the primitive representation of this type, ignoring the valid range and whether the

compiler/rustc_ast_lowering/src/expr.rs

+12-9
Original file line numberDiff line numberDiff line change
@@ -828,15 +828,18 @@ impl<'hir> LoweringContext<'_, 'hir> {
828828
span,
829829
Some(Arc::clone(&self.allow_gen_future)),
830830
);
831-
self.lower_attrs(inner_hir_id, &[Attribute {
832-
kind: AttrKind::Normal(ptr::P(NormalAttr::from_ident(Ident::new(
833-
sym::track_caller,
834-
span,
835-
)))),
836-
id: self.tcx.sess.psess.attr_id_generator.mk_attr_id(),
837-
style: AttrStyle::Outer,
838-
span: unstable_span,
839-
}]);
831+
self.lower_attrs(
832+
inner_hir_id,
833+
&[Attribute {
834+
kind: AttrKind::Normal(ptr::P(NormalAttr::from_ident(Ident::new(
835+
sym::track_caller,
836+
span,
837+
)))),
838+
id: self.tcx.sess.psess.attr_id_generator.mk_attr_id(),
839+
style: AttrStyle::Outer,
840+
span: unstable_span,
841+
}],
842+
);
840843
}
841844
}
842845

compiler/rustc_ast_lowering/src/format.rs

+6-3
Original file line numberDiff line numberDiff line change
@@ -362,13 +362,16 @@ fn make_format_spec<'hir>(
362362
debug_hex,
363363
} = &placeholder.format_options;
364364
let fill = ctx.expr_char(sp, fill.unwrap_or(' '));
365-
let align =
366-
ctx.expr_lang_item_type_relative(sp, hir::LangItem::FormatAlignment, match alignment {
365+
let align = ctx.expr_lang_item_type_relative(
366+
sp,
367+
hir::LangItem::FormatAlignment,
368+
match alignment {
367369
Some(FormatAlignment::Left) => sym::Left,
368370
Some(FormatAlignment::Right) => sym::Right,
369371
Some(FormatAlignment::Center) => sym::Center,
370372
None => sym::Unknown,
371-
});
373+
},
374+
);
372375
// This needs to match `Flag` in library/core/src/fmt/rt.rs.
373376
let flags: u32 = ((sign == Some(FormatSign::Plus)) as u32)
374377
| ((sign == Some(FormatSign::Minus)) as u32) << 1

compiler/rustc_ast_lowering/src/item.rs

+23-14
Original file line numberDiff line numberDiff line change
@@ -304,12 +304,15 @@ impl<'hir> LoweringContext<'_, 'hir> {
304304
);
305305
this.arena.alloc(this.ty(span, hir::TyKind::Err(guar)))
306306
}
307-
Some(ty) => this.lower_ty(ty, ImplTraitContext::OpaqueTy {
308-
origin: hir::OpaqueTyOrigin::TyAlias {
309-
parent: this.local_def_id(id),
310-
in_assoc_ty: false,
307+
Some(ty) => this.lower_ty(
308+
ty,
309+
ImplTraitContext::OpaqueTy {
310+
origin: hir::OpaqueTyOrigin::TyAlias {
311+
parent: this.local_def_id(id),
312+
in_assoc_ty: false,
313+
},
311314
},
312-
}),
315+
),
313316
},
314317
);
315318
hir::ItemKind::TyAlias(ty, generics)
@@ -966,12 +969,15 @@ impl<'hir> LoweringContext<'_, 'hir> {
966969
hir::ImplItemKind::Type(ty)
967970
}
968971
Some(ty) => {
969-
let ty = this.lower_ty(ty, ImplTraitContext::OpaqueTy {
970-
origin: hir::OpaqueTyOrigin::TyAlias {
971-
parent: this.local_def_id(i.id),
972-
in_assoc_ty: true,
972+
let ty = this.lower_ty(
973+
ty,
974+
ImplTraitContext::OpaqueTy {
975+
origin: hir::OpaqueTyOrigin::TyAlias {
976+
parent: this.local_def_id(i.id),
977+
in_assoc_ty: true,
978+
},
973979
},
974-
});
980+
);
975981
hir::ImplItemKind::Type(ty)
976982
}
977983
},
@@ -1152,10 +1158,13 @@ impl<'hir> LoweringContext<'_, 'hir> {
11521158

11531159
pub(super) fn lower_const_body(&mut self, span: Span, expr: Option<&Expr>) -> hir::BodyId {
11541160
self.lower_body(|this| {
1155-
(&[], match expr {
1156-
Some(expr) => this.lower_expr_mut(expr),
1157-
None => this.expr_err(span, this.dcx().span_delayed_bug(span, "no block")),
1158-
})
1161+
(
1162+
&[],
1163+
match expr {
1164+
Some(expr) => this.lower_expr_mut(expr),
1165+
None => this.expr_err(span, this.dcx().span_delayed_bug(span, "no block")),
1166+
},
1167+
)
11591168
})
11601169
}
11611170

compiler/rustc_attr_parsing/src/session_diagnostics.rs

+21-15
Original file line numberDiff line numberDiff line change
@@ -204,21 +204,27 @@ pub(crate) struct UnsupportedLiteral {
204204

205205
impl<'a, G: EmissionGuarantee> Diagnostic<'a, G> for UnsupportedLiteral {
206206
fn into_diag(self, dcx: DiagCtxtHandle<'a>, level: Level) -> Diag<'a, G> {
207-
let mut diag = Diag::new(dcx, level, match self.reason {
208-
UnsupportedLiteralReason::Generic => fluent::attr_parsing_unsupported_literal_generic,
209-
UnsupportedLiteralReason::CfgString => {
210-
fluent::attr_parsing_unsupported_literal_cfg_string
211-
}
212-
UnsupportedLiteralReason::CfgBoolean => {
213-
fluent::attr_parsing_unsupported_literal_cfg_boolean
214-
}
215-
UnsupportedLiteralReason::DeprecatedString => {
216-
fluent::attr_parsing_unsupported_literal_deprecated_string
217-
}
218-
UnsupportedLiteralReason::DeprecatedKvPair => {
219-
fluent::attr_parsing_unsupported_literal_deprecated_kv_pair
220-
}
221-
});
207+
let mut diag = Diag::new(
208+
dcx,
209+
level,
210+
match self.reason {
211+
UnsupportedLiteralReason::Generic => {
212+
fluent::attr_parsing_unsupported_literal_generic
213+
}
214+
UnsupportedLiteralReason::CfgString => {
215+
fluent::attr_parsing_unsupported_literal_cfg_string
216+
}
217+
UnsupportedLiteralReason::CfgBoolean => {
218+
fluent::attr_parsing_unsupported_literal_cfg_boolean
219+
}
220+
UnsupportedLiteralReason::DeprecatedString => {
221+
fluent::attr_parsing_unsupported_literal_deprecated_string
222+
}
223+
UnsupportedLiteralReason::DeprecatedKvPair => {
224+
fluent::attr_parsing_unsupported_literal_deprecated_kv_pair
225+
}
226+
},
227+
);
222228
diag.span(self.span);
223229
diag.code(E0565);
224230
if self.is_bytestr {

compiler/rustc_borrowck/src/diagnostics/bound_region_errors.rs

+19-18
Original file line numberDiff line numberDiff line change
@@ -156,24 +156,25 @@ pub(crate) trait TypeOpInfo<'tcx> {
156156
return;
157157
};
158158

159-
let placeholder_region = ty::Region::new_placeholder(tcx, ty::Placeholder {
160-
universe: adjusted_universe.into(),
161-
bound: placeholder.bound,
162-
});
163-
164-
let error_region =
165-
if let RegionElement::PlaceholderRegion(error_placeholder) = error_element {
166-
let adjusted_universe =
167-
error_placeholder.universe.as_u32().checked_sub(base_universe.as_u32());
168-
adjusted_universe.map(|adjusted| {
169-
ty::Region::new_placeholder(tcx, ty::Placeholder {
170-
universe: adjusted.into(),
171-
bound: error_placeholder.bound,
172-
})
173-
})
174-
} else {
175-
None
176-
};
159+
let placeholder_region = ty::Region::new_placeholder(
160+
tcx,
161+
ty::Placeholder { universe: adjusted_universe.into(), bound: placeholder.bound },
162+
);
163+
164+
let error_region = if let RegionElement::PlaceholderRegion(error_placeholder) =
165+
error_element
166+
{
167+
let adjusted_universe =
168+
error_placeholder.universe.as_u32().checked_sub(base_universe.as_u32());
169+
adjusted_universe.map(|adjusted| {
170+
ty::Region::new_placeholder(
171+
tcx,
172+
ty::Placeholder { universe: adjusted.into(), bound: error_placeholder.bound },
173+
)
174+
})
175+
} else {
176+
None
177+
};
177178

178179
debug!(?placeholder_region);
179180

compiler/rustc_borrowck/src/diagnostics/conflict_errors.rs

+16-16
Original file line numberDiff line numberDiff line change
@@ -147,10 +147,10 @@ impl<'infcx, 'tcx> MirBorrowckCtxt<'_, 'infcx, 'tcx> {
147147
span,
148148
desired_action.as_noun(),
149149
partially_str,
150-
self.describe_place_with_options(moved_place, DescribePlaceOpt {
151-
including_downcast: true,
152-
including_tuple_field: true,
153-
}),
150+
self.describe_place_with_options(
151+
moved_place,
152+
DescribePlaceOpt { including_downcast: true, including_tuple_field: true },
153+
),
154154
);
155155

156156
let reinit_spans = maybe_reinitialized_locations
@@ -280,10 +280,10 @@ impl<'infcx, 'tcx> MirBorrowckCtxt<'_, 'infcx, 'tcx> {
280280
self.suggest_adding_bounds(&mut err, ty, copy_did, span);
281281
}
282282

283-
let opt_name = self.describe_place_with_options(place.as_ref(), DescribePlaceOpt {
284-
including_downcast: true,
285-
including_tuple_field: true,
286-
});
283+
let opt_name = self.describe_place_with_options(
284+
place.as_ref(),
285+
DescribePlaceOpt { including_downcast: true, including_tuple_field: true },
286+
);
287287
let note_msg = match opt_name {
288288
Some(name) => format!("`{name}`"),
289289
None => "value".to_owned(),
@@ -765,17 +765,17 @@ impl<'infcx, 'tcx> MirBorrowckCtxt<'_, 'infcx, 'tcx> {
765765
}
766766
let spans: Vec<_> = spans_set.into_iter().collect();
767767

768-
let (name, desc) = match self.describe_place_with_options(moved_place, DescribePlaceOpt {
769-
including_downcast: true,
770-
including_tuple_field: true,
771-
}) {
768+
let (name, desc) = match self.describe_place_with_options(
769+
moved_place,
770+
DescribePlaceOpt { including_downcast: true, including_tuple_field: true },
771+
) {
772772
Some(name) => (format!("`{name}`"), format!("`{name}` ")),
773773
None => ("the variable".to_string(), String::new()),
774774
};
775-
let path = match self.describe_place_with_options(used_place, DescribePlaceOpt {
776-
including_downcast: true,
777-
including_tuple_field: true,
778-
}) {
775+
let path = match self.describe_place_with_options(
776+
used_place,
777+
DescribePlaceOpt { including_downcast: true, including_tuple_field: true },
778+
) {
779779
Some(name) => format!("`{name}`"),
780780
None => "value".to_string(),
781781
};

compiler/rustc_borrowck/src/diagnostics/mod.rs

+4-4
Original file line numberDiff line numberDiff line change
@@ -304,10 +304,10 @@ impl<'infcx, 'tcx> MirBorrowckCtxt<'_, 'infcx, 'tcx> {
304304
/// End-user visible description of `place` if one can be found.
305305
/// If the place is a temporary for instance, `None` will be returned.
306306
pub(super) fn describe_place(&self, place_ref: PlaceRef<'tcx>) -> Option<String> {
307-
self.describe_place_with_options(place_ref, DescribePlaceOpt {
308-
including_downcast: false,
309-
including_tuple_field: true,
310-
})
307+
self.describe_place_with_options(
308+
place_ref,
309+
DescribePlaceOpt { including_downcast: false, including_tuple_field: true },
310+
)
311311
}
312312

313313
/// End-user visible description of `place` if one can be found. If the place is a temporary

compiler/rustc_borrowck/src/diagnostics/region_errors.rs

+9-6
Original file line numberDiff line numberDiff line change
@@ -1100,12 +1100,15 @@ impl<'infcx, 'tcx> MirBorrowckCtxt<'_, 'infcx, 'tcx> {
11001100
let closure_ty = Ty::new_closure(
11011101
tcx,
11021102
closure_def_id.to_def_id(),
1103-
ty::ClosureArgs::new(tcx, ty::ClosureArgsParts {
1104-
parent_args: args.parent_args(),
1105-
closure_kind_ty: args.kind_ty(),
1106-
tupled_upvars_ty: args.tupled_upvars_ty(),
1107-
closure_sig_as_fn_ptr_ty,
1108-
})
1103+
ty::ClosureArgs::new(
1104+
tcx,
1105+
ty::ClosureArgsParts {
1106+
parent_args: args.parent_args(),
1107+
closure_kind_ty: args.kind_ty(),
1108+
tupled_upvars_ty: args.tupled_upvars_ty(),
1109+
closure_sig_as_fn_ptr_ty,
1110+
},
1111+
)
11091112
.args,
11101113
);
11111114

compiler/rustc_borrowck/src/lib.rs

+7-3
Original file line numberDiff line numberDiff line change
@@ -1668,9 +1668,13 @@ impl<'a, 'tcx> MirBorrowckCtxt<'a, '_, 'tcx> {
16681668
match elem {
16691669
ProjectionElem::Deref => match place_ty.ty.kind() {
16701670
ty::Ref(..) | ty::RawPtr(..) => {
1671-
self.move_errors.push(MoveError::new(place, location, BorrowedContent {
1672-
target_place: place_ref.project_deeper(&[elem], tcx),
1673-
}));
1671+
self.move_errors.push(MoveError::new(
1672+
place,
1673+
location,
1674+
BorrowedContent {
1675+
target_place: place_ref.project_deeper(&[elem], tcx),
1676+
},
1677+
));
16741678
return;
16751679
}
16761680
ty::Adt(adt, _) => {

compiler/rustc_borrowck/src/region_infer/opaque_types.rs

+4-4
Original file line numberDiff line numberDiff line change
@@ -166,10 +166,10 @@ impl<'tcx> RegionInferenceContext<'tcx> {
166166
// FIXME(oli-obk): collect multiple spans for better diagnostics down the road.
167167
prev.span = prev.span.substitute_dummy(concrete_type.span);
168168
} else {
169-
result.insert(opaque_type_key.def_id, OpaqueHiddenType {
170-
ty,
171-
span: concrete_type.span,
172-
});
169+
result.insert(
170+
opaque_type_key.def_id,
171+
OpaqueHiddenType { ty, span: concrete_type.span },
172+
);
173173
}
174174

175175
// Check that all opaque types have the same region parameters if they have the same

compiler/rustc_borrowck/src/type_check/input_output.rs

+14-11
Original file line numberDiff line numberDiff line change
@@ -75,17 +75,20 @@ impl<'a, 'tcx> TypeChecker<'a, 'tcx> {
7575
let output_ty = Ty::new_coroutine(
7676
self.tcx(),
7777
self.tcx().coroutine_for_closure(mir_def_id),
78-
ty::CoroutineArgs::new(self.tcx(), ty::CoroutineArgsParts {
79-
parent_args: args.parent_args(),
80-
kind_ty: Ty::from_coroutine_closure_kind(self.tcx(), args.kind()),
81-
return_ty: user_provided_sig.output(),
82-
tupled_upvars_ty,
83-
// For async closures, none of these can be annotated, so just fill
84-
// them with fresh ty vars.
85-
resume_ty: next_ty_var(),
86-
yield_ty: next_ty_var(),
87-
witness: next_ty_var(),
88-
})
78+
ty::CoroutineArgs::new(
79+
self.tcx(),
80+
ty::CoroutineArgsParts {
81+
parent_args: args.parent_args(),
82+
kind_ty: Ty::from_coroutine_closure_kind(self.tcx(), args.kind()),
83+
return_ty: user_provided_sig.output(),
84+
tupled_upvars_ty,
85+
// For async closures, none of these can be annotated, so just fill
86+
// them with fresh ty vars.
87+
resume_ty: next_ty_var(),
88+
yield_ty: next_ty_var(),
89+
witness: next_ty_var(),
90+
},
91+
)
8992
.args,
9093
);
9194

0 commit comments

Comments
 (0)