@@ -371,38 +371,43 @@ impl<'a, 'gcx, 'tcx> FnCtxt<'a, 'gcx, 'tcx> {
371
371
372
372
let tcx = self . tcx ;
373
373
374
- // Check if we have an enum variant here.
375
- match self_ty. sty {
376
- ty:: Adt ( adt_def, _) if adt_def. is_enum ( ) => {
377
- let variant_def = adt_def. variants . iter ( ) . find ( |vd| {
378
- tcx. hygienic_eq ( method_name, vd. ident , adt_def. did )
379
- } ) ;
380
- if let Some ( variant_def) = variant_def {
381
- check_type_alias_enum_variants_enabled ( tcx, span) ;
382
-
383
- let def = Def :: VariantCtor ( variant_def. did , variant_def. ctor_kind ) ;
384
- tcx. check_stability ( def. def_id ( ) , Some ( expr_id) , span) ;
385
- return Ok ( def) ;
374
+ let mode = probe:: Mode :: Path ;
375
+ match self . probe_for_name ( span, mode, method_name, IsSuggestion ( false ) ,
376
+ self_ty, expr_id, ProbeScope :: TraitsInScope ) {
377
+ Ok ( pick) => {
378
+ if let Some ( import_id) = pick. import_id {
379
+ let import_def_id = tcx. hir ( ) . local_def_id ( import_id) ;
380
+ debug ! ( "resolve_ufcs: used_trait_import: {:?}" , import_def_id) ;
381
+ Lrc :: get_mut ( & mut self . tables . borrow_mut ( ) . used_trait_imports )
382
+ . unwrap ( ) . insert ( import_def_id) ;
386
383
}
387
- } ,
388
- _ => ( ) ,
389
- }
390
384
391
- let mode = probe:: Mode :: Path ;
392
- let pick = self . probe_for_name ( span, mode, method_name, IsSuggestion ( false ) ,
393
- self_ty, expr_id, ProbeScope :: TraitsInScope ) ?;
385
+ let def = pick. item . def ( ) ;
386
+ tcx. check_stability ( def. def_id ( ) , Some ( expr_id) , span) ;
394
387
395
- if let Some ( import_id) = pick. import_id {
396
- let import_def_id = tcx. hir ( ) . local_def_id ( import_id) ;
397
- debug ! ( "resolve_ufcs: used_trait_import: {:?}" , import_def_id) ;
398
- Lrc :: get_mut ( & mut self . tables . borrow_mut ( ) . used_trait_imports )
399
- . unwrap ( ) . insert ( import_def_id) ;
400
- }
401
-
402
- let def = pick. item . def ( ) ;
403
- tcx. check_stability ( def. def_id ( ) , Some ( expr_id) , span) ;
388
+ Ok ( def)
389
+ }
390
+ Err ( err) => {
391
+ // Check if we have an enum variant.
392
+ match self_ty. sty {
393
+ ty:: Adt ( adt_def, _) if adt_def. is_enum ( ) => {
394
+ let variant_def = adt_def. variants . iter ( ) . find ( |vd| {
395
+ tcx. hygienic_eq ( method_name, vd. ident , adt_def. did )
396
+ } ) ;
397
+ if let Some ( variant_def) = variant_def {
398
+ check_type_alias_enum_variants_enabled ( tcx, span) ;
399
+
400
+ let def = Def :: VariantCtor ( variant_def. did , variant_def. ctor_kind ) ;
401
+ tcx. check_stability ( def. def_id ( ) , Some ( expr_id) , span) ;
402
+ return Ok ( def) ;
403
+ }
404
+ } ,
405
+ _ => ( ) ,
406
+ }
404
407
405
- Ok ( def)
408
+ Err ( err)
409
+ }
410
+ }
406
411
}
407
412
408
413
/// Find item with name `item_name` defined in impl/trait `def_id`
0 commit comments