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](https://github.com/rust-lang/rust/issues/89008#issuecomment-1285128060). 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](https://github.com/rust-lang/rust/issues/89008#issuecomment-950110735) (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>
This commit is contained in:
commit
e67f09ac79
@ -1,19 +0,0 @@
|
||||
error[E0271]: type mismatch resolving `<Empty<_> as Stream>::Item == Repr`
|
||||
--> $DIR/issue-89008.rs:38:43
|
||||
|
|
||||
LL | fn line_stream<'a, Repr>(&'a self) -> Self::LineStreamFut<'a, Repr> {
|
||||
| ---- ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ type mismatch resolving `<Empty<_> as Stream>::Item == Repr`
|
||||
| |
|
||||
| this type parameter
|
||||
|
|
||||
note: expected this to be `()`
|
||||
--> $DIR/issue-89008.rs:17:17
|
||||
|
|
||||
LL | type Item = ();
|
||||
| ^^
|
||||
= note: expected unit type `()`
|
||||
found type parameter `Repr`
|
||||
|
||||
error: aborting due to previous error
|
||||
|
||||
For more information about this error, try `rustc --explain E0271`.
|
@ -1,42 +1,36 @@
|
||||
// check-fail
|
||||
// check-pass
|
||||
// edition:2021
|
||||
// known-bug: #88908
|
||||
|
||||
// This should pass, but seems to run into a TAIT bug.
|
||||
|
||||
#![feature(type_alias_impl_trait)]
|
||||
|
||||
use std::future::Future;
|
||||
use std::marker::PhantomData;
|
||||
|
||||
trait Stream {
|
||||
type Item;
|
||||
}
|
||||
|
||||
struct Empty<T>(T);
|
||||
impl<T> Stream for Empty<T> {
|
||||
type Item = ();
|
||||
struct Empty<T> {
|
||||
_phantom: PhantomData<T>,
|
||||
}
|
||||
fn empty<T>() -> Empty<T> {
|
||||
todo!()
|
||||
|
||||
impl<T> Stream for Empty<T> {
|
||||
type Item = T;
|
||||
}
|
||||
|
||||
trait X {
|
||||
type LineStream<'a, Repr>: Stream<Item = Repr> where Self: 'a;
|
||||
|
||||
type LineStreamFut<'a,Repr>: Future<Output = Self::LineStream<'a, Repr>> where Self: 'a;
|
||||
|
||||
fn line_stream<'a,Repr>(&'a self) -> Self::LineStreamFut<'a,Repr>;
|
||||
type LineStreamFut<'a, Repr>: Future<Output = Self::LineStream<'a, Repr>> where Self: 'a;
|
||||
fn line_stream<'a, Repr>(&'a self) -> Self::LineStreamFut<'a, Repr>;
|
||||
}
|
||||
|
||||
struct Y;
|
||||
|
||||
impl X for Y {
|
||||
type LineStream<'a, Repr> = impl Stream<Item = Repr>;
|
||||
|
||||
type LineStreamFut<'a, Repr> = impl Future<Output = Self::LineStream<'a, Repr>> ;
|
||||
|
||||
type LineStreamFut<'a, Repr> = impl Future<Output = Self::LineStream<'a, Repr>>;
|
||||
fn line_stream<'a, Repr>(&'a self) -> Self::LineStreamFut<'a, Repr> {
|
||||
async {empty()}
|
||||
async { Empty { _phantom: PhantomData } }
|
||||
}
|
||||
}
|
||||
|
Loading…
x
Reference in New Issue
Block a user