rust-lang / rust-clippy

A bunch of lints to catch common mistakes and improve your Rust code. Book: https://doc.rust-lang.org/clippy/
https://rust-lang.github.io/rust-clippy/
Other
11.24k stars 1.51k forks source link

ICE: missing_fields_in_debug on `core` ` unexpected non-type Node::GenericParam: Type { default: None, synthetic: false }` #10887

Closed matthiaskrgr closed 1 year ago

matthiaskrgr commented 1 year ago

Summary

Found by running clippy on rustcs core

Version

rustc 1.72.0-nightly (9eee230cd 2023-06-04)
binary: rustc
commit-hash: 9eee230cd0a56bfba3ce65121798d9f9f4341cdd
commit-date: 2023-06-04
host: x86_64-unknown-linux-gnu
release: 1.72.0-nightly
LLVM version: 16.0.4

Error output

Backtrace

``` Building bootstrap Finished dev [unoptimized] target(s) in 0.02s Checking stage0 library artifacts (x86_64-unknown-linux-gnu) Checking core v0.0.0 (/home/matthias/vcs/github/rust/library/core) Compiling unwind v0.0.0 (/home/matthias/vcs/github/rust/library/unwind) Compiling std v0.0.0 (/home/matthias/vcs/github/rust/library/std) error: internal compiler error: compiler/rustc_hir_analysis/src/collect/type_of.rs:492:18: unexpected non-type Node::GenericParam: Type { default: None, synthetic: false } thread 'rustc' panicked at 'Box', /rustc/9eee230cd0a56bfba3ce65121798d9f9f4341cdd/compiler/rustc_errors/src/lib.rs:1650:9 stack backtrace: 0: 0x7f01d5969ba1 - std::backtrace_rs::backtrace::libunwind::trace::h9a9187caf3af91d1 at /rustc/9eee230cd0a56bfba3ce65121798d9f9f4341cdd/library/std/src/../../backtrace/src/backtrace/libunwind.rs:93:5 1: 0x7f01d5969ba1 - std::backtrace_rs::backtrace::trace_unsynchronized::hb7edc6b3aa152770 at /rustc/9eee230cd0a56bfba3ce65121798d9f9f4341cdd/library/std/src/../../backtrace/src/backtrace/mod.rs:66:5 2: 0x7f01d5969ba1 - std::sys_common::backtrace::_print_fmt::h2cb92da4808aa2bb at /rustc/9eee230cd0a56bfba3ce65121798d9f9f4341cdd/library/std/src/sys_common/backtrace.rs:65:5 3: 0x7f01d5969ba1 - ::fmt::hd8232dceaa5f842a at /rustc/9eee230cd0a56bfba3ce65121798d9f9f4341cdd/library/std/src/sys_common/backtrace.rs:44:22 4: 0x7f01d59ca18f - core::fmt::rt::Argument::fmt::hbb868be86ad03968 at /rustc/9eee230cd0a56bfba3ce65121798d9f9f4341cdd/library/core/src/fmt/rt.rs:138:9 5: 0x7f01d59ca18f - core::fmt::write::ha174691b29cb8587 at /rustc/9eee230cd0a56bfba3ce65121798d9f9f4341cdd/library/core/src/fmt/mod.rs:1094:21 6: 0x7f01d595cdb1 - std::io::Write::write_fmt::h16c27c35c166af5d at /rustc/9eee230cd0a56bfba3ce65121798d9f9f4341cdd/library/std/src/io/mod.rs:1713:15 7: 0x7f01d59699b5 - std::sys_common::backtrace::_print::ha2df7b232cdda68a at /rustc/9eee230cd0a56bfba3ce65121798d9f9f4341cdd/library/std/src/sys_common/backtrace.rs:47:5 8: 0x7f01d59699b5 - std::sys_common::backtrace::print::h8c0a7734e29006f9 at /rustc/9eee230cd0a56bfba3ce65121798d9f9f4341cdd/library/std/src/sys_common/backtrace.rs:34:9 9: 0x7f01d596c677 - std::panicking::default_hook::{{closure}}::h8a35ce5756ca853f 10: 0x7f01d596c464 - std::panicking::default_hook::hac20b200f3148ff6 at /rustc/9eee230cd0a56bfba3ce65121798d9f9f4341cdd/library/std/src/panicking.rs:288:9 11: 0x7f01d8b96d1b - rustc_driver_impl[99c4d2c9209ccfb0]::install_ice_hook::{closure#0} 12: 0x7f01d596cdbd - as core::ops::function::Fn>::call::haec4d3264083e3ef at /rustc/9eee230cd0a56bfba3ce65121798d9f9f4341cdd/library/alloc/src/boxed.rs:1999:9 13: 0x7f01d596cdbd - std::panicking::rust_panic_with_hook::h52fee6bdefb6b7d6 at /rustc/9eee230cd0a56bfba3ce65121798d9f9f4341cdd/library/std/src/panicking.rs:709:13 14: 0x7f01d90a3271 - std[f32b9bd0414b81da]::panicking::begin_panic::::{closure#0} 15: 0x7f01d909ee66 - std[f32b9bd0414b81da]::sys_common::backtrace::__rust_end_short_backtrace::::{closure#0}, !> 16: 0x7f01d9119b36 - std[f32b9bd0414b81da]::panicking::begin_panic:: 17: 0x7f01d9098e74 - ::bug:: 18: 0x7f01d9098c16 - ::bug:: 19: 0x7f01d91277c5 - rustc_middle[622728272c2e3e3b]::util::bug::opt_span_bug_fmt::::{closure#0} 20: 0x7f01d91243ea - rustc_middle[622728272c2e3e3b]::ty::context::tls::with_opt::::{closure#0}, !>::{closure#0} 21: 0x7f01d91243ba - rustc_middle[622728272c2e3e3b]::ty::context::tls::with_context_opt::::{closure#0}, !>::{closure#0}, !> 22: 0x7f01d6e664fd - rustc_middle[622728272c2e3e3b]::util::bug::bug_fmt 23: 0x7f01d7f9532d - rustc_hir_analysis[edf2ec8e9f871517]::collect::type_of::type_of 24: 0x7f01d6d15114 - rustc_query_impl[d998e27c23e50912]::plumbing::__rust_begin_short_backtrace::> 25: 0x7f01d6d14e70 - >::call_once 26: 0x7f01d6c1ffd5 - rustc_query_system[1ec15744c4bd462a]::query::plumbing::try_execute_query::>, false, false, false>, rustc_query_impl[d998e27c23e50912]::plumbing::QueryCtxt, false> 27: 0x7f01d851ea93 - rustc_query_impl[d998e27c23e50912]::query_impl::type_of::get_query_non_incr::__rust_end_short_backtrace 28: 0x55728eb91fd8 - rustc_middle[622728272c2e3e3b]::query::plumbing::query_get_at::>> 29: 0x55728eba887c - ::check_item 30: 0x7f01d8f4c863 - ::check_local 31: 0x7f01d8f3d007 - as rustc_hir[efa68a57dfc3b978]::intravisit::Visitor>::visit_nested_item 32: 0x7f01d8f14418 - rustc_hir[efa68a57dfc3b978]::intravisit::walk_mod::> 33: 0x7f01d8f3d012 - as rustc_hir[efa68a57dfc3b978]::intravisit::Visitor>::visit_nested_item 34: 0x7f01d8f14418 - rustc_hir[efa68a57dfc3b978]::intravisit::walk_mod::> 35: 0x7f01d821b61e - rustc_lint[53b2d595f425fb45]::late::late_lint_crate:: 36: 0x7f01d821aa98 - ::time::<(), rustc_lint[53b2d595f425fb45]::late::check_crate::{closure#0}::{closure#0}> 37: 0x7f01d802f923 - ::time::<(), rustc_interface[91e8f532f23dd0fa]::passes::analysis::{closure#5}::{closure#1}::{closure#2}::{closure#0}> 38: 0x7f01d802f49e - as core[87699bbb0bcd8c66]::ops::function::FnOnce<()>>::call_once 39: 0x7f01d802ef98 - ::time::<(), rustc_interface[91e8f532f23dd0fa]::passes::analysis::{closure#5}> 40: 0x7f01d802e70d - rustc_interface[91e8f532f23dd0fa]::passes::analysis 41: 0x7f01d80926da - rustc_query_impl[d998e27c23e50912]::plumbing::__rust_begin_short_backtrace::> 42: 0x7f01d80926c9 - >::call_once 43: 0x7f01d824a428 - rustc_query_system[1ec15744c4bd462a]::query::plumbing::try_execute_query::>, false, false, false>, rustc_query_impl[d998e27c23e50912]::plumbing::QueryCtxt, false> 44: 0x7f01d824a1f9 - rustc_query_impl[d998e27c23e50912]::query_impl::analysis::get_query_non_incr::__rust_end_short_backtrace 45: 0x7f01d821ebc5 - ::enter::> 46: 0x7f01d7dd5630 - ::enter::, rustc_span[9735a68f1ff93904]::ErrorGuaranteed>> 47: 0x7f01d7dd2c40 - std[f32b9bd0414b81da]::sys_common::backtrace::__rust_begin_short_backtrace::, rustc_driver_impl[99c4d2c9209ccfb0]::run_compiler::{closure#1}>::{closure#0}, core[87699bbb0bcd8c66]::result::Result<(), rustc_span[9735a68f1ff93904]::ErrorGuaranteed>>::{closure#0}::{closure#0}, core[87699bbb0bcd8c66]::result::Result<(), rustc_span[9735a68f1ff93904]::ErrorGuaranteed>> 48: 0x7f01d7dd23e5 - <::spawn_unchecked_, rustc_driver_impl[99c4d2c9209ccfb0]::run_compiler::{closure#1}>::{closure#0}, core[87699bbb0bcd8c66]::result::Result<(), rustc_span[9735a68f1ff93904]::ErrorGuaranteed>>::{closure#0}::{closure#0}, core[87699bbb0bcd8c66]::result::Result<(), rustc_span[9735a68f1ff93904]::ErrorGuaranteed>>::{closure#1} as core[87699bbb0bcd8c66]::ops::function::FnOnce<()>>::call_once::{shim:vtable#0} 49: 0x7f01d59772b5 - as core::ops::function::FnOnce>::call_once::h11bdbf737e1deec8 at /rustc/9eee230cd0a56bfba3ce65121798d9f9f4341cdd/library/alloc/src/boxed.rs:1985:9 50: 0x7f01d59772b5 - as core::ops::function::FnOnce>::call_once::hcf010e79019e090c at /rustc/9eee230cd0a56bfba3ce65121798d9f9f4341cdd/library/alloc/src/boxed.rs:1985:9 51: 0x7f01d59772b5 - std::sys::unix::thread::Thread::new::thread_start::h2506d9823e010db7 at /rustc/9eee230cd0a56bfba3ce65121798d9f9f4341cdd/library/std/src/sys/unix/thread.rs:108:17 52: 0x7f01d560abb5 - 53: 0x7f01d568cd90 - 54: 0x0 - note: we would appreciate a bug report: https://github.com/rust-lang/rust-clippy/issues/new note: rustc 1.72.0-nightly (9eee230cd 2023-06-04) running on x86_64-unknown-linux-gnu note: compiler flags: --crate-type lib -C opt-level=3 -C embed-bitcode=no -C codegen-units=16 -C debuginfo=2 -C overflow-checks=on -Z unstable-options -C target-cpu=native -C symbol-mangling-version=legacy -Z unstable-options -Z unstable-options -Z force-unstable-if-unmarked -Z macro-backtrace -C link-args=-Wl,-z,origin -C link-args=-Wl,-rpath,$ORIGIN/../lib -C split-debuginfo=off -C prefer-dynamic -Z inline-mir -C lto=off -Z crate-attr=doc(html_root_url="https://doc.rust-lang.org/nightly/") -Z binary-dep-depinfo note: some of the compiler flags provided by cargo are hidden query stack during panic: #0 [type_of] computing type of `ptr::::F` #1 [analysis] running analysis passes on this crate end of query stack note: Clippy version: clippy 0.1.72 (9eee230 2023-06-04) error: could not compile `core` (lib) Build completed unsuccessfully in 0:00:08 ```

blyxyas commented 1 year ago

Could you give more details? What's the command you used to build rustc with Clippy?

matthiaskrgr commented 1 year ago

You can check out the nightly commit on the rustc repo to make sure there are no incompatibilities

rustc --version --verbose =>

rustc 1.72.0-nightly (398fa2187 2023-06-03)
binary: rustc
commit-hash: 398fa2187c88de46c13c142f600064483a563c86     //// <=== use this
commit-date: 2023-06-03
host: x86_64-unknown-linux-gnu
release: 1.72.0-nightly
LLVM version: 16.0.4

in the rustc repo: git checkout 398fa2187c88de46c13c142f600064483a563c86

then x.py clippy which should reproduce the ICE

y21 commented 1 year ago

oops, this probably happens because of this blanket impl inside of core itself: https://doc.rust-lang.org/stable/std/fmt/trait.Debug.html#impl-Debug-for-F

the lint calls tcx.type_of() with the generic param F, and that ICEs here: https://github.com/rust-lang/rust/blob/e6d4725c76f3b526c74454bc51afdf6daf133506/compiler/rustc_hir_analysis/src/collect/type_of.rs#L489-L493

@rustbot claim