I wrote a test named 'gen' in Rust, and when I ran the test, I found that it was filtered out. After capturing the command, I found that it had added the characters "r#" before "gen". Testing with other names does not work, it can run normally.
My environment is ArchLinux 6.10.2-arch1-1.
wrong command:
I think it is a lsp issue.
cargo test --package Temp --bin Temp -- r#gen --exact --show-output
r# is the syntax for raw identifiers, which you use if you want your identifier to be a keyword in Rust. For example a variable or field named type is not possible as type is a keyword in Rust. Instead, you'd use the raw identifier r#type instead. That being said, I have no idea why this is happening in your case, gen is not a keyword in Rust and it is also strange to find it in the CLI.[1]
Testing locally I found out that cargo test can handle the other way around, i.e. match a function with a raw identifier to a query without it. For example, having a test
#[test]
fn r#match() {
assert!(true);
}
is run with cargo test -- match or cargo test -- r#match. But a test
#[test]
fn gen() {
assert!(true);
}
is not run with cargo test -- r#gen (as you've already deduced).
Edit: seems like genwill be a keyword in the 2024 edition. Looks like your IDE setup already treats it like a keyword, even though in earlier editions it is not yet one.