@@ -10,6 +10,7 @@ use rustc_infer::traits::{
10
10
use rustc_middle:: ty;
11
11
use rustc_middle:: ty:: error:: { ExpectedFound , TypeError } ;
12
12
13
+ use super :: eval_ctxt:: GenerateProofTree ;
13
14
use super :: { Certainty , InferCtxtEvalExt } ;
14
15
15
16
/// A trait engine using the new trait solver.
@@ -46,8 +47,11 @@ impl<'tcx> TraitEngine<'tcx> for FulfillmentCtxt<'tcx> {
46
47
self . obligations
47
48
. drain ( ..)
48
49
. map ( |obligation| {
49
- let code =
50
- infcx. probe ( |_| match infcx. evaluate_root_goal ( obligation. clone ( ) . into ( ) ) {
50
+ let code = infcx. probe ( |_| {
51
+ match infcx
52
+ . evaluate_root_goal ( obligation. clone ( ) . into ( ) , GenerateProofTree :: No )
53
+ . 0
54
+ {
51
55
Ok ( ( _, Certainty :: Maybe ( MaybeCause :: Ambiguity ) , _) ) => {
52
56
FulfillmentErrorCode :: CodeAmbiguity { overflow : false }
53
57
}
@@ -60,7 +64,8 @@ impl<'tcx> TraitEngine<'tcx> for FulfillmentCtxt<'tcx> {
60
64
Err ( _) => {
61
65
bug ! ( "did not expect selection error when collecting ambiguity errors" )
62
66
}
63
- } ) ;
67
+ }
68
+ } ) ;
64
69
65
70
FulfillmentError {
66
71
obligation : obligation. clone ( ) ,
@@ -81,61 +86,62 @@ impl<'tcx> TraitEngine<'tcx> for FulfillmentCtxt<'tcx> {
81
86
let mut has_changed = false ;
82
87
for obligation in mem:: take ( & mut self . obligations ) {
83
88
let goal = obligation. clone ( ) . into ( ) ;
84
- let ( changed, certainty, nested_goals) = match infcx. evaluate_root_goal ( goal) {
85
- Ok ( result) => result,
86
- Err ( NoSolution ) => {
87
- errors. push ( FulfillmentError {
88
- obligation : obligation. clone ( ) ,
89
- code : match goal. predicate . kind ( ) . skip_binder ( ) {
90
- ty:: PredicateKind :: Clause ( ty:: Clause :: Projection ( _) ) => {
91
- FulfillmentErrorCode :: CodeProjectionError (
92
- // FIXME: This could be a `Sorts` if the term is a type
93
- MismatchedProjectionTypes { err : TypeError :: Mismatch } ,
94
- )
95
- }
96
- ty:: PredicateKind :: AliasRelate ( _, _, _) => {
97
- FulfillmentErrorCode :: CodeProjectionError (
98
- MismatchedProjectionTypes { err : TypeError :: Mismatch } ,
99
- )
100
- }
101
- ty:: PredicateKind :: Subtype ( pred) => {
102
- let ( a, b) = infcx. instantiate_binder_with_placeholders (
103
- goal. predicate . kind ( ) . rebind ( ( pred. a , pred. b ) ) ,
104
- ) ;
105
- let expected_found = ExpectedFound :: new ( true , a, b) ;
106
- FulfillmentErrorCode :: CodeSubtypeError (
107
- expected_found,
108
- TypeError :: Sorts ( expected_found) ,
109
- )
110
- }
111
- ty:: PredicateKind :: Coerce ( pred) => {
112
- let ( a, b) = infcx. instantiate_binder_with_placeholders (
113
- goal. predicate . kind ( ) . rebind ( ( pred. a , pred. b ) ) ,
114
- ) ;
115
- let expected_found = ExpectedFound :: new ( false , a, b) ;
116
- FulfillmentErrorCode :: CodeSubtypeError (
117
- expected_found,
118
- TypeError :: Sorts ( expected_found) ,
119
- )
120
- }
121
- ty:: PredicateKind :: Clause ( _)
122
- | ty:: PredicateKind :: ObjectSafe ( _)
123
- | ty:: PredicateKind :: ClosureKind ( _, _, _)
124
- | ty:: PredicateKind :: Ambiguous => {
125
- FulfillmentErrorCode :: CodeSelectionError (
126
- SelectionError :: Unimplemented ,
127
- )
128
- }
129
- ty:: PredicateKind :: ConstEquate ( ..)
130
- | ty:: PredicateKind :: TypeWellFormedFromEnv ( _) => {
131
- bug ! ( "unexpected goal: {goal:?}" )
132
- }
133
- } ,
134
- root_obligation : obligation,
135
- } ) ;
136
- continue ;
137
- }
138
- } ;
89
+ let ( changed, certainty, nested_goals) =
90
+ match infcx. evaluate_root_goal ( goal, GenerateProofTree :: No ) . 0 {
91
+ Ok ( result) => result,
92
+ Err ( NoSolution ) => {
93
+ errors. push ( FulfillmentError {
94
+ obligation : obligation. clone ( ) ,
95
+ code : match goal. predicate . kind ( ) . skip_binder ( ) {
96
+ ty:: PredicateKind :: Clause ( ty:: Clause :: Projection ( _) ) => {
97
+ FulfillmentErrorCode :: CodeProjectionError (
98
+ // FIXME: This could be a `Sorts` if the term is a type
99
+ MismatchedProjectionTypes { err : TypeError :: Mismatch } ,
100
+ )
101
+ }
102
+ ty:: PredicateKind :: AliasRelate ( _, _, _) => {
103
+ FulfillmentErrorCode :: CodeProjectionError (
104
+ MismatchedProjectionTypes { err : TypeError :: Mismatch } ,
105
+ )
106
+ }
107
+ ty:: PredicateKind :: Subtype ( pred) => {
108
+ let ( a, b) = infcx. instantiate_binder_with_placeholders (
109
+ goal. predicate . kind ( ) . rebind ( ( pred. a , pred. b ) ) ,
110
+ ) ;
111
+ let expected_found = ExpectedFound :: new ( true , a, b) ;
112
+ FulfillmentErrorCode :: CodeSubtypeError (
113
+ expected_found,
114
+ TypeError :: Sorts ( expected_found) ,
115
+ )
116
+ }
117
+ ty:: PredicateKind :: Coerce ( pred) => {
118
+ let ( a, b) = infcx. instantiate_binder_with_placeholders (
119
+ goal. predicate . kind ( ) . rebind ( ( pred. a , pred. b ) ) ,
120
+ ) ;
121
+ let expected_found = ExpectedFound :: new ( false , a, b) ;
122
+ FulfillmentErrorCode :: CodeSubtypeError (
123
+ expected_found,
124
+ TypeError :: Sorts ( expected_found) ,
125
+ )
126
+ }
127
+ ty:: PredicateKind :: Clause ( _)
128
+ | ty:: PredicateKind :: ObjectSafe ( _)
129
+ | ty:: PredicateKind :: ClosureKind ( _, _, _)
130
+ | ty:: PredicateKind :: Ambiguous => {
131
+ FulfillmentErrorCode :: CodeSelectionError (
132
+ SelectionError :: Unimplemented ,
133
+ )
134
+ }
135
+ ty:: PredicateKind :: ConstEquate ( ..)
136
+ | ty:: PredicateKind :: TypeWellFormedFromEnv ( _) => {
137
+ bug ! ( "unexpected goal: {goal:?}" )
138
+ }
139
+ } ,
140
+ root_obligation : obligation,
141
+ } ) ;
142
+ continue ;
143
+ }
144
+ } ;
139
145
// Push any nested goals that we get from unifying our canonical response
140
146
// with our obligation onto the fulfillment context.
141
147
self . obligations . extend ( nested_goals. into_iter ( ) . map ( |goal| {
0 commit comments