rust/tests
Samuel Tardieu 8eed35023f
New lint: redundant_test_prefix (#13710)
This PR has started as an effort to proceed from the feedback in
rust-lang/rust-clippy#12861.

- Checks test functions (functions marked with `#[test]` annotation) for
redundant "test_" prefix.
- Auto-fix is supported (and handles collisions gracefully, see below).
- If removing "test_" prefix from, say, `test_foo()` results in a name
collision (either because function `foo()` is already defined within the
current scope, or because the `foo()` call exists within function --
thus creating an unwanted recursion), lint suggests function rename,
warning the user that a simple trimming of `test_` prefix will result in
a name collision.
- If removing "test_" prefix results in invalid identifier (consider
`test_const`, `test_`, `test_42`), then again no auto-fix is suggested,
user is asked to rename function, with a note that a simple prefix
trimming will result in an invalid function name.
(`Applicability::HasPlaceholders` is used and user is suggested to: drop
`test_` prefix + add `_works` suffix, i.e. `test_foo` becomes
`foo_works` -- but again, user has to apply those changes manually).
- If trimmed version of the function name is a valid identifier, doesn't
result in name collision or unwanted recursion, then user is able to run
auto-fix.

fixes rust-lang/rust-clippy#8931

changelog: new lint: [`redundant_test_prefix`]
2025-04-16 06:15:18 +00:00
..
test_utils
ui New lint: redundant_test_prefix (#13710) 2025-04-16 06:15:18 +00:00
ui-cargo Merge commit '9f9a822509' into clippy-subtree-update 2025-02-28 23:27:09 +01:00
ui-internal Merge commit '1e5237f4a5' into clippy-subtree-update 2025-03-20 22:34:29 +01:00
ui-toml Add unsafe markers to accomodate edition 2024 rules 2025-04-15 20:33:01 +02:00
workspace_test Merge commit 'cb806113e0' into clippy-subtree-update 2024-08-08 19:13:50 +02:00
check-fmt.rs Merge commit 'cb806113e0' into clippy-subtree-update 2024-08-08 19:13:50 +02:00
clippy.toml Fix situations identified by collapsible_if new hits 2025-03-25 19:50:24 +01:00
compile-test.rs Run UI tests with edition 2024 by default 2025-04-15 20:33:01 +02:00
config-metadata.rs Merge commit 'a109190d70' into clippy-subtree-update 2024-10-18 13:44:06 +02:00
dogfood.rs dogfood: run with -D clippy::dbg_macro 2025-04-10 07:38:16 +02:00
headers.rs
integration.rs Merge commit 'cb806113e0' into clippy-subtree-update 2024-08-08 19:13:50 +02:00
lint_message_convention.rs Merge commit '1e5237f4a5' into clippy-subtree-update 2025-03-20 22:34:29 +01:00
missing-test-files.rs Merge commit '51d49c1ae2' into clippy-subtree-update 2025-01-28 19:33:54 +01:00
versioncheck.rs Clippy: skip check_host_compiler check in rustc testsuite 2025-02-28 23:27:22 +01:00
workspace.rs