rust-lang / rust-lang/rust

`E0277` Emitted Twice

Open
#125,685 1 comment 0 reactions 1 assignee View on GitHub

@compiler-errors is already working on this.

Since May 28, 2024.

A-diagnostics A-trait-system D-verbose T-compiler
Dominant language
Rust
Stars
119k
Forks
16.1k
PR merge metrics
PR metrics pending

Description

Code
fn main() {}

trait Foo {
    type Output;
}

fn baz<I>(x: &<I as Foo>::Output) {}
Current output
error[E0277]: the trait bound `I: Foo` is not satisfied
  --> test.rs:23:15
   |
23 | fn baz<I>(x: &<I as Foo>::Output) {}
   |               ^^^^^^^^^^^^^^^^^^ the trait `Foo` is not implemented for `I`
   |
help: consider restricting type parameter `I`
   |
23 | fn baz<I: Foo>(x: &<I as Foo>::Output) {}
   |         +++++

error[E0277]: the trait bound `I: Foo` is not satisfied
  --> test.rs:23:35
   |
23 | fn baz<I>(x: &<I as Foo>::Output) {}
   |                                   ^^ the trait `Foo` is not implemented for `I`
   |
help: consider restricting type parameter `I`
   |
23 | fn baz<I: Foo>(x: &<I as Foo>::Output) {}
   |         +++++

error: aborting due to 2 previous errors

For more information about this error, try `rustc --explain E0277`.
Desired output
error[E0277]: the trait bound `I: Foo` is not satisfied
 --> <source>:7:15
  |
7 | fn baz<I>(x: &<I as Foo>::Output) {}
  |               ^^^^^^^^^^^^^^^^^^ the trait `Foo` is not implemented for `I`
  |
help: consider restricting type parameter `I`
  |
7 | fn baz<I: Foo>(x: &<I as Foo>::Output) {}
  |         +++++

error: aborting due to 1 previous error

For more information about this error, try `rustc --explain E0277`.
Bisect

searched nightlies: from nightly-2024-02-01 to nightly-2024-03-16
regressed nightly: nightly-2024-02-15
searched commit range: https://github.com/rust-lang/rust/compare/a84bb95a1f65bfe25038f188763a18e096a86ab2...ee9c7c940c07d8b67c9a6b2ec930db70dcd23a46
regressed commit: https://github.com/rust-lang/rust/commit/ee9c7c940c07d8b67c9a6b2ec930db70dcd23a46 (PR: https://github.com/rust-lang/rust/pull/120847)

bisected with cargo-bisect-rustc v0.6.8

Host triple: x86_64-unknown-linux-gnu
Reproduce with:

cargo bisect-rustc --prompt --start=1.77.0 --end=1.78.0 
Rust Version
rustc 1.80.0-dev
binary: rustc
commit-hash: unknown
commit-date: unknown
host: x86_64-unknown-linux-gnu
release: 1.80.0-dev
LLVM version: 18.1.6

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.

Assessment

This issue has not been assessed yet.

Get new issues in your inbox

A short digest of beginner-friendly GitHub issues.