Skip to content

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

Open
@lcnr

Description

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

Metadata

Metadata

Assignees

No one assigned

    Labels

    A-lintsArea: Lints (warnings about flaws in source code) such as unused_mut.C-bugCategory: This is a bug.F-trivial_bounds`#![feature(trivial_bounds)]`L-trivial_boundsLint: trivial_boundsT-compilerRelevant to the compiler team, which will review and decide on the PR/issue.

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions