duplicated_attributes: false positive with apistos crate
Nobody has claimed this yet.
Assessment
- Difficulty
- 3/5
- Estimated time
- 1-2 days
- Newbie friendliness
- 58/100
Research direction
Start by reproducing the duplicated_attributes warning with the apistos ErrorResponse example in service/api/error_response.rs, then trace the duplicated_attributes lint entry point and its handling of generated attributes. Done means the three distinct status attributes no longer produce warnings while genuine duplicates remain reported.
Written by the indexing model from the issue text.
Description
Summary
The duplicated_attributes lint yields false positives when using the apistos crate for OpenAPI documentation.
Lint Name
duplicated_attributes
Reproducer
I tried this code:
#[derive(Debug, Serialize, JsonSchema, ApiErrorComponent)]
#[openapi_error(
status(code = 400, description = "An invalid request has been made."),
status(code = 404, description = "The specified resource has not been found."),
status(code = 500, description = "An internal server error occurred.")
)]
pub enum ErrorResponse {
BadRequest(String),
InternalServerError(String),
NotFound(String),
}
I saw this happen:
warning: duplicated attribute
--> service/src/api/error_response.rs:12:12
|
12 | status(code = 404, description = "The specified resource has not been found."),
| ^^^^^^^^^^
|
note: first defined here
--> service/src/api/error_response.rs:11:12
|
11 | status(code = 400, description = "An invalid request has been made."),
| ^^^^^^^^^^
help: remove this attribute
--> service/src/api/error_response.rs:12:12
|
12 | status(code = 404, description = "The specified resource has not been found."),
| ^^^^^^^^^^
= help: for further information visit https://rust-lang.github.io/rust-clippy/master/index.html#duplicated_attributes
= note: `-W clippy::duplicated-attributes` implied by `-W clippy::all`
= help: to override `-W clippy::all` add `#[allow(clippy::duplicated_attributes)]`
I expected to see this happen:
No warnings should be emitted.
Version
rustc 1.80.0 (051478957 2024-07-21)
binary: rustc
commit-hash: 051478957371ee0084a7c0913941d2a8c4757bb9
commit-date: 2024-07-21
host: aarch64-apple-darwin
release: 1.80.0
LLVM version: 18.1.7
Additional Labels
No response
- Dominant language
- Rust
- Stars
- 13.5k
- Forks
- 2.2k
- Avg merge
- 2d 10h
- Merged PRs (30d)
- 32
Contributor guide
First steps
- Read the whole issue, then the project's contributing guide.
- Comment on the issue to say you are picking it up — it saves two people doing the same work.
- Fork the repository and make your change on a branch.
- Open a pull request that references the issue number.
More from rust-lang/rust-clippy
-
C-bug L-suggestion
Difficulty 2/5 1-3 hours Newbie friendliness 72/100
rust-lang/rust-clippy#17674 · 5 comments ·
-
C-bug L-suggestion
Difficulty 2/5 1-3 hours Newbie friendliness 78/100
rust-lang/rust-clippy#17673 · 3 comments ·
-
C-bug I-false-positive
Difficulty 2/5 1-3 hours Newbie friendliness 76/100
rust-lang/rust-clippy#17566 ·
-
A-documentation
Difficulty 2/5 1-3 hours Newbie friendliness 65/100
rust-lang/rust-clippy#17259 · 3 comments ·
-
A-documentation A-website C-bug
Difficulty 2/5 1-3 hours Newbie friendliness 78/100
rust-lang/rust-clippy#16981 · 1 reaction ·
All issues in rust-lang/rust-clippy
Similar issues
-
Difficulty 2/5 1-3 hours Newbie friendliness 86/100
kwakseongjae/auto-hwp#319 ·
-
area:cli bug filter-quality good first issue priority:medium
Difficulty 2/5 1-3 hours Newbie friendliness 84/100
-
Difficulty 1/5 Under an hour Newbie friendliness 72/100
bevyengine/bevy#25861 ·
-
comp-datalake
Difficulty 2/5 1-3 hours Newbie friendliness 88/100
ClickHouse/ClickHouse#121222 ·
-
enhancement remote
Difficulty 2/5 1-3 hours Newbie friendliness 68/100