Skip to content
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

Add a vars_since_snapshot method to UnificationTable #21

Merged
merged 5 commits into from
Mar 22, 2019

Conversation

varkor
Copy link
Member

@varkor varkor commented Mar 20, 2019

Follow up to #19.

Adds UnificationTable::vars_since_snapshot, making UnificationStore::values_since_snapshot accessible publicly.

Also do a little refactoring to clean things up.

These changes are necessary for refactoring in rustc. Apologies for not making these changes at the same time: I didn't previously test the new version of ena in rustc. I've integrated these changes in a local branch of rustc, so this should be the last change.

@varkor
Copy link
Member Author

varkor commented Mar 21, 2019

@eddyb suggested a cleaner API, so I'm going to update this PR soon accordingly.

Edit: I've updated the API.

src/unify/mod.rs Outdated
snapshot: &Snapshot<S>,
) -> impl Iterator<Item = S::Key> + '_ {
self.values.values_since_snapshot(&snapshot.snapshot).map(move |idx| {
self.values[idx].parent
Copy link
Member

@eddyb eddyb Mar 21, 2019

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Wait, this is wrong, isn't it? parent is (I think) the unification parent, which would mean this method may return variables older than the snapshot, and may miss some of the newer variables (which, while unified in the unification table, may still be found in values that haven't been normalized since the unification).

You should probably return Range<S::Key> by using UnifyKey::from_index, AFAICT (look for other uses of from_index - I assume some u32 check may be involved?)

Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

@nikomatsakis Why doesn't ena rely entirely on usize and leave u32 (or smaller) key handling to the users?

Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Convenience for end-users, I guess. But I think the code you highlighted here @eddyb is outdated, no?

@varkor varkor changed the title Add a vars_since_snapshot method to UnificationTable [Do not merge] Add a vars_since_snapshot method to UnificationTable Mar 21, 2019
@varkor varkor changed the title [Do not merge] Add a vars_since_snapshot method to UnificationTable Add a vars_since_snapshot method to UnificationTable Mar 22, 2019
@nikomatsakis nikomatsakis merged commit 7ad2655 into rust-lang:master Mar 22, 2019
@crlf0710 crlf0710 mentioned this pull request Mar 23, 2019
@varkor varkor deleted the vars_since_snapshot branch March 23, 2019 12:51
bors added a commit to rust-lang/rust that referenced this pull request Mar 27, 2019
Refactor InferenceFudger (née RegionFudger)

- Rename `RegionFudger` (and related methods) to `InferenceFudger`.
- Take integer and float inference variables into account.
- Refactor `types_created_since_snapshot` and `vars_created_since_snapshot` with the [new version of ena](rust-lang/ena#21).
- Some other refactoring in the area.

r? @eddyb
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

3 participants