File tree Expand file tree Collapse file tree 1 file changed +21
-10
lines changed
compiler/rustc_typeck/src/check Expand file tree Collapse file tree 1 file changed +21
-10
lines changed Original file line number Diff line number Diff line change @@ -1205,16 +1205,27 @@ pub fn check_type_bounds<'tcx>(
12051205 // ParamEnv for normalization specifically.
12061206 let normalize_param_env = {
12071207 let mut predicates = param_env. caller_bounds ( ) . iter ( ) . collect :: < Vec < _ > > ( ) ;
1208- predicates. push (
1209- ty:: Binder :: dummy ( ty:: ProjectionPredicate {
1210- projection_ty : ty:: ProjectionTy {
1211- item_def_id : trait_ty. def_id ,
1212- substs : rebased_substs,
1213- } ,
1214- ty : impl_ty_value,
1215- } )
1216- . to_predicate ( tcx) ,
1217- ) ;
1208+ match impl_ty_value. kind ( ) {
1209+ ty:: Projection ( proj)
1210+ if proj. item_def_id == trait_ty. def_id && proj. substs == rebased_substs =>
1211+ {
1212+ // Don't include this predicate if the projected type is
1213+ // exactly the same as the projection. This can occur in
1214+ // (somewhat dubious) code like this:
1215+ //
1216+ // impl<T> X for T where T: X { type Y = <T as X>::Y; }
1217+ }
1218+ _ => predicates. push (
1219+ ty:: Binder :: dummy ( ty:: ProjectionPredicate {
1220+ projection_ty : ty:: ProjectionTy {
1221+ item_def_id : trait_ty. def_id ,
1222+ substs : rebased_substs,
1223+ } ,
1224+ ty : impl_ty_value,
1225+ } )
1226+ . to_predicate ( tcx) ,
1227+ ) ,
1228+ } ;
12181229 ty:: ParamEnv :: new ( tcx. intern_predicates ( & predicates) , Reveal :: UserFacing )
12191230 } ;
12201231
You can’t perform that action at this time.
0 commit comments