rust-lang / rust

Empowering everyone to build reliable and efficient software.
https://www.rust-lang.org
Other
98.58k stars 12.74k forks source link

[Nightly ICE] double panic / DefIf does not have a "type_of" / method resolution should've emitted an error #129616

Open LunarLambda opened 2 months ago

LunarLambda commented 2 months ago

Code

fn main() {
    println!("{:?}", <md5::Md5 as md5::digest::OutputSizeUser>::OutputSize::USIZE);
}
[dependencies]
md-5 = "=0.10.6"

Meta

rustc --version --verbose:

rustc 1.82.0-nightly (c6db1ca3c 2024-08-25)
binary: rustc
commit-hash: c6db1ca3c93ad69692a4c4b5542f26fda4bf3aec
commit-date: 2024-08-25
host: x86_64-unknown-linux-gnu
release: 1.82.0-nightly
LLVM version: 19.1.0

Error output

thread 'rustc' panicked at compiler/rustc_metadata/src/rmeta/decoder/cstore_impl.rs:214:1:
DefId(22:34 ~ crypto_common[1bc4]::OutputSizeUser::OutputSize) does not have a "type_of"

[Backtrace output, see below]

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: please make sure that you have updated to the latest nightly

note: please attach the file at `/home/lambda/ice/rustc-ice-2024-08-26T15_33_42-3644.txt` to your bug report

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 [type_of] computing type of `crypto_common::OutputSizeUser::OutputSize`
#1 [typeck] type-checking `main`
end of query stack
note: no errors encountered even though delayed bugs were created

note: those delayed bugs will now be shown as internal compiler errors

error: internal compiler error: method resolution should've emitted an error
 --> src/main.rs:2:22
  |
2 |     println!("{:?}", <md5::Md5 as md5::digest::OutputSizeUser>::OutputSize::USIZE);
  |                      ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
  |
note: delayed at compiler/rustc_hir_typeck/src/fn_ctxt/_impl.rs:837:22 - disabled backtrace
 --> src/main.rs:2:22
  |
2 |     println!("{:?}", <md5::Md5 as md5::digest::OutputSizeUser>::OutputSize::USIZE);
  |                      ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^

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: please make sure that you have updated to the latest nightly

note: please attach the file at `/home/lambda/ice/rustc-ice-2024-08-26T15_33_42-3644.txt` to your bug report

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:
end of query stack
thread 'rustc' panicked at core/src/panicking.rs:229:5:
panic in a destructor during cleanup

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: please make sure that you have updated to the latest nightly

note: please attach the file at `/home/lambda/ice/rustc-ice-2024-08-26T15_33_42-3644.txt` to your bug report

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:
end of query stack
thread caused non-unwinding panic. aborting.
error: could not compile `ice` (bin "ice")

Caused by:
  process didn't exit successfully: `/home/lambda/.local/share/rustup/toolchains/nightly-x86_64-unknown-linux-gnu/bin/rustc --crate-name ice --edition=2021 src/main.rs --error-format=json --json=diagnostic-rendered-ansi,artifacts,future-incompat --diagnostic-width=157 --crate-type bin --emit=dep-info,link -C embed-bitcode=no -C debuginfo=2 --check-cfg 'cfg(docsrs)' --check-cfg 'cfg(feature, values())' -C metadata=9203647a68f5151c -C extra-filename=-9203647a68f5151c --out-dir /home/lambda/ice/target/debug/deps -C incremental=/home/lambda/ice/target/debug/incremental -L dependency=/home/lambda/ice/target/debug/deps --extern md5=/home/lambda/ice/target/debug/deps/libmd5-86a47fe7a9060491.rlib` (signal: 6, SIGABRT: process abort signal)
Backtrace

``` stack backtrace: 0: 0x7a298c3b327d - ::fmt::h08c68512b2311366 1: 0x7a298cc04c97 - core::fmt::write::h6e3f8345ff37039b 2: 0x7a298dba0e91 - std::io::Write::write_fmt::hc6823578ffc00004 3: 0x7a298c3b595b - std::panicking::default_hook::{{closure}}::hee63056ca50632bf 4: 0x7a298c3b55ce - std::panicking::default_hook::hf7cfdbe4468ff824 5: 0x7a298b52ee19 - std[bb0a3357faafffca]::panicking::update_hook::>::{closure#0} 6: 0x7a298c3b6277 - std::panicking::rust_panic_with_hook::hdfce2b8bd7fc4cbd 7: 0x7a298c3b5f37 - std::panicking::begin_panic_handler::{{closure}}::h1fea56f9bbc92609 8: 0x7a298c3b3739 - std::sys::backtrace::__rust_end_short_backtrace::h60ce9d111c920856 9: 0x7a298c3b5c04 - rust_begin_unwind 10: 0x7a298928fe93 - core::panicking::panic_fmt::hca2ff70b38236a4a 11: 0x7a298ba8dfa2 - rustc_metadata[ae979ed0731722c8]::rmeta::decoder::cstore_impl::provide_extern::type_of::{closure#2} 12: 0x7a298cc282f7 - rustc_query_impl[bd1d0c2d52a1173]::plumbing::__rust_begin_short_backtrace::> 13: 0x7a298d01d2a3 - rustc_query_system[cf6f668eb9b403cb]::query::plumbing::try_execute_query::>, false, false, false>, rustc_query_impl[bd1d0c2d52a1173]::plumbing::QueryCtxt, true> 14: 0x7a298d01ac9a - rustc_query_impl[bd1d0c2d52a1173]::query_impl::type_of::get_query_incr::__rust_end_short_backtrace 15: 0x7a298d362915 - rustc_middle[a76a08f9151f3d73]::query::plumbing::query_get_at::>> 16: 0x7a298b873ed3 - ::suggest_traits_to_import 17: 0x7a298b860fea - ::report_no_match_method_error 18: 0x7a298b89598a - ::report_method_error 19: 0x7a298d6f3688 - ::check_expr_path 20: 0x7a298d5f3398 - ::check_expr_with_expectation_and_args 21: 0x7a298d5f5ba7 - ::check_expr_with_expectation_and_args 22: 0x7a298982c28d - ::confirm_builtin_call 23: 0x7a298d5f4e68 - ::check_expr_with_expectation_and_args 24: 0x7a298d5f7997 - ::check_expr_with_expectation_and_args 25: 0x7a298d5f5ba7 - ::check_expr_with_expectation_and_args 26: 0x7a298982c28d - ::confirm_builtin_call 27: 0x7a298d5f4e68 - ::check_expr_with_expectation_and_args 28: 0x7a298982c28d - ::confirm_builtin_call 29: 0x7a298d5f4e68 - ::check_expr_with_expectation_and_args 30: 0x7a298d5ee0bd - ::check_block_with_expected 31: 0x7a298d5f5578 - ::check_expr_with_expectation_and_args 32: 0x7a298d5ee0bd - ::check_block_with_expected 33: 0x7a298d5f5578 - ::check_expr_with_expectation_and_args 34: 0x7a298ccd544c - rustc_hir_typeck[690d2b981901c23e]::check::check_fn 35: 0x7a298d183732 - rustc_hir_typeck[690d2b981901c23e]::typeck 36: 0x7a298d183175 - rustc_query_impl[bd1d0c2d52a1173]::plumbing::__rust_begin_short_backtrace::> 37: 0x7a298d17a18a - rustc_query_system[cf6f668eb9b403cb]::query::plumbing::try_execute_query::>, false, false, false>, rustc_query_impl[bd1d0c2d52a1173]::plumbing::QueryCtxt, true> 38: 0x7a298d019914 - rustc_query_impl[bd1d0c2d52a1173]::query_impl::typeck::get_query_incr::__rust_end_short_backtrace 39: 0x7a298d175f89 - ::par_body_owners::::{closure#0} 40: 0x7a298d173e32 - rustc_hir_analysis[dc85b8d661b4e95e]::check_crate 41: 0x7a298d1711ff - rustc_interface[af22c66eb3c80e7d]::passes::run_required_analyses 42: 0x7a298d768dde - rustc_interface[af22c66eb3c80e7d]::passes::analysis 43: 0x7a298d768db1 - rustc_query_impl[bd1d0c2d52a1173]::plumbing::__rust_begin_short_backtrace::> 44: 0x7a298dbdbb0d - rustc_query_system[cf6f668eb9b403cb]::query::plumbing::try_execute_query::>, false, false, false>, rustc_query_impl[bd1d0c2d52a1173]::plumbing::QueryCtxt, true> 45: 0x7a298dbdb7ba - rustc_query_impl[bd1d0c2d52a1173]::query_impl::analysis::get_query_incr::__rust_end_short_backtrace 46: 0x7a298d9d4d6a - rustc_interface[af22c66eb3c80e7d]::interface::run_compiler::, rustc_driver_impl[dbde3d5700ccbd28]::run_compiler::{closure#0}>::{closure#1} 47: 0x7a298da43310 - std[bb0a3357faafffca]::sys::backtrace::__rust_begin_short_backtrace::, rustc_driver_impl[dbde3d5700ccbd28]::run_compiler::{closure#0}>::{closure#1}, core[38f94b13edbf1545]::result::Result<(), rustc_span[b6fe7948518089fa]::ErrorGuaranteed>>::{closure#0}, core[38f94b13edbf1545]::result::Result<(), rustc_span[b6fe7948518089fa]::ErrorGuaranteed>>::{closure#0}::{closure#0}, core[38f94b13edbf1545]::result::Result<(), rustc_span[b6fe7948518089fa]::ErrorGuaranteed>> 48: 0x7a298da4397a - <::spawn_unchecked_, rustc_driver_impl[dbde3d5700ccbd28]::run_compiler::{closure#0}>::{closure#1}, core[38f94b13edbf1545]::result::Result<(), rustc_span[b6fe7948518089fa]::ErrorGuaranteed>>::{closure#0}, core[38f94b13edbf1545]::result::Result<(), rustc_span[b6fe7948518089fa]::ErrorGuaranteed>>::{closure#0}::{closure#0}, core[38f94b13edbf1545]::result::Result<(), rustc_span[b6fe7948518089fa]::ErrorGuaranteed>>::{closure#1} as core[38f94b13edbf1545]::ops::function::FnOnce<()>>::call_once::{shim:vtable#0} 49: 0x7a298da43ceb - std::sys::pal::unix::thread::Thread::new::thread_start::h5575404a57e52770 50: 0x7a298f0fd39d - 51: 0x7a298f18249c - 52: 0x0 - ```

rustc-ice-2024-08-26T15_33_42-3644.txt

jieyouxu commented 2 months ago

searched nightlies: from nightly-2024-06-07 to nightly-2024-08-26 regressed nightly: nightly-2024-08-18 searched commit range: https://github.com/rust-lang/rust/compare/506052d49d3903ea554e4ce760cc53610cff4ef5...feeba198f2c5455b31ca898c859385d5161f0bd8 regressed commit: https://github.com/rust-lang/rust/commit/9b318d2e93ce35e7ba32d8cfa96a1dbe63a7bed1

bisected with cargo-bisect-rustc v0.6.8 Host triple: aarch64-unknown-linux-gnu Reproduce with: ```bash cargo bisect-rustc --regress=ice ```
jieyouxu commented 2 months ago

128786 cc @estebank, bisection looks probably correct due to external crate def interactions

ambiso commented 2 months ago

I believe this is the line that's crashing?

At least it's the only type_of that occurs in that PR (that is related to the regressed commit).

compiler-errors commented 2 months ago

Should be fixed by #https://github.com/rust-lang/rust/pull/129250