rust-lang / rust-lang/rust

Spurious E0034 for trait methods coming from blanket impl on functions which already have other errors

Open
#161,544 1 comment 0 reactions 0 assignees View on GitHub

Nobody has claimed this yet.

C-bug needs-triage T-compiler T-types WG-trait-system-refactor
Dominant language
Rust
Stars
119k
Forks
16.1k
PR merge metrics
PR metrics pending

Description

I tried this code:

#![recursion_limit = "1"]
trait ArgA {}
impl<T> ArgA for (T,) {}
impl ArgA for i32 {}

trait ArgB {}
impl<T> ArgB for (T,) {}
impl ArgB for u8 {}
trait AmbiguousA<Args> {
    fn foo(&self) {}
}
trait AmbiguousB<Args> {
    fn foo(&self) {}
}
impl<Args, F> AmbiguousA<Args> for F
where
    F: Fn(Args),
    Args: ArgA,
{
}
impl<Args, F> AmbiguousB<Args> for F
where
    F: Fn(Args),
    Args: ArgB,
{
}

// broken functions
fn thing(a: ((((((((((i32,),),),),),),),),),)) {}
fn thingb(a: DoesNotExist) {}
fn main() {
    thing.foo();
    thingb.foo();
}

I expected to see this happen: I expected to see recursion depth and E0425 as the sole errors.

Instead, this happened: I got recursion depth, E0425, and E0034 for thing.foo() and thingb.foo() on nightly (next-solver). On stable, thingb throws E0599 instead, but the E0034 for thing is still there.

Note: This was originally noticed in https://github.com/bevyengine/bevy/issues/25511
where there is an additional complication: Its caused by the recursion depth, and when depending on bevy as a library, the recursion depth warnings were hidden, making the E0034 the only visible error.

Meta

rustc --version --verbose:

rustc 1.100.0-nightly (c656540d6 2026-08-21)
binary: rustc
commit-hash: c656540d6467dee1381f0cbd882412d6bd1cd5ae
commit-date: 2026-08-21
host: x86_64-unknown-linux-gnu
release: 1.100.0-nightly
LLVM version: 23.1.0

Contributor guide

Open the contributing guide

First steps

  1. Read the whole issue, then the project's contributing guide.
  2. Comment on the issue to say you are picking it up — it saves two people doing the same work.
  3. Fork the repository and make your change on a branch.
  4. Open a pull request that references the issue number.

Research direction

Start by compiling the supplied reproducer with nightly and the next-solver enabled, comparing the recursion-depth, unresolved-name, and method-call diagnostics. Trace rustc's trait-method lookup and error-reporting path for the two broken functions; done means the spurious E0034 diagnostics are no longer emitted while the expected errors remain.

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
Active
Clarity
Mostly clear
Newbie friendliness
48/100

Get new issues in your inbox

A short digest of beginner-friendly GitHub issues.