Skip to content

log should not consume its arguments #4532

@bstrie

Description

@bstrie
fn main(){
    let mut v = ~[1,1,1,1,1,2,2,2,2,2,3,3,3,3,3,];
    log(error, v);
    log(error, v);  // nope
}

The above code fails to compile:

view.rs:4:15: 4:16 error: use of moved variable: `v`
view.rs:4     log(error, v);
                         ^
view.rs:3:15: 3:16 note: move of variable occurred here
view.rs:3     log(error, v);
                         ^
error: aborting due to previous error

@nikomatsakis confirms that this is undesirable:

13:00 < bstrie> nmatsakis: also, I've noticed that
                https://gist.github.com/4566644 is an error because v is moved
                out, and I'm wondering if that's intentional
13:01 < nmatsakis> bstrie: hmm, I can see why it happens but it does seem
                   non-ideal.  I'm working on a total rewrite of the module
                   that decides what's a move and what's not.
13:01 < nmatsakis> it could no doubt be made smarter around log
13:01 < bstrie> ah, okay
13:01 < bstrie> I just feel like log should be "transparent" in that respect
13:02 < nmatsakis> yes
13:02 < nmatsakis> I agree
13:02 < nmatsakis> it doesn't "consume" it's input

Metadata

Metadata

Assignees

No one assigned

    Labels

    Type

    No type

    Projects

    No projects

    Milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions