@@ -798,13 +798,16 @@ impl<'a, 'tcx> FnCtxt<'a, 'tcx> {
798798 bug ! ( "`resolve_ty_and_res_fully_qualified_call` called on `LangItem`" )
799799 }
800800 } ;
801+
802+ self . register_wf_obligation (
803+ ty. raw . into ( ) ,
804+ qself. span ,
805+ ObligationCauseCode :: WellFormed ( None ) ,
806+ ) ;
807+ self . select_obligations_where_possible ( |_| { } ) ;
808+
801809 if let Some ( & cached_result) = self . typeck_results . borrow ( ) . type_dependent_defs ( ) . get ( hir_id)
802810 {
803- self . register_wf_obligation (
804- ty. raw . into ( ) ,
805- qself. span ,
806- ObligationCauseCode :: WellFormed ( None ) ,
807- ) ;
808811 // Return directly on cache hit. This is useful to avoid doubly reporting
809812 // errors with default match binding modes. See #44614.
810813 let def = cached_result. map_or ( Res :: Err , |( kind, def_id) | Res :: Def ( kind, def_id) ) ;
@@ -824,18 +827,6 @@ impl<'a, 'tcx> FnCtxt<'a, 'tcx> {
824827
825828 let trait_missing_method =
826829 matches ! ( error, method:: MethodError :: NoMatch ( _) ) && ty. normalized . is_trait ( ) ;
827- // If we have a path like `MyTrait::missing_method`, then don't register
828- // a WF obligation for `dyn MyTrait` when method lookup fails. Otherwise,
829- // register a WF obligation so that we can detect any additional
830- // errors in the self type.
831- if !trait_missing_method {
832- self . register_wf_obligation (
833- ty. raw . into ( ) ,
834- qself. span ,
835- ObligationCauseCode :: WellFormed ( None ) ,
836- ) ;
837- }
838-
839830 if item_name. name != kw:: Empty {
840831 self . report_method_error (
841832 hir_id,
@@ -849,14 +840,6 @@ impl<'a, 'tcx> FnCtxt<'a, 'tcx> {
849840 result
850841 } ) ;
851842
852- if result. is_ok ( ) {
853- self . register_wf_obligation (
854- ty. raw . into ( ) ,
855- qself. span ,
856- ObligationCauseCode :: WellFormed ( None ) ,
857- ) ;
858- }
859-
860843 // Write back the new resolution.
861844 self . write_resolution ( hir_id, result) ;
862845 (
0 commit comments