-
-
Notifications
You must be signed in to change notification settings - Fork 14.8k
[WIP] -Zhigher-ranked-assumptions-v2 #155887
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Draft
BoxyUwU
wants to merge
6
commits into
rust-lang:main
Choose a base branch
from
BoxyUwU:higher_ranked_assumptions_v2
base: main
Could not load branches
Branch not found: {{ refName }}
Loading
Could not load tags
Nothing to show
Loading
Are you sure you want to change the base?
Some commits from the old base branch may be removed from the timeline,
and old review comments may become outdated.
Draft
Changes from all commits
Commits
Show all changes
6 commits
Select commit
Hold shift + click to select a range
b90709a
add higher ranked assumptions v2 flag
BoxyUwU a4649b4
new region constraint representation
BoxyUwU 2bee929
compute and track assumptions on entered binders
BoxyUwU 48a0966
produce new region constraints
BoxyUwU 045c85f
destructure in root universe
BoxyUwU 02a859d
rewrite region constraints to smaller universes
BoxyUwU File filter
Filter by extension
Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
There are no files selected for viewing
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| Original file line number | Diff line number | Diff line change |
|---|---|---|
|
|
@@ -123,6 +123,9 @@ pub struct InferCtxtInner<'tcx> { | |
| /// region constraints would've been added. | ||
| region_constraint_storage: Option<RegionConstraintStorage<'tcx>>, | ||
|
|
||
| /// Used by the next solver when `-Zhigher-ranked-assumptions=v2` is set. | ||
| solver_region_constraint_storage: SolverRegionConstraintStorage<'tcx>, | ||
|
|
||
| /// A set of constraints that regionck must validate. | ||
| /// | ||
| /// Each constraint has the form `T:'a`, meaning "some type `T` must | ||
|
|
@@ -170,6 +173,7 @@ impl<'tcx> InferCtxtInner<'tcx> { | |
| float_unification_storage: Default::default(), | ||
| float_origin_origin_storage: Default::default(), | ||
| region_constraint_storage: Some(Default::default()), | ||
| solver_region_constraint_storage: SolverRegionConstraintStorage::new(), | ||
| region_obligations: Default::default(), | ||
| region_assumptions: Default::default(), | ||
| hir_typeck_potentially_region_dependent_goals: Default::default(), | ||
|
|
@@ -314,6 +318,16 @@ pub struct InferCtxt<'tcx> { | |
| /// bound. | ||
| universe: Cell<ty::UniverseIndex>, | ||
|
|
||
| /// List of assumed wellformed types which we can derive implied | ||
| /// bounds on a `for<...>` from. Only used unstabley and by the | ||
| /// new solver. | ||
| universe_assumptions_for_next_solver: RefCell< | ||
|
Member
Author
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. maybe should be in InferCtxtInner instead but also having it next to |
||
| FxIndexMap< | ||
| ty::UniverseIndex, | ||
| Option<rustc_type_ir::region_constraint::Assumptions<TyCtxt<'tcx>>>, | ||
| >, | ||
| >, | ||
|
|
||
| next_trait_solver: bool, | ||
|
|
||
| pub obligation_inspector: Cell<Option<ObligationInspector<'tcx>>>, | ||
|
|
@@ -606,6 +620,7 @@ impl<'tcx> InferCtxtBuilder<'tcx> { | |
| reported_signature_mismatch: Default::default(), | ||
| tainted_by_errors: Cell::new(None), | ||
| universe: Cell::new(ty::UniverseIndex::ROOT), | ||
| universe_assumptions_for_next_solver: RefCell::new(Default::default()), | ||
| next_trait_solver, | ||
| obligation_inspector: Cell::new(None), | ||
| } | ||
|
|
@@ -1721,3 +1736,46 @@ impl<'tcx> InferCtxt<'tcx> { | |
| } | ||
| } | ||
| } | ||
|
|
||
| type SolverRegionConstraint<'tcx> = | ||
| rustc_type_ir::region_constraint::RegionConstraint<TyCtxt<'tcx>>; | ||
|
|
||
| #[derive(Clone, Debug)] | ||
| struct SolverRegionConstraintStorage<'tcx>(SolverRegionConstraint<'tcx>); | ||
|
|
||
| impl<'tcx> SolverRegionConstraintStorage<'tcx> { | ||
| fn new() -> Self { | ||
| SolverRegionConstraintStorage(SolverRegionConstraint::And(Box::new([]))) | ||
| } | ||
|
|
||
| fn get_constraint(&self) -> SolverRegionConstraint<'tcx> { | ||
| self.0.clone() | ||
| } | ||
|
|
||
| fn pop(&mut self) -> Option<SolverRegionConstraint<'tcx>> { | ||
| match &mut self.0 { | ||
| SolverRegionConstraint::And(and) => { | ||
| let mut and = core::mem::take(and).into_iter().collect::<Vec<_>>(); | ||
| let popped = and.pop()?; | ||
| self.0 = SolverRegionConstraint::And(and.into_boxed_slice()); | ||
| Some(popped) | ||
| } | ||
| _ => unreachable!(), | ||
| } | ||
| } | ||
|
|
||
| #[instrument(level = "debug")] | ||
| fn push(&mut self, constraint: SolverRegionConstraint<'tcx>) { | ||
| match &mut self.0 { | ||
| SolverRegionConstraint::And(and) => { | ||
| let and = core::mem::take(and) | ||
| .into_iter() | ||
| .chain([constraint]) | ||
| .collect::<Vec<_>>() | ||
| .into_boxed_slice(); | ||
| self.0 = SolverRegionConstraint::And(and); | ||
| } | ||
| _ => unreachable!(), | ||
| } | ||
| } | ||
| } | ||
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Oops, something went wrong.
Oops, something went wrong.
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
Uh oh!
There was an error while loading. Please reload this page.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
typo (and in many other places i say solve not solver)
View changes since the review