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
@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
First steps
- Read the whole issue, then the project's contributing guide.
- Comment on the issue to say you are picking it up — it saves two people doing the same work.
- Fork the repository and make your change on a branch.
- Open a pull request that references the issue number.
Assessment
This issue has not been assessed yet.