Skip to content

Functional record update should respect privacy (or consume a non-Copy source) #21407

Closed
@arielb1

Description

@arielb1

Tracking issue for: rust-lang/rfcs#736

Old Description:

Functional record update does not mark the source as consumed, even if does not implement Copy. This means that e.g. the source's destructor will eventually be run, so the following code prints ["Heap Spray"]:

pub fn free_and_use<T>(t: Vec<T>) -> Vec<T> {
    Vec { ..t }
}

fn main() {
    let v = vec!["Hello, World!"];
    let r = free_and_use(v);
    for _ in range(0, 65536u32) {
        vec!["Heap Spray"];
    }
    println!("{}", r);
}

Metadata

Metadata

Assignees

Labels

No labels
No labels

Type

No type

Projects

No projects

Milestone

Relationships

None yet

Development

No branches or pull requests

Issue actions