Skip to content

RA extension completely freezes in VS Code when using fn-memo crate #7906

@matteomeli

Description

@matteomeli

I ran into various issues while trying to use this crate. As soon as I import the crate and start using functions/types from it, RA gets stuck on formatting when trying to save the file. After that the extension becomes unusable, syntax highlighting is broken, formatting is broken, code navigation is broken, run/debug button don't work, etc. Tried to restart server but no luck, only way seems to be to close and restart VS Code, but same problem is encountered again as soon as the same file is edited and/or saved.

My guess is that the root of the problem might be related to recursive closures analysis, which fn-memo (and its dependency recur-fn) are about. But can't be sure.

Windows WSL2 Ubuntu
rust-analyzer version: 2021-03-01 (5df3ee8)
Cargo TOML:

[package]
name = "test"
version = "0.1.0"
authors = [""]
edition = "2018"

# See more keys and their definitions at https://doc.rust-lang.org/cargo/reference/manifest.html

[dependencies]
fn-memo = { version = "1.2", default-features = false }

Minimal example. A lib project only having lib.rs containing the following:

#[cfg(test)]
mod tests {
    use fn_memo::{recur_fn::recur_fn, unsync, FnMemo};
    
    #[test]
    fn it_works() {
        let fib = unsync::memoize(recur_fn(|fib, n: usize| {
            println!("Evaluating {}", n);
            if n <= 1 {
                n
            } else {
                fib(n - 1) + fib(n - 2)
            }
        }));

        assert_eq!(55, fib.call(10));
        assert_eq!(5, fib.call(5));
    }
}

Metadata

Metadata

Assignees

No one assigned

    Labels

    A-chalkchalk related issueA-tytype system / type inference / traits / method resolutionC-bugCategory: bugS-blockedStatus: marked as blocked ❌ on something else such as an RFC or other implementation work.

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions