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

Mixing #[rstest] and #[serial] breaks VS Code's IntelliSense with rust-analyzer #112

Closed
mtilda opened this issue Jun 18, 2024 · 2 comments
Closed

Comments

@mtilda
Copy link

mtilda commented Jun 18, 2024

Background

I am using the crates rstest and serial_test.

VS Code's IntelliSense stops working when I define a test function with both #[rstest] and #[serial].

IntelliSense is a VS Code feature (or rather a collection of features) that provide suggestions, information about symbols, and navigational tools.

The VS Code extension rust-analyzer provides support for the Rust language.

The root cause of this problem could be any one of the above mentioned technologies. Let me know if you think this issue does not belong on this repository.

Steps to reproduce

  1. Install VS Code (I am on version 1.90.1)

  2. Install the extension rust-analyzer (I am on version v0.3.2002)

  3. Install Rust (I am on 1.78.0)

  4. Use the command cargo init to create a new cargo package.

  5. Add the necessary dependencies with the command cargo add rstest serial_test; or if you want the same versions as me, use the command cargo add rstest@0.21.0 serial_test@3.1.1

  6. Open VS Code

  7. Paste this in src/main.rs:

    mod tests;
    
    fn main() {
        println!("Hello, world!");
    }
  8. Create src/tests.rs with the following content:

    #[cfg(test)]
    mod tests {
        use rstest::rstest;
        use serial_test::serial;
    
        #[rstest]
        fn test_a() {
            // IntelliSense works here
            let _example = vec![1,2,3];
        }
    
        #[test]
        #[serial]
        fn test_b() {
            // IntelliSense works here
            let _example = vec![1,2,3];
        }
    
        #[rstest]
        #[serial]
        fn test_c() {
            // IntelliSense does not work here
            let _example = vec![1,2,3];
        }
    }

Expected behavior

  • Between _example and =, We should expect to see the inferred type Vec<i32>.
  • Hover your mouse over the _example in each test function. We should expect to see a Peek.
  • Type a . after vec![1,2,3] and before the ;. We should expect to see a drop down of suggestions (see screenshots).

Screenshots

IntelliSense working inside test_a

IntelliSense working inside test_b

IntelliSense not working inside test_c

@mtilda
Copy link
Author

mtilda commented Jun 18, 2024

Cross-posted: la10736/rstest#262 (comment)

@palfrey
Copy link
Owner

palfrey commented Jun 20, 2024

Fixed by rust-lang/rust-analyzer#17462

@palfrey palfrey closed this as completed Jun 20, 2024
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

2 participants