Skip to content

Commit dbedf40

Browse files
Reformat type_of
1 parent 252fa78 commit dbedf40

File tree

1 file changed

+30
-23
lines changed

1 file changed

+30
-23
lines changed

compiler/rustc_hir_analysis/src/collect/type_of.rs

+30-23
Original file line numberDiff line numberDiff line change
@@ -278,8 +278,11 @@ pub(super) fn type_of(tcx: TyCtxt<'_>, def_id: DefId) -> ty::EarlyBinder<Ty<'_>>
278278
}
279279
TraitItemKind::Const(ty, body_id) => body_id
280280
.and_then(|body_id| {
281-
is_suggestable_infer_ty(ty)
282-
.then(|| infer_placeholder_type(tcx, def_id, body_id, ty.span, item.ident, "constant",))
281+
is_suggestable_infer_ty(ty).then(|| {
282+
infer_placeholder_type(
283+
tcx, def_id, body_id, ty.span, item.ident, "constant",
284+
)
285+
})
283286
})
284287
.unwrap_or_else(|| icx.to_ty(ty)),
285288
TraitItemKind::Type(_, Some(ty)) => icx.to_ty(ty),
@@ -335,14 +338,15 @@ pub(super) fn type_of(tcx: TyCtxt<'_>, def_id: DefId) -> ty::EarlyBinder<Ty<'_>>
335338
}
336339
}
337340
ItemKind::TyAlias(self_ty, _) => icx.to_ty(self_ty),
338-
ItemKind::Impl(hir::Impl { self_ty, .. }) => {
339-
match self_ty.find_self_aliases() {
340-
spans if spans.len() > 0 => {
341-
let guar = tcx.sess.emit_err(crate::errors::SelfInImplSelf { span: spans.into(), note: () });
342-
tcx.ty_error(guar)
343-
},
344-
_ => icx.to_ty(*self_ty),
341+
ItemKind::Impl(hir::Impl { self_ty, .. }) => match self_ty.find_self_aliases() {
342+
spans if spans.len() > 0 => {
343+
let guar = tcx.sess.emit_err(crate::errors::SelfInImplSelf {
344+
span: spans.into(),
345+
note: (),
346+
});
347+
tcx.ty_error(guar)
345348
}
349+
_ => icx.to_ty(*self_ty),
346350
},
347351
ItemKind::Fn(..) => {
348352
let substs = InternalSubsts::identity_for_item(tcx, def_id.to_def_id());
@@ -364,7 +368,10 @@ pub(super) fn type_of(tcx: TyCtxt<'_>, def_id: DefId) -> ty::EarlyBinder<Ty<'_>>
364368
..
365369
}) => {
366370
if in_trait && !tcx.impl_defaultness(owner).has_value() {
367-
span_bug!(tcx.def_span(def_id), "tried to get type of this RPITIT with no definition");
371+
span_bug!(
372+
tcx.def_span(def_id),
373+
"tried to get type of this RPITIT with no definition"
374+
);
368375
}
369376
find_opaque_ty_constraints_for_rpit(tcx, def_id, owner)
370377
}
@@ -453,15 +460,12 @@ pub(super) fn type_of(tcx: TyCtxt<'_>, def_id: DefId) -> ty::EarlyBinder<Ty<'_>>
453460
tcx.adt_def(tcx.hir().get_parent_item(hir_id)).repr().discr_type().to_ty(tcx)
454461
}
455462

456-
Node::TypeBinding(
457-
TypeBinding {
458-
hir_id: binding_id,
459-
kind: TypeBindingKind::Equality { term: Term::Const(e) },
460-
ident,
461-
..
462-
},
463-
) if let Node::TraitRef(trait_ref) =
464-
tcx.hir().get_parent(*binding_id)
463+
Node::TypeBinding(TypeBinding {
464+
hir_id: binding_id,
465+
kind: TypeBindingKind::Equality { term: Term::Const(e) },
466+
ident,
467+
..
468+
}) if let Node::TraitRef(trait_ref) = tcx.hir().get_parent(*binding_id)
465469
&& e.hir_id == hir_id =>
466470
{
467471
let Some(trait_def_id) = trait_ref.trait_def_id() else {
@@ -487,10 +491,13 @@ pub(super) fn type_of(tcx: TyCtxt<'_>, def_id: DefId) -> ty::EarlyBinder<Ty<'_>>
487491
}
488492
}
489493

490-
Node::TypeBinding(
491-
TypeBinding { hir_id: binding_id, gen_args, kind, ident, .. },
492-
) if let Node::TraitRef(trait_ref) =
493-
tcx.hir().get_parent(*binding_id)
494+
Node::TypeBinding(TypeBinding {
495+
hir_id: binding_id,
496+
gen_args,
497+
kind,
498+
ident,
499+
..
500+
}) if let Node::TraitRef(trait_ref) = tcx.hir().get_parent(*binding_id)
494501
&& let Some((idx, _)) =
495502
gen_args.args.iter().enumerate().find(|(_, arg)| {
496503
if let GenericArg::Const(ct) = arg {

0 commit comments

Comments
 (0)