Skip to content

Compiler too restrictive for unused variables interacting with closures #29163

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Closed
tbu- opened this issue Oct 19, 2015 · 3 comments
Closed

Compiler too restrictive for unused variables interacting with closures #29163

tbu- opened this issue Oct 19, 2015 · 3 comments
Labels
A-closures Area: Closures (`|…| { … }`)

Comments

@tbu-
Copy link
Contributor

tbu- commented Oct 19, 2015

I'd like to write the following code with map:

fn foobar(map: Option<&BTreeMap<u32,u32>>) {
    let temp;
    let map = match map {
        Some(a) => a,
        None => { temp = BTreeMap::new(); &temp }
    }
    // Do something.
}

But the following thing doesn't work:

let temp;
map.unwrap_or_else(|| { temp = BTreeMap::new(); &temp })
@tbu-
Copy link
Contributor Author

tbu- commented Oct 19, 2015

Looks similar to #8338.

@sfackler sfackler added the A-closures Area: Closures (`|…| { … }`) label Oct 19, 2015
@steveklabnik
Copy link
Member

Triage: no change. reproducible: https://is.gd/ktvqme

@Mark-Simulacrum
Copy link
Member

Closing as per #8338 (comment).

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
A-closures Area: Closures (`|…| { … }`)
Projects
None yet
Development

No branches or pull requests

4 participants