Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

DefId does not have a "def_span" for async function in separate package #111031

Closed
undefinedvalue opened this issue Apr 30, 2023 · 0 comments · Fixed by #111039
Closed

DefId does not have a "def_span" for async function in separate package #111031

undefinedvalue opened this issue Apr 30, 2023 · 0 comments · Fixed by #111039
Assignees
Labels
C-bug Category: This is a bug. I-ICE Issue: The compiler panicked, giving an Internal Compilation Error (ICE) ❄️ T-compiler Relevant to the compiler team, which will review and decide on the PR/issue.

Comments

@undefinedvalue
Copy link

I'm getting a DefId does not have a "def_span" ICE under when calling an async method for a trait defined in another package when using the qualified method syntax. It works if the trait is defined in the same package as main and it also works if using standard method syntax.

This happens on the most recent nightly compiler as of this posting.

This seems similar to but distinct from #110206.

Code

A minimal example with the following files exists at https://github.com/undefinedvalue/asynctest

In lib.rs of a package named "asynclib":

#![allow(incomplete_features)]
#![feature(async_fn_in_trait)]

pub trait SomeTrait {
    async fn doasync(&mut self);
}

In main.rs of a package that depends on the "asynclib":

#![allow(incomplete_features)]
#![feature(async_fn_in_trait)]

fn main() {
    asynclib::SomeTrait::doasync(&mut Foo);
}

struct Foo;

impl asynclib::SomeTrait for Foo {
    async fn doasync(&mut self) {
    }
}

Note: It works if instead main() is this:

use asynclib::SomeTrait;
Foo.doasync();

Meta

rustc --version --verbose:

rustc 1.71.0-nightly (87b1f891e 2023-04-29)
binary: rustc
commit-hash: 87b1f891ea76713462cfc5a15137a8fe2b24ecc2
commit-date: 2023-04-29
host: x86_64-unknown-linux-gnu
release: 1.71.0-nightly
LLVM version: 16.0.2

Error output

thread 'rustc' panicked at 'DefId(20:6 ~ asynclib[e66f]::SomeTrait::doasync::{opaque#0}) does not have a "def_span"', compiler/rustc_metadata/src/rmeta/decoder/cstore_impl.rs:205:1
Backtrace

   Compiling asyncmain v0.0.0 (/home/anna/workspace/asynctest/asyncmain)
thread 'rustc' panicked at 'DefId(20:6 ~ asynclib[e66f]::SomeTrait::doasync::{opaque#0}) does not have a "def_span"', compiler/rustc_metadata/src/rmeta/decoder/cstore_impl.rs:205:1
stack backtrace:
   0:     0x7fba39169331 - std::backtrace_rs::backtrace::libunwind::trace::h8355d489046eea9f
                               at /rustc/87b1f891ea76713462cfc5a15137a8fe2b24ecc2/library/std/src/../../backtrace/src/backtrace/libunwind.rs:93:5
   1:     0x7fba39169331 - std::backtrace_rs::backtrace::trace_unsynchronized::h5224130277357a26
                               at /rustc/87b1f891ea76713462cfc5a15137a8fe2b24ecc2/library/std/src/../../backtrace/src/backtrace/mod.rs:66:5
   2:     0x7fba39169331 - std::sys_common::backtrace::_print_fmt::hecc97c6ada6b37c5
                               at /rustc/87b1f891ea76713462cfc5a15137a8fe2b24ecc2/library/std/src/sys_common/backtrace.rs:65:5
   3:     0x7fba39169331 - <std::sys_common::backtrace::_print::DisplayBacktrace as core::fmt::Display>::fmt::ha40fb82141ca69c7
                               at /rustc/87b1f891ea76713462cfc5a15137a8fe2b24ecc2/library/std/src/sys_common/backtrace.rs:44:22
   4:     0x7fba391c9f1f - core::fmt::rt::Argument::fmt::h3abab6d788a756e3
                               at /rustc/87b1f891ea76713462cfc5a15137a8fe2b24ecc2/library/core/src/fmt/rt.rs:138:9
   5:     0x7fba391c9f1f - core::fmt::write::h0d9c37369cab45ae
                               at /rustc/87b1f891ea76713462cfc5a15137a8fe2b24ecc2/library/core/src/fmt/mod.rs:1094:21
   6:     0x7fba3915c4a1 - std::io::Write::write_fmt::h48802cd26188edd4
                               at /rustc/87b1f891ea76713462cfc5a15137a8fe2b24ecc2/library/std/src/io/mod.rs:1712:15
   7:     0x7fba39169145 - std::sys_common::backtrace::_print::hd06dedc75707c8aa
                               at /rustc/87b1f891ea76713462cfc5a15137a8fe2b24ecc2/library/std/src/sys_common/backtrace.rs:47:5
   8:     0x7fba39169145 - std::sys_common::backtrace::print::he87158405a814203
                               at /rustc/87b1f891ea76713462cfc5a15137a8fe2b24ecc2/library/std/src/sys_common/backtrace.rs:34:9
   9:     0x7fba3916bc87 - std::panicking::default_hook::{{closure}}::hed443a04a4ae9143
  10:     0x7fba3916ba74 - std::panicking::default_hook::hcb7845fe9b5159b6
                               at /rustc/87b1f891ea76713462cfc5a15137a8fe2b24ecc2/library/std/src/panicking.rs:288:9
  11:     0x7fba3c3ec015 - rustc_driver_impl[738786893c5490bf]::DEFAULT_HOOK::{closure#0}::{closure#0}
  12:     0x7fba3916c3a7 - <alloc::boxed::Box<F,A> as core::ops::function::Fn<Args>>::call::h1480dd017092d509
                               at /rustc/87b1f891ea76713462cfc5a15137a8fe2b24ecc2/library/alloc/src/boxed.rs:1976:9
  13:     0x7fba3916c3a7 - std::panicking::rust_panic_with_hook::he4834f7686de7b98
                               at /rustc/87b1f891ea76713462cfc5a15137a8fe2b24ecc2/library/std/src/panicking.rs:695:13
  14:     0x7fba3916c127 - std::panicking::begin_panic_handler::{{closure}}::ha2d182560a0fb060
                               at /rustc/87b1f891ea76713462cfc5a15137a8fe2b24ecc2/library/std/src/panicking.rs:582:13
  15:     0x7fba39169776 - std::sys_common::backtrace::__rust_end_short_backtrace::h2df9d74a88462a94
                               at /rustc/87b1f891ea76713462cfc5a15137a8fe2b24ecc2/library/std/src/sys_common/backtrace.rs:150:18
  16:     0x7fba3916be92 - rust_begin_unwind
                               at /rustc/87b1f891ea76713462cfc5a15137a8fe2b24ecc2/library/std/src/panicking.rs:578:5
  17:     0x7fba391c61c3 - core::panicking::panic_fmt::hdf51123d3e5c1099
                               at /rustc/87b1f891ea76713462cfc5a15137a8fe2b24ecc2/library/core/src/panicking.rs:67:14
  18:     0x7fba3c828e82 - rustc_metadata[ae0e66a2a2c113fb]::rmeta::decoder::cstore_impl::provide_extern::def_span::{closure#2}
  19:     0x7fba3bd25f26 - rustc_metadata[ae0e66a2a2c113fb]::rmeta::decoder::cstore_impl::provide_extern::def_span
  20:     0x7fba3acb60ed - rustc_query_system[34a9c542073df]::query::plumbing::try_execute_query::<rustc_query_impl[5c8c89bc676e7b7e]::queries::def_span, rustc_query_impl[5c8c89bc676e7b7e]::plumbing::QueryCtxt>
  21:     0x7fba3acb396a - <rustc_query_impl[5c8c89bc676e7b7e]::Queries as rustc_middle[4a9d2aea1650cf38]::ty::query::QueryEngine>::def_span
  22:     0x7fba3a9deefa - <rustc_infer[5d7b6307277651b3]::infer::InferCtxt>::infer_projection
  23:     0x7fba3a9c990c - rustc_trait_selection[87bbd939b3c90e9c]::traits::project::normalize_projection_type
  24:     0x7fba3a9c7365 - <rustc_trait_selection[87bbd939b3c90e9c]::traits::project::AssocTypeNormalizer as rustc_type_ir[1d3e9495482829d7]::fold::TypeFolder<rustc_middle[4a9d2aea1650cf38]::ty::context::TyCtxt>>::fold_ty
  25:     0x7fba3a5d99db - <rustc_infer[5d7b6307277651b3]::infer::at::At as rustc_trait_selection[87bbd939b3c90e9c]::traits::project::NormalizeExt>::normalize::<rustc_middle[4a9d2aea1650cf38]::ty::sty::FnSig>
  26:     0x7fba3a5be187 - <rustc_hir_typeck[e3c70be22799a2fb]::fn_ctxt::FnCtxt>::check_call
  27:     0x7fba3aa8e99a - <rustc_hir_typeck[e3c70be22799a2fb]::fn_ctxt::FnCtxt>::check_expr_with_expectation_and_args
  28:     0x7fba3aae463b - <rustc_hir_typeck[e3c70be22799a2fb]::fn_ctxt::FnCtxt>::check_block_with_expected
  29:     0x7fba3aa8ef24 - <rustc_hir_typeck[e3c70be22799a2fb]::fn_ctxt::FnCtxt>::check_expr_with_expectation_and_args
  30:     0x7fba3ac67d86 - <rustc_hir_typeck[e3c70be22799a2fb]::fn_ctxt::FnCtxt>::check_return_expr
  31:     0x7fba3ac5f51e - rustc_hir_typeck[e3c70be22799a2fb]::check::check_fn
  32:     0x7fba3ac484ea - rustc_hir_typeck[e3c70be22799a2fb]::typeck
  33:     0x7fba3ac3d9c9 - rustc_query_system[34a9c542073df]::query::plumbing::try_execute_query::<rustc_query_impl[5c8c89bc676e7b7e]::queries::typeck, rustc_query_impl[5c8c89bc676e7b7e]::plumbing::QueryCtxt>
  34:     0x7fba3bcfa05a - rustc_hir_typeck[e3c70be22799a2fb]::used_trait_imports
  35:     0x7fba3b022aac - rustc_query_system[34a9c542073df]::query::plumbing::try_execute_query::<rustc_query_impl[5c8c89bc676e7b7e]::queries::used_trait_imports, rustc_query_impl[5c8c89bc676e7b7e]::plumbing::QueryCtxt>
  36:     0x7fba3b8648d3 - rustc_hir_analysis[505c17fd5083e6d3]::check_crate
  37:     0x7fba3b8576fe - rustc_interface[1da25c7cb643f6df]::passes::analysis
  38:     0x7fba3bb68cef - rustc_query_system[34a9c542073df]::query::plumbing::try_execute_query::<rustc_query_impl[5c8c89bc676e7b7e]::queries::analysis, rustc_query_impl[5c8c89bc676e7b7e]::plumbing::QueryCtxt>
  39:     0x7fba3bb68820 - <rustc_query_impl[5c8c89bc676e7b7e]::Queries as rustc_middle[4a9d2aea1650cf38]::ty::query::QueryEngine>::analysis
  40:     0x7fba3b60d86a - <rustc_middle[4a9d2aea1650cf38]::ty::context::GlobalCtxt>::enter::<rustc_driver_impl[738786893c5490bf]::run_compiler::{closure#1}::{closure#2}::{closure#4}, core[af2acebbc2b23591]::result::Result<(), rustc_span[8cddaddefb760954]::ErrorGuaranteed>>
  41:     0x7fba3b60cb6a - <rustc_interface[1da25c7cb643f6df]::interface::Compiler>::enter::<rustc_driver_impl[738786893c5490bf]::run_compiler::{closure#1}::{closure#2}, core[af2acebbc2b23591]::result::Result<core[af2acebbc2b23591]::option::Option<rustc_interface[1da25c7cb643f6df]::queries::Linker>, rustc_span[8cddaddefb760954]::ErrorGuaranteed>>
  42:     0x7fba3b60abc1 - rustc_span[8cddaddefb760954]::set_source_map::<core[af2acebbc2b23591]::result::Result<(), rustc_span[8cddaddefb760954]::ErrorGuaranteed>, rustc_interface[1da25c7cb643f6df]::interface::run_compiler<core[af2acebbc2b23591]::result::Result<(), rustc_span[8cddaddefb760954]::ErrorGuaranteed>, rustc_driver_impl[738786893c5490bf]::run_compiler::{closure#1}>::{closure#0}::{closure#0}>
  43:     0x7fba3b60a267 - std[b167bfecd85c8427]::sys_common::backtrace::__rust_begin_short_backtrace::<rustc_interface[1da25c7cb643f6df]::util::run_in_thread_pool_with_globals<rustc_interface[1da25c7cb643f6df]::interface::run_compiler<core[af2acebbc2b23591]::result::Result<(), rustc_span[8cddaddefb760954]::ErrorGuaranteed>, rustc_driver_impl[738786893c5490bf]::run_compiler::{closure#1}>::{closure#0}, core[af2acebbc2b23591]::result::Result<(), rustc_span[8cddaddefb760954]::ErrorGuaranteed>>::{closure#0}::{closure#0}, core[af2acebbc2b23591]::result::Result<(), rustc_span[8cddaddefb760954]::ErrorGuaranteed>>
  44:     0x7fba3b609b85 - <<std[b167bfecd85c8427]::thread::Builder>::spawn_unchecked_<rustc_interface[1da25c7cb643f6df]::util::run_in_thread_pool_with_globals<rustc_interface[1da25c7cb643f6df]::interface::run_compiler<core[af2acebbc2b23591]::result::Result<(), rustc_span[8cddaddefb760954]::ErrorGuaranteed>, rustc_driver_impl[738786893c5490bf]::run_compiler::{closure#1}>::{closure#0}, core[af2acebbc2b23591]::result::Result<(), rustc_span[8cddaddefb760954]::ErrorGuaranteed>>::{closure#0}::{closure#0}, core[af2acebbc2b23591]::result::Result<(), rustc_span[8cddaddefb760954]::ErrorGuaranteed>>::{closure#1} as core[af2acebbc2b23591]::ops::function::FnOnce<()>>::call_once::{shim:vtable#0}
  45:     0x7fba391768c5 - <alloc::boxed::Box<F,A> as core::ops::function::FnOnce<Args>>::call_once::ha80838fe840f5c99
                               at /rustc/87b1f891ea76713462cfc5a15137a8fe2b24ecc2/library/alloc/src/boxed.rs:1962:9
  46:     0x7fba391768c5 - <alloc::boxed::Box<F,A> as core::ops::function::FnOnce<Args>>::call_once::hb7b8292ae0f012c1
                               at /rustc/87b1f891ea76713462cfc5a15137a8fe2b24ecc2/library/alloc/src/boxed.rs:1962:9
  47:     0x7fba391768c5 - std::sys::unix::thread::Thread::new::thread_start::h64b218fd2c840776
                               at /rustc/87b1f891ea76713462cfc5a15137a8fe2b24ecc2/library/std/src/sys/unix/thread.rs:108:17
  48:     0x7fba38e90402 - start_thread
                               at ./nptl/pthread_create.c:442:8
  49:     0x7fba38f1f590 - __GI___clone3
                               at ./misc/../sysdeps/unix/sysv/linux/x86_64/clone3.S:81
  50:                0x0 - <unknown>

error: the compiler unexpectedly panicked. this is a bug.

note: we would appreciate a bug report: https://github.com/rust-lang/rust/issues/new?labels=C-bug%2C+I-ICE%2C+T-compiler&template=ice.md

note: rustc 1.71.0-nightly (87b1f891e 2023-04-29) running on x86_64-unknown-linux-gnu

note: compiler flags: --crate-type bin -C embed-bitcode=no -C debuginfo=2 -C incremental=[REDACTED]

note: some of the compiler flags provided by cargo are hidden

query stack during panic:
#0 [def_span] looking up span for `asynclib::SomeTrait::doasync::{opaque#0}`
#1 [typeck] type-checking `main`
#2 [used_trait_imports] finding used_trait_imports `main`
#3 [analysis] running analysis passes on this crate
end of query stack
error: could not compile `asyncmain` (bin "asyncmain")

@undefinedvalue undefinedvalue added C-bug Category: This is a bug. I-ICE Issue: The compiler panicked, giving an Internal Compilation Error (ICE) ❄️ T-compiler Relevant to the compiler team, which will review and decide on the PR/issue. labels Apr 30, 2023
@compiler-errors compiler-errors self-assigned this Apr 30, 2023
Dylan-DPC added a commit to Dylan-DPC/rust that referenced this issue May 2, 2023
…t, r=tmiasko

Encode def span for foreign return-position `impl Trait` in trait

Fixes rust-lang#111031, yet another def-span encoding issue :/

Includes a smaller repro than the issue, but I can confirm it ICEs:

```
query stack during panic:
#0 [def_span] looking up span for `rpitit::Foo::bar::{opaque#0}`
#1 [object_safety_violations] determining object safety of trait `rpitit::Foo`
rust-lang#2 [check_is_object_safe] checking if trait `rpitit::Foo` is object safe
rust-lang#3 [typeck] type-checking `main`
rust-lang#4 [used_trait_imports] finding used_trait_imports `main`
rust-lang#5 [analysis] running analysis passes on this crate
```

Luckily since this only affects nightly, this desn't need to be backported.
Dylan-DPC added a commit to Dylan-DPC/rust that referenced this issue May 3, 2023
…t, r=tmiasko

Encode def span for foreign return-position `impl Trait` in trait

Fixes rust-lang#111031, yet another def-span encoding issue :/

Includes a smaller repro than the issue, but I can confirm it ICEs:

```
query stack during panic:
#0 [def_span] looking up span for `rpitit::Foo::bar::{opaque#0}`
#1 [object_safety_violations] determining object safety of trait `rpitit::Foo`
rust-lang#2 [check_is_object_safe] checking if trait `rpitit::Foo` is object safe
rust-lang#3 [typeck] type-checking `main`
rust-lang#4 [used_trait_imports] finding used_trait_imports `main`
rust-lang#5 [analysis] running analysis passes on this crate
```

Luckily since this only affects nightly, this desn't need to be backported.
Dylan-DPC added a commit to Dylan-DPC/rust that referenced this issue May 3, 2023
…t, r=tmiasko

Encode def span for foreign return-position `impl Trait` in trait

Fixes rust-lang#111031, yet another def-span encoding issue :/

Includes a smaller repro than the issue, but I can confirm it ICEs:

```
query stack during panic:
#0 [def_span] looking up span for `rpitit::Foo::bar::{opaque#0}`
#1 [object_safety_violations] determining object safety of trait `rpitit::Foo`
rust-lang#2 [check_is_object_safe] checking if trait `rpitit::Foo` is object safe
rust-lang#3 [typeck] type-checking `main`
rust-lang#4 [used_trait_imports] finding used_trait_imports `main`
rust-lang#5 [analysis] running analysis passes on this crate
```

Luckily since this only affects nightly, this desn't need to be backported.
Dylan-DPC added a commit to Dylan-DPC/rust that referenced this issue May 3, 2023
…t, r=tmiasko

Encode def span for foreign return-position `impl Trait` in trait

Fixes rust-lang#111031, yet another def-span encoding issue :/

Includes a smaller repro than the issue, but I can confirm it ICEs:

```
query stack during panic:
#0 [def_span] looking up span for `rpitit::Foo::bar::{opaque#0}`
#1 [object_safety_violations] determining object safety of trait `rpitit::Foo`
rust-lang#2 [check_is_object_safe] checking if trait `rpitit::Foo` is object safe
rust-lang#3 [typeck] type-checking `main`
rust-lang#4 [used_trait_imports] finding used_trait_imports `main`
rust-lang#5 [analysis] running analysis passes on this crate
```

Luckily since this only affects nightly, this desn't need to be backported.
@bors bors closed this as completed in b194b43 May 4, 2023
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
C-bug Category: This is a bug. I-ICE Issue: The compiler panicked, giving an Internal Compilation Error (ICE) ❄️ T-compiler Relevant to the compiler team, which will review and decide on the PR/issue.
Projects
None yet
Development

Successfully merging a pull request may close this issue.

2 participants