Skip to content

borrowck unsoundness #13497

Closed
Closed
@emberian

Description

@emberian
fn read_lines_borrowed() -> ~[&str] {
    let rawLines: ~[~str] = ~[~"foo  ", ~"  bar"];
    rawLines.iter().map(|l| l.trim()).collect()
}

fn main() {
    println!("{}", read_lines_borrowed());
}

read_lines_borrowed is not rejected. but the value it returns cannot possibly be valid, since rawLines is going to be free'd after it returns, leaving the collected references dangling.

Metadata

Metadata

Assignees

No one assigned

    Labels

    A-type-systemArea: Type systemE-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