Skip to content

"unknown scope" error on mutable borrowed pointer #4500

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
jbclements opened this issue Jan 15, 2013 · 3 comments
Closed

"unknown scope" error on mutable borrowed pointer #4500

jbclements opened this issue Jan 15, 2013 · 3 comments
Labels
A-lifetimes Area: Lifetimes / regions A-type-system Area: Type system I-ICE Issue: The compiler panicked, giving an Internal Compilation Error (ICE) ❄️
Milestone

Comments

@jbclements
Copy link
Contributor

This code

fn main () {
    let mut p: & int = & 4;
    p = ~3;
}

Produces this error:

foo.rs:2:12: 2:14 warning: variable `p` is assigned to, but never used
foo.rs:2     let mut p: & int = & 3;
                     ^~
foo.rs:3:4: 3:5 warning: value assigned to `p` is never read
foo.rs:3     p = ~3;
             ^
foo.rs:3:8: 3:10 error: illegal borrow: borrowed value does not live long enough
foo.rs:3     p = ~3;
                 ^~
foo.rs:1:11: 4:1 note: borrowed pointer must be valid for the block at 1:11...
foo.rs:1 fn main () {
foo.rs:2     let mut p: & int = & 3;
foo.rs:3     p = ~3;
foo.rs:4 }
note: ...but borrowed value is only valid for unknown scope: 22.  Please report a bug.
error: aborting due to previous error
@catamorphism
Copy link
Contributor

I think this is the same as #3860, and I'll test it once I have my fix for that one ready (so... close...!)

@ghost ghost assigned catamorphism Jan 17, 2013
@catamorphism
Copy link
Contributor

Oh, this is related to #3860 but not quite the same. The code that prints out scopes doesn't handle the case where the scope is associated with a statement ID. This shouldn't be hard to fix.

@catamorphism
Copy link
Contributor

Fixed in 96b4f43

Kimundi pushed a commit to Kimundi/rust that referenced this issue Jan 20, 2013
Prevents a case of "unknown scope, this is a bug".

I judged this too small to review. Closes rust-lang#4500
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
A-lifetimes Area: Lifetimes / regions A-type-system Area: Type system I-ICE Issue: The compiler panicked, giving an Internal Compilation Error (ICE) ❄️
Projects
None yet
Development

No branches or pull requests

2 participants