Skip to content

log should not consume its arguments #4532

Closed

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

Activity

  1. brson commented on Feb 5, 2013

    @brson
    Contributor

    log should be removed from the language.

  2. catamorphism commented on Apr 25, 2013

    @catamorphism
    Contributor

    Closing, because as I understand it, we're removing log.

  3. bstrie commented on Apr 26, 2013

    @bstrie
    ContributorAuthor

    Indeed, does not reproduce with error!() in place of log.

  4. added a commit that references this issue on Aug 20, 2025
  5. added a commit that references this issue on Aug 21, 2026
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

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