Skip to content

Commit 0faf7fb

Browse files
committed
compare_impl_method: Make trait predicate filter specific to Self
1 parent edeb9c4 commit 0faf7fb

File tree

1 file changed

+10
-3
lines changed

1 file changed

+10
-3
lines changed

src/librustc_typeck/check/compare_method.rs

+10-3
Original file line numberDiff line numberDiff line change
@@ -188,10 +188,17 @@ fn compare_predicate_entailment<'a, 'tcx>(tcx: TyCtxt<'a, 'tcx, 'tcx>,
188188
match pred {
189189
ty::Predicate::Trait(trait_ref) => {
190190
if trait_ref.def_id() == trait_def_id {
191-
false
192-
} else {
193-
true
191+
use ty::TypeVariants::TyParam;
192+
if let TyParam(param) = trait_ref.skip_binder().self_ty().sty {
193+
if param.is_self() {
194+
debug!(
195+
"compare_impl_method: removing `{:?}` from trait_m_predicates",
196+
pred);
197+
return false;
198+
}
199+
}
194200
}
201+
true
195202
}
196203
_ => true
197204
}

0 commit comments

Comments
 (0)