Skip to content
Closed
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
15 changes: 1 addition & 14 deletions compiler/rustc_monomorphize/src/collector.rs
Original file line number Diff line number Diff line change
Expand Up @@ -1590,20 +1590,7 @@ impl<'v> RootCollector<'_, 'v> {
fn process_nested_body(&mut self, def_id: LocalDefId) {
match self.tcx.def_kind(def_id) {
DefKind::Closure => {
// for 'pub async fn foo(..)' also trying to monomorphize foo::{closure}
let is_pub_fn_coroutine =
match *self.tcx.type_of(def_id).instantiate_identity().kind() {
ty::Coroutine(cor_id, _args) => {
let tcx = self.tcx;
let parent_id = tcx.parent(cor_id);
tcx.def_kind(parent_id) == DefKind::Fn
&& tcx.asyncness(parent_id).is_async()
&& tcx.visibility(parent_id).is_public()
}
ty::Closure(..) | ty::CoroutineClosure(..) => false,
_ => unreachable!(),
};
if (self.strategy == MonoItemCollectionStrategy::Eager || is_pub_fn_coroutine)
if self.strategy == MonoItemCollectionStrategy::Eager
&& !self
.tcx
.generics_of(self.tcx.typeck_root_def_id(def_id.to_def_id()))
Expand Down
11 changes: 4 additions & 7 deletions tests/codegen-llvm/async-fn-debug-awaitee-field.rs
Original file line number Diff line number Diff line change
Expand Up @@ -18,11 +18,8 @@ pub async fn async_fn_test() {

pub async fn foo() {}

// NONMSVC: [[AWAITEE_TYPE:![0-9]*]] = !DICompositeType(tag: DW_TAG_structure_type, name: "{async_fn_env#0}", scope: [[AWAITEE_SCOPE:![0-9]*]],
// MSVC: [[AWAITEE_TYPE:![0-9]*]] = !DICompositeType(tag: DW_TAG_union_type, name: "enum2$<async_fn_debug_awaitee_field::foo::async_fn_env$0>",
// NONMSVC: [[AWAITEE_SCOPE]] = !DINamespace(name: "foo",
// NONMSVC: [[GEN:!.*]] = !DICompositeType(tag: DW_TAG_structure_type, name: "{async_fn_env#0}", scope: [[GEN_SCOPE:![0-9]*]],
// MSVC: [[GEN:!.*]] = !DICompositeType(tag: DW_TAG_union_type, name: "enum2$<async_fn_debug_awaitee_field::async_fn_test::async_fn_env$0>",
// NONMSVC: [[GEN_SCOPE:!.*]] = !DINamespace(name: "async_fn_test",
// CHECK: [[SUSPEND_STRUCT:!.*]] = !DICompositeType(tag: DW_TAG_structure_type, name: "Suspend0", scope: [[GEN]],
// CHECK: !DIDerivedType(tag: DW_TAG_member, name: "__awaitee", scope: [[SUSPEND_STRUCT]], {{.*}}, baseType: [[AWAITEE_TYPE]],
// CHECK: !DIDerivedType(tag: DW_TAG_member, name: "__awaitee", scope: [[SUSPEND_STRUCT]], {{.*}}, baseType: [[AWAITEE_TYPE:![0-9]*]],
// NONMSVC: [[AWAITEE_TYPE]] = !DICompositeType(tag: DW_TAG_structure_type, name: "{async_fn_env#0}", scope: [[AWAITEE_SCOPE:![0-9]*]],
// MSVC: [[AWAITEE_TYPE]] = !DICompositeType(tag: DW_TAG_union_type, name: "enum2$<async_fn_debug_awaitee_field::foo::async_fn_env$0>",
// NONMSVC: [[AWAITEE_SCOPE]] = !DINamespace(name: "foo",
10 changes: 0 additions & 10 deletions tests/codegen-units/item-collection/async-fn-impl.rs

This file was deleted.

89 changes: 0 additions & 89 deletions tests/codegen-units/item-collection/opaque-return-impls.rs

This file was deleted.

8 changes: 4 additions & 4 deletions tests/coverage/async.cov-map
Original file line number Diff line number Diff line change
Expand Up @@ -103,21 +103,21 @@ Number of file 0 mappings: 3
Highest counter ID seen: (none)

Function name: async::g
Raw bytes (9): 0x[01, 01, 00, 01, 01, 1b, 01, 00, 12]
Raw bytes (9): 0x[01, 01, 00, 01, 01, 1b, 01, 00, 16]
Number of files: 1
- file 0 => $DIR/async.rs
Number of expressions: 0
Number of file 0 mappings: 1
- Code(Counter(0)) at (prev + 27, 1) to (start + 0, 18)
- Code(Counter(0)) at (prev + 27, 1) to (start + 0, 22)
Highest counter ID seen: c0

Function name: async::g::{closure#0} (unused)
Raw bytes (64): 0x[01, 01, 00, 0c, 00, 1b, 13, 00, 14, 00, 01, 0b, 00, 0c, 00, 01, 09, 00, 0a, 00, 00, 0e, 00, 17, 00, 00, 1b, 00, 1c, 00, 00, 20, 00, 22, 00, 01, 09, 00, 0a, 00, 00, 0e, 00, 17, 00, 00, 1b, 00, 1c, 00, 00, 20, 00, 22, 00, 01, 0e, 00, 10, 00, 02, 01, 00, 02]
Raw bytes (64): 0x[01, 01, 00, 0c, 00, 1b, 17, 00, 18, 00, 01, 0b, 00, 0c, 00, 01, 09, 00, 0a, 00, 00, 0e, 00, 17, 00, 00, 1b, 00, 1c, 00, 00, 20, 00, 22, 00, 01, 09, 00, 0a, 00, 00, 0e, 00, 17, 00, 00, 1b, 00, 1c, 00, 00, 20, 00, 22, 00, 01, 0e, 00, 10, 00, 02, 01, 00, 02]
Number of files: 1
- file 0 => $DIR/async.rs
Number of expressions: 0
Number of file 0 mappings: 12
- Code(Zero) at (prev + 27, 19) to (start + 0, 20)
- Code(Zero) at (prev + 27, 23) to (start + 0, 24)
- Code(Zero) at (prev + 1, 11) to (start + 0, 12)
- Code(Zero) at (prev + 1, 9) to (start + 0, 10)
- Code(Zero) at (prev + 0, 14) to (start + 0, 23)
Expand Down
4 changes: 2 additions & 2 deletions tests/coverage/async.coverage
Original file line number Diff line number Diff line change
Expand Up @@ -24,8 +24,8 @@
LL| |
LL| 0|async fn foo() -> [bool; 10] { [false; 10] } // unused function; executor does not block on `h()`
LL| |
LL| 1|async fn g(x: u8) {
^0
LL| 1|pub async fn g(x: u8) {
^0
LL| 0| match x {
LL| 0| y if e().await == y => (),
LL| 0| y if f().await == y => (),
Expand Down
2 changes: 1 addition & 1 deletion tests/coverage/async.rs
Original file line number Diff line number Diff line change
Expand Up @@ -24,7 +24,7 @@ async fn f() -> u8 { 1 }

async fn foo() -> [bool; 10] { [false; 10] } // unused function; executor does not block on `h()`

async fn g(x: u8) {
pub async fn g(x: u8) {
match x {
y if e().await == y => (),
y if f().await == y => (),
Expand Down
6 changes: 1 addition & 5 deletions tests/ui/async-await/future-sizes/async-awaiting-fut.rs
Original file line number Diff line number Diff line change
@@ -1,11 +1,7 @@
// FIXME(#61117): Respect debuginfo-level-tests, do not force debuginfo=0
//@ compile-flags: -C debuginfo=0
//@ compile-flags: -C panic=abort -Z print-type-sizes --crate-type lib
//@ needs-deterministic-layouts
//@ compile-flags: -Z print-type-sizes --crate-type lib
//@ edition:2021
//@ build-pass
//@ ignore-pass
//@ only-x86_64

async fn wait() {}

Expand Down
37 changes: 0 additions & 37 deletions tests/ui/async-await/future-sizes/async-awaiting-fut.stdout
Original file line number Diff line number Diff line change
Expand Up @@ -48,39 +48,6 @@ print-type-size variant `Returned`: 1024 bytes
print-type-size upvar `.arg`: 1024 bytes
print-type-size variant `Panicked`: 1024 bytes
print-type-size upvar `.arg`: 1024 bytes
print-type-size type: `std::task::Context<'_>`: 32 bytes, alignment: 8 bytes
print-type-size field `.waker`: 8 bytes
print-type-size field `.local_waker`: 8 bytes
print-type-size field `.ext`: 16 bytes
print-type-size field `._marker`: 0 bytes
print-type-size field `._marker2`: 0 bytes
print-type-size type: `std::panic::Location<'_>`: 24 bytes, alignment: 8 bytes
print-type-size field `.filename`: 16 bytes
print-type-size field `.line`: 4 bytes
print-type-size field `.col`: 4 bytes
print-type-size field `._filename`: 0 bytes
print-type-size type: `core::task::wake::ExtData<'_>`: 16 bytes, alignment: 8 bytes
print-type-size variant `Some`: 16 bytes
print-type-size field `.0`: 16 bytes
print-type-size variant `None`: 0 bytes
print-type-size field `.0`: 0 bytes
print-type-size type: `std::panic::AssertUnwindSafe<core::task::wake::ExtData<'_>>`: 16 bytes, alignment: 8 bytes
print-type-size field `.0`: 16 bytes
print-type-size type: `std::ptr::NonNull<str>`: 16 bytes, alignment: 8 bytes
print-type-size field `.pointer`: 16 bytes
print-type-size type: `std::pin::Pin<&mut {async fn body of big_fut()}>`: 8 bytes, alignment: 8 bytes
print-type-size field `.pointer`: 8 bytes
print-type-size type: `std::pin::Pin<&mut {async fn body of calls_fut<{async fn body of big_fut()}>()}>`: 8 bytes, alignment: 8 bytes
print-type-size field `.pointer`: 8 bytes
print-type-size type: `std::pin::Pin<&mut {async fn body of test()}>`: 8 bytes, alignment: 8 bytes
print-type-size field `.pointer`: 8 bytes
print-type-size type: `std::pin::Pin<&mut {async fn body of wait()}>`: 8 bytes, alignment: 8 bytes
print-type-size field `.pointer`: 8 bytes
print-type-size type: `std::ptr::DynMetadata<dyn std::any::Any>`: 8 bytes, alignment: 8 bytes
print-type-size field `._vtable_ptr`: 8 bytes
print-type-size field `._phantom`: 0 bytes
print-type-size type: `std::ptr::NonNull<std::ptr::metadata::VTable>`: 8 bytes, alignment: 8 bytes
print-type-size field `.pointer`: 8 bytes
print-type-size type: `std::mem::ManuallyDrop<bool>`: 1 bytes, alignment: 1 bytes
print-type-size field `.value`: 1 bytes
print-type-size type: `std::mem::ManuallyDrop<{async fn body of wait()}>`: 1 bytes, alignment: 1 bytes
Expand All @@ -103,7 +70,3 @@ print-type-size discriminant: 1 bytes
print-type-size variant `Unresumed`: 0 bytes
print-type-size variant `Returned`: 0 bytes
print-type-size variant `Panicked`: 0 bytes
print-type-size type: `std::marker::PhantomData<&str>`: 0 bytes, alignment: 1 bytes
print-type-size type: `std::marker::PhantomData<*mut ()>`: 0 bytes, alignment: 1 bytes
print-type-size type: `std::marker::PhantomData<dyn std::any::Any>`: 0 bytes, alignment: 1 bytes
print-type-size type: `std::marker::PhantomData<fn(&()) -> &()>`: 0 bytes, alignment: 1 bytes
6 changes: 1 addition & 5 deletions tests/ui/async-await/future-sizes/large-arg.rs
Original file line number Diff line number Diff line change
@@ -1,11 +1,7 @@
// FIXME(#61117): Respect debuginfo-level-tests, do not force debuginfo=0
//@ compile-flags: -C debuginfo=0
//@ compile-flags: -C panic=abort -Z print-type-sizes --crate-type=lib
//@ needs-deterministic-layouts
//@ compile-flags: -Z print-type-sizes --crate-type=lib
//@ edition: 2021
//@ build-pass
//@ ignore-pass
//@ only-x86_64

pub async fn test() {
let _ = a([0u8; 1024]).await;
Expand Down
42 changes: 0 additions & 42 deletions tests/ui/async-await/future-sizes/large-arg.stdout
Original file line number Diff line number Diff line change
Expand Up @@ -58,45 +58,3 @@ print-type-size variant `Returned`: 1024 bytes
print-type-size upvar `.t`: 1024 bytes
print-type-size variant `Panicked`: 1024 bytes
print-type-size upvar `.t`: 1024 bytes
print-type-size type: `std::task::Context<'_>`: 32 bytes, alignment: 8 bytes
print-type-size field `.waker`: 8 bytes
print-type-size field `.local_waker`: 8 bytes
print-type-size field `.ext`: 16 bytes
print-type-size field `._marker`: 0 bytes
print-type-size field `._marker2`: 0 bytes
print-type-size type: `std::panic::Location<'_>`: 24 bytes, alignment: 8 bytes
print-type-size field `.filename`: 16 bytes
print-type-size field `.line`: 4 bytes
print-type-size field `.col`: 4 bytes
print-type-size field `._filename`: 0 bytes
print-type-size type: `core::task::wake::ExtData<'_>`: 16 bytes, alignment: 8 bytes
print-type-size variant `Some`: 16 bytes
print-type-size field `.0`: 16 bytes
print-type-size variant `None`: 0 bytes
print-type-size field `.0`: 0 bytes
print-type-size type: `std::panic::AssertUnwindSafe<core::task::wake::ExtData<'_>>`: 16 bytes, alignment: 8 bytes
print-type-size field `.0`: 16 bytes
print-type-size type: `std::ptr::NonNull<str>`: 16 bytes, alignment: 8 bytes
print-type-size field `.pointer`: 16 bytes
print-type-size type: `std::pin::Pin<&mut {async fn body of a<[u8; 1024]>()}>`: 8 bytes, alignment: 8 bytes
print-type-size field `.pointer`: 8 bytes
print-type-size type: `std::pin::Pin<&mut {async fn body of b<[u8; 1024]>()}>`: 8 bytes, alignment: 8 bytes
print-type-size field `.pointer`: 8 bytes
print-type-size type: `std::pin::Pin<&mut {async fn body of c<[u8; 1024]>()}>`: 8 bytes, alignment: 8 bytes
print-type-size field `.pointer`: 8 bytes
print-type-size type: `std::pin::Pin<&mut {async fn body of test()}>`: 8 bytes, alignment: 8 bytes
print-type-size field `.pointer`: 8 bytes
print-type-size type: `std::ptr::DynMetadata<dyn std::any::Any>`: 8 bytes, alignment: 8 bytes
print-type-size field `._vtable_ptr`: 8 bytes
print-type-size field `._phantom`: 0 bytes
print-type-size type: `std::ptr::NonNull<std::ptr::metadata::VTable>`: 8 bytes, alignment: 8 bytes
print-type-size field `.pointer`: 8 bytes
print-type-size type: `std::task::Poll<()>`: 1 bytes, alignment: 1 bytes
print-type-size discriminant: 1 bytes
print-type-size variant `Ready`: 0 bytes
print-type-size field `.0`: 0 bytes
print-type-size variant `Pending`: 0 bytes
print-type-size type: `std::marker::PhantomData<&str>`: 0 bytes, alignment: 1 bytes
print-type-size type: `std::marker::PhantomData<*mut ()>`: 0 bytes, alignment: 1 bytes
print-type-size type: `std::marker::PhantomData<dyn std::any::Any>`: 0 bytes, alignment: 1 bytes
print-type-size type: `std::marker::PhantomData<fn(&()) -> &()>`: 0 bytes, alignment: 1 bytes
6 changes: 1 addition & 5 deletions tests/ui/print_type_sizes/async.rs
Original file line number Diff line number Diff line change
@@ -1,11 +1,7 @@
// FIXME(#61117): Respect debuginfo-level-tests, do not force debuginfo=0
//@ compile-flags: -C debuginfo=0
//@ compile-flags: -C panic=abort -Z print-type-sizes --crate-type lib
//@ needs-deterministic-layouts
//@ compile-flags: -Z print-type-sizes --crate-type lib
//@ edition:2021
//@ build-pass
//@ ignore-pass
//@ only-x86_64

#![allow(dropping_copy_types)]

Expand Down
33 changes: 0 additions & 33 deletions tests/ui/print_type_sizes/async.stdout
Original file line number Diff line number Diff line change
Expand Up @@ -16,35 +16,6 @@ print-type-size type: `std::mem::MaybeUninit<[u8; 8192]>`: 8192 bytes, alignment
print-type-size variant `MaybeUninit`: 8192 bytes
print-type-size field `.uninit`: 0 bytes
print-type-size field `.value`: 8192 bytes
print-type-size type: `std::task::Context<'_>`: 32 bytes, alignment: 8 bytes
print-type-size field `.waker`: 8 bytes
print-type-size field `.local_waker`: 8 bytes
print-type-size field `.ext`: 16 bytes
print-type-size field `._marker`: 0 bytes
print-type-size field `._marker2`: 0 bytes
print-type-size type: `std::panic::Location<'_>`: 24 bytes, alignment: 8 bytes
print-type-size field `.filename`: 16 bytes
print-type-size field `.line`: 4 bytes
print-type-size field `.col`: 4 bytes
print-type-size field `._filename`: 0 bytes
print-type-size type: `core::task::wake::ExtData<'_>`: 16 bytes, alignment: 8 bytes
print-type-size variant `Some`: 16 bytes
print-type-size field `.0`: 16 bytes
print-type-size variant `None`: 0 bytes
print-type-size field `.0`: 0 bytes
print-type-size type: `std::panic::AssertUnwindSafe<core::task::wake::ExtData<'_>>`: 16 bytes, alignment: 8 bytes
print-type-size field `.0`: 16 bytes
print-type-size type: `std::ptr::NonNull<str>`: 16 bytes, alignment: 8 bytes
print-type-size field `.pointer`: 16 bytes
print-type-size type: `std::pin::Pin<&mut {async fn body of test()}>`: 8 bytes, alignment: 8 bytes
print-type-size field `.pointer`: 8 bytes
print-type-size type: `std::pin::Pin<&mut {async fn body of wait()}>`: 8 bytes, alignment: 8 bytes
print-type-size field `.pointer`: 8 bytes
print-type-size type: `std::ptr::DynMetadata<dyn std::any::Any>`: 8 bytes, alignment: 8 bytes
print-type-size field `._vtable_ptr`: 8 bytes
print-type-size field `._phantom`: 0 bytes
print-type-size type: `std::ptr::NonNull<std::ptr::metadata::VTable>`: 8 bytes, alignment: 8 bytes
print-type-size field `.pointer`: 8 bytes
print-type-size type: `std::mem::ManuallyDrop<{async fn body of wait()}>`: 1 bytes, alignment: 1 bytes
print-type-size field `.value`: 1 bytes
print-type-size type: `std::mem::MaybeUninit<{async fn body of wait()}>`: 1 bytes, alignment: 1 bytes
Expand All @@ -61,7 +32,3 @@ print-type-size discriminant: 1 bytes
print-type-size variant `Unresumed`: 0 bytes
print-type-size variant `Returned`: 0 bytes
print-type-size variant `Panicked`: 0 bytes
print-type-size type: `std::marker::PhantomData<&str>`: 0 bytes, alignment: 1 bytes
print-type-size type: `std::marker::PhantomData<*mut ()>`: 0 bytes, alignment: 1 bytes
print-type-size type: `std::marker::PhantomData<dyn std::any::Any>`: 0 bytes, alignment: 1 bytes
print-type-size type: `std::marker::PhantomData<fn(&()) -> &()>`: 0 bytes, alignment: 1 bytes
Loading