Skip to content

Duplicate doubly higher-ranked trait bound fails to compile #140071

Open
@Veykril

Description

@Veykril

I tried this code:

fn f()
where
    for<'db> for<'a> fn(&'a str): std::fmt::Debug,
    for<'db> for<'a> fn(&'a str): std::fmt::Debug,
{
}

I expected to see this happen:

It compiles successfully like it does when the bound is not duplicated as in

fn f()
where
    for<'db> for<'a> fn(&'a str): std::fmt::Debug,
{
}

or when a layer of for binders is removed

fn f()
where
    for<'a> fn(&'a str): std::fmt::Debug,
    for<'a> fn(&'a str): std::fmt::Debug,
{
}

Instead, this happened:

error[E0283]: type annotations needed: cannot satisfy `for<'a> fn(&'a str): Debug`
  --> tests\tracked_method_inherent_return_ref.rs:36:35
   |
36 |     for<'db> for<'a> fn(&'a str): std::fmt::Debug,
   |                                   ^^^^^^^^^^^^^^^
   |
note: multiple `impl`s or `where` clauses satisfying `for<'a> fn(&'a str): Debug` found
  --> tests\tracked_method_inherent_return_ref.rs:36:35
   |
36 |     for<'db> for<'a> fn(&'a str): std::fmt::Debug,
   |                                   ^^^^^^^^^^^^^^^
37 |     for<'db> for<'a> fn(&'a str): std::fmt::Debug,
   |                                   ^^^^^^^^^^^^^^^
   = note: and another `impl` found in the `core` crate:
           - impl<F> Debug for F
             where F: FnPtr;

For more information about this error, try `rustc --explain E0283`.
error: could not compile `salsa` (test "tracked_method_inherent_return_ref") due to 1 previous error

Meta

rustc --version --verbose:

rustc 1.88.0-nightly (5e17a2a91 2025-04-05)
binary: rustc
commit-hash: 5e17a2a91dd7dbefd8b4a1087c2e42257457deeb
commit-date: 2025-04-05
host: x86_64-pc-windows-msvc
release: 1.88.0-nightly
LLVM version: 20.1.2

Metadata

Metadata

Assignees

No one assigned

    Labels

    A-trait-systemArea: Trait systemC-bugCategory: This is a bug.T-typesRelevant to the types 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