Rollup merge of #95225 - compiler-errors:impl-future-generator-ty, r=oli-obk

remove `[async output]` from `impl Future` pretty-printing

self-explanatory, guess it's not as helpful as I thought when I added it 4 months ago
re https://github.com/rust-lang/rust/issues/95089#issuecomment-1075482851
This commit is contained in:
Matthias Krüger 2022-03-23 22:13:25 +01:00 committed by GitHub
commit 1f346bd6a5
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
16 changed files with 39 additions and 34 deletions

View File

@ -41,6 +41,7 @@
#![feature(new_uninit)] #![feature(new_uninit)]
#![feature(nll)] #![feature(nll)]
#![feature(once_cell)] #![feature(once_cell)]
#![feature(let_chains)]
#![feature(let_else)] #![feature(let_else)]
#![feature(min_specialization)] #![feature(min_specialization)]
#![feature(trusted_len)] #![feature(trusted_len)]

View File

@ -896,44 +896,48 @@ pub trait PrettyPrinter<'tcx>:
); );
if !generics.is_empty() || !assoc_items.is_empty() { if !generics.is_empty() || !assoc_items.is_empty() {
p!("<");
let mut first = true; let mut first = true;
for ty in generics { for ty in generics {
if !first { if first {
p!("<");
first = false;
} else {
p!(", "); p!(", ");
} }
p!(print(trait_ref.rebind(*ty))); p!(print(trait_ref.rebind(*ty)));
first = false;
} }
for (assoc_item_def_id, term) in assoc_items { for (assoc_item_def_id, term) in assoc_items {
if !first { // Skip printing `<[generator@] as Generator<_>>::Return` from async blocks
if let Some(ty) = term.skip_binder().ty() &&
let ty::Projection(ty::ProjectionTy { item_def_id, .. }) = ty.kind() &&
Some(*item_def_id) == self.tcx().lang_items().generator_return() {
continue;
}
if first {
p!("<");
first = false;
} else {
p!(", "); p!(", ");
} }
p!(write("{} = ", self.tcx().associated_item(assoc_item_def_id).name)); p!(write("{} = ", self.tcx().associated_item(assoc_item_def_id).name));
match term.skip_binder() { match term.skip_binder() {
Term::Ty(ty) => { Term::Ty(ty) => {
// Skip printing `<[generator@] as Generator<_>>::Return` from async blocks p!(print(ty))
if matches!(
ty.kind(), ty::Projection(ty::ProjectionTy { item_def_id, .. })
if Some(*item_def_id) == self.tcx().lang_items().generator_return()
) {
p!("[async output]")
} else {
p!(print(ty))
}
} }
Term::Const(c) => { Term::Const(c) => {
p!(print(c)); p!(print(c));
} }
}; };
first = false;
} }
p!(">"); if !first {
p!(">");
}
} }
first = false; first = false;

View File

@ -24,7 +24,7 @@ async fn return_targets_async_block_not_async_fn() -> u8 {
return 0u8; return 0u8;
}; };
let _: &dyn Future<Output = ()> = &block; let _: &dyn Future<Output = ()> = &block;
//~^ ERROR type mismatch resolving `<impl Future<Output = [async output]> as Future>::Output == ()` //~^ ERROR type mismatch resolving `<impl Future as Future>::Output == ()`
} }
fn no_break_in_async_block() { fn no_break_in_async_block() {

View File

@ -31,7 +31,7 @@ LL | |
LL | | } LL | | }
| |_^ expected `u8`, found `()` | |_^ expected `u8`, found `()`
error[E0271]: type mismatch resolving `<impl Future<Output = [async output]> as Future>::Output == ()` error[E0271]: type mismatch resolving `<impl Future as Future>::Output == ()`
--> $DIR/async-block-control-flow-static-semantics.rs:26:39 --> $DIR/async-block-control-flow-static-semantics.rs:26:39
| |
LL | let _: &dyn Future<Output = ()> = &block; LL | let _: &dyn Future<Output = ()> = &block;
@ -47,7 +47,7 @@ LL | fn return_targets_async_block_not_fn() -> u8 {
| | | |
| implicitly returns `()` as its body has no tail or `return` expression | implicitly returns `()` as its body has no tail or `return` expression
error[E0271]: type mismatch resolving `<impl Future<Output = [async output]> as Future>::Output == ()` error[E0271]: type mismatch resolving `<impl Future as Future>::Output == ()`
--> $DIR/async-block-control-flow-static-semantics.rs:17:39 --> $DIR/async-block-control-flow-static-semantics.rs:17:39
| |
LL | let _: &dyn Future<Output = ()> = &block; LL | let _: &dyn Future<Output = ()> = &block;

View File

@ -46,8 +46,8 @@ LL | pub const fn from_generator<T>(gen: T) -> impl Future<Output = T::Return>
| the expected opaque type | the expected opaque type
| the found opaque type | the found opaque type
| |
= note: expected opaque type `impl Future<Output = [async output]>` (`async` closure body) = note: expected opaque type `impl Future` (`async` closure body)
found opaque type `impl Future<Output = [async output]>` (`async` closure body) found opaque type `impl Future` (`async` closure body)
error: aborting due to 3 previous errors error: aborting due to 3 previous errors

View File

@ -4,7 +4,7 @@ error: future cannot be sent between threads safely
LL | spawn(async { LL | spawn(async {
| ^^^^^ future created by async block is not `Send` | ^^^^^ future created by async block is not `Send`
| |
= help: within `impl Future<Output = [async output]>`, the trait `Send` is not implemented for `*mut ()` = help: within `impl Future`, the trait `Send` is not implemented for `*mut ()`
note: future is not `Send` as this value is used across an await note: future is not `Send` as this value is used across an await
--> $DIR/issue-67252-unnamed-future.rs:20:16 --> $DIR/issue-67252-unnamed-future.rs:20:16
| |

View File

@ -44,13 +44,13 @@ LL | require_send(send_fut);
= note: required because of the requirements on the impl of `Send` for `Arc<RefCell<i32>>` = note: required because of the requirements on the impl of `Send` for `Arc<RefCell<i32>>`
= note: required because it appears within the type `[static generator@$DIR/issue-68112.rs:47:31: 47:36]` = note: required because it appears within the type `[static generator@$DIR/issue-68112.rs:47:31: 47:36]`
= note: required because it appears within the type `from_generator::GenFuture<[static generator@$DIR/issue-68112.rs:47:31: 47:36]>` = note: required because it appears within the type `from_generator::GenFuture<[static generator@$DIR/issue-68112.rs:47:31: 47:36]>`
= note: required because it appears within the type `impl Future<Output = [async output]>` = note: required because it appears within the type `impl Future`
= note: required because it appears within the type `impl Future<Output = Arc<RefCell<i32>>>` = note: required because it appears within the type `impl Future<Output = Arc<RefCell<i32>>>`
= note: required because it appears within the type `impl Future<Output = Arc<RefCell<i32>>>` = note: required because it appears within the type `impl Future<Output = Arc<RefCell<i32>>>`
= note: required because it appears within the type `{ResumeTy, impl Future<Output = Arc<RefCell<i32>>>, (), i32, Ready<i32>}` = note: required because it appears within the type `{ResumeTy, impl Future<Output = Arc<RefCell<i32>>>, (), i32, Ready<i32>}`
= note: required because it appears within the type `[static generator@$DIR/issue-68112.rs:55:26: 59:6]` = note: required because it appears within the type `[static generator@$DIR/issue-68112.rs:55:26: 59:6]`
= note: required because it appears within the type `from_generator::GenFuture<[static generator@$DIR/issue-68112.rs:55:26: 59:6]>` = note: required because it appears within the type `from_generator::GenFuture<[static generator@$DIR/issue-68112.rs:55:26: 59:6]>`
= note: required because it appears within the type `impl Future<Output = [async output]>` = note: required because it appears within the type `impl Future`
note: required by a bound in `require_send` note: required by a bound in `require_send`
--> $DIR/issue-68112.rs:11:25 --> $DIR/issue-68112.rs:11:25
| |

View File

@ -4,7 +4,7 @@ error: future cannot be sent between threads safely
LL | assert_send(async { LL | assert_send(async {
| ^^^^^^^^^^^ future created by async block is not `Send` | ^^^^^^^^^^^ future created by async block is not `Send`
| |
= help: within `impl Future<Output = [async output]>`, the trait `Send` is not implemented for `*const u8` = help: within `impl Future`, the trait `Send` is not implemented for `*const u8`
note: future is not `Send` as this value is used across an await note: future is not `Send` as this value is used across an await
--> $DIR/issue-65436-raw-ptr-not-send.rs:14:35 --> $DIR/issue-65436-raw-ptr-not-send.rs:14:35
| |

View File

@ -14,7 +14,7 @@ LL | async fn foo() {
= note: required because it appears within the type `{ResumeTy, (NotSend,), impl Future<Output = ()>, ()}` = note: required because it appears within the type `{ResumeTy, (NotSend,), impl Future<Output = ()>, ()}`
= note: required because it appears within the type `[static generator@$DIR/partial-drop-partial-reinit.rs:22:16: 27:2]` = note: required because it appears within the type `[static generator@$DIR/partial-drop-partial-reinit.rs:22:16: 27:2]`
= note: required because it appears within the type `from_generator::GenFuture<[static generator@$DIR/partial-drop-partial-reinit.rs:22:16: 27:2]>` = note: required because it appears within the type `from_generator::GenFuture<[static generator@$DIR/partial-drop-partial-reinit.rs:22:16: 27:2]>`
= note: required because it appears within the type `impl Future<Output = [async output]>` = note: required because it appears within the type `impl Future`
= note: required because it appears within the type `impl Future<Output = ()>` = note: required because it appears within the type `impl Future<Output = ()>`
note: required by a bound in `gimme_send` note: required by a bound in `gimme_send`
--> $DIR/partial-drop-partial-reinit.rs:10:18 --> $DIR/partial-drop-partial-reinit.rs:10:18

View File

@ -28,7 +28,7 @@ note: required by a bound in `from_generator`
LL | T: Generator<ResumeTy, Yield = ()>, LL | T: Generator<ResumeTy, Yield = ()>,
| ^^^^^^^^^^ required by this bound in `from_generator` | ^^^^^^^^^^ required by this bound in `from_generator`
error[E0280]: the requirement `<impl Future<Output = [async output]> as Future>::Output == u32` is not satisfied error[E0280]: the requirement `<impl Future as Future>::Output == u32` is not satisfied
--> $DIR/async.rs:7:25 --> $DIR/async.rs:7:25
| |
LL | async fn foo(x: u32) -> u32 { LL | async fn foo(x: u32) -> u32 {

View File

@ -1,4 +1,4 @@
error[E0271]: type mismatch resolving `<impl Future<Output = [async output]> as Future>::Output == impl Stream<Item = Repr>` error[E0271]: type mismatch resolving `<impl Future as Future>::Output == impl Stream<Item = Repr>`
--> $DIR/issue-89008.rs:39:43 --> $DIR/issue-89008.rs:39:43
| |
LL | type LineStream<'a, Repr> = impl Stream<Item = Repr>; LL | type LineStream<'a, Repr> = impl Stream<Item = Repr>;

View File

@ -12,7 +12,7 @@ impl<S> Bar for S {
type E = impl std::marker::Copy; type E = impl std::marker::Copy;
fn foo<T>() -> Self::E { fn foo<T>() -> Self::E {
//~^ ERROR type parameter `T` is part of concrete type but not used in parameter list for the `impl Trait` type alias //~^ ERROR type parameter `T` is part of concrete type but not used in parameter list for the `impl Trait` type alias
//~| ERROR the trait bound `impl Future<Output = [async output]>: Copy` is not satisfied //~| ERROR the trait bound `impl Future: Copy` is not satisfied
async {} async {}
} }
} }

View File

@ -1,8 +1,8 @@
error[E0277]: the trait bound `impl Future<Output = [async output]>: Copy` is not satisfied error[E0277]: the trait bound `impl Future: Copy` is not satisfied
--> $DIR/issue-55872-2.rs:13:20 --> $DIR/issue-55872-2.rs:13:20
| |
LL | fn foo<T>() -> Self::E { LL | fn foo<T>() -> Self::E {
| ^^^^^^^ the trait `Copy` is not implemented for `impl Future<Output = [async output]>` | ^^^^^^^ the trait `Copy` is not implemented for `impl Future`
error: type parameter `T` is part of concrete type but not used in parameter list for the `impl Trait` type alias error: type parameter `T` is part of concrete type but not used in parameter list for the `impl Trait` type alias
--> $DIR/issue-55872-2.rs:13:28 --> $DIR/issue-55872-2.rs:13:28

View File

@ -15,7 +15,7 @@ LL | pub const fn from_generator<T>(gen: T) -> impl Future<Output = T::Return>
| ------------------------------- the found opaque type | ------------------------------- the found opaque type
| |
= note: expected opaque type `impl Future<Output = u8>` = note: expected opaque type `impl Future<Output = u8>`
found opaque type `impl Future<Output = [async output]>` found opaque type `impl Future`
= note: distinct uses of `impl Trait` result in different opaque types = note: distinct uses of `impl Trait` result in different opaque types
error: aborting due to previous error error: aborting due to previous error

View File

@ -4,7 +4,7 @@ error: `[closure@$DIR/non-structural-match-types.rs:9:17: 9:22]` cannot be used
LL | const { || {} } => {}, LL | const { || {} } => {},
| ^^^^^^^^^^^^^^^ | ^^^^^^^^^^^^^^^
error: `impl Future<Output = [async output]>` cannot be used in patterns error: `impl Future` cannot be used in patterns
--> $DIR/non-structural-match-types.rs:12:9 --> $DIR/non-structural-match-types.rs:12:9
| |
LL | const { async {} } => {}, LL | const { async {} } => {},

View File

@ -81,7 +81,7 @@ LL | pub const fn from_generator<T>(gen: T) -> impl Future<Output = T::Return>
| ------------------------------- the found opaque type | ------------------------------- the found opaque type
| |
= note: expected struct `Pin<Box<(dyn Future<Output = i32> + Send + 'static)>>` = note: expected struct `Pin<Box<(dyn Future<Output = i32> + Send + 'static)>>`
found opaque type `impl Future<Output = [async output]>` found opaque type `impl Future`
help: you need to pin and box this expression help: you need to pin and box this expression
| |
LL ~ Box::pin(async { LL ~ Box::pin(async {