Skip to content

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

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
Veykril opened this issue Apr 20, 2025 · 1 comment
Open

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

Veykril opened this issue Apr 20, 2025 · 1 comment
Labels
A-trait-system Area: Trait system C-bug Category: This is a bug. T-types Relevant to the types team, which will review and decide on the PR/issue.

Comments

@Veykril
Copy link
Member

Veykril commented Apr 20, 2025

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
@Veykril Veykril added the C-bug Category: This is a bug. label Apr 20, 2025
@rustbot rustbot added the needs-triage This issue may need triage. Remove it if it has been sufficiently triaged. label Apr 20, 2025
@fmease
Copy link
Member

fmease commented Apr 20, 2025

#21974

@lolbinarycat lolbinarycat added the A-trait-system Area: Trait system label Apr 30, 2025
@jieyouxu jieyouxu added T-types Relevant to the types team, which will review and decide on the PR/issue. and removed needs-triage This issue may need triage. Remove it if it has been sufficiently triaged. labels Apr 30, 2025
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
A-trait-system Area: Trait system C-bug Category: This is a bug. T-types Relevant to the types team, which will review and decide on the PR/issue.
Projects
None yet
Development

No branches or pull requests

5 participants