Skip to content
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

Improper use of closures not detected #51486

Open
remexre opened this issue Jun 11, 2018 · 2 comments
Open

Improper use of closures not detected #51486

remexre opened this issue Jun 11, 2018 · 2 comments
Labels
A-closures Area: Closures (`|…| { … }`) A-diagnostics Area: Messages for errors, warnings, and lints C-bug Category: This is a bug. T-compiler Relevant to the compiler team, which will review and decide on the PR/issue.

Comments

@remexre
Copy link
Contributor

remexre commented Jun 11, 2018

The following code gets "overflow evaluating the requirement [closure@src/main.rs:20:19: 20:28]: std::ops::FnMut<(i32,)>" if the line in main is uncommented.
If the error should exist (which I'm unsure about), it should be detected without needing to call map.
If not, that's a bug.

enum Foo<T> {
    A(T),
    B(Box<Foo<T>>, Box<Foo<T>>),
}

impl<T> Foo<T> {
    fn map<F, T2>(self, mut f: F) -> Foo<T2>
    where
        F: FnMut(T) -> T2,
    {
        match self {
            Foo::A(x) => Foo::A(f(x)),
            Foo::B(x, y) => Foo::B(Box::new(x.map(&mut f)), Box::new(y.map(&mut f))),
        }
    }
}

fn main() {
    // Foo::A(0).map(|x| x + 1);
}
@estebank estebank added A-diagnostics Area: Messages for errors, warnings, and lints A-closures Area: Closures (`|…| { … }`) labels Jan 19, 2019
@JohnTitor JohnTitor added C-bug Category: This is a bug. T-compiler Relevant to the compiler team, which will review and decide on the PR/issue. labels Oct 2, 2019
@estebank
Copy link
Contributor

Closing as duplicate of #50043.

@estebank
Copy link
Contributor

Ah, realized that the report is quite more specific than the linked ticket. Keeping open.

@estebank estebank reopened this Nov 11, 2022
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
A-closures Area: Closures (`|…| { … }`) A-diagnostics Area: Messages for errors, warnings, and lints C-bug Category: This is a bug. T-compiler Relevant to the compiler team, which will review and decide on the PR/issue.
Projects
None yet
Development

No branches or pull requests

3 participants