use the correct node args for substitution

This commit is contained in:
y21 2023-09-05 19:08:34 +02:00
parent cf10690ad4
commit 18f36897ef
4 changed files with 137 additions and 23 deletions

View file

@ -244,6 +244,47 @@ mod issue11300 {
// and `i32: Helper2<[i32, 3]>` is true, so this call is indeed unncessary.
foo3([1, 2, 3]);
}
fn ice() {
struct S1;
impl S1 {
pub fn foo<I: IntoIterator>(&self, _: I) {}
}
S1.foo([1, 2]);
// ICE that occured in itertools
trait Itertools {
fn interleave_shortest<J>(self, other: J)
where
J: IntoIterator,
Self: Sized;
}
impl<I: Iterator> Itertools for I {
fn interleave_shortest<J>(self, other: J)
where
J: IntoIterator,
Self: Sized,
{
}
}
let v0: Vec<i32> = vec![0, 2, 4];
let v1: Vec<i32> = vec![1, 3, 5, 7];
v0.into_iter().interleave_shortest(v1);
trait TraitWithLifetime<'a> {}
impl<'a> TraitWithLifetime<'a> for std::array::IntoIter<&'a i32, 2> {}
struct Helper;
impl<'a> Helper {
fn with_lt<I>(&self, _: I)
where
I: IntoIterator + TraitWithLifetime<'a>,
{
}
}
Helper.with_lt([&1, &2].into_iter());
}
}
#[derive(Copy, Clone)]

View file

@ -244,6 +244,47 @@ mod issue11300 {
// and `i32: Helper2<[i32, 3]>` is true, so this call is indeed unncessary.
foo3([1, 2, 3].into_iter());
}
fn ice() {
struct S1;
impl S1 {
pub fn foo<I: IntoIterator>(&self, _: I) {}
}
S1.foo([1, 2].into_iter());
// ICE that occured in itertools
trait Itertools {
fn interleave_shortest<J>(self, other: J)
where
J: IntoIterator,
Self: Sized;
}
impl<I: Iterator> Itertools for I {
fn interleave_shortest<J>(self, other: J)
where
J: IntoIterator,
Self: Sized,
{
}
}
let v0: Vec<i32> = vec![0, 2, 4];
let v1: Vec<i32> = vec![1, 3, 5, 7];
v0.into_iter().interleave_shortest(v1.into_iter());
trait TraitWithLifetime<'a> {}
impl<'a> TraitWithLifetime<'a> for std::array::IntoIter<&'a i32, 2> {}
struct Helper;
impl<'a> Helper {
fn with_lt<I>(&self, _: I)
where
I: IntoIterator + TraitWithLifetime<'a>,
{
}
}
Helper.with_lt([&1, &2].into_iter());
}
}
#[derive(Copy, Clone)]

View file

@ -202,5 +202,29 @@ note: this parameter accepts any `IntoIterator`, so you don't need to call `.int
LL | I: IntoIterator<Item = i32>,
| ^^^^^^^^^^^^^^^^^^^^^^^^
error: aborting due to 26 previous errors
error: explicit call to `.into_iter()` in function argument accepting `IntoIterator`
--> $DIR/useless_conversion.rs:254:16
|
LL | S1.foo([1, 2].into_iter());
| ^^^^^^^^^^^^^^^^^^ help: consider removing the `.into_iter()`: `[1, 2]`
|
note: this parameter accepts any `IntoIterator`, so you don't need to call `.into_iter()`
--> $DIR/useless_conversion.rs:251:27
|
LL | pub fn foo<I: IntoIterator>(&self, _: I) {}
| ^^^^^^^^^^^^
error: explicit call to `.into_iter()` in function argument accepting `IntoIterator`
--> $DIR/useless_conversion.rs:273:44
|
LL | v0.into_iter().interleave_shortest(v1.into_iter());
| ^^^^^^^^^^^^^^ help: consider removing the `.into_iter()`: `v1`
|
note: this parameter accepts any `IntoIterator`, so you don't need to call `.into_iter()`
--> $DIR/useless_conversion.rs:260:20
|
LL | J: IntoIterator,
| ^^^^^^^^^^^^
error: aborting due to 28 previous errors