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

ice: expected async fn to have impl Future output, but it returns impl Future<Output = i32> #112848

Closed
matthiaskrgr opened this issue Jun 20, 2023 · 2 comments · Fixed by #112868
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

@matthiaskrgr
Copy link
Member

Code

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

trait MyTrait {
    async fn foo(&self) -> i32;
    async fn bar(&self) -> i32;
}

impl MyTrait for i32 {
    async fn MyTrait(&self) -> i32 {
        *self
    }

    async fn bar(&self) -> i32 {
        self.foo().await
    }
}

fn main() {}

Meta

rustc --version --verbose:

rustc 1.72.0-nightly (6fc0273b5 2023-06-20)
binary: rustc
commit-hash: 6fc0273b5a57eb78cc00841181113fda3e509478
commit-date: 2023-06-20
host: x86_64-unknown-linux-gnu
release: 1.72.0-nightly
LLVM version: 16.0.5

Error output

error[E0407]: method `MyTrait` is not a member of trait `MyTrait`
  --> crash.rs:10:5
   |
10 | /     async fn MyTrait(&self) -> i32 {
11 | |         *self
12 | |     }
   | |_____^ not a member of trait `MyTrait`
Backtrace

error: internal compiler error: compiler/rustc_hir_analysis/src/check/mod.rs:416:21: expected async fn to have `impl Future` output, but it returns impl Future<Output = i32>
 --> crash.rs:5:14
  |
5 |     async fn foo(&self) -> i32;
  |              ^^^

thread 'rustc' panicked at 'Box<dyn Any>', /rustc/6fc0273b5a57eb78cc00841181113fda3e509478/compiler/rustc_errors/src/lib.rs:994:33
stack backtrace:
   0:     0x7f7f51390dc1 - std::backtrace_rs::backtrace::libunwind::trace::h1549ddfd8a258aeb
                               at /rustc/6fc0273b5a57eb78cc00841181113fda3e509478/library/std/src/../../backtrace/src/backtrace/libunwind.rs:93:5
   1:     0x7f7f51390dc1 - std::backtrace_rs::backtrace::trace_unsynchronized::he8406d242e2495d8
                               at /rustc/6fc0273b5a57eb78cc00841181113fda3e509478/library/std/src/../../backtrace/src/backtrace/mod.rs:66:5
   2:     0x7f7f51390dc1 - std::sys_common::backtrace::_print_fmt::hcbd55f29c8b6bb87
                               at /rustc/6fc0273b5a57eb78cc00841181113fda3e509478/library/std/src/sys_common/backtrace.rs:65:5
   3:     0x7f7f51390dc1 - <std::sys_common::backtrace::_print::DisplayBacktrace as core::fmt::Display>::fmt::hc330ee62a3534284
                               at /rustc/6fc0273b5a57eb78cc00841181113fda3e509478/library/std/src/sys_common/backtrace.rs:44:22
   4:     0x7f7f513f23df - core::fmt::rt::Argument::fmt::h944c617571c59f55
                               at /rustc/6fc0273b5a57eb78cc00841181113fda3e509478/library/core/src/fmt/rt.rs:138:9
   5:     0x7f7f513f23df - core::fmt::write::hdfb34466040e87e7
                               at /rustc/6fc0273b5a57eb78cc00841181113fda3e509478/library/core/src/fmt/mod.rs:1094:21
   6:     0x7f7f51383927 - std::io::Write::write_fmt::hc3f6c030108d0f8f
                               at /rustc/6fc0273b5a57eb78cc00841181113fda3e509478/library/std/src/io/mod.rs:1714:15
   7:     0x7f7f51390bd5 - std::sys_common::backtrace::_print::h090226f042b44130
                               at /rustc/6fc0273b5a57eb78cc00841181113fda3e509478/library/std/src/sys_common/backtrace.rs:47:5
   8:     0x7f7f51390bd5 - std::sys_common::backtrace::print::h881d7f1cf79f05ba
                               at /rustc/6fc0273b5a57eb78cc00841181113fda3e509478/library/std/src/sys_common/backtrace.rs:34:9
   9:     0x7f7f51393983 - std::panicking::default_hook::{{closure}}::hf0985bb10495a514
                               at /rustc/6fc0273b5a57eb78cc00841181113fda3e509478/library/std/src/panicking.rs:269:22
  10:     0x7f7f51393714 - std::panicking::default_hook::h1534132078381b49
                               at /rustc/6fc0273b5a57eb78cc00841181113fda3e509478/library/std/src/panicking.rs:288:9
  11:     0x7f7f501af98b - <rustc_driver_impl[6aaee82d15fcd1b5]::install_ice_hook::{closure#0} as core[c45177fb2e5c300e]::ops::function::FnOnce<(&core[c45177fb2e5c300e]::panic::panic_info::PanicInfo,)>>::call_once::{shim:vtable#0}
  12:     0x7f7f513941ae - <alloc::boxed::Box<F,A> as core::ops::function::Fn<Args>>::call::h461508deb496d74f
                               at /rustc/6fc0273b5a57eb78cc00841181113fda3e509478/library/alloc/src/boxed.rs:2007:9
  13:     0x7f7f513941ae - std::panicking::rust_panic_with_hook::h1bba696c0525b1be
                               at /rustc/6fc0273b5a57eb78cc00841181113fda3e509478/library/std/src/panicking.rs:709:13
  14:     0x7f7f503120f1 - std[33c81befc1327b2c]::panicking::begin_panic::<rustc_errors[45ab742dbf8d46a1]::ExplicitBug>::{closure#0}
  15:     0x7f7f5030fa16 - std[33c81befc1327b2c]::sys_common::backtrace::__rust_end_short_backtrace::<std[33c81befc1327b2c]::panicking::begin_panic<rustc_errors[45ab742dbf8d46a1]::ExplicitBug>::{closure#0}, !>
  16:     0x7f7f502b9c46 - std[33c81befc1327b2c]::panicking::begin_panic::<rustc_errors[45ab742dbf8d46a1]::ExplicitBug>
  17:     0x7f7f5030e20e - <rustc_errors[45ab742dbf8d46a1]::HandlerInner>::span_bug::<rustc_span[a992d7e7973c1be2]::span_encoding::Span, alloc[5f60cdf87399dbe2]::string::String>
  18:     0x7f7f5030df3d - <rustc_errors[45ab742dbf8d46a1]::Handler>::span_bug::<rustc_span[a992d7e7973c1be2]::span_encoding::Span, alloc[5f60cdf87399dbe2]::string::String>
  19:     0x7f7f5031234d - rustc_middle[4875513d3ec05678]::util::bug::opt_span_bug_fmt::<rustc_span[a992d7e7973c1be2]::span_encoding::Span>::{closure#0}
  20:     0x7f7f5031237a - rustc_middle[4875513d3ec05678]::ty::context::tls::with_opt::<rustc_middle[4875513d3ec05678]::util::bug::opt_span_bug_fmt<rustc_span[a992d7e7973c1be2]::span_encoding::Span>::{closure#0}, !>::{closure#0}
  21:     0x7f7f5031109a - rustc_middle[4875513d3ec05678]::ty::context::tls::with_context_opt::<rustc_middle[4875513d3ec05678]::ty::context::tls::with_opt<rustc_middle[4875513d3ec05678]::util::bug::opt_span_bug_fmt<rustc_span[a992d7e7973c1be2]::span_encoding::Span>::{closure#0}, !>::{closure#0}, !>
  22:     0x7f7f50310a64 - rustc_middle[4875513d3ec05678]::util::bug::span_bug_fmt::<rustc_span[a992d7e7973c1be2]::span_encoding::Span>
  23:     0x7f7f4f4b0535 - rustc_hir_analysis[37adeb9a3b5fd3e]::check::check::check_impl_items_against_trait
  24:     0x7f7f4f4a40ee - rustc_hir_analysis[37adeb9a3b5fd3e]::check::check::check_mod_item_types
  25:     0x7f7f4ee4ca3c - rustc_query_impl[8b1986df9d148b15]::plumbing::__rust_begin_short_backtrace::<rustc_query_impl[8b1986df9d148b15]::query_impl::check_mod_item_types::dynamic_query::{closure#2}::{closure#0}, rustc_middle[4875513d3ec05678]::query::erase::Erased<[u8; 0usize]>>
  26:     0x7f7f4ee4ca1e - <rustc_query_impl[8b1986df9d148b15]::query_impl::check_mod_item_types::dynamic_query::{closure#2} as core[c45177fb2e5c300e]::ops::function::FnOnce<(rustc_middle[4875513d3ec05678]::ty::context::TyCtxt, rustc_span[a992d7e7973c1be2]::def_id::LocalDefId)>>::call_once
  27:     0x7f7f4e857f6f - rustc_query_system[cca36986bbe76e10]::query::plumbing::try_execute_query::<rustc_query_impl[8b1986df9d148b15]::DynamicConfig<rustc_query_system[cca36986bbe76e10]::query::caches::VecCache<rustc_span[a992d7e7973c1be2]::def_id::LocalDefId, rustc_middle[4875513d3ec05678]::query::erase::Erased<[u8; 0usize]>>, false, false, false>, rustc_query_impl[8b1986df9d148b15]::plumbing::QueryCtxt, false>
  28:     0x7f7f4fb1bc12 - rustc_query_impl[8b1986df9d148b15]::query_impl::check_mod_item_types::get_query_non_incr::__rust_end_short_backtrace
  29:     0x7f7f4f5c1927 - <rustc_middle[4875513d3ec05678]::hir::map::Map>::for_each_module::<rustc_hir_analysis[37adeb9a3b5fd3e]::check_crate::{closure#6}::{closure#0}>
  30:     0x7f7f4f5c113d - <rustc_session[9b1eb2cc4d9315ee]::session::Session>::time::<(), rustc_hir_analysis[37adeb9a3b5fd3e]::check_crate::{closure#6}>
  31:     0x7f7f4f5bf657 - rustc_hir_analysis[37adeb9a3b5fd3e]::check_crate
  32:     0x7f7f4f5b2cfa - rustc_interface[f2bb2657274807ca]::passes::analysis
  33:     0x7f7f4f61ba7a - rustc_query_impl[8b1986df9d148b15]::plumbing::__rust_begin_short_backtrace::<rustc_query_impl[8b1986df9d148b15]::query_impl::analysis::dynamic_query::{closure#2}::{closure#0}, rustc_middle[4875513d3ec05678]::query::erase::Erased<[u8; 1usize]>>
  34:     0x7f7f4f61ba69 - <rustc_query_impl[8b1986df9d148b15]::query_impl::analysis::dynamic_query::{closure#2} as core[c45177fb2e5c300e]::ops::function::FnOnce<(rustc_middle[4875513d3ec05678]::ty::context::TyCtxt, ())>>::call_once
  35:     0x7f7f4f8313e8 - rustc_query_system[cca36986bbe76e10]::query::plumbing::try_execute_query::<rustc_query_impl[8b1986df9d148b15]::DynamicConfig<rustc_query_system[cca36986bbe76e10]::query::caches::SingleCache<rustc_middle[4875513d3ec05678]::query::erase::Erased<[u8; 1usize]>>, false, false, false>, rustc_query_impl[8b1986df9d148b15]::plumbing::QueryCtxt, false>
  36:     0x7f7f4f8311c7 - rustc_query_impl[8b1986df9d148b15]::query_impl::analysis::get_query_non_incr::__rust_end_short_backtrace
  37:     0x7f7f4f6cc4d5 - <rustc_middle[4875513d3ec05678]::ty::context::GlobalCtxt>::enter::<rustc_driver_impl[6aaee82d15fcd1b5]::run_compiler::{closure#1}::{closure#2}::{closure#4}, core[c45177fb2e5c300e]::result::Result<(), rustc_span[a992d7e7973c1be2]::ErrorGuaranteed>>
  38:     0x7f7f4f6cb49e - rustc_span[a992d7e7973c1be2]::set_source_map::<core[c45177fb2e5c300e]::result::Result<(), rustc_span[a992d7e7973c1be2]::ErrorGuaranteed>, rustc_interface[f2bb2657274807ca]::interface::run_compiler<core[c45177fb2e5c300e]::result::Result<(), rustc_span[a992d7e7973c1be2]::ErrorGuaranteed>, rustc_driver_impl[6aaee82d15fcd1b5]::run_compiler::{closure#1}>::{closure#0}::{closure#0}>
  39:     0x7f7f4f6c3c79 - <scoped_tls[708333a90650a86b]::ScopedKey<rustc_span[a992d7e7973c1be2]::SessionGlobals>>::set::<rustc_interface[f2bb2657274807ca]::interface::run_compiler<core[c45177fb2e5c300e]::result::Result<(), rustc_span[a992d7e7973c1be2]::ErrorGuaranteed>, rustc_driver_impl[6aaee82d15fcd1b5]::run_compiler::{closure#1}>::{closure#0}, core[c45177fb2e5c300e]::result::Result<(), rustc_span[a992d7e7973c1be2]::ErrorGuaranteed>>
  40:     0x7f7f4f6c3276 - std[33c81befc1327b2c]::sys_common::backtrace::__rust_begin_short_backtrace::<rustc_interface[f2bb2657274807ca]::util::run_in_thread_pool_with_globals<rustc_interface[f2bb2657274807ca]::interface::run_compiler<core[c45177fb2e5c300e]::result::Result<(), rustc_span[a992d7e7973c1be2]::ErrorGuaranteed>, rustc_driver_impl[6aaee82d15fcd1b5]::run_compiler::{closure#1}>::{closure#0}, core[c45177fb2e5c300e]::result::Result<(), rustc_span[a992d7e7973c1be2]::ErrorGuaranteed>>::{closure#0}::{closure#0}, core[c45177fb2e5c300e]::result::Result<(), rustc_span[a992d7e7973c1be2]::ErrorGuaranteed>>
  41:     0x7f7f4f6c3025 - <<std[33c81befc1327b2c]::thread::Builder>::spawn_unchecked_<rustc_interface[f2bb2657274807ca]::util::run_in_thread_pool_with_globals<rustc_interface[f2bb2657274807ca]::interface::run_compiler<core[c45177fb2e5c300e]::result::Result<(), rustc_span[a992d7e7973c1be2]::ErrorGuaranteed>, rustc_driver_impl[6aaee82d15fcd1b5]::run_compiler::{closure#1}>::{closure#0}, core[c45177fb2e5c300e]::result::Result<(), rustc_span[a992d7e7973c1be2]::ErrorGuaranteed>>::{closure#0}::{closure#0}, core[c45177fb2e5c300e]::result::Result<(), rustc_span[a992d7e7973c1be2]::ErrorGuaranteed>>::{closure#1} as core[c45177fb2e5c300e]::ops::function::FnOnce<()>>::call_once::{shim:vtable#0}
  42:     0x7f7f5139e635 - <alloc::boxed::Box<F,A> as core::ops::function::FnOnce<Args>>::call_once::h9b20d6135dc15bb0
                               at /rustc/6fc0273b5a57eb78cc00841181113fda3e509478/library/alloc/src/boxed.rs:1993:9
  43:     0x7f7f5139e635 - <alloc::boxed::Box<F,A> as core::ops::function::FnOnce<Args>>::call_once::he0b0b7512c2c83c3
                               at /rustc/6fc0273b5a57eb78cc00841181113fda3e509478/library/alloc/src/boxed.rs:1993:9
  44:     0x7f7f5139e635 - std::sys::unix::thread::Thread::new::thread_start::hf6254ce8e731db9d
                               at /rustc/6fc0273b5a57eb78cc00841181113fda3e509478/library/std/src/sys/unix/thread.rs:108:17
  45:     0x7f7f4ce9d44b - <unknown>
  46:     0x7f7f4cf20e40 - <unknown>
  47:                0x0 - <unknown>

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.72.0-nightly (6fc0273b5 2023-06-20) running on x86_64-unknown-linux-gnu

query stack during panic:
#0 [check_mod_item_types] checking item types in top-level module
#1 [analysis] running analysis passes on this crate
end of query stack
error: aborting due to 2 previous errors

@matthiaskrgr matthiaskrgr added 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. C-bug Category: This is a bug. labels Jun 20, 2023
@matthiaskrgr
Copy link
Member Author

#112596 cc @compiler-errors

@compiler-errors compiler-errors self-assigned this Jun 20, 2023
@compiler-errors compiler-errors changed the title ice: expected async fn to have impl Future output, but it returns impl Future<Output = i32> ice: expected async fn to have impl Future output, but it returns impl Future<Output = i32> Jun 20, 2023
@bors bors closed this as completed in 5ed75a9 Jun 21, 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.

3 participants
@matthiaskrgr @compiler-errors and others