about summary refs log tree commit diff
path: root/compiler/rustc_llvm/llvm-wrapper/RustWrapper.cpp
diff options
context:
space:
mode:
authorSamuel Tardieu <sam@rfc1149.net>2025-04-16 06:15:18 +0000
committerGitHub <noreply@github.com>2025-04-16 06:15:18 +0000
commit8eed35023f26bc45ab86d5b8f080c4025faa58cf (patch)
tree11cd9a2b91cecb4475af254ef58d8ca8e18d4af7 /compiler/rustc_llvm/llvm-wrapper/RustWrapper.cpp
parent08c78e00951715570546eb182f65bc535a470bf9 (diff)
parente2422a618d9d3a432f3c2b1873dd0b8278106d66 (diff)
downloadrust-8eed35023f26bc45ab86d5b8f080c4025faa58cf.tar.gz
rust-8eed35023f26bc45ab86d5b8f080c4025faa58cf.zip
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`]
Diffstat (limited to 'compiler/rustc_llvm/llvm-wrapper/RustWrapper.cpp')
0 files changed, 0 insertions, 0 deletions