@@ -127,33 +127,32 @@ where
127
127
goal : Goal < I , Self > ,
128
128
assumption : I :: Clause ,
129
129
) -> Result < ( ) , NoSolution > {
130
- if let Some ( trait_clause) = assumption. as_trait_clause ( ) {
131
- if trait_clause. polarity ( ) != goal. predicate . polarity {
132
- return Err ( NoSolution ) ;
133
- }
134
-
135
- if trait_clause. def_id ( ) == goal. predicate . def_id ( ) {
136
- if DeepRejectCtxt :: relate_rigid_rigid ( ecx. cx ( ) ) . args_may_unify (
137
- goal. predicate . trait_ref . args ,
138
- trait_clause. skip_binder ( ) . trait_ref . args ,
139
- ) {
140
- return Ok ( ( ) ) ;
141
- }
142
- }
143
-
130
+ fn trait_def_id_matches < I : Interner > (
131
+ cx : I ,
132
+ clause_def_id : I :: DefId ,
133
+ goal_def_id : I :: DefId ,
134
+ ) -> bool {
135
+ clause_def_id == goal_def_id
144
136
// PERF(sized-hierarchy): Sizedness supertraits aren't elaborated to improve perf, so
145
- // check for a `Sized` subtrait when looking for `MetaSized`. `PointeeSized` bounds
146
- // are syntactic sugar for a lack of bounds so don't need this.
147
- if ecx. cx ( ) . is_lang_item ( goal. predicate . def_id ( ) , TraitSolverLangItem :: MetaSized )
148
- && ecx. cx ( ) . is_lang_item ( trait_clause. def_id ( ) , TraitSolverLangItem :: Sized )
149
- {
150
- let meta_sized_clause =
151
- trait_predicate_with_def_id ( ecx. cx ( ) , trait_clause, goal. predicate . def_id ( ) ) ;
152
- return Self :: fast_reject_assumption ( ecx, goal, meta_sized_clause) ;
153
- }
137
+ // check for a `MetaSized` supertrait being matched against a `Sized` assumption.
138
+ //
139
+ // `PointeeSized` bounds are syntactic sugar for a lack of bounds so don't need this.
140
+ || ( cx. is_lang_item ( clause_def_id, TraitSolverLangItem :: Sized )
141
+ && cx. is_lang_item ( goal_def_id, TraitSolverLangItem :: MetaSized ) )
154
142
}
155
143
156
- Err ( NoSolution )
144
+ if let Some ( trait_clause) = assumption. as_trait_clause ( )
145
+ && trait_clause. polarity ( ) == goal. predicate . polarity
146
+ && trait_def_id_matches ( ecx. cx ( ) , trait_clause. def_id ( ) , goal. predicate . def_id ( ) )
147
+ && DeepRejectCtxt :: relate_rigid_rigid ( ecx. cx ( ) ) . args_may_unify (
148
+ goal. predicate . trait_ref . args ,
149
+ trait_clause. skip_binder ( ) . trait_ref . args ,
150
+ )
151
+ {
152
+ return Ok ( ( ) ) ;
153
+ } else {
154
+ Err ( NoSolution )
155
+ }
157
156
}
158
157
159
158
fn match_assumption (
0 commit comments