Unsized parameters are not flagged in trait definitions
Nobody has claimed this yet.
- Dominant language
- Rust
- Stars
- 119k
- Forks
- 16.1k
- PR merge metrics
- PR metrics pending
Description
Code
trait Trait<T: ?Sized> {
fn method(t: T);
}
Current output
<none>
Desired output
A warning that the `?Sized` constraint is useless
Rationale and extra context
Any concrete choice of T that's unsized will result in E0277 when the trait is implemented, so marking it as unsized isn't allowing anything that wasn't already valid. This exact error will appear if method has a default implementation.
Similar redundant constructions like comparing unsigned values to 0 are flagged, so I'd expect this to be too.
Other cases
No response
Rust Version
stable 1.80.1
Anything else?
No response
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
Start with the reported trait definition and compare its handling with existing diagnostics for redundant constructions. Add a warning for the useless ?Sized constraint on an unsized parameter in a trait method, and verify that the example produces the warning without changing valid cases.
Written by the indexing model from the issue text.
Assessment
- Tech stack
- rust
- Domain
- compilers
- Issue type
- Bug
- Difficulty
- 4/5
- Estimated time
- 3-5 days
- Activity status
- Stale
- Clarity
- Mostly clear
- Newbie friendliness
- 35/100