Skip to content

trivial_bounds lint lints on non-global associated type constraints #140311

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Open
lcnr opened this issue Apr 25, 2025 · 0 comments
Open

trivial_bounds lint lints on non-global associated type constraints #140311

lcnr opened this issue Apr 25, 2025 · 0 comments
Labels
needs-triage This issue may need triage. Remove it if it has been sufficiently triaged.

Comments

@lcnr
Copy link
Contributor

lcnr commented Apr 25, 2025

#![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.

@rustbot rustbot added the needs-triage This issue may need triage. Remove it if it has been sufficiently triaged. label Apr 25, 2025
@lcnr lcnr changed the title trivial_bounds lint lints on global trait bound with non-global associated type constraints trivial_bounds lint lints on non-global associated type constraints Apr 25, 2025
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
needs-triage This issue may need triage. Remove it if it has been sufficiently triaged.
Projects
None yet
Development

No branches or pull requests

2 participants