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

thread 'rustc' panicked at 'DefId(146:722 ~ libp2p_swarm[d5e9]::behaviour::NetworkBehaviour::ToSwarm) does not have a "type_of"' #11190

Closed
thomaseizinger opened this issue Jul 19, 2023 · 3 comments · Fixed by #11191
Labels
C-bug Category: Clippy is not doing the correct thing I-ICE Issue: Clippy panicked, giving an Internal Compilation Error (ICE) ❄️

Comments

@thomaseizinger
Copy link

Summary

The error is reproducible on rust-libp2p. A link to the error is here: https://github.com/libp2p/rust-libp2p/actions/runs/5600000763/jobs/10241748470?pr=4217#step:6:989

  • git clone [email protected]:libp2p/rust-libp2p.git
  • git checkout 1acf4a5e17fe2c5c172cdd91d1ccd15b9b1004e3 (I verified on this commit last)
  • cargo +beta custom-clippy

Version

rustc 1.72.0-beta.1 (7ba605cd9 2023-07-11)
binary: rustc
commit-hash: 7ba605cd90d6467bda469d1cd2148ac32ea562bf
commit-date: 2023-07-11
host: x86_64-unknown-linux-gnu
release: 1.72.0-beta.1
LLVM version: 16.0.5

Error output

Backtrace

thread 'rustc' panicked at 'DefId(146:722 ~ libp2p_swarm[3e56]::behaviour::NetworkBehaviour::ToSwarm) does not have a "type_of"', compiler/rustc_metadata/src/rmeta/decoder/cstore_impl.rs:205:1
stack backtrace:
 0:     0x7fa9efb63a71 - std::backtrace_rs::backtrace::libunwind::trace::h94777a5a344c8170
                             at /rustc/7ba605cd90d6467bda469d1cd2148ac32ea562bf/library/std/src/../../backtrace/src/backtrace/libunwind.rs:93:5
 1:     0x7fa9efb63a71 - std::backtrace_rs::backtrace::trace_unsynchronized::he095887f858ff498
                             at /rustc/7ba605cd90d6467bda469d1cd2148ac32ea562bf/library/std/src/../../backtrace/src/backtrace/mod.rs:66:5
 2:     0x7fa9efb63a71 - std::sys_common::backtrace::_print_fmt::heb80af79c3e3532a
                             at /rustc/7ba605cd90d6467bda469d1cd2148ac32ea562bf/library/std/src/sys_common/backtrace.rs:65:5
 3:     0x7fa9efb63a71 - <std::sys_common::backtrace::_print::DisplayBacktrace as core::fmt::Display>::fmt::h9a19c935d592dfb2
                             at /rustc/7ba605cd90d6467bda469d1cd2148ac32ea562bf/library/std/src/sys_common/backtrace.rs:44:22
 4:     0x7fa9efbc9d7f - core::fmt::rt::Argument::fmt::hddb6050609fa06fe
                             at /rustc/7ba605cd90d6467bda469d1cd2148ac32ea562bf/library/core/src/fmt/rt.rs:138:9
 5:     0x7fa9efbc9d7f - core::fmt::write::ha8844a5a3cd50a2c
                             at /rustc/7ba605cd90d6467bda469d1cd2148ac32ea562bf/library/core/src/fmt/mod.rs:1094:21
 6:     0x7fa9efb564b7 - std::io::Write::write_fmt::hb99d0740afb1c700
                             at /rustc/7ba605cd90d6467bda469d1cd2148ac32ea562bf/library/std/src/io/mod.rs:1714:15
 7:     0x7fa9efb63885 - std::sys_common::backtrace::_print::h0d0593de5707e0ff
                             at /rustc/7ba605cd90d6467bda469d1cd2148ac32ea562bf/library/std/src/sys_common/backtrace.rs:47:5
 8:     0x7fa9efb63885 - std::sys_common::backtrace::print::hbcfa6697a1a39978
                             at /rustc/7ba605cd90d6467bda469d1cd2148ac32ea562bf/library/std/src/sys_common/backtrace.rs:34:9
 9:     0x7fa9efb66663 - std::panicking::default_hook::{{closure}}::he1e63e7051fb08fe
                             at /rustc/7ba605cd90d6467bda469d1cd2148ac32ea562bf/library/std/src/panicking.rs:269:22
10:     0x7fa9efb663f4 - std::panicking::default_hook::h72264c321cf51b86
                             at /rustc/7ba605cd90d6467bda469d1cd2148ac32ea562bf/library/std/src/panicking.rs:288:9
11:     0x7fa9f2e35c1b - <rustc_driver_impl[9022bb2727ba2234]::install_ice_hook::{closure#0} as core[e4967467b6217607]::ops::function::FnOnce<(&core[e4967467b6217607]::panic::panic_info::Panic
12:     0x7fa9efb66e8e - <alloc::boxed::Box<F,A> as core::ops::function::Fn<Args>>::call::h7dda1de8100a31f6
                             at /rustc/7ba605cd90d6467bda469d1cd2148ac32ea562bf/library/alloc/src/boxed.rs:2007:9
13:     0x7fa9efb66e8e - std::panicking::rust_panic_with_hook::hd8d4ad75aad75468
                             at /rustc/7ba605cd90d6467bda469d1cd2148ac32ea562bf/library/std/src/panicking.rs:709:13
14:     0x7fa9efb66c17 - std::panicking::begin_panic_handler::{{closure}}::h512fa2700c56c434
                             at /rustc/7ba605cd90d6467bda469d1cd2148ac32ea562bf/library/std/src/panicking.rs:597:13
15:     0x7fa9efb63ed6 - std::sys_common::backtrace::__rust_end_short_backtrace::h49b29d9ed805b763
                             at /rustc/7ba605cd90d6467bda469d1cd2148ac32ea562bf/library/std/src/sys_common/backtrace.rs:151:18
16:     0x7fa9efb66962 - rust_begin_unwind
                             at /rustc/7ba605cd90d6467bda469d1cd2148ac32ea562bf/library/std/src/panicking.rs:593:5
17:     0x7fa9efbc5fd3 - core::panicking::panic_fmt::hf10924179b0733e8
                             at /rustc/7ba605cd90d6467bda469d1cd2148ac32ea562bf/library/core/src/panicking.rs:67:14
18:     0x7fa9f3309e72 - rustc_metadata[bad9f683e1a4028]::rmeta::decoder::cstore_impl::provide_extern::type_of::{closure#2}
19:     0x7fa9f0f90ac7 - rustc_query_impl[ca17851a876816be]::plumbing::__rust_begin_short_backtrace::<rustc_query_impl[ca17851a876816be]::query_impl::type_of::dynamic_query::{closure#2}::{clos
20:     0x7fa9f0f905f0 - <rustc_query_impl[ca17851a876816be]::query_impl::type_of::dynamic_query::{closure#2} as core[e4967467b6217607]::ops::function::FnOnce<(rustc_middle[9c74e7ef4ffdc64f]::
21:     0x7fa9f1c224d1 - rustc_query_system[e52d09ec8c9901f8]::query::plumbing::try_execute_query::<rustc_query_impl[ca17851a876816be]::DynamicConfig<rustc_query_system[e52d09ec8c9901f8]::quer
22:     0x7fa9f2796c2b - rustc_query_impl[ca17851a876816be]::query_impl::type_of::get_query_incr::__rust_end_short_backtrace
23:     0x562cc111ccef - rustc_middle[9c74e7ef4ffdc64f]::query::plumbing::query_get_at::<rustc_query_system[e52d09ec8c9901f8]::query::caches::DefaultCache<rustc_span[f261485185b8127d]::def_id:
24:     0x562cc113e77c - clippy_lints[19070363130151e9]::redundant_type_annotations::is_redundant_in_func_call
25:     0x562cc113e86f - <clippy_lints[19070363130151e9]::redundant_type_annotations::RedundantTypeAnnotations as rustc_lint[9e62062d10dbe12e]::passes::LateLintPass>::check_local
26:     0x7fa9f3238df3 - <rustc_lint[9e62062d10dbe12e]::late::RuntimeCombinedLateLintPass as rustc_lint[9e62062d10dbe12e]::passes::LateLintPass>::check_local
27:     0x7fa9f32168f1 - <rustc_lint[9e62062d10dbe12e]::late::LateContextAndPass<rustc_lint[9e62062d10dbe12e]::late::RuntimeCombinedLateLintPass> as rustc_hir[c71688bad7d0abe8]::intravisit::Vi
28:     0x7fa9f31eba8b - rustc_hir[c71688bad7d0abe8]::intravisit::walk_block::<rustc_lint[9e62062d10dbe12e]::late::LateContextAndPass<rustc_lint[9e62062d10dbe12e]::late::RuntimeCombinedLateLin
29:     0x7fa9f3216879 - <rustc_lint[9e62062d10dbe12e]::late::LateContextAndPass<rustc_lint[9e62062d10dbe12e]::late::RuntimeCombinedLateLintPass> as rustc_hir[c71688bad7d0abe8]::intravisit::Vi
30:     0x7fa9f32157c1 - <rustc_lint[9e62062d10dbe12e]::late::LateContextAndPass<rustc_lint[9e62062d10dbe12e]::late::RuntimeCombinedLateLintPass>>::with_lint_attrs::<<rustc_lint[9e62062d10dbe1
31:     0x7fa9f321676c - <rustc_lint[9e62062d10dbe12e]::late::LateContextAndPass<rustc_lint[9e62062d10dbe12e]::late::RuntimeCombinedLateLintPass> as rustc_hir[c71688bad7d0abe8]::intravisit::Vi
32:     0x7fa9f3216bc5 - <rustc_lint[9e62062d10dbe12e]::late::LateContextAndPass<rustc_lint[9e62062d10dbe12e]::late::RuntimeCombinedLateLintPass> as rustc_hir[c71688bad7d0abe8]::intravisit::Vi
33:     0x7fa9f3216daa - <rustc_lint[9e62062d10dbe12e]::late::LateContextAndPass<rustc_lint[9e62062d10dbe12e]::late::RuntimeCombinedLateLintPass> as rustc_hir[c71688bad7d0abe8]::intravisit::Vi
34:     0x7fa9f31ed483 - rustc_hir[c71688bad7d0abe8]::intravisit::walk_item::<rustc_lint[9e62062d10dbe12e]::late::LateContextAndPass<rustc_lint[9e62062d10dbe12e]::late::RuntimeCombinedLateLint
35:     0x7fa9f3217557 - <rustc_lint[9e62062d10dbe12e]::late::LateContextAndPass<rustc_lint[9e62062d10dbe12e]::late::RuntimeCombinedLateLintPass> as rustc_hir[c71688bad7d0abe8]::intravisit::Vi
36:     0x7fa9f31eba8b - rustc_hir[c71688bad7d0abe8]::intravisit::walk_block::<rustc_lint[9e62062d10dbe12e]::late::LateContextAndPass<rustc_lint[9e62062d10dbe12e]::late::RuntimeCombinedLateLin
37:     0x7fa9f3216879 - <rustc_lint[9e62062d10dbe12e]::late::LateContextAndPass<rustc_lint[9e62062d10dbe12e]::late::RuntimeCombinedLateLintPass> as rustc_hir[c71688bad7d0abe8]::intravisit::Vi
38:     0x7fa9f32157c1 - <rustc_lint[9e62062d10dbe12e]::late::LateContextAndPass<rustc_lint[9e62062d10dbe12e]::late::RuntimeCombinedLateLintPass>>::with_lint_attrs::<<rustc_lint[9e62062d10dbe1
39:     0x7fa9f321676c - <rustc_lint[9e62062d10dbe12e]::late::LateContextAndPass<rustc_lint[9e62062d10dbe12e]::late::RuntimeCombinedLateLintPass> as rustc_hir[c71688bad7d0abe8]::intravisit::Vi
40:     0x7fa9f3216bc5 - <rustc_lint[9e62062d10dbe12e]::late::LateContextAndPass<rustc_lint[9e62062d10dbe12e]::late::RuntimeCombinedLateLintPass> as rustc_hir[c71688bad7d0abe8]::intravisit::Vi
41:     0x7fa9f3216daa - <rustc_lint[9e62062d10dbe12e]::late::LateContextAndPass<rustc_lint[9e62062d10dbe12e]::late::RuntimeCombinedLateLintPass> as rustc_hir[c71688bad7d0abe8]::intravisit::Vi
42:     0x7fa9f31ed483 - rustc_hir[c71688bad7d0abe8]::intravisit::walk_item::<rustc_lint[9e62062d10dbe12e]::late::LateContextAndPass<rustc_lint[9e62062d10dbe12e]::late::RuntimeCombinedLateLint
43:     0x7fa9f3217557 - <rustc_lint[9e62062d10dbe12e]::late::LateContextAndPass<rustc_lint[9e62062d10dbe12e]::late::RuntimeCombinedLateLintPass> as rustc_hir[c71688bad7d0abe8]::intravisit::Vi
44:     0x7fa9f31eccf8 - rustc_hir[c71688bad7d0abe8]::intravisit::walk_mod::<rustc_lint[9e62062d10dbe12e]::late::LateContextAndPass<rustc_lint[9e62062d10dbe12e]::late::RuntimeCombinedLateLintP
45:     0x7fa9f22a352e - rustc_lint[9e62062d10dbe12e]::late::late_lint_crate::<rustc_lint[9e62062d10dbe12e]::BuiltinCombinedLateLintPass>
46:     0x7fa9f22a2978 - <rustc_session[ac31272b89124e68]::session::Session>::time::<(), rustc_lint[9e62062d10dbe12e]::late::check_crate<rustc_lint[9e62062d10dbe12e]::BuiltinCombinedLateLintPa
47:     0x7fa9f22a2813 - <rustc_session[ac31272b89124e68]::session::Session>::time::<(), rustc_interface[703edc9b7010fe6b]::passes::analysis::{closure#5}::{closure#1}::{closure#2}::{closure#0}
48:     0x7fa9f22a234f - <core[e4967467b6217607]::panic::unwind_safe::AssertUnwindSafe<rustc_interface[703edc9b7010fe6b]::passes::analysis::{closure#5}::{closure#1}> as core[e4967467b6217607]:
49:     0x7fa9f22a1d70 - <rustc_session[ac31272b89124e68]::session::Session>::time::<(), rustc_interface[703edc9b7010fe6b]::passes::analysis::{closure#5}>
50:     0x7fa9f22a0887 - rustc_interface[703edc9b7010fe6b]::passes::analysis
51:     0x7fa9f22fb3ea - rustc_query_impl[ca17851a876816be]::plumbing::__rust_begin_short_backtrace::<rustc_query_impl[ca17851a876816be]::query_impl::analysis::dynamic_query::{closure#2}::{clo
52:     0x7fa9f22fb3d9 - <rustc_query_impl[ca17851a876816be]::query_impl::analysis::dynamic_query::{closure#2} as core[e4967467b6217607]::ops::function::FnOnce<(rustc_middle[9c74e7ef4ffdc64f]:
53:     0x7fa9f25f2eff - rustc_query_system[e52d09ec8c9901f8]::query::plumbing::try_execute_query::<rustc_query_impl[ca17851a876816be]::DynamicConfig<rustc_query_system[e52d09ec8c9901f8]::quer
54:     0x7fa9f25f2aa4 - rustc_query_impl[ca17851a876816be]::query_impl::analysis::get_query_incr::__rust_end_short_backtrace
55:     0x7fa9f206e9b5 - <rustc_middle[9c74e7ef4ffdc64f]::ty::context::GlobalCtxt>::enter::<rustc_driver_impl[9022bb2727ba2234]::run_compiler::{closure#1}::{closure#2}::{closure#4}, core[e4967
56:     0x7fa9f206dfe2 - <rustc_interface[703edc9b7010fe6b]::interface::Compiler>::enter::<rustc_driver_impl[9022bb2727ba2234]::run_compiler::{closure#1}::{closure#2}, core[e4967467b6217607]::
57:     0x7fa9f2067135 - rustc_span[f261485185b8127d]::set_source_map::<core[e4967467b6217607]::result::Result<(), rustc_span[f261485185b8127d]::ErrorGuaranteed>, rustc_interface[703edc9b7010fe6b]::interface::run_compiler<core[e4967467b6217607]::result::Result<(), rustc_span[f261485185b8127d]::ErrorGuaranteed>, rustc_driver_impl[9022bb2727ba2234]::run_compiler::{closure#1}>::{closure#0}::{closure#0}>
58:     0x7fa9f2066ba6 - <scoped_tls[c50e4eaf01ac5aa0]::ScopedKey<rustc_span[f261485185b8127d]::SessionGlobals>>::set::<rustc_interface[703edc9b7010fe6b]::interface::run_compiler<core[e4967467b6217607]::result::Result<(), rustc_span[f261485185b8127d]::ErrorGuaranteed>, rustc_driver_impl[9022bb2727ba2234]::run_compiler::{closure#1}>::{closure#0}, core[e4967467b6217607]::result::Result<(), rustc_span[f261485185b8127d]::ErrorGuaranteed>>
59:     0x7fa9f206616c - std[608f0a5433fa9789]::sys_common::backtrace::__rust_begin_short_backtrace::<rustc_interface[703edc9b7010fe6b]::util::run_in_thread_pool_with_globals<rustc_interface[703edc9b7010fe6b]::interface::run_compiler<core[e4967467b6217607]::result::Result<(), rustc_span[f261485185b8127d]::ErrorGuaranteed>, rustc_driver_impl[9022bb2727ba2234]::run_compiler::{closure#1}>::{closure#0}, core[e4967467b6217607]::result::Result<(), rustc_span[f261485185b8127d]::ErrorGuaranteed>>::{closure#0}::{closure#0}, core[e4967467b6217607]::result::Result<(), rustc_span[f261485185b8127d]::ErrorGuaranteed>>
60:     0x7fa9f2065f35 - <<std[608f0a5433fa9789]::thread::Builder>::spawn_unchecked_<rustc_interface[703edc9b7010fe6b]::util::run_in_thread_pool_with_globals<rustc_interface[703edc9b7010fe6b]::interface::run_compiler<core[e4967467b6217607]::result::Result<(), rustc_span[f261485185b8127d]::ErrorGuaranteed>, rustc_driver_impl[9022bb2727ba2234]::run_compiler::{closure#1}>::{closure#0}, core[e4967467b6217607]::result::Result<(), rustc_span[f261485185b8127d]::ErrorGuaranteed>>::{closure#0}::{closure#0}, core[e4967467b6217607]::result::Result<(), rustc_span[f261485185b8127d]::ErrorGuaranteed>>::{closure#1} as core[e4967467b6217607]::ops::function::FnOnce<()>>::call_once::{shim:vtable#0}
61:     0x7fa9efb71305 - <alloc::boxed::Box<F,A> as core::ops::function::FnOnce<Args>>::call_once::h2b1aee684822b9e4
                             at /rustc/7ba605cd90d6467bda469d1cd2148ac32ea562bf/library/alloc/src/boxed.rs:1993:9
62:     0x7fa9efb71305 - <alloc::boxed::Box<F,A> as core::ops::function::FnOnce<Args>>::call_once::hefb9a903e14e5c77
                             at /rustc/7ba605cd90d6467bda469d1cd2148ac32ea562bf/library/alloc/src/boxed.rs:1993:9
63:     0x7fa9efb71305 - std::sys::unix::thread::Thread::new::thread_start::h13ba2a34a82ad56b
                             at /rustc/7ba605cd90d6467bda469d1cd2148ac32ea562bf/library/std/src/sys/unix/thread.rs:108:17
64:     0x7fa9ef81744b - <unknown>
65:     0x7fa9ef89ae40 - <unknown>
66:                0x0 - <unknown>

@thomaseizinger thomaseizinger added C-bug Category: Clippy is not doing the correct thing I-ICE Issue: Clippy panicked, giving an Internal Compilation Error (ICE) ❄️ labels Jul 19, 2023
@y21
Copy link
Member

y21 commented Jul 19, 2023

minimal reproducible example:

trait NetworkBehaviour {
    type ToSwarm;
}
struct Foo {
    ping: (),
}
impl NetworkBehaviour for Foo {
    type ToSwarm = i32;
}
fn foo() {
    let _out_event: <Foo as NetworkBehaviour>::ToSwarm = unimplemented!();
}

https://play.rust-lang.org/?version=stable&mode=debug&edition=2021&gist=59e0ad957c93e3a3ff15cf6fbd7ed717

@y21
Copy link
Member

y21 commented Jul 19, 2023

Oh wait, looks like I just found a different ICE while trying to minimize this one 😅
The MRE I posted is not quite the same I don't think

@Alexendoo
Copy link
Member

The type_of query runs different code for local and foreign definitions. The ICE in the example is the one you'd see if the trait was defined in a different crate but it's the same issue in both cases

bors added a commit that referenced this issue Aug 6, 2023
…ogiq

redundant_type_annotations: only pass certain def kinds to type_of

Fixes #11190
Fixes rust-lang/rust#113516

Also adds an `is_lint_allowed` check to skip the lint when it's not needed

changelog: none
@bors bors closed this as completed in 526d115 Aug 6, 2023
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
C-bug Category: Clippy is not doing the correct thing I-ICE Issue: Clippy panicked, giving an Internal Compilation Error (ICE) ❄️
Projects
None yet
Development

Successfully merging a pull request may close this issue.

3 participants