@@ -331,53 +331,25 @@ impl<'a, D: HirDatabase> InferenceContext<'a, D> {
331331 fn resolve_obligations_as_possible ( & mut self ) {
332332 let obligations = mem:: replace ( & mut self . obligations , Vec :: new ( ) ) ;
333333 for obligation in obligations {
334- match & obligation {
335- Obligation :: Trait ( tr) => {
336- let in_env = InEnvironment :: new ( self . trait_env . clone ( ) , tr. clone ( ) ) ;
337- let canonicalized = self . canonicalizer ( ) . canonicalize_trait_ref ( in_env) ;
338- let solution = self
339- . db
340- . implements ( self . resolver . krate ( ) . unwrap ( ) , canonicalized. value . clone ( ) ) ;
341- match solution {
342- Some ( Solution :: Unique ( substs) ) => {
343- canonicalized. apply_solution ( self , substs. 0 ) ;
344- }
345- Some ( Solution :: Ambig ( Guidance :: Definite ( substs) ) ) => {
346- canonicalized. apply_solution ( self , substs. 0 ) ;
347- self . obligations . push ( obligation) ;
348- }
349- Some ( _) => {
350- // FIXME use this when trying to resolve everything at the end
351- self . obligations . push ( obligation) ;
352- }
353- None => {
354- // FIXME obligation cannot be fulfilled => diagnostic
355- }
356- } ;
334+ let in_env = InEnvironment :: new ( self . trait_env . clone ( ) , obligation. clone ( ) ) ;
335+ let canonicalized = self . canonicalizer ( ) . canonicalize_obligation ( in_env) ;
336+ let solution =
337+ self . db . solve ( self . resolver . krate ( ) . unwrap ( ) , canonicalized. value . clone ( ) ) ;
338+
339+ match solution {
340+ Some ( Solution :: Unique ( substs) ) => {
341+ canonicalized. apply_solution ( self , substs. 0 ) ;
357342 }
358- Obligation :: Projection ( pr) => {
359- let in_env = InEnvironment :: new ( self . trait_env . clone ( ) , pr. clone ( ) ) ;
360- let canonicalized = self . canonicalizer ( ) . canonicalize_projection ( in_env) ;
361- let solution = self
362- . db
363- . normalize ( self . resolver . krate ( ) . unwrap ( ) , canonicalized. value . clone ( ) ) ;
364-
365- match solution {
366- Some ( Solution :: Unique ( substs) ) => {
367- canonicalized. apply_solution ( self , substs. 0 ) ;
368- }
369- Some ( Solution :: Ambig ( Guidance :: Definite ( substs) ) ) => {
370- canonicalized. apply_solution ( self , substs. 0 ) ;
371- self . obligations . push ( obligation) ;
372- }
373- Some ( _) => {
374- // FIXME use this when trying to resolve everything at the end
375- self . obligations . push ( obligation) ;
376- }
377- None => {
378- // FIXME obligation cannot be fulfilled => diagnostic
379- }
380- } ;
343+ Some ( Solution :: Ambig ( Guidance :: Definite ( substs) ) ) => {
344+ canonicalized. apply_solution ( self , substs. 0 ) ;
345+ self . obligations . push ( obligation) ;
346+ }
347+ Some ( _) => {
348+ // FIXME use this when trying to resolve everything at the end
349+ self . obligations . push ( obligation) ;
350+ }
351+ None => {
352+ // FIXME obligation cannot be fulfilled => diagnostic
381353 }
382354 } ;
383355 }
0 commit comments