Skip to content

Incorrect warning about value assigned to variable not being used #3796

@robertknight

Description

@robertknight

Compiling this code results in a warning: "test.rs:8:1: 8:2 warning: value assigned to x is never read", though since the variable has been captured by the lambda f() by reference, the assignment does have an effect when f() is invoked subsequently.

Tested with git commit 07edf90

fn main() {
    let mut x = 1;
    let f = fn() -> int {
        return x+20;
    };
    io::println(f().to_str());
    x += 1;
    io::println(f().to_str());
}

Metadata

Metadata

Assignees

No one assigned

    Labels

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions