diff options
| author | Jacob Pratt <jacob@jhpratt.dev> | 2025-07-04 05:47:24 +0200 |
|---|---|---|
| committer | GitHub <noreply@github.com> | 2025-07-04 05:47:24 +0200 |
| commit | 9de211b95ab35d99c1cc52aaaddd37fbbd90d4b7 (patch) | |
| tree | 90473eb2d6ecc0d5ab75a645a7ae4bb33edabbd2 /compiler/rustc_trait_selection/src | |
| parent | 826d4bc858a323d51c6bcd98a5b2076cdb651435 (diff) | |
| parent | 91c53c97a990e9d1ab87b2d932362a53236fba49 (diff) | |
Rollup merge of #143307 - compiler-errors:fast-path-nitpicks, r=lcnr
Fast path nitpicks Miscellaneous commits that I didn't really want to fold into anything else. Fixes one theoretical bug with the fast path not considering polarity for `T: !Sized` bounds.
Diffstat (limited to 'compiler/rustc_trait_selection/src')
| -rw-r--r-- | compiler/rustc_trait_selection/src/traits/query/type_op/prove_predicate.rs | 14 | ||||
| -rw-r--r-- | compiler/rustc_trait_selection/src/traits/util.rs | 7 |
2 files changed, 6 insertions, 15 deletions
diff --git a/compiler/rustc_trait_selection/src/traits/query/type_op/prove_predicate.rs b/compiler/rustc_trait_selection/src/traits/query/type_op/prove_predicate.rs index 18971c47831..22eeb285b37 100644 --- a/compiler/rustc_trait_selection/src/traits/query/type_op/prove_predicate.rs +++ b/compiler/rustc_trait_selection/src/traits/query/type_op/prove_predicate.rs @@ -21,19 +21,9 @@ impl<'tcx> super::QueryTypeOp<'tcx> for ProvePredicate<'tcx> { if let ty::PredicateKind::Clause(ty::ClauseKind::WellFormed(term)) = key.value.predicate.kind().skip_binder() + && term.is_trivially_wf(tcx) { - match term.as_type()?.kind() { - ty::Param(_) - | ty::Bool - | ty::Char - | ty::Int(_) - | ty::Float(_) - | ty::Str - | ty::Uint(_) => { - return Some(()); - } - _ => {} - } + return Some(()); } None diff --git a/compiler/rustc_trait_selection/src/traits/util.rs b/compiler/rustc_trait_selection/src/traits/util.rs index a05bae53566..141454bfe37 100644 --- a/compiler/rustc_trait_selection/src/traits/util.rs +++ b/compiler/rustc_trait_selection/src/traits/util.rs @@ -368,16 +368,17 @@ pub fn sizedness_fast_path<'tcx>(tcx: TyCtxt<'tcx>, predicate: ty::Predicate<'tc // Proving `Sized`/`MetaSized`, very often on "obviously sized" types like // `&T`, accounts for about 60% percentage of the predicates we have to prove. No need to // canonicalize and all that for such cases. - if let ty::PredicateKind::Clause(ty::ClauseKind::Trait(trait_ref)) = + if let ty::PredicateKind::Clause(ty::ClauseKind::Trait(trait_pred)) = predicate.kind().skip_binder() + && trait_pred.polarity == ty::PredicatePolarity::Positive { - let sizedness = match tcx.as_lang_item(trait_ref.def_id()) { + let sizedness = match tcx.as_lang_item(trait_pred.def_id()) { Some(LangItem::Sized) => SizedTraitKind::Sized, Some(LangItem::MetaSized) => SizedTraitKind::MetaSized, _ => return false, }; - if trait_ref.self_ty().has_trivial_sizedness(tcx, sizedness) { + if trait_pred.self_ty().has_trivial_sizedness(tcx, sizedness) { debug!("fast path -- trivial sizedness"); return true; } |
