Skip to content

"unknown scope" error on mutable borrowed pointer #4500

Closed
@jbclements

Description

@jbclements

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

Metadata

Metadata

Assignees

No one assigned

    Labels

    A-lifetimesArea: Lifetimes / regionsA-type-systemArea: Type systemI-ICEIssue: The compiler panicked, giving an Internal Compilation Error (ICE) ❄️

    Type

    No type

    Projects

    No projects

    Milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions