@@ -913,29 +913,32 @@ impl<'db> Inference<'db> {
913
913
let concrete_trait_id = self . rewrite ( concrete_trait_id) . no_err ( ) ;
914
914
enrich_lookup_context ( self . db , concrete_trait_id, & mut lookup_context) ;
915
915
916
- // Don't try to resolve impls if the first generic param is a variable.
917
- let generic_args = concrete_trait_id. generic_args ( self . db ) ;
918
- match generic_args. first ( ) {
919
- Some ( GenericArgumentId :: Type ( ty) ) => {
920
- if let TypeLongId :: Var ( _) = ty. lookup_intern ( self . db ) {
921
- // Don't try to infer such impls.
922
- return Ok ( SolutionSet :: Ambiguous ( Ambiguity :: WillNotInfer ( concrete_trait_id) ) ) ;
916
+ if !impl_var_trait_item_mappings
917
+ . types
918
+ . iter ( )
919
+ . any ( |( _, ty) | ty. is_var_free ( self . db ) && ty. is_missing ( self . db ) )
920
+ {
921
+ // Don't try to resolve impls if the first generic param is a variable.
922
+ let dont_infer = Ok ( SolutionSet :: Ambiguous ( Ambiguity :: WillNotInfer ( concrete_trait_id) ) ) ;
923
+ match concrete_trait_id. generic_args ( self . db ) . first ( ) {
924
+ Some ( GenericArgumentId :: Type ( ty) )
925
+ if matches ! ( ty. lookup_intern( self . db) , TypeLongId :: Var ( _) ) =>
926
+ {
927
+ return dont_infer;
923
928
}
924
- }
925
- Some ( GenericArgumentId :: Impl ( imp) ) => {
926
- // Don't try to infer such impls.
927
- if let ImplLongId :: ImplVar ( _) = imp. lookup_intern ( self . db ) {
928
- return Ok ( SolutionSet :: Ambiguous ( Ambiguity :: WillNotInfer ( concrete_trait_id) ) ) ;
929
+ Some ( GenericArgumentId :: Impl ( imp) )
930
+ if matches ! ( imp. lookup_intern( self . db) , ImplLongId :: ImplVar ( _) ) =>
931
+ {
932
+ return dont_infer;
929
933
}
930
- }
931
- Some ( GenericArgumentId :: Constant ( const_value) ) => {
932
- if let ConstValue :: Var ( _, _) = const_value. lookup_intern ( self . db ) {
933
- // Don't try to infer such impls.
934
- return Ok ( SolutionSet :: Ambiguous ( Ambiguity :: WillNotInfer ( concrete_trait_id) ) ) ;
934
+ Some ( GenericArgumentId :: Constant ( const_value) )
935
+ if matches ! ( const_value. lookup_intern( self . db) , ConstValue :: Var ( _, _) ) =>
936
+ {
937
+ return dont_infer;
935
938
}
939
+ _ => { }
936
940
}
937
- _ => { }
938
- } ;
941
+ }
939
942
let ( canonical_trait, canonicalizer) = CanonicalTrait :: canonicalize (
940
943
self . db ,
941
944
self . inference_id ,
0 commit comments