diff --git a/compiler/rustc_middle/src/lib.rs b/compiler/rustc_middle/src/lib.rs index a575f27ad3860..fa2dad5ce25f0 100644 --- a/compiler/rustc_middle/src/lib.rs +++ b/compiler/rustc_middle/src/lib.rs @@ -41,6 +41,7 @@ #![feature(new_uninit)] #![feature(nll)] #![feature(once_cell)] +#![feature(let_chains)] #![feature(let_else)] #![feature(min_specialization)] #![feature(trusted_len)] diff --git a/compiler/rustc_middle/src/ty/print/pretty.rs b/compiler/rustc_middle/src/ty/print/pretty.rs index 00cb9907d95a5..5cfd9a5edfb19 100644 --- a/compiler/rustc_middle/src/ty/print/pretty.rs +++ b/compiler/rustc_middle/src/ty/print/pretty.rs @@ -896,44 +896,48 @@ pub trait PrettyPrinter<'tcx>: ); if !generics.is_empty() || !assoc_items.is_empty() { - p!("<"); let mut first = true; for ty in generics { - if !first { + if first { + p!("<"); + first = false; + } else { p!(", "); } p!(print(trait_ref.rebind(*ty))); - first = false; } 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!(write("{} = ", self.tcx().associated_item(assoc_item_def_id).name)); match term.skip_binder() { Term::Ty(ty) => { - // Skip printing `<[generator@] as Generator<_>>::Return` from async blocks - 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)) - } + p!(print(ty)) } Term::Const(c) => { p!(print(c)); } }; - - first = false; } - p!(">"); + if !first { + p!(">"); + } } first = false; diff --git a/src/test/ui/async-await/async-block-control-flow-static-semantics.rs b/src/test/ui/async-await/async-block-control-flow-static-semantics.rs index e3832767203bb..f6c6f90a39378 100644 --- a/src/test/ui/async-await/async-block-control-flow-static-semantics.rs +++ b/src/test/ui/async-await/async-block-control-flow-static-semantics.rs @@ -24,7 +24,7 @@ async fn return_targets_async_block_not_async_fn() -> u8 { return 0u8; }; let _: &dyn Future = █ - //~^ ERROR type mismatch resolving ` as Future>::Output == ()` + //~^ ERROR type mismatch resolving `::Output == ()` } fn no_break_in_async_block() { diff --git a/src/test/ui/async-await/async-block-control-flow-static-semantics.stderr b/src/test/ui/async-await/async-block-control-flow-static-semantics.stderr index fe864c65b7cf2..919904ce3b6a2 100644 --- a/src/test/ui/async-await/async-block-control-flow-static-semantics.stderr +++ b/src/test/ui/async-await/async-block-control-flow-static-semantics.stderr @@ -31,7 +31,7 @@ LL | | LL | | } | |_^ expected `u8`, found `()` -error[E0271]: type mismatch resolving ` as Future>::Output == ()` +error[E0271]: type mismatch resolving `::Output == ()` --> $DIR/async-block-control-flow-static-semantics.rs:26:39 | LL | let _: &dyn Future = █ @@ -47,7 +47,7 @@ LL | fn return_targets_async_block_not_fn() -> u8 { | | | implicitly returns `()` as its body has no tail or `return` expression -error[E0271]: type mismatch resolving ` as Future>::Output == ()` +error[E0271]: type mismatch resolving `::Output == ()` --> $DIR/async-block-control-flow-static-semantics.rs:17:39 | LL | let _: &dyn Future = █ diff --git a/src/test/ui/async-await/generator-desc.stderr b/src/test/ui/async-await/generator-desc.stderr index 4a45d8d2a9423..79834ed7ec1a8 100644 --- a/src/test/ui/async-await/generator-desc.stderr +++ b/src/test/ui/async-await/generator-desc.stderr @@ -46,8 +46,8 @@ LL | pub const fn from_generator(gen: T) -> impl Future | the expected opaque type | the found opaque type | - = note: expected opaque type `impl Future` (`async` closure body) - found opaque type `impl Future` (`async` closure body) + = note: expected opaque type `impl Future` (`async` closure body) + found opaque type `impl Future` (`async` closure body) error: aborting due to 3 previous errors diff --git a/src/test/ui/async-await/issue-67252-unnamed-future.stderr b/src/test/ui/async-await/issue-67252-unnamed-future.stderr index f32e074d75d62..19b90f1d878c7 100644 --- a/src/test/ui/async-await/issue-67252-unnamed-future.stderr +++ b/src/test/ui/async-await/issue-67252-unnamed-future.stderr @@ -4,7 +4,7 @@ error: future cannot be sent between threads safely LL | spawn(async { | ^^^^^ future created by async block is not `Send` | - = help: within `impl Future`, 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 --> $DIR/issue-67252-unnamed-future.rs:20:16 | diff --git a/src/test/ui/async-await/issue-68112.stderr b/src/test/ui/async-await/issue-68112.stderr index a8c2ebe12fa18..9682a7055e93c 100644 --- a/src/test/ui/async-await/issue-68112.stderr +++ b/src/test/ui/async-await/issue-68112.stderr @@ -44,13 +44,13 @@ LL | require_send(send_fut); = note: required because of the requirements on the impl of `Send` for `Arc>` = 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 `impl Future` + = note: required because it appears within the type `impl Future` = note: required because it appears within the type `impl Future>>` = note: required because it appears within the type `impl Future>>` = note: required because it appears within the type `{ResumeTy, impl Future>>, (), i32, Ready}` = 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 `impl Future` + = note: required because it appears within the type `impl Future` note: required by a bound in `require_send` --> $DIR/issue-68112.rs:11:25 | diff --git a/src/test/ui/async-await/issues/issue-65436-raw-ptr-not-send.stderr b/src/test/ui/async-await/issues/issue-65436-raw-ptr-not-send.stderr index b4d2006480390..cf023bd0f9705 100644 --- a/src/test/ui/async-await/issues/issue-65436-raw-ptr-not-send.stderr +++ b/src/test/ui/async-await/issues/issue-65436-raw-ptr-not-send.stderr @@ -4,7 +4,7 @@ error: future cannot be sent between threads safely LL | assert_send(async { | ^^^^^^^^^^^ future created by async block is not `Send` | - = help: within `impl Future`, 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 --> $DIR/issue-65436-raw-ptr-not-send.rs:14:35 | diff --git a/src/test/ui/async-await/partial-drop-partial-reinit.stderr b/src/test/ui/async-await/partial-drop-partial-reinit.stderr index 2097642eb24ab..a83b1d660c34c 100644 --- a/src/test/ui/async-await/partial-drop-partial-reinit.stderr +++ b/src/test/ui/async-await/partial-drop-partial-reinit.stderr @@ -14,7 +14,7 @@ LL | async fn foo() { = note: required because it appears within the type `{ResumeTy, (NotSend,), impl Future, ()}` = 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 `impl Future` + = note: required because it appears within the type `impl Future` = note: required because it appears within the type `impl Future` note: required by a bound in `gimme_send` --> $DIR/partial-drop-partial-reinit.rs:10:18 diff --git a/src/test/ui/chalkify/bugs/async.stderr b/src/test/ui/chalkify/bugs/async.stderr index 7a86561bcb9ce..3d62f059f37cd 100644 --- a/src/test/ui/chalkify/bugs/async.stderr +++ b/src/test/ui/chalkify/bugs/async.stderr @@ -28,7 +28,7 @@ note: required by a bound in `from_generator` LL | T: Generator, | ^^^^^^^^^^ required by this bound in `from_generator` -error[E0280]: the requirement ` as Future>::Output == u32` is not satisfied +error[E0280]: the requirement `::Output == u32` is not satisfied --> $DIR/async.rs:7:25 | LL | async fn foo(x: u32) -> u32 { diff --git a/src/test/ui/generic-associated-types/bugs/issue-89008.stderr b/src/test/ui/generic-associated-types/bugs/issue-89008.stderr index c2687ca540153..3e607d4004e85 100644 --- a/src/test/ui/generic-associated-types/bugs/issue-89008.stderr +++ b/src/test/ui/generic-associated-types/bugs/issue-89008.stderr @@ -1,4 +1,4 @@ -error[E0271]: type mismatch resolving ` as Future>::Output == impl Stream` +error[E0271]: type mismatch resolving `::Output == impl Stream` --> $DIR/issue-89008.rs:39:43 | LL | type LineStream<'a, Repr> = impl Stream; diff --git a/src/test/ui/impl-trait/issue-55872-2.rs b/src/test/ui/impl-trait/issue-55872-2.rs index 17a6a85787442..1841d7b3d372d 100644 --- a/src/test/ui/impl-trait/issue-55872-2.rs +++ b/src/test/ui/impl-trait/issue-55872-2.rs @@ -12,7 +12,7 @@ impl Bar for S { type E = impl std::marker::Copy; fn foo() -> Self::E { //~^ 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: Copy` is not satisfied + //~| ERROR the trait bound `impl Future: Copy` is not satisfied async {} } } diff --git a/src/test/ui/impl-trait/issue-55872-2.stderr b/src/test/ui/impl-trait/issue-55872-2.stderr index b76b564dfb139..76122e60c4cb6 100644 --- a/src/test/ui/impl-trait/issue-55872-2.stderr +++ b/src/test/ui/impl-trait/issue-55872-2.stderr @@ -1,8 +1,8 @@ -error[E0277]: the trait bound `impl Future: Copy` is not satisfied +error[E0277]: the trait bound `impl Future: Copy` is not satisfied --> $DIR/issue-55872-2.rs:13:20 | LL | fn foo() -> Self::E { - | ^^^^^^^ the trait `Copy` is not implemented for `impl Future` + | ^^^^^^^ 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 --> $DIR/issue-55872-2.rs:13:28 diff --git a/src/test/ui/impl-trait/issues/issue-78722.stderr b/src/test/ui/impl-trait/issues/issue-78722.stderr index 130678de2370c..86bde9a0cddab 100644 --- a/src/test/ui/impl-trait/issues/issue-78722.stderr +++ b/src/test/ui/impl-trait/issues/issue-78722.stderr @@ -15,7 +15,7 @@ LL | pub const fn from_generator(gen: T) -> impl Future | ------------------------------- the found opaque type | = note: expected opaque type `impl Future` - found opaque type `impl Future` + found opaque type `impl Future` = note: distinct uses of `impl Trait` result in different opaque types error: aborting due to previous error diff --git a/src/test/ui/pattern/non-structural-match-types.stderr b/src/test/ui/pattern/non-structural-match-types.stderr index 31168e29eb82f..91fed81eaeff6 100644 --- a/src/test/ui/pattern/non-structural-match-types.stderr +++ b/src/test/ui/pattern/non-structural-match-types.stderr @@ -4,7 +4,7 @@ error: `[closure@$DIR/non-structural-match-types.rs:9:17: 9:22]` cannot be used LL | const { || {} } => {}, | ^^^^^^^^^^^^^^^ -error: `impl Future` cannot be used in patterns +error: `impl Future` cannot be used in patterns --> $DIR/non-structural-match-types.rs:12:9 | LL | const { async {} } => {}, diff --git a/src/test/ui/suggestions/expected-boxed-future-isnt-pinned.stderr b/src/test/ui/suggestions/expected-boxed-future-isnt-pinned.stderr index 550ed4b03b039..7ef4895249cec 100644 --- a/src/test/ui/suggestions/expected-boxed-future-isnt-pinned.stderr +++ b/src/test/ui/suggestions/expected-boxed-future-isnt-pinned.stderr @@ -81,7 +81,7 @@ LL | pub const fn from_generator(gen: T) -> impl Future | ------------------------------- the found opaque type | = note: expected struct `Pin + Send + 'static)>>` - found opaque type `impl Future` + found opaque type `impl Future` help: you need to pin and box this expression | LL ~ Box::pin(async {