-
Notifications
You must be signed in to change notification settings - Fork 12.8k
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Normalize projections appearing in impl Trait
#62221
Conversation
r? @cramertj (rust_highfive has picked a reviewer for you, use r? to override) |
This comment has been minimized.
This comment has been minimized.
So this now fails the test with lifetimes:
Not sure whether this would be fixed by @nikomatsakis' first suggestion in #60414 (comment)... |
Hmm, I'm not able to build the compiler at all with these changes. (I have a local clone.) I'm trying a build now from HEAD^ to see which commit causes the problems. |
OK, building from HEAD^ works. I'm going to take a look at that failing test, but my hunch is that we should cut if from the PR and leave it for "future work" :P |
Applying this diff does indeed make the test pass: modified src/test/ui/impl-trait/bound-normalization-pass.rs
@@ -43,12 +43,14 @@ mod lifetimes {
}
/// Like above.
- fn foo2_pass<'a, T: Trait<'a, Assoc=()> + 'a>() -> impl FooLike<Output=T::Assoc> + 'a {
+ fn foo2_pass<'a, T: Trait<'a, Assoc=()> + 'a>(
+ ) -> impl FooLike<Output=<T as Trait<'a>>::Assoc> + 'a {
Foo(())
}
/// Normalization to type containing bound region.
- fn foo2_pass2<'a, T: Trait<'a, Assoc=&'a ()> + 'a>() -> impl FooLike<Output=T::Assoc> + 'a {
+ fn foo2_pass2<'a, T: Trait<'a, Assoc=&'a ()> + 'a>(
+ ) -> impl FooLike<Output=<T as Trait<'a>>::Assoc> + 'a {
Foo(&())
}
} Still, I'm not entirely sure why that is needed, given the |
OK, I think I know the cause. It is indeed pretty unrelated to this PR and is basically just a bug in the way we are handling the impl trait desugaring. It arises from the hack where we use |
Ah dang it this is all explained in #51525 =) |
@jonas-schievink forgive me, but I force pushed to your branch -- I think this PR though is ready to land now. |
Okay, go ahead! I didn't have Internet since friday so couldn't do any work on this unfortunately. |
@bors r+ |
📌 Commit 66e0266 has been approved by |
…tsakis Normalize projections appearing in `impl Trait` Fixes #60414 This does not try to do the same for `existential type`s (which have the same bug), since that always seems to lead to cycle errors.
☀️ Test successful - checks-azure, checks-travis, status-appveyor |
Now this signature is allowed:
(kpp/futures-async-combinators@06702ec#diff-7afe74b649f99a176a8b54176b0859a8R105) Whereas is was impossible in the previous releases. And this looks as a bug to me. |
@kpp On first glance, that looks like an expected outcome of this. Where do you see the bug? This equivalent example fails to compile due to ICEs on stable and beta, which this PR fixes: pub trait Stream {
type Item;
}
pub trait Future {
type Output;
}
struct MyStream<T> {
v: Vec<T>,
}
impl<T> Stream for MyStream<T> {
type Item = T;
}
pub fn flatten_stream<Fut, St>(future: Fut) -> impl Stream<Item = Fut::Output>
where Fut: Future<Output = St>,
St: Stream<Item = Fut::Output>,
{
MyStream {
v: Vec::new(),
}
}
In particular: |
I got the following error on nightly-2019-07-06 with the signature above:
|
That does look expected to me. In the type mismatch error here you can see that the
|
Fixes #60414
This does not try to do the same for
existential type
s (which have the same bug), since that always seems to lead to cycle errors.