@@ -17,8 +17,8 @@ use crate::{
17
17
Adjust , Adjustment , AutoBorrow , InferOk , InferResult , InferenceContext , OverloadedDeref ,
18
18
PointerCast , TypeError , TypeMismatch ,
19
19
} ,
20
- static_lifetime, Canonical , DomainGoal , FnPointer , FnSig , InEnvironment , Interner , Solution ,
21
- Substitution , Ty , TyBuilder , TyExt , TyKind ,
20
+ static_lifetime, Canonical , DomainGoal , FnPointer , FnSig , Guidance , InEnvironment , Interner ,
21
+ Solution , Substitution , Ty , TyBuilder , TyExt , TyKind ,
22
22
} ;
23
23
24
24
pub ( crate ) type CoerceResult = Result < InferOk < ( Vec < Adjustment > , Ty ) > , TypeError > ;
@@ -541,7 +541,7 @@ impl<'a> InferenceContext<'a> {
541
541
_ => return Err ( TypeError ) ,
542
542
} ;
543
543
544
- let trait_ref = {
544
+ let coerce_unsized_tref = {
545
545
let b = TyBuilder :: trait_ref ( self . db , coerce_unsized_trait) ;
546
546
if b. remaining ( ) != 2 {
547
547
// The CoerceUnsized trait should have two generic params: Self and T.
@@ -551,7 +551,7 @@ impl<'a> InferenceContext<'a> {
551
551
} ;
552
552
553
553
let goal: InEnvironment < DomainGoal > =
554
- InEnvironment :: new ( & self . trait_env . env , trait_ref . cast ( & Interner ) ) ;
554
+ InEnvironment :: new ( & self . trait_env . env , coerce_unsized_tref . cast ( & Interner ) ) ;
555
555
556
556
let canonicalized = self . canonicalize ( goal) ;
557
557
@@ -575,8 +575,11 @@ impl<'a> InferenceContext<'a> {
575
575
} ,
576
576
) ;
577
577
}
578
- // FIXME: should we accept ambiguous results here?
579
- _ => return Err ( TypeError ) ,
578
+ Solution :: Ambig ( guidance) => {
579
+ if let Guidance :: Definite ( subst) = guidance {
580
+ canonicalized. apply_solution ( & mut self . table , subst) ;
581
+ }
582
+ }
580
583
} ;
581
584
let unsize =
582
585
Adjustment { kind : Adjust :: Pointer ( PointerCast :: Unsize ) , target : to_ty. clone ( ) } ;
0 commit comments