Skip to content

Commit b81f581

Browse files
committed
Auto merge of #80843 - Mark-Simulacrum:fmt-bump, r=petrochenkov
Bump rustfmt version
2 parents a3ed564 + d5b760b commit b81f581

File tree

30 files changed

+224
-164
lines changed

30 files changed

+224
-164
lines changed

compiler/rustc_ast_lowering/src/lib.rs

+3-1
Original file line numberDiff line numberDiff line change
@@ -506,7 +506,9 @@ impl<'a, 'hir> LoweringContext<'a, 'hir> {
506506
let count = generics
507507
.params
508508
.iter()
509-
.filter(|param| matches!(param.kind, ast::GenericParamKind::Lifetime { .. }))
509+
.filter(|param| {
510+
matches!(param.kind, ast::GenericParamKind::Lifetime { .. })
511+
})
510512
.count();
511513
self.lctx.type_def_lifetime_params.insert(def_id.to_def_id(), count);
512514
}

compiler/rustc_builtin_macros/src/deriving/generic/mod.rs

+1-1
Original file line numberDiff line numberDiff line change
@@ -598,7 +598,7 @@ impl<'a> TraitDef<'a> {
598598

599599
let mut ty_params = params
600600
.iter()
601-
.filter(|param| matches!(param.kind, ast::GenericParamKind::Type{..}))
601+
.filter(|param| matches!(param.kind, ast::GenericParamKind::Type { .. }))
602602
.peekable();
603603

604604
if ty_params.peek().is_some() {

compiler/rustc_errors/src/diagnostic_builder.rs

+1-1
Original file line numberDiff line numberDiff line change
@@ -36,7 +36,7 @@ macro_rules! forward_inner_docs {
3636
($e:expr => $i:item) => {
3737
#[doc = $e]
3838
$i
39-
}
39+
};
4040
}
4141

4242
/// In general, the `DiagnosticBuilder` uses deref to allow access to

compiler/rustc_errors/src/snippet.rs

+10-5
Original file line numberDiff line numberDiff line change
@@ -122,11 +122,13 @@ impl Annotation {
122122
}
123123

124124
pub fn is_multiline(&self) -> bool {
125-
matches!(self.annotation_type,
125+
matches!(
126+
self.annotation_type,
126127
AnnotationType::Multiline(_)
127-
| AnnotationType::MultilineStart(_)
128-
| AnnotationType::MultilineLine(_)
129-
| AnnotationType::MultilineEnd(_))
128+
| AnnotationType::MultilineStart(_)
129+
| AnnotationType::MultilineLine(_)
130+
| AnnotationType::MultilineEnd(_)
131+
)
130132
}
131133

132134
pub fn len(&self) -> usize {
@@ -158,7 +160,10 @@ impl Annotation {
158160

159161
pub fn takes_space(&self) -> bool {
160162
// Multiline annotations always have to keep vertical space.
161-
matches!(self.annotation_type, AnnotationType::MultilineStart(_) | AnnotationType::MultilineEnd(_))
163+
matches!(
164+
self.annotation_type,
165+
AnnotationType::MultilineStart(_) | AnnotationType::MultilineEnd(_)
166+
)
162167
}
163168
}
164169

compiler/rustc_hir/src/hir.rs

+4-4
Original file line numberDiff line numberDiff line change
@@ -1543,10 +1543,10 @@ pub fn is_range_literal(expr: &Expr<'_>) -> bool {
15431543
**qpath,
15441544
QPath::LangItem(
15451545
LangItem::Range
1546-
| LangItem::RangeTo
1547-
| LangItem::RangeFrom
1548-
| LangItem::RangeFull
1549-
| LangItem::RangeToInclusive,
1546+
| LangItem::RangeTo
1547+
| LangItem::RangeFrom
1548+
| LangItem::RangeFull
1549+
| LangItem::RangeToInclusive,
15501550
_,
15511551
)
15521552
),

compiler/rustc_infer/src/infer/error_reporting/nice_region_error/trait_impl_difference.rs

+6-1
Original file line numberDiff line numberDiff line change
@@ -132,7 +132,12 @@ impl Visitor<'tcx> for TypeParamSpanVisitor<'tcx> {
132132
[segment]
133133
if segment
134134
.res
135-
.map(|res| matches!(res, Res::SelfTy(_, _) | Res::Def(hir::def::DefKind::TyParam, _)))
135+
.map(|res| {
136+
matches!(
137+
res,
138+
Res::SelfTy(_, _) | Res::Def(hir::def::DefKind::TyParam, _)
139+
)
140+
})
136141
.unwrap_or(false) =>
137142
{
138143
self.types.push(path.span);

compiler/rustc_middle/src/hir/map/mod.rs

+3-3
Original file line numberDiff line numberDiff line change
@@ -569,9 +569,9 @@ impl<'hir> Map<'hir> {
569569
self.find(self.get_parent_node(id)),
570570
Some(
571571
Node::Item(_)
572-
| Node::TraitItem(_)
573-
| Node::ImplItem(_)
574-
| Node::Expr(Expr { kind: ExprKind::Closure(..), .. }),
572+
| Node::TraitItem(_)
573+
| Node::ImplItem(_)
574+
| Node::Expr(Expr { kind: ExprKind::Closure(..), .. }),
575575
)
576576
)
577577
}

compiler/rustc_middle/src/mir/mod.rs

+2-4
Original file line numberDiff line numberDiff line change
@@ -962,8 +962,7 @@ impl<'tcx> LocalDecl<'tcx> {
962962
opt_ty_info: _,
963963
opt_match_place: _,
964964
pat_span: _,
965-
})
966-
| BindingForm::ImplicitSelf(ImplicitSelfKind::Imm),
965+
}) | BindingForm::ImplicitSelf(ImplicitSelfKind::Imm),
967966
)))
968967
)
969968
}
@@ -980,8 +979,7 @@ impl<'tcx> LocalDecl<'tcx> {
980979
opt_ty_info: _,
981980
opt_match_place: _,
982981
pat_span: _,
983-
})
984-
| BindingForm::ImplicitSelf(_),
982+
}) | BindingForm::ImplicitSelf(_),
985983
)))
986984
)
987985
}

compiler/rustc_middle/src/ty/diagnostics.rs

+11-7
Original file line numberDiff line numberDiff line change
@@ -12,13 +12,17 @@ impl<'tcx> TyS<'tcx> {
1212
pub fn is_primitive_ty(&self) -> bool {
1313
matches!(
1414
self.kind(),
15-
Bool | Char | Str | Int(_) | Uint(_) | Float(_)
16-
| Infer(
17-
InferTy::IntVar(_)
18-
| InferTy::FloatVar(_)
19-
| InferTy::FreshIntTy(_)
20-
| InferTy::FreshFloatTy(_)
21-
)
15+
Bool | Char
16+
| Str
17+
| Int(_)
18+
| Uint(_)
19+
| Float(_)
20+
| Infer(
21+
InferTy::IntVar(_)
22+
| InferTy::FloatVar(_)
23+
| InferTy::FreshIntTy(_)
24+
| InferTy::FreshFloatTy(_)
25+
)
2226
)
2327
}
2428

compiler/rustc_middle/src/ty/error.rs

+7-4
Original file line numberDiff line numberDiff line change
@@ -646,11 +646,14 @@ impl<T> Trait<T> for X {
646646
let current_method_ident = body_owner.and_then(|n| n.ident()).map(|i| i.name);
647647

648648
// We don't want to suggest calling an assoc fn in a scope where that isn't feasible.
649-
let callable_scope = matches!(body_owner, Some(
649+
let callable_scope = matches!(
650+
body_owner,
651+
Some(
650652
hir::Node::Item(hir::Item { kind: hir::ItemKind::Fn(..), .. })
651-
| hir::Node::TraitItem(hir::TraitItem { kind: hir::TraitItemKind::Fn(..), .. })
652-
| hir::Node::ImplItem(hir::ImplItem { kind: hir::ImplItemKind::Fn(..), .. }),
653-
));
653+
| hir::Node::TraitItem(hir::TraitItem { kind: hir::TraitItemKind::Fn(..), .. })
654+
| hir::Node::ImplItem(hir::ImplItem { kind: hir::ImplItemKind::Fn(..), .. }),
655+
)
656+
);
654657
let impl_comparison = matches!(
655658
cause_code,
656659
ObligationCauseCode::CompareImplMethodObligation { .. }

compiler/rustc_middle/src/ty/sty.rs

+8-2
Original file line numberDiff line numberDiff line change
@@ -1871,8 +1871,14 @@ impl<'tcx> TyS<'tcx> {
18711871
pub fn is_scalar(&self) -> bool {
18721872
matches!(
18731873
self.kind(),
1874-
Bool | Char | Int(_) | Float(_) | Uint(_) | FnDef(..) | FnPtr(_) | RawPtr(_)
1875-
| Infer(IntVar(_) | FloatVar(_))
1874+
Bool | Char
1875+
| Int(_)
1876+
| Float(_)
1877+
| Uint(_)
1878+
| FnDef(..)
1879+
| FnPtr(_)
1880+
| RawPtr(_)
1881+
| Infer(IntVar(_) | FloatVar(_))
18761882
)
18771883
}
18781884

compiler/rustc_mir_build/src/build/expr/as_place.rs

+46-40
Original file line numberDiff line numberDiff line change
@@ -6,8 +6,8 @@ use crate::build::{BlockAnd, BlockAndExtension, Builder};
66
use crate::thir::*;
77
use rustc_hir::def_id::DefId;
88
use rustc_hir::HirId;
9-
use rustc_middle::middle::region;
109
use rustc_middle::hir::place::ProjectionKind as HirProjectionKind;
10+
use rustc_middle::middle::region;
1111
use rustc_middle::mir::AssertKind::BoundsCheck;
1212
use rustc_middle::mir::*;
1313
use rustc_middle::ty::{self, CanonicalUserTypeAnnotation, Ty, TyCtxt, Variance};
@@ -57,7 +57,8 @@ crate enum PlaceBase {
5757
/// DefId of the closure
5858
closure_def_id: DefId,
5959
/// The trait closure implements, `Fn`, `FnMut`, `FnOnce`
60-
closure_kind: ty::ClosureKind },
60+
closure_kind: ty::ClosureKind,
61+
},
6162
}
6263

6364
/// `PlaceBuilder` is used to create places during MIR construction. It allows you to "build up" a
@@ -81,8 +82,7 @@ crate struct PlaceBuilder<'tcx> {
8182
fn convert_to_hir_projections_and_truncate_for_capture<'tcx>(
8283
mir_projections: &[PlaceElem<'tcx>],
8384
) -> Vec<HirProjectionKind> {
84-
85-
let mut hir_projections = Vec::new();
85+
let mut hir_projections = Vec::new();
8686

8787
for mir_projection in mir_projections {
8888
let hir_projection = match mir_projection {
@@ -91,20 +91,20 @@ fn convert_to_hir_projections_and_truncate_for_capture<'tcx>(
9191
// We will never encouter this for multivariant enums,
9292
// read the comment for `Downcast`.
9393
HirProjectionKind::Field(field.index() as u32, VariantIdx::new(0))
94-
},
94+
}
9595
ProjectionElem::Downcast(..) => {
9696
// This projections exist only for enums that have
9797
// multiple variants. Since such enums that are captured
9898
// completely, we can stop here.
99-
break
100-
},
99+
break;
100+
}
101101
ProjectionElem::Index(..)
102102
| ProjectionElem::ConstantIndex { .. }
103103
| ProjectionElem::Subslice { .. } => {
104104
// We don't capture array-access projections.
105105
// We can stop here as arrays are captured completely.
106-
break
107-
},
106+
break;
107+
}
108108
};
109109

110110
hir_projections.push(hir_projection);
@@ -181,9 +181,9 @@ fn find_capture_matching_projections<'a, 'tcx>(
181181
// If an ancestor is found, `idx` is the index within the list of captured places
182182
// for root variable `var_hir_id` and `capture` is the `ty::CapturedPlace` itself.
183183
let (idx, capture) = root_variable_min_captures.iter().enumerate().find(|(_, capture)| {
184-
let possible_ancestor_proj_kinds =
185-
capture.place.projections.iter().map(|proj| proj.kind).collect();
186-
is_ancestor_or_same_capture(&possible_ancestor_proj_kinds, &hir_projections)
184+
let possible_ancestor_proj_kinds =
185+
capture.place.projections.iter().map(|proj| proj.kind).collect();
186+
is_ancestor_or_same_capture(&possible_ancestor_proj_kinds, &hir_projections)
187187
})?;
188188

189189
// 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>(
213213
ty::ClosureKind::FnOnce => {}
214214
}
215215

216-
let (capture_index, capture) =
217-
if let Some(capture_details) = find_capture_matching_projections(
216+
let (capture_index, capture) = if let Some(capture_details) =
217+
find_capture_matching_projections(
218218
typeck_results,
219219
var_hir_id,
220220
closure_def_id,
221221
&from_builder.projection,
222222
) {
223-
capture_details
224-
} else {
225-
if !tcx.features().capture_disjoint_fields {
226-
bug!(
227-
"No associated capture found for {:?}[{:#?}] even though \
223+
capture_details
224+
} else {
225+
if !tcx.features().capture_disjoint_fields {
226+
bug!(
227+
"No associated capture found for {:?}[{:#?}] even though \
228228
capture_disjoint_fields isn't enabled",
229-
var_hir_id,
230-
from_builder.projection
231-
)
232-
} else {
233-
// FIXME(project-rfc-2229#24): Handle this case properly
234-
debug!(
235-
"No associated capture found for {:?}[{:#?}]",
236-
var_hir_id,
237-
from_builder.projection,
238-
);
239-
}
240-
return Err(var_hir_id);
241-
};
229+
var_hir_id,
230+
from_builder.projection
231+
)
232+
} else {
233+
// FIXME(project-rfc-2229#24): Handle this case properly
234+
debug!(
235+
"No associated capture found for {:?}[{:#?}]",
236+
var_hir_id, from_builder.projection,
237+
);
238+
}
239+
return Err(var_hir_id);
240+
};
242241

243-
let closure_ty =
244-
typeck_results.node_type(tcx.hir().local_def_id_to_hir_id(closure_def_id.expect_local()));
242+
let closure_ty = typeck_results
243+
.node_type(tcx.hir().local_def_id_to_hir_id(closure_def_id.expect_local()));
245244

246245
let substs = match closure_ty.kind() {
247246
ty::Closure(_, substs) => ty::UpvarSubsts::Closure(substs),
@@ -256,7 +255,8 @@ fn to_upvars_resolved_place_builder<'a, 'tcx>(
256255
// we know that the capture exists and is the `capture_index`-th capture.
257256
let var_ty = substs.tupled_upvars_ty().tuple_element_ty(capture_index).unwrap();
258257

259-
upvar_resolved_place_builder = upvar_resolved_place_builder.field(Field::new(capture_index), var_ty);
258+
upvar_resolved_place_builder =
259+
upvar_resolved_place_builder.field(Field::new(capture_index), var_ty);
260260

261261
// If the variable is captured via ByRef(Immutable/Mutable) Borrow,
262262
// we need to deref it
@@ -270,8 +270,9 @@ fn to_upvars_resolved_place_builder<'a, 'tcx>(
270270

271271
// We used some of the projections to build the capture itself,
272272
// now we apply the remaining to the upvar resolved place.
273-
upvar_resolved_place_builder.projection.extend(
274-
curr_projections.drain(next_projection..));
273+
upvar_resolved_place_builder
274+
.projection
275+
.extend(curr_projections.drain(next_projection..));
275276

276277
Ok(upvar_resolved_place_builder)
277278
}
@@ -356,7 +357,11 @@ impl<'a, 'tcx> Builder<'a, 'tcx> {
356357

357358
/// This is used when constructing a compound `Place`, so that we can avoid creating
358359
/// intermediate `Place` values until we know the full set of projections.
359-
crate fn as_place_builder<M>(&mut self, block: BasicBlock, expr: M) -> BlockAnd<PlaceBuilder<'tcx>>
360+
crate fn as_place_builder<M>(
361+
&mut self,
362+
block: BasicBlock,
363+
expr: M,
364+
) -> BlockAnd<PlaceBuilder<'tcx>>
360365
where
361366
M: Mirror<'tcx, Output = Expr<'tcx>>,
362367
{
@@ -627,7 +632,8 @@ impl<'a, 'tcx> Builder<'a, 'tcx> {
627632
if is_outermost_index {
628633
self.read_fake_borrows(block, fake_borrow_temps, source_info)
629634
} else {
630-
base_place = base_place.expect_upvars_resolved(self.hir.tcx(), self.hir.typeck_results());
635+
base_place =
636+
base_place.expect_upvars_resolved(self.hir.tcx(), self.hir.typeck_results());
631637
self.add_fake_borrows_of_base(
632638
&base_place,
633639
block,
@@ -679,7 +685,7 @@ impl<'a, 'tcx> Builder<'a, 'tcx> {
679685
let tcx = self.hir.tcx();
680686
let local = match base_place.base {
681687
PlaceBase::Local(local) => local,
682-
PlaceBase::Upvar { .. } => bug!("Expected PlacseBase::Local found Upvar")
688+
PlaceBase::Upvar { .. } => bug!("Expected PlacseBase::Local found Upvar"),
683689
};
684690

685691
let place_ty = Place::ty_from(local, &base_place.projection, &self.local_decls, tcx);

0 commit comments

Comments
 (0)