diff options
| author | Michael Goulet <michael@errs.io> | 2023-08-01 00:58:10 +0000 |
|---|---|---|
| committer | Michael Goulet <michael@errs.io> | 2023-08-01 23:10:38 +0000 |
| commit | 44be25d8a2262a77ada651f0129b0ea6f8cb4755 (patch) | |
| tree | 2419901bdd9653a8ce880bb51187bd04d853050c /compiler | |
| parent | 8696fa71b3ac0d8c468edc36502a304d38c7fd24 (diff) | |
| download | rust-44be25d8a2262a77ada651f0129b0ea6f8cb4755.tar.gz rust-44be25d8a2262a77ada651f0129b0ea6f8cb4755.zip | |
don't create a predicate for just a comparison
Diffstat (limited to 'compiler')
| -rw-r--r-- | compiler/rustc_ty_utils/src/ty.rs | 14 |
1 files changed, 10 insertions, 4 deletions
diff --git a/compiler/rustc_ty_utils/src/ty.rs b/compiler/rustc_ty_utils/src/ty.rs index 827df192e66..08c405dfbcc 100644 --- a/compiler/rustc_ty_utils/src/ty.rs +++ b/compiler/rustc_ty_utils/src/ty.rs @@ -58,11 +58,17 @@ fn sized_constraint_for_ty<'tcx>( // we know that `T` is Sized and do not need to check // it on the impl. - let Some(sized_trait) = tcx.lang_items().sized_trait() else { return vec![ty] }; - let sized_predicate = - ty::TraitRef::new(tcx, sized_trait, [ty]).without_const().to_predicate(tcx); + let Some(sized_trait_def_id) = tcx.lang_items().sized_trait() else { return vec![ty] }; let predicates = tcx.predicates_of(adtdef.did()).predicates; - if predicates.iter().any(|(p, _)| *p == sized_predicate) { vec![] } else { vec![ty] } + if predicates.iter().any(|(p, _)| { + p.as_trait_clause().is_some_and(|trait_pred| { + trait_pred.def_id() == sized_trait_def_id && trait_pred.self_ty().skip_binder() == ty + }) + }) { + vec![] + } else { + vec![ty] + } } Placeholder(..) | Bound(..) | Infer(..) => { |
