Skip to content

Automatic reborrow #40942

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
GAJaloyan opened this issue Mar 31, 2017 · 1 comment
Closed

Automatic reborrow #40942

GAJaloyan opened this issue Mar 31, 2017 · 1 comment
Labels
T-lang Relevant to the language team, which will review and decide on the PR/issue.

Comments

@GAJaloyan
Copy link
Contributor

Hi everybody,
While playing with Rust move/borrow, I ran across a strange behavior, that comes from the following code:

struct Point<'a> {x123: &'a mut i32, y541: &'a mut i32}

fn main() {
    let p123 = Point {x123: &mut 10, y541: &mut 11};
    let x : &mut i32 = p123.x123; 
    let y = p123.y541;
    let z = p123;
}

The thing that happens is that p123.x123 is borrowed by x, while p123.y541 is moved in y (according to the error messages). I think that this may happen from the type inference that finds that x and p123.x123 do not have the same type of pointer (different lifetimes ?) and hence does a reborrow, is it correct ? Is it an expected feature of the type checker ?

Thanks in advance.

@Mark-Simulacrum Mark-Simulacrum added the T-lang Relevant to the language team, which will review and decide on the PR/issue. label Jun 20, 2017
@Mark-Simulacrum
Copy link
Member

I believe this is expected behavior, see #35919.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
T-lang Relevant to the language team, which will review and decide on the PR/issue.
Projects
None yet
Development

No branches or pull requests

2 participants