@@ -351,19 +351,34 @@ impl<'tcx> Cx<'tcx> {
351
351
} ) ;
352
352
}
353
353
}
354
- let adt_data =
355
- if let hir :: ExprKind :: Path ( hir :: QPath :: Resolved ( _ , ref path ) ) = fun . kind {
354
+ let adt_data = if let hir :: ExprKind :: Path ( qpath ) = fun . kind {
355
+ match qpath {
356
356
// Tuple-like ADTs are represented as ExprKind::Call. We convert them here.
357
- expr_ty. ty_adt_def ( ) . and_then ( |adt_def| match path. res {
358
- Res :: Def ( DefKind :: Ctor ( _, CtorKind :: Fn ) , ctor_id) => {
359
- Some ( ( adt_def, adt_def. variant_index_with_ctor_id ( ctor_id) ) )
360
- }
361
- Res :: SelfCtor ( ..) => Some ( ( adt_def, FIRST_VARIANT ) ) ,
362
- _ => None ,
363
- } )
364
- } else {
365
- None
366
- } ;
357
+ hir:: QPath :: Resolved ( _, ref path) => {
358
+ expr_ty. ty_adt_def ( ) . and_then ( |adt_def| match path. res {
359
+ Res :: Def ( DefKind :: Ctor ( _, CtorKind :: Fn ) , ctor_id) => {
360
+ Some ( ( adt_def, adt_def. variant_index_with_ctor_id ( ctor_id) ) )
361
+ }
362
+ Res :: SelfCtor ( ..) => Some ( ( adt_def, FIRST_VARIANT ) ) ,
363
+ _ => None ,
364
+ } )
365
+ }
366
+ hir:: QPath :: TypeRelative ( _ty, _) => {
367
+ expr_ty. ty_adt_def ( ) . and_then ( |adt_def| {
368
+ if let Some ( ( DefKind :: Ctor ( _, CtorKind :: Fn ) , ctor_id) ) =
369
+ self . typeck_results ( ) . type_dependent_def ( fun. hir_id )
370
+ {
371
+ Some ( ( adt_def, adt_def. variant_index_with_ctor_id ( ctor_id) ) )
372
+ } else {
373
+ None
374
+ }
375
+ } )
376
+ }
377
+ _ => None ,
378
+ }
379
+ } else {
380
+ None
381
+ } ;
367
382
if let Some ( ( adt_def, index) ) = adt_data {
368
383
let substs = self . typeck_results ( ) . node_substs ( fun. hir_id ) ;
369
384
let user_provided_types = self . typeck_results ( ) . user_provided_types ( ) ;
0 commit comments