@@ -278,8 +278,11 @@ pub(super) fn type_of(tcx: TyCtxt<'_>, def_id: DefId) -> ty::EarlyBinder<Ty<'_>>
278
278
}
279
279
TraitItemKind :: Const ( ty, body_id) => body_id
280
280
. 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
+ } )
283
286
} )
284
287
. unwrap_or_else ( || icx. to_ty ( ty) ) ,
285
288
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<'_>>
335
338
}
336
339
}
337
340
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 )
345
348
}
349
+ _ => icx. to_ty ( * self_ty) ,
346
350
} ,
347
351
ItemKind :: Fn ( ..) => {
348
352
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<'_>>
364
368
..
365
369
} ) => {
366
370
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
+ ) ;
368
375
}
369
376
find_opaque_ty_constraints_for_rpit ( tcx, def_id, owner)
370
377
}
@@ -453,15 +460,12 @@ pub(super) fn type_of(tcx: TyCtxt<'_>, def_id: DefId) -> ty::EarlyBinder<Ty<'_>>
453
460
tcx. adt_def ( tcx. hir ( ) . get_parent_item ( hir_id) ) . repr ( ) . discr_type ( ) . to_ty ( tcx)
454
461
}
455
462
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)
465
469
&& e. hir_id == hir_id =>
466
470
{
467
471
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<'_>>
487
491
}
488
492
}
489
493
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)
494
501
&& let Some ( ( idx, _) ) =
495
502
gen_args. args . iter ( ) . enumerate ( ) . find ( |( _, arg) | {
496
503
if let GenericArg :: Const ( ct) = arg {
0 commit comments