Skip to content

Infer length of @-box borrows (or just borrow for the whole block) #2575

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

Closed
pcwalton opened this issue Jun 13, 2012 · 2 comments
Closed

Infer length of @-box borrows (or just borrow for the whole block) #2575

pcwalton opened this issue Jun 13, 2012 · 2 comments
Assignees
Labels
A-type-system Area: Type system

Comments

@pcwalton
Copy link
Contributor

It would be very nice if we could borrow for the whole block when borrowing an @ when passing it as a function parameter.

Also if we could say what we think the liveness ranges are that would help the error messages.

@ghost ghost assigned nikomatsakis Jun 13, 2012
@nikomatsakis
Copy link
Contributor

By the way: I do not want to borrow any longer than necessary because it can lead to unnecessary borrowck errors (not for @, but for ~). I did start a patch to borrow @ for longer than ~ but decided against it in the end.

However, I have an alternate plan: basically we create a region variable that is lower-bounded with the region of the call (that is the current length of the borrow). Then we upper bound it with the enclosing block—or, in fact, with the innermost "looping" enclosing block. The standard region inference stuff should then pick the smallest possible block that fits these constraints. I put some of the required machinery in but not all of it yet.

@nikomatsakis
Copy link
Contributor

This is done, long ago.

celinval added a commit to celinval/rust-dev that referenced this issue Jun 4, 2024
Fix broken link introduced by rust-lang#1138 and add a link to Coding conventions.
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
A-type-system Area: Type system
Projects
None yet
Development

No branches or pull requests

2 participants