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

rust-analyzer hangs when having &dyn Fn... as one of the parameter to another Fn #13293

Closed
chomosuke opened this issue Sep 25, 2022 · 1 comment
Labels
A-ty type system / type inference / traits / method resolution C-bug Category: bug I-hang Issue: The analysis never terminates, due to infinite loops, deadlock, livelock, etc.

Comments

@chomosuke
Copy link

rust-analyzer version: rust-analyzer 0.3.1194-standalone (67920f7 2022-09-04)

rustc version: rustc 1.64.0 (a55dd71d5 2022-09-19)

relevant settings: None, all default

When analyzing the following code, rust analyzer hangs at around 45% of CPU with no stderr output:

fn main() {}

mod memoize {
    use core::hash::Hash;
    use std::collections::HashMap;

    pub struct Memoize<P, R, F> {
        mem: HashMap<P, R>,
        f: F,
    }
    impl<Par: Hash, Ret, F: Fn(Par, &dyn Fn(Par) -> Ret) -> Ret> Memoize<Par, Ret, F> {
        pub fn new(f: F) -> Self {
            Self {
                mem: HashMap::new(),
                f,
            }
        }
    }

    #[cfg(test)]
    mod test {
        use super::*;

        #[test]
        fn coins() {
            let solve = Memoize::new(|target: usize, rec| {
            });
        }
    }
}

If the file is changed and saved after that, the diagnostics does not update to reflect the new code.

If I run cargo check, everything seems correct:
image

@chomosuke chomosuke changed the title rust-analyzer hangs when having &dyn Fn as one of the parameter to another Fn rust-analyzer hangs when having &dyn Fn... as one of the parameter to another Fn Sep 25, 2022
@jonas-schievink jonas-schievink added A-ty type system / type inference / traits / method resolution C-bug Category: bug I-hang Issue: The analysis never terminates, due to infinite loops, deadlock, livelock, etc. labels Jan 31, 2023
@lowr
Copy link
Contributor

lowr commented Feb 13, 2023

Duplicate of #11063.

@lowr lowr closed this as not planned Won't fix, can't repro, duplicate, stale Feb 13, 2023
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
A-ty type system / type inference / traits / method resolution C-bug Category: bug I-hang Issue: The analysis never terminates, due to infinite loops, deadlock, livelock, etc.
Projects
None yet
Development

No branches or pull requests

3 participants