Skip to content

str.word_iter().collect() allows slices to escape the borrowck #7713

Closed
@huonw

Description

@huonw
fn main() {
    let v = {
        let s = ~"foo bar";
        s.word_iter().collect::<~[&str]>()
    };
    println(v.to_str());
}
// prints [foo, , ^@]

Changing the v.to_str() to fmt!("%?", v) still compiles and outputs

rust: task failed at 'left: 0 does not equal right: 128', /home/huon/rust/src/libstd/str.rs:1727
rust: domain main @0x25ba1b0 root task failed

Metadata

Metadata

Assignees

No one assigned

    Labels

    A-lifetimesArea: Lifetimes / regions

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions