Skip to content
Merged
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
4 changes: 4 additions & 0 deletions compiler/rustc_infer/src/infer/outlives/obligations.rs
Original file line number Diff line number Diff line change
Expand Up @@ -170,6 +170,10 @@ impl<'tcx> InferCtxt<'tcx> {
std::mem::take(&mut self.inner.borrow_mut().region_obligations)
}

pub fn clone_registered_region_obligations(&self) -> Vec<TypeOutlivesConstraint<'tcx>> {
self.inner.borrow().region_obligations.clone()
}

pub fn register_region_assumption(&self, assumption: ty::ArgOutlivesPredicate<'tcx>) {
let mut inner = self.inner.borrow_mut();
inner.undo_log.push(UndoLog::PushRegionAssumption);
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -55,6 +55,12 @@ pub fn compute_implied_outlives_bounds_inner<'tcx>(
span: Span,
disable_implied_bounds_hack: bool,
) -> Result<Vec<OutlivesBound<'tcx>>, NoSolution> {
// Inside mir borrowck, each computation starts with an empty list.
assert!(
ocx.infcx.inner.borrow().region_obligations().is_empty(),
"compute_implied_outlives_bounds assumes region obligations are empty before starting"
);

let normalize_ty = |ty| -> Result<_, NoSolution> {
// We must normalize the type so we can compute the right outlives components.
// for example, if we have some constrained param type like `T: Trait<Out = U>`,
Expand Down Expand Up @@ -143,7 +149,7 @@ pub fn compute_implied_outlives_bounds_inner<'tcx>(
&& ty.visit_with(&mut ContainsBevyParamSet { tcx: ocx.infcx.tcx }).is_break()
{
for TypeOutlivesConstraint { sup_type, sub_region, .. } in
ocx.infcx.take_registered_region_obligations()
ocx.infcx.clone_registered_region_obligations()
{
let mut components = smallvec![];
push_outlives_components(ocx.infcx.tcx, sup_type, &mut components);
Expand Down
6 changes: 4 additions & 2 deletions tests/ui/implied-bounds/bevy_world_query.rs
Original file line number Diff line number Diff line change
@@ -1,6 +1,8 @@
#![crate_name = "bevy_ecs"]

//@ check-pass
//@ revisions: current next
//@ ignore-compare-mode-next-solver (explicit revisions)
//@[next] compile-flags: -Znext-solver
#![crate_name = "bevy_ecs"]

// We currently special case bevy from erroring on incorrect implied bounds
// from normalization (issue #109628).
Expand Down
Loading