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

Compiler panicks when impl for async trait has a mismatch #104183

Closed
WhyNotHugo opened this issue Nov 9, 2022 · 2 comments · Fixed by #104214
Closed

Compiler panicks when impl for async trait has a mismatch #104183

WhyNotHugo opened this issue Nov 9, 2022 · 2 comments · Fixed by #104214
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

@WhyNotHugo
Copy link

WhyNotHugo commented Nov 9, 2022

Essentially, if my trait has async fn do(s: &String) and my impl has async fn do(s: String) the compiler panics.

Note that the code is invalid and compilation should fail.

Meta

rustc --version --verbose:

x rustc --version --verbose
rustc 1.67.0-nightly (1286ee23e 2022-11-05)
binary: rustc
commit-hash: 1286ee23e4e2dec8c1696d3d76c6b26d97bbcf82
commit-date: 2022-11-05
host: x86_64-unknown-linux-gnu
release: 1.67.0-nightly
LLVM version: 15.0.4

Error output

> cargo build
   Compiling vstorage v0.1.0 (/home/hugo/clones/codeberg.org/WhyNotHugo/vdirsyncer.rs/vstorage)
warning: the feature `async_fn_in_trait` is incomplete and may not be safe to use and/or cause compiler crashes
 --> vstorage/src/lib.rs:4:12
  |
4 | #![feature(async_fn_in_trait)]
  |            ^^^^^^^^^^^^^^^^^
  |
  = note: see issue #91611 <https://github.com/rust-lang/rust/issues/91611> for more information
  = note: `#[warn(incomplete_features)]` on by default

warning: field `read_only` is never read
  --> vstorage/src/filesystem.rs:25:5
   |
23 | pub struct FilesystemStorage {
   |            ----------------- field in this struct
24 |     path: PathBuf,
25 |     read_only: bool,
   |     ^^^^^^^^^
   |
   = note: `#[warn(dead_code)]` on by default

error: internal compiler error: no errors encountered even though `delay_span_bug` issued

error: internal compiler error: could not unify `fn(&FilesystemCollection, &String) -> _` and `fn(&FilesystemCollection, String) -> impl Future<Output = Result<(Item, String), std::io::Error>>`: ArgumentSorts(ExpectedFound { expected: &std::string::String, found: std::string::String }, 1)
   --> vstorage/src/filesystem.rs:132:42
    |
132 |     async fn get(&self, href: String) -> Result<(Item, Etag)> {
    |                                          ^^^^^^^^^^^^^^^^^^^^
    |
    = note: delayed at compiler/rustc_hir_analysis/src/check/compare_method.rs:529:33

error: internal compiler error: TyKind::Error constructed but no error reported
  |
  = note: delayed at compiler/rustc_trait_selection/src/traits/project.rs:2295:41

error: internal compiler error[E0053]: method `get` has an incompatible type for trait
   --> vstorage/src/filesystem.rs:132:31
    |
132 |     async fn get(&self, href: String) -> Result<(Item, Etag)> {
    |                               ^^^^^^ help: change the parameter type to match the trait: `&String`
    |
note: while checking the return type of the `async fn`
   --> vstorage/src/filesystem.rs:132:42
    |
132 |     async fn get(&self, href: String) -> Result<(Item, Etag)> {
    |                                          ^^^^^^^^^^^^^^^^^^^^ checked the `Output` of this `async fn`, found opaque type

error: internal compiler error: could not unify `fn(&FilesystemCollection, &Vec<String>) -> _` and `fn(&FilesystemCollection, Vec<String>) -> impl Future<Output = Result<Vec<(Item, String)>, std::io::Error>>`: ArgumentSorts(ExpectedFound { expected: &std::vec::Vec<std::string::String>, found: std::vec::Vec<std::string::String> }, 1)
   --> vstorage/src/filesystem.rs:144:53
    |
144 |     async fn get_many(&self, hrefs: Vec<String>) -> Result<Vec<(Item, Etag)>> {
    |                                                     ^^^^^^^^^^^^^^^^^^^^^^^^^
    |
    = note: delayed at compiler/rustc_hir_analysis/src/check/compare_method.rs:529:33

error: internal compiler error[E0053]: method `get_many` has an incompatible type for trait
   --> vstorage/src/filesystem.rs:144:37
    |
144 |     async fn get_many(&self, hrefs: Vec<String>) -> Result<Vec<(Item, Etag)>> {
    |                                     ^^^^^^^^^^^ help: change the parameter type to match the trait: `&Vec<String>`
    |
note: while checking the return type of the `async fn`
   --> vstorage/src/filesystem.rs:144:53
    |
144 |     async fn get_many(&self, hrefs: Vec<String>) -> Result<Vec<(Item, Etag)>> {
    |                                                     ^^^^^^^^^^^^^^^^^^^^^^^^^ checked the `Output` of this `async fn`, found opaque type

error: internal compiler error: could not unify `fn(&mut FilesystemCollection, &String, &String, &Item) -> _` and `fn(&mut FilesystemCollection, String, String, &Item) -> impl Future<Output = Result<String, std::io::Error>>`: ArgumentSorts(ExpectedFound { expected: &std::string::String, found: std::string::String }, 1)
   --> vstorage/src/filesystem.rs:198:76
    |
198 |     async fn update(&mut self, href: String, etag: String, item: &Item) -> Result<Etag> {
    |                                                                            ^^^^^^^^^^^^
    |
    = note: delayed at compiler/rustc_hir_analysis/src/check/compare_method.rs:529:33

error: internal compiler error[E0053]: method `update` has an incompatible type for trait
   --> vstorage/src/filesystem.rs:198:38
    |
198 |     async fn update(&mut self, href: String, etag: String, item: &Item) -> Result<Etag> {
    |                                      ^^^^^^ help: change the parameter type to match the trait: `&String`
    |
note: while checking the return type of the `async fn`
   --> vstorage/src/filesystem.rs:198:76
    |
198 |     async fn update(&mut self, href: String, etag: String, item: &Item) -> Result<Etag> {
    |                                                                            ^^^^^^^^^^^^ checked the `Output` of this `async fn`, found opaque type

error: internal compiler error: TyKind::Error constructed but no error reported
  |
  = note: delayed at compiler/rustc_hir_typeck/src/fn_ctxt/_impl.rs:730:23

error: internal compiler error: TyKind::Error constructed but no error reported
  |
  = note: delayed at compiler/rustc_hir_typeck/src/coercion.rs:176:49

error: internal compiler error: TyKind::Error constructed but no error reported
  |
  = note: delayed at compiler/rustc_hir_typeck/src/fn_ctxt/checks.rs:118:29

error: internal compiler error: `InferCtxt` incorrectly tainted by errors
  |
  = note: delayed at compiler/rustc_infer/src/infer/mod.rs:1256:27

error: internal compiler error: TyKind::Error constructed but no error reported
  |
  = note: delayed at compiler/rustc_hir_typeck/src/coercion.rs:1028:53

error: internal compiler error: TyKind::Error constructed but no error reported
  |
  = note: delayed at compiler/rustc_hir_typeck/src/fallback.rs:109:58

error: internal compiler error: TyKind::Error constructed but no error reported
  |
  = note: delayed at /rustc/1286ee23e4e2dec8c1696d3d76c6b26d97bbcf82/compiler/rustc_middle/src/ty/relate.rs:419:59

error: internal compiler error: TyKind::Error constructed but no error reported
  |
  = note: delayed at compiler/rustc_trait_selection/src/traits/project.rs:1242:30

error: internal compiler error: TyKind::Error constructed but no error reported
  |
  = note: delayed at compiler/rustc_infer/src/infer/sub.rs:121:31

error: internal compiler error: expected fullfillment errors
  |
  = note: delayed at compiler/rustc_trait_selection/src/traits/error_reporting/mod.rs:459:23

error: internal compiler error: TyKind::Error constructed but no error reported
  |
  = note: delayed at compiler/rustc_mir_build/src/build/mod.rs:621:18

error: internal compiler error: broken MIR in DefId(0:183 ~ vstorage[9b4b]::filesystem::{impl#2}::get_many) ("return type"): bad type [type error]
   --> vstorage/src/filesystem.rs:144:5
    |
144 |     async fn get_many(&self, hrefs: Vec<String>) -> Result<Vec<(Item, Etag)>> {
    |     ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
    |
    = note: delayed at compiler/rustc_borrowck/src/type_check/mod.rs:520:13

error: internal compiler error: TyKind::Error constructed but no error reported
  |
  = note: delayed at compiler/rustc_borrowck/src/type_check/mod.rs:797:20

error: internal compiler error: broken MIR in DefId(0:183 ~ vstorage[9b4b]::filesystem::{impl#2}::get_many) (LocalDecl { mutability: Mut, local_info: None, internal: false, is_block_tail: None, ty: [type error], user_ty: None, source_info: SourceInfo { span: vstorage/src/filesystem.rs:144:5: 144:78 (#0), scope: scope[0] } }): bad type [type error]
   --> vstorage/src/filesystem.rs:144:5
    |
144 |     async fn get_many(&self, hrefs: Vec<String>) -> Result<Vec<(Item, Etag)>> {
    |     ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
    |
    = note: delayed at compiler/rustc_borrowck/src/type_check/mod.rs:520:13

error: internal compiler error: TyKind::Error constructed but no error reported
  |
  = note: delayed at compiler/rustc_hir_analysis/src/collect/type_of.rs:824:17

error: internal compiler error: broken MIR in DefId(0:185 ~ vstorage[9b4b]::filesystem::{impl#2}::get_many::{closure#0}) ("return type"): bad type [type error]
   --> vstorage/src/filesystem.rs:144:79
    |
144 |       async fn get_many(&self, hrefs: Vec<String>) -> Result<Vec<(Item, Etag)>> {
    |  _______________________________________________________________________________^
145 | |         // No specialisation for this type; it's fast enough for now.
146 | |         let mut items = Vec::with_capacity(hrefs.len());
147 | |         for href in hrefs {
...   |
150 | |         Ok(items)
151 | |     }
    | |_____^
    |
    = note: delayed at compiler/rustc_borrowck/src/type_check/mod.rs:520:13

error: internal compiler error: broken MIR in DefId(0:185 ~ vstorage[9b4b]::filesystem::{impl#2}::get_many::{closure#0}) (LocalDecl { mutability: Mut, local_info: None, internal: false, is_block_tail: None, ty: [type error], user_ty: None, source_info: SourceInfo { span: vstorage/src/filesystem.rs:144:79: 151:6 (#0), scope: scope[0] } }): bad type [type error]
   --> vstorage/src/filesystem.rs:144:79
    |
144 |       async fn get_many(&self, hrefs: Vec<String>) -> Result<Vec<(Item, Etag)>> {
    |  _______________________________________________________________________________^
145 | |         // No specialisation for this type; it's fast enough for now.
146 | |         let mut items = Vec::with_capacity(hrefs.len());
147 | |         for href in hrefs {
...   |
150 | |         Ok(items)
151 | |     }
    | |_____^
    |
    = note: delayed at compiler/rustc_borrowck/src/type_check/mod.rs:520:13

thread 'rustc' panicked at 'Box<dyn Any>', compiler/rustc_errors/src/lib.rs:1585:13
stack backtrace:
   0:     0x7f8e36468f90 - std::backtrace_rs::backtrace::libunwind::trace::he1ec9308d56754ef
                               at /rustc/1286ee23e4e2dec8c1696d3d76c6b26d97bbcf82/library/std/src/../../backtrace/src/backtrace/libunwind.rs:93:5
   1:     0x7f8e36468f90 - std::backtrace_rs::backtrace::trace_unsynchronized::h5c2c7548e45673aa
                               at /rustc/1286ee23e4e2dec8c1696d3d76c6b26d97bbcf82/library/std/src/../../backtrace/src/backtrace/mod.rs:66:5
   2:     0x7f8e36468f90 - std::sys_common::backtrace::_print_fmt::h8a3c0940409c1027
                               at /rustc/1286ee23e4e2dec8c1696d3d76c6b26d97bbcf82/library/std/src/sys_common/backtrace.rs:65:5
   3:     0x7f8e36468f90 - <std::sys_common::backtrace::_print::DisplayBacktrace as core::fmt::Display>::fmt::h61aef9b82866f95a
                               at /rustc/1286ee23e4e2dec8c1696d3d76c6b26d97bbcf82/library/std/src/sys_common/backtrace.rs:44:22
   4:     0x7f8e325c8bae - core::fmt::write::h7d5b70072d28dbfa
                               at /rustc/1286ee23e4e2dec8c1696d3d76c6b26d97bbcf82/library/core/src/fmt/mod.rs:1209:17
   5:     0x7f8e3645d075 - std::io::Write::write_fmt::h3d31360947679d21
                               at /rustc/1286ee23e4e2dec8c1696d3d76c6b26d97bbcf82/library/std/src/io/mod.rs:1682:15
   6:     0x7f8e36468d55 - std::sys_common::backtrace::_print::h6759e5b850bdca22
                               at /rustc/1286ee23e4e2dec8c1696d3d76c6b26d97bbcf82/library/std/src/sys_common/backtrace.rs:47:5
   7:     0x7f8e36468d55 - std::sys_common::backtrace::print::h1ad0f6b710bf019e
                               at /rustc/1286ee23e4e2dec8c1696d3d76c6b26d97bbcf82/library/std/src/sys_common/backtrace.rs:34:9
   8:     0x7f8e3646b06f - std::panicking::default_hook::{{closure}}::hd26f3c852c581cdf
                               at /rustc/1286ee23e4e2dec8c1696d3d76c6b26d97bbcf82/library/std/src/panicking.rs:267:22
   9:     0x7f8e3646adaa - std::panicking::default_hook::h92c20606c36e74d2
                               at /rustc/1286ee23e4e2dec8c1696d3d76c6b26d97bbcf82/library/std/src/panicking.rs:286:9
  10:     0x7f8e356ef154 - rustc_driver[f3db849b868bf2ae]::DEFAULT_HOOK::{closure#0}::{closure#0}
  11:     0x7f8e3646b85d - <alloc::boxed::Box<F,A> as core::ops::function::Fn<Args>>::call::h33523ae862b9476b
                               at /rustc/1286ee23e4e2dec8c1696d3d76c6b26d97bbcf82/library/alloc/src/boxed.rs:2001:9
  12:     0x7f8e3646b85d - std::panicking::rust_panic_with_hook::hc9f74d355270b517
                               at /rustc/1286ee23e4e2dec8c1696d3d76c6b26d97bbcf82/library/std/src/panicking.rs:692:13
  13:     0x7f8e35756511 - std[3f3511bd14de1a0b]::panicking::begin_panic::<rustc_errors[35630e0ab5d06bf2]::ExplicitBug>::{closure#0}
  14:     0x7f8e35754ca6 - std[3f3511bd14de1a0b]::sys_common::backtrace::__rust_end_short_backtrace::<std[3f3511bd14de1a0b]::panicking::begin_panic<rustc_errors[35630e0ab5d06bf2]::ExplicitBug>::{closure#0}, !>
  15:     0x7f8e35754c76 - std[3f3511bd14de1a0b]::panicking::begin_panic::<rustc_errors[35630e0ab5d06bf2]::ExplicitBug>
  16:     0x7f8e357510c6 - std[3f3511bd14de1a0b]::panic::panic_any::<rustc_errors[35630e0ab5d06bf2]::ExplicitBug>
  17:     0x7f8e34cac288 - <rustc_errors[35630e0ab5d06bf2]::HandlerInner>::flush_delayed::<alloc[8a94a0f38e11af27]::vec::Vec<rustc_errors[35630e0ab5d06bf2]::diagnostic::Diagnostic>, &str>
  18:     0x7f8e34aa5dbe - <rustc_interface[524480e3db7d7602]::passes::QueryContext>::enter::<<rustc_interface[524480e3db7d7602]::queries::Queries>::ongoing_codegen::{closure#0}::{closure#0}, core[449086d7d8ac0eaf]::result::Result<alloc[8a94a0f38e11af27]::boxed::Box<dyn core[449086d7d8ac0eaf]::any::Any>, rustc_errors[35630e0ab5d06bf2]::ErrorGuaranteed>>
  19:     0x7f8e34a660b3 - <rustc_interface[524480e3db7d7602]::queries::Queries>::ongoing_codegen
  20:     0x7f8e34a651c2 - <rustc_interface[524480e3db7d7602]::interface::Compiler>::enter::<rustc_driver[f3db849b868bf2ae]::run_compiler::{closure#1}::{closure#2}, core[449086d7d8ac0eaf]::result::Result<core[449086d7d8ac0eaf]::option::Option<rustc_interface[524480e3db7d7602]::queries::Linker>, rustc_errors[35630e0ab5d06bf2]::ErrorGuaranteed>>
  21:     0x7f8e34a60202 - rustc_span[a814485cde60f581]::with_source_map::<core[449086d7d8ac0eaf]::result::Result<(), rustc_errors[35630e0ab5d06bf2]::ErrorGuaranteed>, rustc_interface[524480e3db7d7602]::interface::run_compiler<core[449086d7d8ac0eaf]::result::Result<(), rustc_errors[35630e0ab5d06bf2]::ErrorGuaranteed>, rustc_driver[f3db849b868bf2ae]::run_compiler::{closure#1}>::{closure#0}::{closure#1}>
  22:     0x7f8e34a5fcf9 - <scoped_tls[d7bcc67860d72135]::ScopedKey<rustc_span[a814485cde60f581]::SessionGlobals>>::set::<rustc_interface[524480e3db7d7602]::interface::run_compiler<core[449086d7d8ac0eaf]::result::Result<(), rustc_errors[35630e0ab5d06bf2]::ErrorGuaranteed>, rustc_driver[f3db849b868bf2ae]::run_compiler::{closure#1}>::{closure#0}, core[449086d7d8ac0eaf]::result::Result<(), rustc_errors[35630e0ab5d06bf2]::ErrorGuaranteed>>
  23:     0x7f8e34a5f308 - std[3f3511bd14de1a0b]::sys_common::backtrace::__rust_begin_short_backtrace::<rustc_interface[524480e3db7d7602]::util::run_in_thread_pool_with_globals<rustc_interface[524480e3db7d7602]::interface::run_compiler<core[449086d7d8ac0eaf]::result::Result<(), rustc_errors[35630e0ab5d06bf2]::ErrorGuaranteed>, rustc_driver[f3db849b868bf2ae]::run_compiler::{closure#1}>::{closure#0}, core[449086d7d8ac0eaf]::result::Result<(), rustc_errors[35630e0ab5d06bf2]::ErrorGuaranteed>>::{closure#0}::{closure#0}, core[449086d7d8ac0eaf]::result::Result<(), rustc_errors[35630e0ab5d06bf2]::ErrorGuaranteed>>
  24:     0x7f8e34a5f02c - <<std[3f3511bd14de1a0b]::thread::Builder>::spawn_unchecked_<rustc_interface[524480e3db7d7602]::util::run_in_thread_pool_with_globals<rustc_interface[524480e3db7d7602]::interface::run_compiler<core[449086d7d8ac0eaf]::result::Result<(), rustc_errors[35630e0ab5d06bf2]::ErrorGuaranteed>, rustc_driver[f3db849b868bf2ae]::run_compiler::{closure#1}>::{closure#0}, core[449086d7d8ac0eaf]::result::Result<(), rustc_errors[35630e0ab5d06bf2]::ErrorGuaranteed>>::{closure#0}::{closure#0}, core[449086d7d8ac0eaf]::result::Result<(), rustc_errors[35630e0ab5d06bf2]::ErrorGuaranteed>>::{closure#1} as core[449086d7d8ac0eaf]::ops::function::FnOnce<()>>::call_once::{shim:vtable#0}
  25:     0x7f8e36472793 - <alloc::boxed::Box<F,A> as core::ops::function::FnOnce<Args>>::call_once::h9dd8eb50b3cb442b
                               at /rustc/1286ee23e4e2dec8c1696d3d76c6b26d97bbcf82/library/alloc/src/boxed.rs:1987:9
  26:     0x7f8e36472793 - <alloc::boxed::Box<F,A> as core::ops::function::FnOnce<Args>>::call_once::hb9b1fdf3a82a5af1
                               at /rustc/1286ee23e4e2dec8c1696d3d76c6b26d97bbcf82/library/alloc/src/boxed.rs:1987:9
  27:     0x7f8e36472793 - std::sys::unix::thread::Thread::new::thread_start::h768bb18f08276a43
                               at /rustc/1286ee23e4e2dec8c1696d3d76c6b26d97bbcf82/library/std/src/sys/unix/thread.rs:108:17
  28:     0x7f8e323198fd - <unknown>
  29:     0x7f8e3239ba60 - <unknown>
  30:                0x0 - <unknown>

note: 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.67.0-nightly (1286ee23e 2022-11-05) running on x86_64-unknown-linux-gnu

note: compiler flags: --crate-type lib -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:
end of query stack
For more information about this error, try `rustc --explain E0053`.
warning: `vstorage` (lib) generated 2 warnings
error: could not compile `vstorage`; 2 warnings emitted

Note that I'm using #![feature(async_fn_in_trait)] which is experimental.

@WhyNotHugo WhyNotHugo 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 Nov 9, 2022
@Noratrieb
Copy link
Member

Noratrieb commented Nov 9, 2022

This happens for all type mismatches in the arguments (but not the arity!)
A minimal example:

#![feature(async_fn_in_trait)]

trait A {
    async fn uwu(x: ());
}

impl A for () {
    async fn uwu(x: u8) {}
}
With the following backtrace:
error: internal compiler error: no errors encountered even though `delay_span_bug` issued

error: internal compiler error: could not unify `fn(()) -> _` and `fn(u8) -> impl Future<Output = ()>`: ArgumentSorts(ExpectedFound { expected: (), found: u8 }, 0)
 --> src/lib.rs:8:25
  |
8 |     async fn uwu(x: u8) {}
  |                         ^
  |
  = note: delayed at compiler/rustc_hir_analysis/src/check/compare_method.rs:529:33

error: internal compiler error: TyKind::Error constructed but no error reported
  |
  = note: delayed at compiler/rustc_trait_selection/src/traits/project.rs:2295:41

error: internal compiler error[[E0053]](https://doc.rust-lang.org/nightly/error-index.html#E0053): method `uwu` has an incompatible type for trait
 --> src/lib.rs:8:21
  |
8 |     async fn uwu(x: u8) {}
  |                     ^^ help: change the parameter type to match the trait: `()`
  |
note: while checking the return type of the `async fn`
 --> src/lib.rs:8:25
  |
8 |     async fn uwu(x: u8) {}
  |                         ^ checked the `Output` of this `async fn`, found opaque type

thread 'rustc' panicked at 'Box<dyn Any>', compiler/rustc_errors/src/lib.rs:1585:13
stack backtrace:
   0:     0x7f2929c17280 - std::backtrace_rs::backtrace::libunwind::trace::h90130e9f1ec9d9fc
                               at /rustc/85f4f41deb1557ca8ab228319d33003dd2f20f45/library/std/src/../../backtrace/src/backtrace/libunwind.rs:93:5
   1:     0x7f2929c17280 - std::backtrace_rs::backtrace::trace_unsynchronized::h40c4f6d986aff2e4
                               at /rustc/85f4f41deb1557ca8ab228319d33003dd2f20f45/library/std/src/../../backtrace/src/backtrace/mod.rs:66:5
   2:     0x7f2929c17280 - std::sys_common::backtrace::_print_fmt::h3822369be0084f83
                               at /rustc/85f4f41deb1557ca8ab228319d33003dd2f20f45/library/std/src/sys_common/backtrace.rs:65:5
   3:     0x7f2929c17280 - <std::sys_common::backtrace::_print::DisplayBacktrace as core::fmt::Display>::fmt::hdae4626daadc9f71
                               at /rustc/85f4f41deb1557ca8ab228319d33003dd2f20f45/library/std/src/sys_common/backtrace.rs:44:22
   4:     0x7f2925d5d4fe - core::fmt::write::h05cdd281d08b9d01
                               at /rustc/85f4f41deb1557ca8ab228319d33003dd2f20f45/library/core/src/fmt/mod.rs:1209:17
   5:     0x7f2929c0b365 - std::io::Write::write_fmt::h8e1559869183c8bb
                               at /rustc/85f4f41deb1557ca8ab228319d33003dd2f20f45/library/std/src/io/mod.rs:1682:15
   6:     0x7f2929c17045 - std::sys_common::backtrace::_print::h61ba1afc98d46ffd
                               at /rustc/85f4f41deb1557ca8ab228319d33003dd2f20f45/library/std/src/sys_common/backtrace.rs:47:5
   7:     0x7f2929c17045 - std::sys_common::backtrace::print::he9728762d292043e
                               at /rustc/85f4f41deb1557ca8ab228319d33003dd2f20f45/library/std/src/sys_common/backtrace.rs:34:9
   8:     0x7f2929c1935f - std::panicking::default_hook::{{closure}}::h726bafb7da990095
                               at /rustc/85f4f41deb1557ca8ab228319d33003dd2f20f45/library/std/src/panicking.rs:267:22
   9:     0x7f2929c1909a - std::panicking::default_hook::hdc60b442b1844a68
                               at /rustc/85f4f41deb1557ca8ab228319d33003dd2f20f45/library/std/src/panicking.rs:286:9
  10:     0x7f2928e98a14 - rustc_driver[b81881107b3cefb1]::DEFAULT_HOOK::{closure#0}::{closure#0}
  11:     0x7f2929c19b4d - <alloc::boxed::Box<F,A> as core::ops::function::Fn<Args>>::call::h3db297037157cab4
                               at /rustc/85f4f41deb1557ca8ab228319d33003dd2f20f45/library/alloc/src/boxed.rs:2032:9
  12:     0x7f2929c19b4d - std::panicking::rust_panic_with_hook::hc98185590f941643
                               at /rustc/85f4f41deb1557ca8ab228319d33003dd2f20f45/library/std/src/panicking.rs:692:13
  13:     0x7f2928effbe1 - std[23e74d0f7912c00c]::panicking::begin_panic::<rustc_errors[43d68c63b698f7a8]::ExplicitBug>::{closure#0}
  14:     0x7f2928efe376 - std[23e74d0f7912c00c]::sys_common::backtrace::__rust_end_short_backtrace::<std[23e74d0f7912c00c]::panicking::begin_panic<rustc_errors[43d68c63b698f7a8]::ExplicitBug>::{closure#0}, !>
  15:     0x7f2928efcd16 - std[23e74d0f7912c00c]::panicking::begin_panic::<rustc_errors[43d68c63b698f7a8]::ExplicitBug>
  16:     0x7f2928efa1f6 - std[23e74d0f7912c00c]::panic::panic_any::<rustc_errors[43d68c63b698f7a8]::ExplicitBug>
  17:     0x7f2928424ed8 - <rustc_errors[43d68c63b698f7a8]::HandlerInner>::flush_delayed::<alloc[e7e939941d2090cd]::vec::Vec<rustc_errors[43d68c63b698f7a8]::diagnostic::Diagnostic>, &str>
  18:     0x7f29281ccc6e - <rustc_interface[74ce99d2ea85b1]::passes::QueryContext>::enter::<<rustc_interface[74ce99d2ea85b1]::queries::Queries>::ongoing_codegen::{closure#0}::{closure#0}, core[c2065954f2d40e37]::result::Result<alloc[e7e939941d2090cd]::boxed::Box<dyn core[c2065954f2d40e37]::any::Any>, rustc_errors[43d68c63b698f7a8]::ErrorGuaranteed>>
  19:     0x7f292818d523 - <rustc_interface[74ce99d2ea85b1]::queries::Queries>::ongoing_codegen
  20:     0x7f292818c632 - <rustc_interface[74ce99d2ea85b1]::interface::Compiler>::enter::<rustc_driver[b81881107b3cefb1]::run_compiler::{closure#1}::{closure#2}, core[c2065954f2d40e37]::result::Result<core[c2065954f2d40e37]::option::Option<rustc_interface[74ce99d2ea85b1]::queries::Linker>, rustc_errors[43d68c63b698f7a8]::ErrorGuaranteed>>
  21:     0x7f2928187672 - rustc_span[7a6d98bdad94076d]::with_source_map::<core[c2065954f2d40e37]::result::Result<(), rustc_errors[43d68c63b698f7a8]::ErrorGuaranteed>, rustc_interface[74ce99d2ea85b1]::interface::run_compiler<core[c2065954f2d40e37]::result::Result<(), rustc_errors[43d68c63b698f7a8]::ErrorGuaranteed>, rustc_driver[b81881107b3cefb1]::run_compiler::{closure#1}>::{closure#0}::{closure#1}>
  22:     0x7f2928187169 - <scoped_tls[866d789ca631dc2f]::ScopedKey<rustc_span[7a6d98bdad94076d]::SessionGlobals>>::set::<rustc_interface[74ce99d2ea85b1]::interface::run_compiler<core[c2065954f2d40e37]::result::Result<(), rustc_errors[43d68c63b698f7a8]::ErrorGuaranteed>, rustc_driver[b81881107b3cefb1]::run_compiler::{closure#1}>::{closure#0}, core[c2065954f2d40e37]::result::Result<(), rustc_errors[43d68c63b698f7a8]::ErrorGuaranteed>>
  23:     0x7f2928186778 - std[23e74d0f7912c00c]::sys_common::backtrace::__rust_begin_short_backtrace::<rustc_interface[74ce99d2ea85b1]::util::run_in_thread_pool_with_globals<rustc_interface[74ce99d2ea85b1]::interface::run_compiler<core[c2065954f2d40e37]::result::Result<(), rustc_errors[43d68c63b698f7a8]::ErrorGuaranteed>, rustc_driver[b81881107b3cefb1]::run_compiler::{closure#1}>::{closure#0}, core[c2065954f2d40e37]::result::Result<(), rustc_errors[43d68c63b698f7a8]::ErrorGuaranteed>>::{closure#0}::{closure#0}, core[c2065954f2d40e37]::result::Result<(), rustc_errors[43d68c63b698f7a8]::ErrorGuaranteed>>
  24:     0x7f292818649c - <<std[23e74d0f7912c00c]::thread::Builder>::spawn_unchecked_<rustc_interface[74ce99d2ea85b1]::util::run_in_thread_pool_with_globals<rustc_interface[74ce99d2ea85b1]::interface::run_compiler<core[c2065954f2d40e37]::result::Result<(), rustc_errors[43d68c63b698f7a8]::ErrorGuaranteed>, rustc_driver[b81881107b3cefb1]::run_compiler::{closure#1}>::{closure#0}, core[c2065954f2d40e37]::result::Result<(), rustc_errors[43d68c63b698f7a8]::ErrorGuaranteed>>::{closure#0}::{closure#0}, core[c2065954f2d40e37]::result::Result<(), rustc_errors[43d68c63b698f7a8]::ErrorGuaranteed>>::{closure#1} as core[c2065954f2d40e37]::ops::function::FnOnce<()>>::call_once::{shim:vtable#0}
  25:     0x7f2929c20a83 - <alloc::boxed::Box<F,A> as core::ops::function::FnOnce<Args>>::call_once::he8eec53b13ee98a2
                               at /rustc/85f4f41deb1557ca8ab228319d33003dd2f20f45/library/alloc/src/boxed.rs:2000:9
  26:     0x7f2929c20a83 - <alloc::boxed::Box<F,A> as core::ops::function::FnOnce<Args>>::call_once::h04d7374ad262fa8b
                               at /rustc/85f4f41deb1557ca8ab228319d33003dd2f20f45/library/alloc/src/boxed.rs:2000:9
  27:     0x7f2929c20a83 - std::sys::unix::thread::Thread::new::thread_start::h0bc6cb3772aee1f7
                               at /rustc/85f4f41deb1557ca8ab228319d33003dd2f20f45/library/std/src/sys/unix/thread.rs:108:17
  28:     0x7f2925bd1609 - start_thread
  29:     0x7f2925af4133 - clone
  30:                0x0 - <unknown>

note: 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.67.0-nightly (85f4f41de 2022-11-08) running on x86_64-unknown-linux-gnu

note: compiler flags: --crate-type lib -C embed-bitcode=no -C codegen-units=1 -C debuginfo=2

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

query stack during panic:
end of query stack

@Noratrieb
Copy link
Member

Noratrieb commented Nov 9, 2022

When not using a normal fn, the proper error is emitted here inside compare_predicate_entailment:

if let Err(_) = compare_predicate_entailment(tcx, impl_m, impl_m_span, trait_m, impl_trait_ref)
{
return;
}

But something gets messed up with the return position impl trait in trait desugaring that doesn't make this work (the arity check above does work).

@rustbot claim

Manishearth added a commit to Manishearth/rust that referenced this issue Nov 10, 2022
…iler-errors

Emit error in `collecting_trait_impl_trait_tys` on mismatched signatures

Previously, a `delay_span_bug` was isssued, failing normalization. This create a `TyKind::Error` in the signature, which caused `compare_predicate_entailment` to swallow its signature mismatch error, causing ICEs because no error was emitted.

fixes rust-lang#104183

r? `@compiler-errors`
matthiaskrgr added a commit to matthiaskrgr/rust that referenced this issue Nov 10, 2022
…iler-errors

Emit error in `collecting_trait_impl_trait_tys` on mismatched signatures

Previously, a `delay_span_bug` was isssued, failing normalization. This create a `TyKind::Error` in the signature, which caused `compare_predicate_entailment` to swallow its signature mismatch error, causing ICEs because no error was emitted.

fixes rust-lang#104183

r? ``@compiler-errors``
@bors bors closed this as completed in 35816ff Nov 12, 2022
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