Skip to content

Commit

Permalink
Rollup merge of #103335 - SarthakSingh31:issue-89008, r=jackh726
Browse files Browse the repository at this point in the history
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>
  • Loading branch information
matthiaskrgr authored Oct 21, 2022
2 parents ebfdf73 + cc6ad45 commit e67f09a
Show file tree
Hide file tree
Showing 2 changed files with 11 additions and 36 deletions.
19 changes: 0 additions & 19 deletions src/test/ui/generic-associated-types/bugs/issue-89008.stderr

This file was deleted.

Original file line number Diff line number Diff line change
@@ -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 } }
}
}

Expand Down

0 comments on commit e67f09a

Please sign in to comment.