@@ -408,45 +408,38 @@ impl<'a, 'gcx, 'tcx> FnCtxt<'a, 'gcx, 'tcx> {
408
408
409
409
let tcx = self . tcx ;
410
410
411
- let mode = probe:: Mode :: Path ;
412
- match self . probe_for_name ( span, mode, method_name, IsSuggestion ( false ) ,
413
- self_ty, expr_id, ProbeScope :: TraitsInScope ) {
414
- Ok ( pick) => {
415
- debug ! ( "resolve_ufcs: pick={:?}" , pick) ;
416
- if let Some ( import_id) = pick. import_id {
417
- let import_def_id = tcx. hir ( ) . local_def_id ( import_id) ;
418
- debug ! ( "resolve_ufcs: used_trait_import: {:?}" , import_def_id) ;
419
- Lrc :: get_mut ( & mut self . tables . borrow_mut ( ) . used_trait_imports )
420
- . unwrap ( ) . insert ( import_def_id) ;
411
+ // Check if we have an enum variant here.
412
+ match self_ty. sty {
413
+ ty:: Adt ( adt_def, _) if adt_def. is_enum ( ) => {
414
+ let variant_def = adt_def. variants . iter ( ) . find ( |vd| {
415
+ tcx. hygienic_eq ( method_name, vd. ident , adt_def. did )
416
+ } ) ;
417
+ if let Some ( variant_def) = variant_def {
418
+ check_type_alias_enum_variants_enabled ( tcx, span) ;
419
+
420
+ let def = Def :: VariantCtor ( variant_def. did , variant_def. ctor_kind ) ;
421
+ tcx. check_stability ( def. def_id ( ) , Some ( expr_id) , span) ;
422
+ return Ok ( def) ;
421
423
}
424
+ } ,
425
+ _ => ( ) ,
426
+ }
422
427
423
- let def = pick. item . def ( ) ;
424
- debug ! ( "resolve_ufcs: def={:?}" , def) ;
425
- tcx. check_stability ( def. def_id ( ) , Some ( expr_id) , span) ;
426
-
427
- Ok ( def)
428
- }
429
- Err ( err) => {
430
- // Check if we have an enum variant.
431
- match self_ty. sty {
432
- ty:: Adt ( adt_def, _) if adt_def. is_enum ( ) => {
433
- let variant_def = adt_def. variants . iter ( ) . find ( |vd| {
434
- tcx. hygienic_eq ( method_name, vd. ident , adt_def. did )
435
- } ) ;
436
- if let Some ( variant_def) = variant_def {
437
- check_type_alias_enum_variants_enabled ( tcx, span) ;
438
-
439
- let def = Def :: VariantCtor ( variant_def. did , variant_def. ctor_kind ) ;
440
- tcx. check_stability ( def. def_id ( ) , Some ( expr_id) , span) ;
441
- return Ok ( def) ;
442
- }
443
- } ,
444
- _ => ( ) ,
445
- }
428
+ let mode = probe:: Mode :: Path ;
429
+ let pick = self . probe_for_name ( span, mode, method_name, IsSuggestion ( false ) ,
430
+ self_ty, expr_id, ProbeScope :: TraitsInScope ) ?;
446
431
447
- Err ( err)
448
- }
432
+ if let Some ( import_id) = pick. import_id {
433
+ let import_def_id = tcx. hir ( ) . local_def_id ( import_id) ;
434
+ debug ! ( "resolve_ufcs: used_trait_import: {:?}" , import_def_id) ;
435
+ Lrc :: get_mut ( & mut self . tables . borrow_mut ( ) . used_trait_imports )
436
+ . unwrap ( ) . insert ( import_def_id) ;
449
437
}
438
+
439
+ let def = pick. item . def ( ) ;
440
+ tcx. check_stability ( def. def_id ( ) , Some ( expr_id) , span) ;
441
+
442
+ Ok ( def)
450
443
}
451
444
452
445
/// Find item with name `item_name` defined in impl/trait `def_id`
0 commit comments