diff options
| author | bors <bors@rust-lang.org> | 2022-09-29 11:04:47 +0000 |
|---|---|---|
| committer | bors <bors@rust-lang.org> | 2022-09-29 11:04:47 +0000 |
| commit | 97f8f4a3da6cfbac4d914eca7d6a87da8f27901c (patch) | |
| tree | dbdf9078b8d8d2df55ab7a35e0e913bd9e9790dd /library/std/src/sys/unix/stack_overflow.rs | |
| parent | ad752bd52115186ab5ebe2fd27f09867112747c1 (diff) | |
| parent | 6d8903ae5f3d3a16a96e0a3e3f32ce88d7998392 (diff) | |
| download | rust-97f8f4a3da6cfbac4d914eca7d6a87da8f27901c.tar.gz rust-97f8f4a3da6cfbac4d914eca7d6a87da8f27901c.zip | |
Auto merge of #13311 - lowr:fix/for-loop-item-resolution, r=Veykril
fix: infer for-loop item type with `IntoIterator` and `Iterator`
Part of #13299
We've been inferring the type of the yielded values in for-loop as `<T as IntoIterator>::Item`. We infer the correct type most of the time when we normalize the projection type, but it turns out not always. We should infer the type as `<<T as IntoIterator>::IntoIter as Iterator>::Item`.
When one specifies `IntoIter` assoc type of `IntoIterator` but not `Item` in generic bounds, we fail to normalize `<T as IntoIterator>::Item` (even though `IntoIter` is defined like so: `type IntoIter: Iterator<Item = Self::Item>` - rustc does *not* normalize projections based on other projection's bound I believe; see [this playground](https://play.rust-lang.org/?version=stable&mode=debug&edition=2021&gist=e88e19385094cb98fadbf647b4c2082e)).
Note that this doesn't fully fix # 13299 - given the following code, chalk can normalize `<I as IntoIterator>::IntoIter` to `S`, but cannot normalize `<S as Iterator>::Item` to `i32`.
```rust
struct S;
impl Iterator for S { type Item = i32; /* ... */ }
fn f<I: IntoIterator<IntoIter = S>>(it: I) {
for elem in it {}
//^^^^{unknown}
}
```
This is because chalk finds multiple answers that satisfy the query `AliasEq(<S as Iterator>::Item = ?X`: `?X = i32` and `?X = <I as IntoIterator>::Item` - which are supposed to be the same type due to the aforementioned bound on `IntoIter` but chalk is unable to figure it out.
Diffstat (limited to 'library/std/src/sys/unix/stack_overflow.rs')
0 files changed, 0 insertions, 0 deletions
