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

Auto complete stops completing when in a "test_log::test" test code block #19006

Open
hak8or opened this issue Jan 23, 2025 · 2 comments · May be fixed by #19037
Open

Auto complete stops completing when in a "test_log::test" test code block #19006

hak8or opened this issue Jan 23, 2025 · 2 comments · May be fixed by #19037
Labels
A-completion autocompletion A-proc-macro proc macro C-bug Category: bug

Comments

@hak8or
Copy link

hak8or commented Jan 23, 2025

This is a continuation of the following I posted in another issue. I found a minimal reproducible case, looks like it's specifically when trying to auto complete a variable's extension methods (meaning after a .) when in a test block that is decorated with #[test] from the test_log crate.

For anyone else coming here because they saw the error in vscode when auto completion was failing, after doing a git bissect on this project between when it worked last for me via 2024-12-16 and when it stopped working via 2024-12-23, I got 02d47f3 as the commit which introduced this behavior for me.

I do see #18834 and #18888 and #18889 attempted to resolve some of the "regressions" from that commit (which was introduced via #18723).

I did try the latest release of 2025-01-13 but still saw the failing case. I also tried master which is 903bc81 as of now, but still no dice. I was hoping if I might be able to "just" revert the commit in question atop master, but the conflict resolution is above my skills with rust and familiarity with this codebase. I have been trying to get a minimal reproducible example but haven't been able to be lucky with what I extract from my proprietary codebase to reproduce this.

Hopefully this helps anyone else who might be getting hit by this.

Originally posted by @hak8or in #18777


rust-analyzer version: this repo checked out at 2025-01-20 and then cargo xtask install

rustc version: rustc 1.84.0 (9fc6b4312 2025-01-07)

editor or extension: vscode, extension version is same as "rust-analyzer version"

relevant settings: toolchain installed using rustup, running on recently updated arch linux

repository link (if public, optional): N/A

code snippet to reproduce:

fn main() {
    println!("Hello, world!");
}

#[cfg(test)]
mod sometests {
    // Comment this out to get working auto complete again.
    use test_log::test;

    #[test]
    fn sometest() {
        let f = 4;
        // f. // refuses to autocomplete when the use exists
    }
}
[package]
name = "rust_test"
version = "0.1.0"
edition = "2021"

[dependencies]
test-log = { version = "0.2.16", features = ["log", "trace"] }

Image

Image

@ChayimFriedman2
Copy link
Contributor

I'm afraid I know the reason and there isn't a lot we can do here, but I will check it out. Anyway it should work if you won't use test_log::test and instead put #[test_log::test].

@hak8or
Copy link
Author

hak8or commented Jan 25, 2025

Thank you! Confirming the change works for me.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
A-completion autocompletion A-proc-macro proc macro C-bug Category: bug
Projects
None yet
3 participants