Skip to content

Commit e67f09a

Browse files
authored
Rollup merge of #103335 - SarthakSingh31:issue-89008, r=jackh726
Replaced wrong test with the correct mcve Closes #89008. The old test was wrong and the compiler was [correctly raising an error](#89008 (comment)). The bug in the issue was resolved at some point but due to the wrong test the issue was never closed. This pr replaces that test with the correct MCVE (made by ``@jackh726).`` The error raised by the bug changed between when the bug was posted (2021-09-08) and when the MCVE [was posted](#89008 (comment)) (2021-10-23). I ran them both through `nightly-2021-09-08` and they produce identical error messages. They also produce identical but different from before error messages when ran through `nightly-2021-10-23`. <details> <summary>Error message with <code>nightly-2021-09-08</code></summary> The code with the original bug report: ``` error[E0277]: the size for values of type `Repr` cannot be known at compilation time --> src/main.rs:23:43 | 23 | fn line_stream<'a, Repr>(&'a self) -> Self::LineStreamFut<'a, Repr> { | ---- ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ doesn't have a size known at compile-time | | | this type parameter needs to be `std::marker::Sized` For more information about this error, try `rustc --explain E0277`. error: could not compile `test-234234` due to previous error ``` MVCE: ``` error[E0277]: the size for values of type `Repr` cannot be known at compilation time --> src/main.rs:30:43 | 30 | fn line_stream<'a, Repr>(&'a self) -> Self::LineStreamFut<'a, Repr> { | ---- ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ doesn't have a size known at compile-time | | | this type parameter needs to be `std::marker::Sized` For more information about this error, try `rustc --explain E0277`. error: could not compile `test-234234` due to previous error ``` </details> <details> <summary>Error message with <code>nightly-2021-10-23</code></summary> The code with the original bug report: ``` error[E0271]: type mismatch resolving `<impl futures::Future as futures::Future>::Output == impl futures::Stream` --> src/main.rs:23:43 | 19 | type LineStream<'a, Repr> = impl Stream<Item = Repr>; | ------------------------ the expected opaque type ... 23 | fn line_stream<'a, Repr>(&'a self) -> Self::LineStreamFut<'a, Repr> { | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ expected opaque type, found struct `futures::stream::Empty` | = note: expected opaque type `impl futures::Stream` found struct `futures::stream::Empty<_>` error: could not find defining uses --> src/main.rs:19:33 | 19 | type LineStream<'a, Repr> = impl Stream<Item = Repr>; | ^^^^^^^^^^^^^^^^^^^^^^^^ For more information about this error, try `rustc --explain E0271`. error: could not compile `test-234234` due to 2 previous errors ``` MCVE: ``` error[E0271]: type mismatch resolving `<impl Future as Future>::Output == impl Stream` --> src/main.rs:30:43 | 28 | type LineStream<'a, Repr> = impl Stream<Item = Repr>; | ------------------------ the expected opaque type 29 | type LineStreamFut<'a, Repr> = impl Future<Output = Self::LineStream<'a, Repr>>; 30 | fn line_stream<'a, Repr>(&'a self) -> Self::LineStreamFut<'a, Repr> { | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ expected opaque type, found struct `Empty` | = note: expected opaque type `impl Stream` found struct `Empty<_>` error: could not find defining uses --> src/main.rs:28:33 | 28 | type LineStream<'a, Repr> = impl Stream<Item = Repr>; | ^^^^^^^^^^^^^^^^^^^^^^^^ For more information about this error, try `rustc --explain E0271`. error: could not compile `test-234234` due to 2 previous errors ``` </details>
2 parents ebfdf73 + cc6ad45 commit e67f09a

File tree

2 files changed

+11
-36
lines changed

2 files changed

+11
-36
lines changed

src/test/ui/generic-associated-types/bugs/issue-89008.stderr

-19
This file was deleted.

src/test/ui/generic-associated-types/bugs/issue-89008.rs src/test/ui/generic-associated-types/issue-89008.rs

+11-17
Original file line numberDiff line numberDiff line change
@@ -1,42 +1,36 @@
1-
// check-fail
1+
// check-pass
22
// edition:2021
3-
// known-bug: #88908
4-
5-
// This should pass, but seems to run into a TAIT bug.
63

74
#![feature(type_alias_impl_trait)]
85

96
use std::future::Future;
7+
use std::marker::PhantomData;
108

119
trait Stream {
1210
type Item;
1311
}
1412

15-
struct Empty<T>(T);
16-
impl<T> Stream for Empty<T> {
17-
type Item = ();
13+
struct Empty<T> {
14+
_phantom: PhantomData<T>,
1815
}
19-
fn empty<T>() -> Empty<T> {
20-
todo!()
16+
17+
impl<T> Stream for Empty<T> {
18+
type Item = T;
2119
}
2220

2321
trait X {
2422
type LineStream<'a, Repr>: Stream<Item = Repr> where Self: 'a;
25-
26-
type LineStreamFut<'a,Repr>: Future<Output = Self::LineStream<'a, Repr>> where Self: 'a;
27-
28-
fn line_stream<'a,Repr>(&'a self) -> Self::LineStreamFut<'a,Repr>;
23+
type LineStreamFut<'a, Repr>: Future<Output = Self::LineStream<'a, Repr>> where Self: 'a;
24+
fn line_stream<'a, Repr>(&'a self) -> Self::LineStreamFut<'a, Repr>;
2925
}
3026

3127
struct Y;
3228

3329
impl X for Y {
3430
type LineStream<'a, Repr> = impl Stream<Item = Repr>;
35-
36-
type LineStreamFut<'a, Repr> = impl Future<Output = Self::LineStream<'a, Repr>> ;
37-
31+
type LineStreamFut<'a, Repr> = impl Future<Output = Self::LineStream<'a, Repr>>;
3832
fn line_stream<'a, Repr>(&'a self) -> Self::LineStreamFut<'a, Repr> {
39-
async {empty()}
33+
async { Empty { _phantom: PhantomData } }
4034
}
4135
}
4236

0 commit comments

Comments
 (0)