Skip to content

Borrow check error with "unknown scope" region for callee's self parameter #4464

Closed
@jld

Description

@jld

A reduced test case, which seems as if it should be valid:

fn broken(v: &r/[u8], i: uint, j: uint) -> &r/[u8] { v.view(i, j) }

The error:

src/test.rs:1:53: 1:54 error: illegal borrow: borrowed value does not live long enough
src/test.rs:1 fn broken(v: &r/[u8], i: uint, j: uint) -> &r/[u8] { v.view(i, j) }
                                                                   ^
src/test.rs:1:51: 1:67 note: borrowed pointer must be valid for the lifetime &r as defined on the block at 1:51...
src/test.rs:1 fn broken(v: &r/[u8], i: uint, j: uint) -> &r/[u8] { v.view(i, j) }
                                                                 ^~~~~~~~~~~~~~~~
note: ...but borrowed value is only valid for unknown scope: 34.  Please report a bug.
error: aborting due to previous error

Metadata

Metadata

Assignees

No one assigned

    Labels

    A-lifetimesArea: Lifetimes / regionsE-easyCall for participation: Easy difficulty. Experience needed to fix: Not much. Good first issue.E-needs-testCall for participation: An issue has been fixed and does not reproduce, but no test has been added.

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions