Skip to content

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

Closed
@hak8or

Description

@hak8or

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

Metadata

Metadata

Assignees

No one assigned

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions