Skip to content
Draft
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
10 changes: 10 additions & 0 deletions compiler/rustc_infer/src/infer/outlives/mod.rs
Original file line number Diff line number Diff line change
Expand Up @@ -32,6 +32,16 @@ pub fn explicit_outlives_bounds<'tcx>(
}

impl<'tcx> InferCtxt<'tcx> {
pub fn has_pending_region_state(&self) -> bool {
let inner = self.inner.borrow();
!inner.region_obligations.is_empty()
|| !inner.region_assumptions.is_empty()
|| inner
.region_constraint_storage
.as_ref()
.is_none_or(|storage| !storage.data.is_empty())
}

/// Process the region constraints and return any errors that
/// result. After this, no more unification operations should be
/// done -- or the compiler will panic -- but it is legal to use
Expand Down
13 changes: 13 additions & 0 deletions compiler/rustc_trait_selection/src/traits/query/type_op/mod.rs
Original file line number Diff line number Diff line change
Expand Up @@ -134,6 +134,19 @@ where
root_def_id: LocalDefId,
span: Span,
) -> Result<TypeOpOutput<'tcx, Self>, ErrorGuaranteed> {
if !infcx.next_trait_solver()
&& !infcx.disable_trait_solver_fast_paths()
&& !infcx.in_snapshot()
&& let Some(output) = Q::try_fast_path(infcx.tcx, &self)
&& !infcx.has_pending_region_state()
{
return Ok(TypeOpOutput {
output: infcx.deeply_resolve_ignoring_regions(output),
constraints: None,
error_info: None,
});
}

let mut error_info = None;
let mut region_constraints = QueryRegionConstraints::default();

Expand Down