@@ -14,8 +14,7 @@ use rustc::session::config::nightly_options;
1414use rustc:: ty:: subst:: { InternalSubsts , Subst , SubstsRef } ;
1515use rustc:: ty:: GenericParamDefKind ;
1616use rustc:: ty:: {
17- self , ParamEnvAnd , ToPolyTraitRef , ToPredicate , TraitRef , Ty , TyCtxt , TypeFoldable ,
18- WithConstness ,
17+ self , ParamEnvAnd , ToPolyTraitRef , ToPredicate , Ty , TyCtxt , TypeFoldable , WithConstness ,
1918} ;
2019use rustc_data_structures:: fx:: FxHashSet ;
2120use rustc_data_structures:: sync:: Lrc ;
@@ -78,7 +77,7 @@ struct ProbeContext<'a, 'tcx> {
7877
7978 /// Collects near misses when trait bounds for type parameters are unsatisfied and is only used
8079 /// for error reporting
81- unsatisfied_predicates : Vec < TraitRef < ' tcx > > ,
80+ unsatisfied_predicates : Vec < ty :: Predicate < ' tcx > > ,
8281
8382 is_suggestion : IsSuggestion ,
8483}
@@ -1224,7 +1223,7 @@ impl<'a, 'tcx> ProbeContext<'a, 'tcx> {
12241223 & self ,
12251224 self_ty : Ty < ' tcx > ,
12261225 probes : ProbesIter ,
1227- possibly_unsatisfied_predicates : & mut Vec < TraitRef < ' tcx > > ,
1226+ possibly_unsatisfied_predicates : & mut Vec < ty :: Predicate < ' tcx > > ,
12281227 unstable_candidates : Option < & mut Vec < ( & ' b Candidate < ' tcx > , Symbol ) > > ,
12291228 ) -> Option < PickResult < ' tcx > >
12301229 where
@@ -1343,7 +1342,7 @@ impl<'a, 'tcx> ProbeContext<'a, 'tcx> {
13431342 & self ,
13441343 self_ty : Ty < ' tcx > ,
13451344 probe : & Candidate < ' tcx > ,
1346- possibly_unsatisfied_predicates : & mut Vec < TraitRef < ' tcx > > ,
1345+ possibly_unsatisfied_predicates : & mut Vec < ty :: Predicate < ' tcx > > ,
13471346 ) -> ProbeResult {
13481347 debug ! ( "consider_probe: self_ty={:?} probe={:?}" , self_ty, probe) ;
13491348
@@ -1398,47 +1397,40 @@ impl<'a, 'tcx> ProbeContext<'a, 'tcx> {
13981397 let predicate = trait_ref. without_const ( ) . to_predicate ( ) ;
13991398 let obligation = traits:: Obligation :: new ( cause, self . param_env , predicate) ;
14001399 if !self . predicate_may_hold ( & obligation) {
1401- if self . probe ( |_| self . select_trait_candidate ( trait_ref) . is_err ( ) ) {
1400+ if self . probe ( |_| {
1401+ match self . select_trait_candidate ( trait_ref) {
1402+ Err ( _) => return true ,
1403+ Ok ( Some ( vtable) )
1404+ if !vtable. borrow_nested_obligations ( ) . is_empty ( ) =>
1405+ {
1406+ for obligation in vtable. borrow_nested_obligations ( ) {
1407+ // Determine exactly which obligation wasn't met, so
1408+ // that we can give more context in the error.
1409+ if !self . predicate_may_hold ( & obligation) {
1410+ result = ProbeResult :: NoMatch ;
1411+ let o = self . resolve_vars_if_possible ( obligation) ;
1412+ possibly_unsatisfied_predicates. push ( o. predicate ) ;
1413+ }
1414+ }
1415+ }
1416+ _ => {
1417+ // Some nested subobligation of this predicate
1418+ // failed.
1419+ //
1420+ // FIXME: try to find the exact nested subobligation
1421+ // and point at it rather than reporting the entire
1422+ // trait-ref?
1423+ result = ProbeResult :: NoMatch ;
1424+ let predicate = self . resolve_vars_if_possible ( & predicate) ;
1425+ possibly_unsatisfied_predicates. push ( predicate) ;
1426+ }
1427+ }
1428+ false
1429+ } ) {
14021430 // This candidate's primary obligation doesn't even
14031431 // select - don't bother registering anything in
14041432 // `potentially_unsatisfied_predicates`.
14051433 return ProbeResult :: NoMatch ;
1406- } else {
1407- self . probe ( |_| {
1408- match self . select_trait_candidate ( trait_ref) {
1409- Ok ( Some ( traits:: VtableImpl ( traits:: VtableImplData {
1410- nested,
1411- ..
1412- } ) ) ) if !nested. is_empty ( ) => {
1413- for obligation in nested {
1414- // Determine exactly which obligation wasn't met, so
1415- // that we can give more context in the error.
1416- if !self . predicate_may_hold ( & obligation) {
1417- result = ProbeResult :: NoMatch ;
1418- if let Some ( poly_trait_ref) =
1419- obligation. predicate . to_opt_poly_trait_ref ( )
1420- {
1421- let trait_ref = poly_trait_ref. clone ( ) ;
1422- let trait_ref = trait_ref. skip_binder ( ) ;
1423- possibly_unsatisfied_predicates
1424- . push ( * trait_ref) ;
1425- }
1426- }
1427- }
1428- }
1429- _ => {
1430- // Some nested subobligation of this predicate
1431- // failed.
1432- //
1433- // FIXME: try to find the exact nested subobligation
1434- // and point at it rather than reporting the entire
1435- // trait-ref?
1436- result = ProbeResult :: NoMatch ;
1437- let trait_ref = self . resolve_vars_if_possible ( & trait_ref) ;
1438- possibly_unsatisfied_predicates. push ( trait_ref) ;
1439- }
1440- }
1441- } ) ;
14421434 }
14431435 }
14441436 vec ! [ ]
@@ -1455,9 +1447,7 @@ impl<'a, 'tcx> ProbeContext<'a, 'tcx> {
14551447 let o = self . resolve_vars_if_possible ( & o) ;
14561448 if !self . predicate_may_hold ( & o) {
14571449 result = ProbeResult :: NoMatch ;
1458- if let & ty:: Predicate :: Trait ( ref pred, _) = & o. predicate {
1459- possibly_unsatisfied_predicates. push ( pred. skip_binder ( ) . trait_ref ) ;
1460- }
1450+ possibly_unsatisfied_predicates. push ( o. predicate ) ;
14611451 }
14621452 }
14631453
0 commit comments