-Znext-solver Ignore region constraints from the nested goals in leakcheck#155749
-Znext-solver Ignore region constraints from the nested goals in leakcheck#155749rust-bors[bot] merged 1 commit intorust-lang:mainfrom
-Znext-solver Ignore region constraints from the nested goals in leakcheck#155749Conversation
-Znext-solver Ignore region constraints from the nested goals in leakcheck
589add8 to
e4719c4
Compare
This comment has been minimized.
This comment has been minimized.
e2650aa to
54588cf
Compare
Canonicalize free regions from inputs as placeholders in root univ Context: The box named *coroutine witness Send lifetime requirements now considered by leakcheck* [this roadmap](https://raw.githubusercontent.com/hexcatnl/roadmap/e380fef94b47c02a056b4c8f05124a9db475b990/next-solver.svg) Fixes (only for the next-solver) #106569 Prerequisite of #155749
Canonicalize free regions from inputs as placeholders in root univ Context: The box named *coroutine witness Send lifetime requirements now considered by leakcheck* [this roadmap](https://raw.githubusercontent.com/hexcatnl/roadmap/e380fef94b47c02a056b4c8f05124a9db475b990/next-solver.svg) Fixes (only for the next-solver) #106569 Prerequisite of #155749
This comment has been minimized.
This comment has been minimized.
54588cf to
29dab0f
Compare
|
r? lcnr |
|
This PR changes a file inside Some changes occurred to the core trait solver cc @rust-lang/initiative-trait-system-refactor changes to the core type system cc @lcnr |
| .for_each(|c| each_edge(c.sub, c.sup)); | ||
| region_constraints.data().constraints[i].0.iter_outlives().for_each( | ||
| |Constraint { kind: _, sub, sup, visible_for_leak_check }| { | ||
| each_edge(sub, sup, visible_for_leak_check) |
There was a problem hiding this comment.
maybe don't even provide any constraints that are not visible to leak hceck to each_edge, feels cleaner to me,
i.e.
| each_edge(sub, sup, visible_for_leak_check) | |
| match visible_for_leak_check { | |
| ty::VisibleForLeakCheck::Yes => | |
| each_edge(sub, sup), | |
| ty::VisibleForLeakCheck::No => {} | |
| } | |
| pub type QueryRegionConstraint<'tcx> = | ||
| (ty::RegionConstraint<'tcx>, ConstraintCategory<'tcx>, ty::VisibleForLeakCheck); |
There was a problem hiding this comment.
not in this PR, but mind adding a FIXME: Convert this into a struct
| // We ignore constraints from the nested goals in leak check. This is to match | ||
| // with the old solver's behavior, which has separated evaluation and fulfillment, | ||
| // and the former doesn't consider outlives obligations from the later. | ||
| let vis = if is_root_goal { |
There was a problem hiding this comment.
why special-case root goals here?
There was a problem hiding this comment.
I thought that we should only ignore region constraints from nested goals and if I mark them as VisibleForLeakCheck::No for root goals as well, they would be so in the InferCtxt outside of the solver and then ignored from the leak check for other goals as well, but after thinking twice, they wouldn't cause universe leaks in other goals anyway 😅 Yeah, so might be okay to remove the spacial casing here
| .into_iter() | ||
| .filter(|&(outlives, _)| seen.insert(outlives)) | ||
| .map(|(outlives, _)| outlives) | ||
| .filter(|&(outlives, _, vis)| seen.insert((outlives, vis))) |
There was a problem hiding this comment.
this may cause us to end up with the same constraint with vis: Yes and vis: No 🤔 I guess it's fine as long as that doesn't cause issues
There was a problem hiding this comment.
I did this deliberately as we could already have the same constraints with different visibilities without this and if that would be the case, the resulting visibility would be order-dependent 🤔
There was a problem hiding this comment.
could eagerly collect into a list, and use a hashmap pointing to the index of the element, on a hit we Or the visibility
| t1, | ||
| r2, | ||
| constraint_category, | ||
| ty::VisibleForLeakCheck::Yes, |
There was a problem hiding this comment.
slightly concerning 🤔
how hard is it to pass VisibleForLeakCheck to here?
There was a problem hiding this comment.
I guess it wouldn't be that hard but I thought visibilities are not real concerns here in borrowck
There was a problem hiding this comment.
they are not 😅 I would love us to somehow defensively guard against this... as rn u need to globally reason about this code for whether it's correct
what do you think you make it into a three-state enum with Yes, No, Unreachable and have the leak_check ICE when encountering Unreachable
There was a problem hiding this comment.
Ah, yes, such global context would be very confusing and fragile to future changes 😅 That would be more desirable 👍
| ty: Ty<'tcx>, | ||
| region: ty::Region<'tcx>, | ||
| category: ConstraintCategory<'tcx>, | ||
| vis: ty::VisibleForLeakCheck, |
There was a problem hiding this comment.
components_must_outlive can always be ty::VisibleForLeakcheck::No/ for TypeOutlives in general 🤔
There was a problem hiding this comment.
I guess they might be decomposed into RegionOutlivesPredicate with component-wise thingy. Would it be okay?
There was a problem hiding this comment.
it matches the old solver which currently never considers type outlives in the leak check 🤔
There was a problem hiding this comment.
but also, we only ever use this in places which won't ever leak check anymore, so 🤷
There was a problem hiding this comment.
Maybe we could try VisibleForLeakCheck::Unreachable here as well?
29dab0f to
cff8c42
Compare
|
This PR was rebased onto a different main commit. Here's a range-diff highlighting what actually changed. Rebasing is a normal part of keeping PRs up to date, so no action is needed—this note is just to help reviewers. |
cff8c42 to
7be9fb6
Compare
| _constraint_category: ConstraintCategory<'tcx>, | ||
| ) { | ||
| self.sub_regions(origin, a, b) | ||
| // We don't do leak check in borrowck |
There was a problem hiding this comment.
That one is for lexical region resolution, not borrowck afaik
There was a problem hiding this comment.
There were one occurence of this in borrowck while I was working on but it became non-neceessary after that, but I was confused by thinking something like "hmm, there were one of these in borrowck" 😅
There was a problem hiding this comment.
yes, this is the implementation used outside of borrowck ,borrowck has a separate impl :3
| let mut constraints = vec![]; | ||
| let mut visibilities = vec![]; |
There was a problem hiding this comment.
why two Vec instead of storing it as a tuple right away and returning that one
| (VisibleForLeakCheck::Unreachable, VisibleForLeakCheck::Unreachable) => { | ||
| VisibleForLeakCheck::Unreachable | ||
| } |
There was a problem hiding this comment.
I would have Unreachable overwrite Yes because it acts more like an Option<VisibleForLeakCheck> 🤔
| @@ -0,0 +1,43 @@ | |||
| //@ check-pass | |||
| //@ compile-flags: -Znext-solver=globally | |||
There was a problem hiding this comment.
can you use revisions in these tests?
7be9fb6 to
961abdd
Compare
Yeah, the initial draft for this couldn't even compile |
| impl VisibleForLeakCheck { | ||
| pub fn and(self, other: VisibleForLeakCheck) -> VisibleForLeakCheck { | ||
| match (self, other) { | ||
| // Make sure that we never overwrite the constraints shouldn't be leak checked |
There was a problem hiding this comment.
| // Make sure that we never overwrite the constraints shouldn't be leak checked | |
| // Make sure that we never overwrite that constraints shouldn't | |
| // be encountered by the leak checked |
|
|
||
| pub fn or(self, other: VisibleForLeakCheck) -> VisibleForLeakCheck { | ||
| match (self, other) { | ||
| // Make sure that we never overwrite the constraints shouldn't be leak checked |
There was a problem hiding this comment.
| // Make sure that we never overwrite the constraints shouldn't be leak checked | |
| // Make sure that we never overwrite that constraints shouldn't | |
| // be encountered by the leak checked |
| // This previously caused an ICE due to a non–well-formed coroutine | ||
| // hidden type failing the leak check in the next-solver. |
There was a problem hiding this comment.
| // This previously caused an ICE due to a non–well-formed coroutine | |
| // hidden type failing the leak check in the next-solver. | |
| // This previously caused an ICE due to a non–well-formed opaque type | |
| // in a coroutine witness failing the leak check in the next-solver. |
| // This previously caused an ICE due to a non–well-formed coroutine | ||
| // hidden type failing the leak check in the next-solver. |
There was a problem hiding this comment.
you have either
- coroutine witness type
- or opaque type hidden type
coroutines don't have hidden types :>
| // Regression test for <https://github.com/rust-lang/trait-system-refactor-initiative/issues/251>. | ||
| // | ||
| // This previously caused an ICE due to a non–well-formed coroutine | ||
| // hidden type failing the leak check in the next-solver. |
There was a problem hiding this comment.
same here
961abdd to
e43a1b5
Compare
|
@bors r=lcnr |
Rollup of 4 pull requests Successful merges: - #154571 (Fix alias path for rustdoc) - #155749 (`-Znext-solver` Ignore region constraints from the nested goals in leakcheck) - #156026 (`bufreader::Buffer`: Remove leftover note about `initialized` field) - #156063 (Map `WSAESHUTDOWN` to `io::ErrorKind::BrokenPipe`)
Rollup merge of #155749 - ShoyuVanilla:leakcheck-vis, r=lcnr `-Znext-solver` Ignore region constraints from the nested goals in leakcheck Fixes rust-lang/trait-system-refactor-initiative#251 Fixes #140577 Fixes #153596
View all comments
Fixes rust-lang/trait-system-refactor-initiative#251
Fixes #140577
Fixes #153596