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

Encode more precise scoping rules for function params #24021

Merged
merged 3 commits into from
Apr 8, 2015

Conversation

pnkfelix
Copy link
Member

@pnkfelix pnkfelix commented Apr 3, 2015

Encode more precise scoping rules for function params

Function params outlive everything in the body (incl temporaries). Thus if we assign them their own CodeExtent, the region inference can properly show that it is sound to have temporaries with destructors that reference the parameters (because such temporaries will be dropped before the parameters are dropped).

Fix #23338

@rust-highfive
Copy link
Collaborator

r? @huonw

(rust_highfive has picked a reviewer for you, use r? to override)

@pnkfelix
Copy link
Member Author

pnkfelix commented Apr 3, 2015

r? @nikomatsakis

(note I have not yet done a full make check locally, so those test cases have not been fully vetted yet against our infrastructure.)

@pnkfelix
Copy link
Member Author

pnkfelix commented Apr 3, 2015

make tidy fails due to the TODO that is sitting there.

and one of the tests got caught on a pretty printer bug, so I put in a workaround for that.

But once I fix the TODO (after I first try out what it suggests), this should be ready for landing (assuming it passes muster according to human review).

Function params which outlive everything in the body (incl
temporaries).  Thus if we assign them their own `CodeExtent`, the
region inference can properly show that it is sound to have
temporaries with destructors that reference the parameters (because
such temporaries will be dropped before the parameters are).

This allows us to address issue 23338 in a clean way.

As a drive-by, fix a mistake in the tyencode for
`CodeExtent::BlockRemainder`.
We ignore pretty for the params-outlive-temps-of-body test because the
way its comments are formatted exercises a known bug in the pretty
printer.
@pnkfelix
Copy link
Member Author

pnkfelix commented Apr 4, 2015

Okay everything checks out; I ran make check successfully and then squashed the commits; this should be ready to land whenever.

@nikomatsakis
Copy link
Contributor

r+ -- though I'm curious about the record_superlifetime thing

@pnkfelix
Copy link
Member Author

pnkfelix commented Apr 8, 2015

@bors r=nikomatsakis 86c5faf

@bors
Copy link
Contributor

bors commented Apr 8, 2015

⌛ Testing commit 86c5faf with merge 9266d59...

bors added a commit that referenced this pull request Apr 8, 2015
Encode more precise scoping rules for function params

Function params outlive everything in the body (incl temporaries).  Thus if we assign them their own `CodeExtent`, the region inference can properly show that it is sound to have temporaries with destructors that reference the parameters (because such temporaries will be dropped before the parameters are dropped).

Fix #23338
@bors bors merged commit 86c5faf into rust-lang:master Apr 8, 2015
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.

RefCell::borrow does not pass borrow-check without a seemingly no-op let binding
5 participants