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

enforce scope shadowing statically with an extra phantom lifetime #13

Merged
merged 1 commit into from
Oct 31, 2015

Conversation

dherman
Copy link
Collaborator

@dherman dherman commented Oct 30, 2015

Fixes #11.

This API change tracks an additional lifetime parameter on a Scope representing the block in which the scope appears, and makes all the allocation API's require an &mut pointer to the scope. The nesting methods then freeze an outer scope so the allocation methods are statically prevented from using it while frozen. But because the allocation methods return a handle tied to the extra block lifetime, rather than the lifetime of the scope pointer itself, multiple allocations within a single block do not cause spurious borrow checker errors.

The net effect is that allocations do not require a dynamic check to enforce that they are not being performed on a Scope that is currently shadowed.

@dherman dherman force-pushed the static-scope-shadowing-restriction branch from fa5d4ca to fdbdf30 Compare October 31, 2015 00:10
@dherman dherman force-pushed the static-scope-shadowing-restriction branch from fdbdf30 to ebc8722 Compare October 31, 2015 00:11
dherman pushed a commit that referenced this pull request Oct 31, 2015
enforce scope shadowing statically with an extra phantom lifetime
@dherman dherman merged commit 89f24a8 into master Oct 31, 2015
@dherman dherman deleted the static-scope-shadowing-restriction branch November 12, 2015 07:42
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.

1 participant