Do not warn for unused variables on trait method declaration
Nobody has claimed this yet.
- Dominant language
- C++
- Stars
- 2.9k
- Forks
- 231
- Avg merge
- 19h 55m
- Merged PRs (30d)
- 67
Description
On the following code, gccrs should not warn about unused variables:
pub trait Foo {
fn Bar(self) -> i32;
}
Since we are simply "declaring" (in C/C++ terms) a trait method, the self variable is not intended to be used here. However, each type that implement the Foo trait will need to use the self variable (or rename it) in their implementation of the Bar method.
The following code, which provides a default implementation for the trait method, should warn:
pub trait Foo {
fn Bar(self) -> i32 {
-1 // default implementation returns -1 for example
}
}
So there should be a distinction between a default trait method implementation and just a 'declaration' like here for unused variables
Originally posted in https://github.com/Rust-GCC/gccrs/pull/540#discussion_r662380851
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.
Research direction
No source file or test is named. Start by tracing the unused-variable warning entry point for Rust trait methods, then compare declaration-only methods with default implementations. Done means declaration-only trait parameters do not warn, while parameters in default implementations still do.
Written by the indexing model from the issue text.
Assessment
- Tech stack
- cpp, rust
- Domain
- compilers
- Issue type
- Bug
- Difficulty
- 4/5
- Estimated time
- 3-5 days
- Activity status
- Stale
- Clarity
- Mostly clear
- Newbie friendliness
- 35/100