`trivial_bounds` lint lints on non-global associated type constraints
Open
Nobody has claimed this yet.
A-lints
C-bug
F-trivial_bounds
L-trivial_bounds
T-compiler
- Dominant language
- Rust
- Stars
- 119k
- Forks
- 16.1k
- PR merge metrics
- PR metrics pending
Description
#![feature(trivial_bounds)]
trait Trait {
type Assoc;
}
impl<T> Trait for T {
type Assoc = T;
}
fn foo<T>()
where
u32: Trait<Assoc = T>,
{
}
this results in
warning: trait bound u32: Trait does not depend on any type or lifetime parameters
--> <source>:12:10
|
12 | u32: Trait<Assoc = T>,
| ^^^^^^^^^^^^^^^^
|
= note: `#[warn(trivial_bounds)]` on by default
but should not, as the corresponding projection bound does reference a generic parameter (and requires this function to only be called with T = u32.
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 by compiling the standalone Rust example with #![feature(trivial_bounds)] and confirm the warning on the associated type constraint. Then trace the trivial_bounds lint handling for projection bounds. Done means this generic-dependent constraint no longer produces the warning while the lint still reports genuinely non-generic bounds.
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
- 45/100