Skip to content

Commit 97c4b78

Browse files
Re-format code with new rustfmt
1 parent 2aa00eb commit 97c4b78

File tree

69 files changed

+647
-484
lines changed

Some content is hidden

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

69 files changed

+647
-484
lines changed

compiler/rustc_ast_passes/src/ast_validation.rs

+8-10
Original file line numberDiff line numberDiff line change
@@ -1213,8 +1213,12 @@ impl<'a> Visitor<'a> for AstValidator<'a> {
12131213
DisallowTildeConstContext::Fn(FnKind::Fn(_, ident, ..)) => {
12141214
errors::TildeConstReason::Function { ident: ident.span }
12151215
}
1216-
&DisallowTildeConstContext::Trait(span) => errors::TildeConstReason::Trait { span },
1217-
&DisallowTildeConstContext::Impl(span) => errors::TildeConstReason::Impl { span },
1216+
&DisallowTildeConstContext::Trait(span) => {
1217+
errors::TildeConstReason::Trait { span }
1218+
}
1219+
&DisallowTildeConstContext::Impl(span) => {
1220+
errors::TildeConstReason::Impl { span }
1221+
}
12181222
DisallowTildeConstContext::TraitObject => {
12191223
errors::TildeConstReason::TraitObject
12201224
}
@@ -1446,9 +1450,7 @@ fn deny_equality_constraints(
14461450
id: rustc_ast::node_id::DUMMY_NODE_ID,
14471451
ident: *ident,
14481452
gen_args,
1449-
kind: AssocConstraintKind::Equality {
1450-
term: predicate.rhs_ty.clone().into(),
1451-
},
1453+
kind: AssocConstraintKind::Equality { term: predicate.rhs_ty.clone().into() },
14521454
span: ident.span,
14531455
});
14541456
// Add `<Bar = RhsTy>` to `Foo`.
@@ -1461,11 +1463,7 @@ fn deny_equality_constraints(
14611463
},
14621464
empty_args => {
14631465
*empty_args = Some(
1464-
AngleBracketedArgs {
1465-
span: ident.span,
1466-
args: thin_vec![arg],
1467-
}
1468-
.into(),
1466+
AngleBracketedArgs { span: ident.span, args: thin_vec![arg] }.into(),
14691467
);
14701468
}
14711469
}

compiler/rustc_borrowck/src/diagnostics/move_errors.rs

+2-1
Original file line numberDiff line numberDiff line change
@@ -607,7 +607,8 @@ impl<'a, 'tcx> MirBorrowckCtxt<'a, 'tcx> {
607607

608608
if let Some(adt) = local_ty.ty_adt_def()
609609
&& adt.repr().packed()
610-
&& let ExpnKind::Macro(MacroKind::Derive, name) = self.body.span.ctxt().outer_expn_data().kind
610+
&& let ExpnKind::Macro(MacroKind::Derive, name) =
611+
self.body.span.ctxt().outer_expn_data().kind
611612
{
612613
err.note(format!("`#[derive({name})]` triggers a move because taking references to the fields of a packed struct is undefined behaviour"));
613614
}

compiler/rustc_builtin_macros/src/format.rs

+10-3
Original file line numberDiff line numberDiff line change
@@ -617,10 +617,17 @@ fn report_missing_placeholders(
617617
let placeholders = pieces
618618
.iter()
619619
.filter_map(|piece| {
620-
if let parse::Piece::NextArgument(argument) = piece && let ArgumentNamed(binding) = argument.position {
621-
let span = fmt_span.from_inner(InnerSpan::new(argument.position_span.start, argument.position_span.end));
620+
if let parse::Piece::NextArgument(argument) = piece
621+
&& let ArgumentNamed(binding) = argument.position
622+
{
623+
let span = fmt_span.from_inner(InnerSpan::new(
624+
argument.position_span.start,
625+
argument.position_span.end,
626+
));
622627
Some((span, binding))
623-
} else { None }
628+
} else {
629+
None
630+
}
624631
})
625632
.collect::<Vec<_>>();
626633

compiler/rustc_const_eval/src/interpret/operator.rs

+2-3
Original file line numberDiff line numberDiff line change
@@ -114,9 +114,8 @@ impl<'mir, 'tcx: 'mir, M: Machine<'mir, 'tcx>> InterpCx<'mir, 'tcx, M> {
114114
use rustc_middle::mir::BinOp::*;
115115

116116
// Performs appropriate non-deterministic adjustments of NaN results.
117-
let adjust_nan = |f: F| -> F {
118-
if f.is_nan() { M::generate_nan(self, &[l, r]) } else { f }
119-
};
117+
let adjust_nan =
118+
|f: F| -> F { if f.is_nan() { M::generate_nan(self, &[l, r]) } else { f } };
120119

121120
let val = match bin_op {
122121
Eq => ImmTy::from_bool(l == r, *self.tcx),

compiler/rustc_expand/src/config.rs

+4-4
Original file line numberDiff line numberDiff line change
@@ -74,7 +74,9 @@ pub fn features(sess: &Session, krate_attrs: &[Attribute], crate_name: Symbol) -
7474
// - E.g. enable `test_2018_feature` if `features_edition` is 2018 or higher
7575
let mut edition_enabled_features = FxHashSet::default();
7676
for f in UNSTABLE_FEATURES {
77-
if let Some(edition) = f.feature.edition && edition <= features_edition {
77+
if let Some(edition) = f.feature.edition
78+
&& edition <= features_edition
79+
{
7880
// FIXME(Manishearth) there is currently no way to set lib features by
7981
// edition.
8082
edition_enabled_features.insert(f.feature.name);
@@ -251,8 +253,7 @@ impl<'a> StripUnconfigured<'a> {
251253
let trees: Vec<_> = stream
252254
.0
253255
.iter()
254-
.flat_map(|tree| {
255-
match tree.clone() {
256+
.flat_map(|tree| match tree.clone() {
256257
AttrTokenTree::Attributes(mut data) => {
257258
data.attrs.flat_map_in_place(|attr| self.process_cfg_attr(&attr));
258259

@@ -277,7 +278,6 @@ impl<'a> StripUnconfigured<'a> {
277278
AttrTokenTree::Token(token, spacing) => {
278279
Some(AttrTokenTree::Token(token, spacing)).into_iter()
279280
}
280-
}
281281
})
282282
.collect();
283283
AttrTokenStream::new(trees)

compiler/rustc_hir_analysis/src/astconv/bounds.rs

+1-3
Original file line numberDiff line numberDiff line change
@@ -194,8 +194,7 @@ impl<'tcx> dyn AstConv<'tcx> + '_ {
194194

195195
self.add_bounds(
196196
param_ty,
197-
ast_bounds.iter().filter(|bound| {
198-
match filter {
197+
ast_bounds.iter().filter(|bound| match filter {
199198
PredicateFilter::All
200199
| PredicateFilter::SelfOnly
201200
| PredicateFilter::SelfAndAssociatedTypeBounds => true,
@@ -209,7 +208,6 @@ impl<'tcx> dyn AstConv<'tcx> + '_ {
209208
false
210209
}
211210
}
212-
}
213211
}),
214212
&mut bounds,
215213
ty::List::empty(),

compiler/rustc_hir_analysis/src/astconv/errors.rs

+12-14
Original file line numberDiff line numberDiff line change
@@ -206,15 +206,14 @@ impl<'o, 'tcx> dyn AstConv<'tcx> + 'o {
206206
&& let parent = hir.get_parent_item(hir.local_def_id_to_hir_id(def_id))
207207
&& let Some(generics) = hir.get_generics(parent.def_id)
208208
{
209-
if generics.bounds_for_param(def_id)
210-
.flat_map(|pred| pred.bounds.iter())
211-
.any(|b| match b {
209+
if generics.bounds_for_param(def_id).flat_map(|pred| pred.bounds.iter()).any(
210+
|b| match b {
212211
hir::GenericBound::Trait(t, ..) => {
213212
t.trait_ref.trait_def_id().as_ref() == Some(best_trait)
214213
}
215214
_ => false,
216-
})
217-
{
215+
},
216+
) {
218217
// The type param already has a bound for `trait_name`, we just need to
219218
// change the associated type.
220219
err.span_suggestion_verbose(
@@ -227,15 +226,14 @@ impl<'o, 'tcx> dyn AstConv<'tcx> + 'o {
227226
Applicability::MaybeIncorrect,
228227
);
229228
} else if suggest_constraining_type_param(
230-
self.tcx(),
231-
generics,
232-
&mut err,
233-
&ty_param_name,
234-
&trait_name,
235-
None,
236-
None,
237-
)
238-
&& suggested_name != assoc_name.name
229+
self.tcx(),
230+
generics,
231+
&mut err,
232+
&ty_param_name,
233+
&trait_name,
234+
None,
235+
None,
236+
) && suggested_name != assoc_name.name
239237
{
240238
// We suggested constraining a type parameter, but the associated type on it
241239
// was also not an exact match, so we also suggest changing it.

compiler/rustc_hir_typeck/src/expr.rs

+13-8
Original file line numberDiff line numberDiff line change
@@ -3173,19 +3173,22 @@ impl<'a, 'tcx> FnCtxt<'a, 'tcx> {
31733173
sym::offset_of_enum,
31743174
ident.span,
31753175
"using enums in offset_of is experimental",
3176-
).emit();
3176+
)
3177+
.emit();
31773178
}
31783179

3179-
let Some((index, variant)) = container_def.variants()
3180+
let Some((index, variant)) = container_def
3181+
.variants()
31803182
.iter_enumerated()
3181-
.find(|(_, v)| v.ident(self.tcx).normalize_to_macros_2_0() == ident) else {
3183+
.find(|(_, v)| v.ident(self.tcx).normalize_to_macros_2_0() == ident)
3184+
else {
31823185
let mut err = type_error_struct!(
31833186
self.tcx().sess,
31843187
ident.span,
31853188
container,
31863189
E0599,
31873190
"no variant named `{ident}` found for enum `{container}`",
3188-
);
3191+
);
31893192
err.span_label(field.span, "variant not found");
31903193
err.emit();
31913194
break;
@@ -3197,24 +3200,26 @@ impl<'a, 'tcx> FnCtxt<'a, 'tcx> {
31973200
container,
31983201
E0795,
31993202
"`{ident}` is an enum variant; expected field at end of `offset_of`",
3200-
);
3203+
);
32013204
err.span_label(field.span, "enum variant");
32023205
err.emit();
32033206
break;
32043207
};
32053208
let (subident, sub_def_scope) =
32063209
self.tcx.adjust_ident_and_get_scope(subfield, variant.def_id, block);
32073210

3208-
let Some((subindex, field)) = variant.fields
3211+
let Some((subindex, field)) = variant
3212+
.fields
32093213
.iter_enumerated()
3210-
.find(|(_, f)| f.ident(self.tcx).normalize_to_macros_2_0() == subident) else {
3214+
.find(|(_, f)| f.ident(self.tcx).normalize_to_macros_2_0() == subident)
3215+
else {
32113216
let mut err = type_error_struct!(
32123217
self.tcx().sess,
32133218
ident.span,
32143219
container,
32153220
E0609,
32163221
"no field named `{subfield}` on enum variant `{container}::{ident}`",
3217-
);
3222+
);
32183223
err.span_label(field.span, "this enum variant...");
32193224
err.span_label(subident.span, "...does not have this field");
32203225
err.emit();

compiler/rustc_hir_typeck/src/fn_ctxt/checks.rs

+26-19
Original file line numberDiff line numberDiff line change
@@ -1864,35 +1864,42 @@ impl<'a, 'tcx> FnCtxt<'a, 'tcx> {
18641864
&& let ExprBindingObligation(_, _, hir_id, ..) = code
18651865
&& !fn_sig.output().is_unit()
18661866
{
1867-
let mut block_num = 0;
1868-
let mut found_semi = false;
1869-
for (_, node) in self.tcx.hir().parent_iter(hir_id) {
1870-
match node {
1871-
hir::Node::Stmt(stmt) => if let hir::StmtKind::Semi(ref expr) = stmt.kind {
1867+
let mut block_num = 0;
1868+
let mut found_semi = false;
1869+
for (_, node) in self.tcx.hir().parent_iter(hir_id) {
1870+
match node {
1871+
hir::Node::Stmt(stmt) => {
1872+
if let hir::StmtKind::Semi(ref expr) = stmt.kind {
18721873
let expr_ty = self.typeck_results.borrow().expr_ty(expr);
18731874
let return_ty = fn_sig.output();
1874-
if !matches!(expr.kind, hir::ExprKind::Ret(..)) &&
1875-
self.can_coerce(expr_ty, return_ty) {
1875+
if !matches!(expr.kind, hir::ExprKind::Ret(..))
1876+
&& self.can_coerce(expr_ty, return_ty)
1877+
{
18761878
found_semi = true;
18771879
}
1878-
},
1879-
hir::Node::Block(_block) => if found_semi {
1880+
}
1881+
}
1882+
hir::Node::Block(_block) => {
1883+
if found_semi {
18801884
block_num += 1;
18811885
}
1882-
hir::Node::Item(item) => if let hir::ItemKind::Fn(..) = item.kind {
1886+
}
1887+
hir::Node::Item(item) => {
1888+
if let hir::ItemKind::Fn(..) = item.kind {
18831889
break;
18841890
}
1885-
_ => {}
18861891
}
1892+
_ => {}
18871893
}
1888-
if block_num > 1 && found_semi {
1889-
diag.span_suggestion_verbose(
1890-
span.shrink_to_lo(),
1891-
"you might have meant to return this to infer its type parameters",
1892-
"return ",
1893-
Applicability::MaybeIncorrect,
1894-
);
1895-
}
1894+
}
1895+
if block_num > 1 && found_semi {
1896+
diag.span_suggestion_verbose(
1897+
span.shrink_to_lo(),
1898+
"you might have meant to return this to infer its type parameters",
1899+
"return ",
1900+
Applicability::MaybeIncorrect,
1901+
);
1902+
}
18961903
}
18971904
diag.emit();
18981905
}

0 commit comments

Comments
 (0)