rust-lang / rust-lang/rust

In presence of `impl <T: Trait1> Trait2 for T`, when `X: Trait2` fails, Rust guides you towards satisfying `X: Trait1` instead of `X: Trait2`

Open
#124,802 4 comments 0 reactions 1 assignee View on GitHub

@dianne is already working on this.

Since Nov 8, 2024.

A-diagnostics E-needs-mcve T-compiler
Dominant language
Rust
Stars
119k
Forks
16.1k
PR merge metrics
PR metrics pending

Description

Code
use rayon::iter::{IntoParallelIterator, ParallelIterator};

pub fn parallelize<T>(v: Vec<T>) -> impl ParallelIterator<Item = T>
where
    // T: Send,
{
    v.into_par_iter()
}
Current output
error[E0599]: the method `into_par_iter` exists for struct `Vec<T>`, but its trait bounds were not satisfied
 --> src/lib.rs:7:7
  |
7 |     v.into_par_iter()
  |       ^^^^^^^^^^^^^
  |
  = note: the following trait bounds were not satisfied:
          `[T]: Sized`
          which is required by `[T]: IntoParallelIterator`
          `[T]: ParallelIterator`
          which is required by `[T]: IntoParallelIterator`

warning: unused import: `IntoParallelIterator`
 --> src/lib.rs:1:19
  |
1 | use rayon::iter::{IntoParallelIterator, ParallelIterator};
  |                   ^^^^^^^^^^^^^^^^^^^^
  |
  = note: `#[warn(unused_imports)]` on by default

Desired output

What's really missing is a T: Send bound.

Rationale and extra context

No response

Other cases

No response

Rust Version
rustc 1.79.0-beta.3 (f5d04caa7 2024-05-03)
binary: rustc
commit-hash: f5d04caa74a1dfa5ffc4082c2c8f621f25336bbc
commit-date: 2024-05-03
host: x86_64-unknown-linux-gnu
release: 1.79.0-beta.3
LLVM version: 18.1.4
Anything else?

I will try to provide a MCVE. In the meantime, @rustbot label +E-needs-mcve

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.