Open
Description
I tried this code:
fn foo<'a, I: ?Sized>(_: &'a I)
where
&'a I: IntoIterator<Item = &'a ()>,
{
}
pub fn bar() {
foo(&[]);
}
pub struct StringInterner<B>(B);
impl<'a, B> IntoIterator for &'a StringInterner<B>
where
&'a B: IntoIterator<Item = &'a ()>,
{
type Item = <&'a B as IntoIterator>::Item;
type IntoIter = <&'a B as IntoIterator>::IntoIter;
fn into_iter(self) -> Self::IntoIter {
todo!()
}
}
I expected to see this happen: it compiles.
Instead, this happened:
error[E0275]: overflow evaluating the requirement `&_: IntoIterator`
--> src/lib.rs:8:5
|
8 | foo(&[]);
| ^^^^^^^^
|
= help: consider increasing the recursion limit by adding a `#![recursion_limit = "256"]` attribute to your crate (`playground`)
note: required for `&StringInterner<_>` to implement `IntoIterator`
--> src/lib.rs:13:13
|
13 | impl<'a, B> IntoIterator for &'a StringInterner<B>
| ^^^^^^^^^^^^ ^^^^^^^^^^^^^^^^^^^^^
14 | where
15 | &'a B: IntoIterator<Item = &'a ()>,
| ------------- unsatisfied trait bound introduced here
= note: 126 redundant requirements hidden
= note: required for `&StringInterner<StringInterner<StringInterner<StringInterner<...>>>>` to implement `IntoIterator`
note: required by a bound in `foo`
--> src/lib.rs:3:12
|
1 | fn foo<'a, I: ?Sized>(_: &'a I)
| --- required by a bound in this function
2 | where
3 | &'a I: IntoIterator<Item = &'a ()>,
| ^^^^^^^^^^^^^^^^^^^^^^^^^^^ required by this bound in `foo`
= note: the full name for the type has been written to '/playground/target/debug/deps/playground-13c85e6c72950c6d.long-type-17257908183752834728.txt'
= note: consider using `--verbose` to print the full type name to the console
Interestingly, it compiles fine if foo(&[])
is changed to foo::<[_]>(&[])
or if the impl
for StringInterner
is removed.
Originally found in wasmi-labs/wasmi#1366.
Meta
rustc --version --verbose
:
1.86.0-nightly
(2025-02-10 6171d944aea415a3023d)