@@ -4,7 +4,7 @@ use std::iter;
4
4
5
5
use super :: assembly:: { self , Candidate , CandidateSource } ;
6
6
use super :: infcx_ext:: InferCtxtExt ;
7
- use super :: { CanonicalResponse , Certainty , EvalCtxt , Goal , QueryResult } ;
7
+ use super :: { CanonicalResponse , Certainty , EvalCtxt , Goal , MaybeCause , QueryResult } ;
8
8
use rustc_hir:: def_id:: DefId ;
9
9
use rustc_infer:: infer:: InferCtxt ;
10
10
use rustc_infer:: traits:: query:: NoSolution ;
@@ -511,11 +511,17 @@ impl<'tcx> EvalCtxt<'_, 'tcx> {
511
511
// If there are *STILL* multiple candidates, give up
512
512
// and report ambiguity.
513
513
i += 1 ;
514
- if i > 1 {
515
- debug ! ( "multiple matches, ambig" ) ;
516
- // FIXME: return overflow if all candidates overflow, otherwise return ambiguity.
517
- unimplemented ! ( ) ;
518
- }
514
+ }
515
+
516
+ if candidates. len ( ) > 1 {
517
+ let certainty = if candidates. iter ( ) . all ( |x| {
518
+ matches ! ( x. result. value. certainty, Certainty :: Maybe ( MaybeCause :: Overflow ) )
519
+ } ) {
520
+ Certainty :: Maybe ( MaybeCause :: Overflow )
521
+ } else {
522
+ Certainty :: AMBIGUOUS
523
+ } ;
524
+ return self . make_canonical_response ( certainty) ;
519
525
}
520
526
}
521
527
@@ -532,17 +538,18 @@ impl<'tcx> EvalCtxt<'_, 'tcx> {
532
538
( CandidateSource :: Impl ( _) , _)
533
539
| ( CandidateSource :: ParamEnv ( _) , _)
534
540
| ( CandidateSource :: AliasBound , _)
535
- | ( CandidateSource :: BuiltinImpl , _) => unimplemented ! ( ) ,
541
+ | ( CandidateSource :: BuiltinImpl , _) => false ,
536
542
}
537
543
}
538
544
539
- fn discard_reservation_impl ( & self , candidate : Candidate < ' tcx > ) -> Candidate < ' tcx > {
545
+ fn discard_reservation_impl ( & self , mut candidate : Candidate < ' tcx > ) -> Candidate < ' tcx > {
540
546
if let CandidateSource :: Impl ( def_id) = candidate. source {
541
547
if let ty:: ImplPolarity :: Reservation = self . tcx ( ) . impl_polarity ( def_id) {
542
548
debug ! ( "Selected reservation impl" ) ;
543
- // FIXME: reduce candidate to ambiguous
544
- // FIXME: replace `var_values` with identity, yeet external constraints.
545
- unimplemented ! ( )
549
+ // We assemble all candidates inside of a probe so by
550
+ // making a new canonical response here our result will
551
+ // have no constraints.
552
+ candidate. result = self . make_canonical_response ( Certainty :: AMBIGUOUS ) . unwrap ( ) ;
546
553
}
547
554
}
548
555
0 commit comments