Skip to content

Commit 1f346bd

Browse files
authored
Rollup merge of rust-lang#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 rust-lang#95089 (comment)
2 parents 23ef234 + bdb4b1e commit 1f346bd

16 files changed

+39
-34
lines changed

compiler/rustc_middle/src/lib.rs

+1
Original file line numberDiff line numberDiff line change
@@ -41,6 +41,7 @@
4141
#![feature(new_uninit)]
4242
#![feature(nll)]
4343
#![feature(once_cell)]
44+
#![feature(let_chains)]
4445
#![feature(let_else)]
4546
#![feature(min_specialization)]
4647
#![feature(trusted_len)]

compiler/rustc_middle/src/ty/print/pretty.rs

+20-16
Original file line numberDiff line numberDiff line change
@@ -896,44 +896,48 @@ pub trait PrettyPrinter<'tcx>:
896896
);
897897

898898
if !generics.is_empty() || !assoc_items.is_empty() {
899-
p!("<");
900899
let mut first = true;
901900

902901
for ty in generics {
903-
if !first {
902+
if first {
903+
p!("<");
904+
first = false;
905+
} else {
904906
p!(", ");
905907
}
906908
p!(print(trait_ref.rebind(*ty)));
907-
first = false;
908909
}
909910

910911
for (assoc_item_def_id, term) in assoc_items {
911-
if !first {
912+
// Skip printing `<[generator@] as Generator<_>>::Return` from async blocks
913+
if let Some(ty) = term.skip_binder().ty() &&
914+
let ty::Projection(ty::ProjectionTy { item_def_id, .. }) = ty.kind() &&
915+
Some(*item_def_id) == self.tcx().lang_items().generator_return() {
916+
continue;
917+
}
918+
919+
if first {
920+
p!("<");
921+
first = false;
922+
} else {
912923
p!(", ");
913924
}
925+
914926
p!(write("{} = ", self.tcx().associated_item(assoc_item_def_id).name));
915927

916928
match term.skip_binder() {
917929
Term::Ty(ty) => {
918-
// Skip printing `<[generator@] as Generator<_>>::Return` from async blocks
919-
if matches!(
920-
ty.kind(), ty::Projection(ty::ProjectionTy { item_def_id, .. })
921-
if Some(*item_def_id) == self.tcx().lang_items().generator_return()
922-
) {
923-
p!("[async output]")
924-
} else {
925-
p!(print(ty))
926-
}
930+
p!(print(ty))
927931
}
928932
Term::Const(c) => {
929933
p!(print(c));
930934
}
931935
};
932-
933-
first = false;
934936
}
935937

936-
p!(">");
938+
if !first {
939+
p!(">");
940+
}
937941
}
938942

939943
first = false;

src/test/ui/async-await/async-block-control-flow-static-semantics.rs

+1-1
Original file line numberDiff line numberDiff line change
@@ -24,7 +24,7 @@ async fn return_targets_async_block_not_async_fn() -> u8 {
2424
return 0u8;
2525
};
2626
let _: &dyn Future<Output = ()> = &block;
27-
//~^ ERROR type mismatch resolving `<impl Future<Output = [async output]> as Future>::Output == ()`
27+
//~^ ERROR type mismatch resolving `<impl Future as Future>::Output == ()`
2828
}
2929

3030
fn no_break_in_async_block() {

src/test/ui/async-await/async-block-control-flow-static-semantics.stderr

+2-2
Original file line numberDiff line numberDiff line change
@@ -31,7 +31,7 @@ LL | |
3131
LL | | }
3232
| |_^ expected `u8`, found `()`
3333

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

50-
error[E0271]: type mismatch resolving `<impl Future<Output = [async output]> as Future>::Output == ()`
50+
error[E0271]: type mismatch resolving `<impl Future as Future>::Output == ()`
5151
--> $DIR/async-block-control-flow-static-semantics.rs:17:39
5252
|
5353
LL | let _: &dyn Future<Output = ()> = &block;

src/test/ui/async-await/generator-desc.stderr

+2-2
Original file line numberDiff line numberDiff line change
@@ -46,8 +46,8 @@ LL | pub const fn from_generator<T>(gen: T) -> impl Future<Output = T::Return>
4646
| the expected opaque type
4747
| the found opaque type
4848
|
49-
= note: expected opaque type `impl Future<Output = [async output]>` (`async` closure body)
50-
found opaque type `impl Future<Output = [async output]>` (`async` closure body)
49+
= note: expected opaque type `impl Future` (`async` closure body)
50+
found opaque type `impl Future` (`async` closure body)
5151

5252
error: aborting due to 3 previous errors
5353

src/test/ui/async-await/issue-67252-unnamed-future.stderr

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

src/test/ui/async-await/issue-68112.stderr

+2-2
Original file line numberDiff line numberDiff line change
@@ -44,13 +44,13 @@ LL | require_send(send_fut);
4444
= note: required because of the requirements on the impl of `Send` for `Arc<RefCell<i32>>`
4545
= note: required because it appears within the type `[static generator@$DIR/issue-68112.rs:47:31: 47:36]`
4646
= note: required because it appears within the type `from_generator::GenFuture<[static generator@$DIR/issue-68112.rs:47:31: 47:36]>`
47-
= note: required because it appears within the type `impl Future<Output = [async output]>`
47+
= note: required because it appears within the type `impl Future`
4848
= note: required because it appears within the type `impl Future<Output = Arc<RefCell<i32>>>`
4949
= note: required because it appears within the type `impl Future<Output = Arc<RefCell<i32>>>`
5050
= note: required because it appears within the type `{ResumeTy, impl Future<Output = Arc<RefCell<i32>>>, (), i32, Ready<i32>}`
5151
= note: required because it appears within the type `[static generator@$DIR/issue-68112.rs:55:26: 59:6]`
5252
= note: required because it appears within the type `from_generator::GenFuture<[static generator@$DIR/issue-68112.rs:55:26: 59:6]>`
53-
= note: required because it appears within the type `impl Future<Output = [async output]>`
53+
= note: required because it appears within the type `impl Future`
5454
note: required by a bound in `require_send`
5555
--> $DIR/issue-68112.rs:11:25
5656
|

src/test/ui/async-await/issues/issue-65436-raw-ptr-not-send.stderr

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

src/test/ui/async-await/partial-drop-partial-reinit.stderr

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

src/test/ui/chalkify/bugs/async.stderr

+1-1
Original file line numberDiff line numberDiff line change
@@ -28,7 +28,7 @@ note: required by a bound in `from_generator`
2828
LL | T: Generator<ResumeTy, Yield = ()>,
2929
| ^^^^^^^^^^ required by this bound in `from_generator`
3030

31-
error[E0280]: the requirement `<impl Future<Output = [async output]> as Future>::Output == u32` is not satisfied
31+
error[E0280]: the requirement `<impl Future as Future>::Output == u32` is not satisfied
3232
--> $DIR/async.rs:7:25
3333
|
3434
LL | async fn foo(x: u32) -> u32 {

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

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

src/test/ui/impl-trait/issue-55872-2.rs

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

src/test/ui/impl-trait/issue-55872-2.stderr

+2-2
Original file line numberDiff line numberDiff line change
@@ -1,8 +1,8 @@
1-
error[E0277]: the trait bound `impl Future<Output = [async output]>: Copy` is not satisfied
1+
error[E0277]: the trait bound `impl Future: Copy` is not satisfied
22
--> $DIR/issue-55872-2.rs:13:20
33
|
44
LL | fn foo<T>() -> Self::E {
5-
| ^^^^^^^ the trait `Copy` is not implemented for `impl Future<Output = [async output]>`
5+
| ^^^^^^^ the trait `Copy` is not implemented for `impl Future`
66

77
error: type parameter `T` is part of concrete type but not used in parameter list for the `impl Trait` type alias
88
--> $DIR/issue-55872-2.rs:13:28

src/test/ui/impl-trait/issues/issue-78722.stderr

+1-1
Original file line numberDiff line numberDiff line change
@@ -15,7 +15,7 @@ LL | pub const fn from_generator<T>(gen: T) -> impl Future<Output = T::Return>
1515
| ------------------------------- the found opaque type
1616
|
1717
= note: expected opaque type `impl Future<Output = u8>`
18-
found opaque type `impl Future<Output = [async output]>`
18+
found opaque type `impl Future`
1919
= note: distinct uses of `impl Trait` result in different opaque types
2020

2121
error: aborting due to previous error

src/test/ui/pattern/non-structural-match-types.stderr

+1-1
Original file line numberDiff line numberDiff line change
@@ -4,7 +4,7 @@ error: `[closure@$DIR/non-structural-match-types.rs:9:17: 9:22]` cannot be used
44
LL | const { || {} } => {},
55
| ^^^^^^^^^^^^^^^
66

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

src/test/ui/suggestions/expected-boxed-future-isnt-pinned.stderr

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

0 commit comments

Comments
 (0)