Closed
Description
The current implementation of precise capture requires that use<>
bounds include all type parameters in scope. This is a temporary limitation that should be lifted. Example:
#![allow(warnings)]
fn main() {
let mut data = vec![1, 2, 3];
let mut i = indices(&data);
data.push(4);
i.next();
}
fn indices<T>(
slice: &[T],
) -> impl Iterator<Item = usize> + use<> {
0 .. slice.len()
}
This code should compile, but it current gives an error (playground):
error: `impl Trait` must mention all type parameters in scope in `use<...>`
--> src/main.rs:12:6
|
10 | fn indices<T>(
| - type parameter is implicitly captured by this `impl Trait`
11 | slice: &[T],
12 | ) -> impl Iterator<Item = usize> + use<> {
| ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
|
= note: currently, all type parameters are required to be mentioned in the precise captures list