rust-lang / rust-lang/rust

Incomplete inference guidance due to `Sized` param-env clause causes method selection failure

Open
#137,812 1 comment 0 reactions 0 assignees View on GitHub

Nobody has claimed this yet.

A-inference A-trait-system C-bug fixed-by-next-solver T-types
Dominant language
Rust
Stars
119k
Forks
16.1k
PR merge metrics
PR metrics pending

Description

I tried this code:

trait Foo<T> {
    fn method();
}

fn test<T, U>()
where
    T: Foo<(i32,)>,
    (U,): Sized,
{
    <T as Foo<(_,)>>::method();
}

I expected to see it work (in the old solver).

Instead, it did not:

error[E0277]: the trait bound `T: Foo<(U,)>` is not satisfied
  --> src/lib.rs:10:6
   |
10 |     <T as Foo<(_,)>>::method();
   |      ^ the trait `Foo<(U,)>` is not implemented for `T`
Meta

stable 1.85 rust, beta rust, and nightly feb 28 2025

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 reproducing the example in src/lib.rs on the reported stable, beta, and nightly Rust versions. Trace the compiler's trait selection and inference handling for the Sized parameter-environment clause; done means the shown method call resolves successfully without the E0277 error.

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
Stale
Clarity
Needs clarification
Newbie friendliness
32/100

Get new issues in your inbox

A short digest of beginner-friendly GitHub issues.