Skip to content

Commit ec2a6d1

Browse files
Apply fast path to old solver too
1 parent 6727471 commit ec2a6d1

File tree

2 files changed

+10
-2
lines changed

2 files changed

+10
-2
lines changed

compiler/rustc_trait_selection/src/traits/fulfill.rs

Lines changed: 6 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -12,7 +12,7 @@ use rustc_middle::bug;
1212
use rustc_middle::ty::abstract_const::NotConstEvaluatable;
1313
use rustc_middle::ty::error::{ExpectedFound, TypeError};
1414
use rustc_middle::ty::{self, Binder, Const, GenericArgsRef, TypeVisitableExt, TypingMode};
15-
use thin_vec::ThinVec;
15+
use thin_vec::{ThinVec, thin_vec};
1616
use tracing::{debug, debug_span, instrument};
1717

1818
use super::effects::{self, HostEffectObligation};
@@ -336,7 +336,7 @@ impl<'a, 'tcx> ObligationProcessor for FulfillProcessor<'a, 'tcx> {
336336
let infcx = self.selcx.infcx;
337337

338338
if sizedness_fast_path(infcx.tcx, obligation.predicate) {
339-
return ProcessResult::Changed(thin_vec::thin_vec![]);
339+
return ProcessResult::Changed(thin_vec![]);
340340
}
341341

342342
if obligation.predicate.has_aliases() {
@@ -541,6 +541,10 @@ impl<'a, 'tcx> ObligationProcessor for FulfillProcessor<'a, 'tcx> {
541541
}
542542

543543
ty::PredicateKind::Clause(ty::ClauseKind::WellFormed(term)) => {
544+
if term.is_trivially_wf(self.selcx.tcx()) {
545+
return ProcessResult::Changed(thin_vec![]);
546+
}
547+
544548
match wf::obligations(
545549
self.selcx.infcx,
546550
obligation.param_env,

compiler/rustc_trait_selection/src/traits/select/mod.rs

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -660,6 +660,10 @@ impl<'cx, 'tcx> SelectionContext<'cx, 'tcx> {
660660
}
661661

662662
ty::PredicateKind::Clause(ty::ClauseKind::WellFormed(term)) => {
663+
if term.is_trivially_wf(self.tcx()) {
664+
return Ok(EvaluatedToOk);
665+
}
666+
663667
// So, there is a bit going on here. First, `WellFormed` predicates
664668
// are coinductive, like trait predicates with auto traits.
665669
// This means that we need to detect if we have recursively

0 commit comments

Comments
 (0)