rust-lang / rust

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

ICE: `body_owned_by: ... has no associated body` #110157

Closed matthiaskrgr closed 1 year ago

matthiaskrgr commented 1 year ago

Code

type NeedsDropResult<T> = Result<T, ()>;

struct NeedsDropTypes<'tcx, F> {}

impl<'tcx, F, I> Iterator for NeedsDropTypes<'tcx, F>
where
    F: Fn(&ty::AdtDef) -> NeedsDropResult<I>,
    I: Iterator<Item = Ty<'tcx>>,
{}

Meta

rustc --version --verbose:

rustc 1.70.0-nightly (696aaad58 2023-04-09)
binary: rustc
commit-hash: 696aaad58c57a589f6fb2ecff5bae2eec581cb71
commit-date: 2023-04-09
host: x86_64-unknown-linux-gnu
release: 1.70.0-nightly
LLVM version: 16.0.2

Error output

error[E0433]: failed to resolve: use of undeclared crate or module `ty`
 --> treereduce.out:8:12
  |
8 |     F: Fn(&ty::AdtDef) -> NeedsDropResult<I>,
  |            ^^ use of undeclared crate or module `ty`

error[E0412]: cannot find type `Ty` in this scope
 --> treereduce.out:9:24
  |
9 |     I: Iterator<Item = Ty<'tcx>>,
  |                        ^^ not found in this scope

error[E0601]: `main` function not found in crate `treereduce`
  --> treereduce.out:10:3
   |
10 | {}
   |   ^ consider adding a `main` function to `treereduce.out`

error[E0392]: parameter `'tcx` is never used
 --> treereduce.out:3:23
  |
3 | struct NeedsDropTypes<'tcx, F> {}
  |                       ^^^^ unused parameter
  |
  = help: consider removing `'tcx`, referring to it in a field, or using a marker such as `PhantomData`

error[E0392]: parameter `F` is never used
 --> treereduce.out:3:29
  |
3 | struct NeedsDropTypes<'tcx, F> {}
  |                             ^ unused parameter
  |
  = help: consider removing `F`, referring to it in a field, or using a marker such as `PhantomData`
  = help: if you intended `F` to be a const parameter, use `const F: usize` instead

error: internal compiler error: compiler/rustc_middle/src/hir/map/mod.rs:425:13: body_owned_by: HirId(DefId(0:8 ~ treereduce[55e2]::{impl#0}).0) (impl <NeedsDropTypes<'tcx, F> as Iterator>) has no associated body
 --> treereduce.out:6:1
  |
6 | impl<'tcx, F, I> Iterator for NeedsDropTypes<'tcx, F>
  | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
Backtrace

``` thread 'rustc' panicked at 'Box', /rustc/696aaad58c57a589f6fb2ecff5bae2eec581cb71/compiler/rustc_errors/src/lib.rs:995:33 stack backtrace: 0: 0x7fbcc8c7bf0a - std::backtrace_rs::backtrace::libunwind::trace::hd26deac9c5400510 at /rustc/696aaad58c57a589f6fb2ecff5bae2eec581cb71/library/std/src/../../backtrace/src/backtrace/libunwind.rs:93:5 1: 0x7fbcc8c7bf0a - std::backtrace_rs::backtrace::trace_unsynchronized::h0d525c5df19c5fb3 at /rustc/696aaad58c57a589f6fb2ecff5bae2eec581cb71/library/std/src/../../backtrace/src/backtrace/mod.rs:66:5 2: 0x7fbcc8c7bf0a - std::sys_common::backtrace::_print_fmt::hfa46a4e5b1417412 at /rustc/696aaad58c57a589f6fb2ecff5bae2eec581cb71/library/std/src/sys_common/backtrace.rs:65:5 3: 0x7fbcc8c7bf0a - ::fmt::hd35deac25c2a2361 at /rustc/696aaad58c57a589f6fb2ecff5bae2eec581cb71/library/std/src/sys_common/backtrace.rs:44:22 4: 0x7fbcc8cdffcf - core::fmt::write::h57692caee39fe498 at /rustc/696aaad58c57a589f6fb2ecff5bae2eec581cb71/library/core/src/fmt/mod.rs:1254:17 5: 0x7fbcc8c6ea45 - std::io::Write::write_fmt::h3cf8ad4e45a4d8c5 at /rustc/696aaad58c57a589f6fb2ecff5bae2eec581cb71/library/std/src/io/mod.rs:1698:15 6: 0x7fbcc8c7bcd5 - std::sys_common::backtrace::_print::hdf25b99ab69d47c1 at /rustc/696aaad58c57a589f6fb2ecff5bae2eec581cb71/library/std/src/sys_common/backtrace.rs:47:5 7: 0x7fbcc8c7bcd5 - std::sys_common::backtrace::print::hf7d8e454ceffbfe6 at /rustc/696aaad58c57a589f6fb2ecff5bae2eec581cb71/library/std/src/sys_common/backtrace.rs:34:9 8: 0x7fbcc8c7e97e - std::panicking::default_hook::{{closure}}::hd867f5f971a369e7 at /rustc/696aaad58c57a589f6fb2ecff5bae2eec581cb71/library/std/src/panicking.rs:269:22 9: 0x7fbcc8c7e725 - std::panicking::default_hook::habf6eee7b304b436 at /rustc/696aaad58c57a589f6fb2ecff5bae2eec581cb71/library/std/src/panicking.rs:288:9 10: 0x7fbcc7a55665 - rustc_driver_impl[2d97b4318b2b8966]::DEFAULT_HOOK::{closure#0}::{closure#0} 11: 0x7fbcc8c7f174 - as core::ops::function::Fn>::call::h0aac6d981c9df2cb at /rustc/696aaad58c57a589f6fb2ecff5bae2eec581cb71/library/alloc/src/boxed.rs:1990:9 12: 0x7fbcc8c7f174 - std::panicking::rust_panic_with_hook::h0ae6f6705c097c51 at /rustc/696aaad58c57a589f6fb2ecff5bae2eec581cb71/library/std/src/panicking.rs:694:13 13: 0x7fbcc7f75371 - std[3958f564ddc007dc]::panicking::begin_panic::::{closure#0} 14: 0x7fbcc7f74d16 - std[3958f564ddc007dc]::sys_common::backtrace::__rust_end_short_backtrace::::{closure#0}, !> 15: 0x7fbcc7fa5d46 - std[3958f564ddc007dc]::panicking::begin_panic:: 16: 0x7fbcc80008d2 - ::span_bug:: 17: 0x7fbcc80006f7 - ::span_bug:: 18: 0x7fbcc7fc663b - rustc_middle[9ae9af9eb73fc3b1]::util::bug::opt_span_bug_fmt::::{closure#0} 19: 0x7fbcc7fc31ba - rustc_middle[9ae9af9eb73fc3b1]::ty::context::tls::with_opt::::{closure#0}, !>::{closure#0} 20: 0x7fbcc7fc3186 - rustc_middle[9ae9af9eb73fc3b1]::ty::context::tls::with_context_opt::::{closure#0}, !>::{closure#0}, !> 21: 0x7fbcc7fc6576 - rustc_middle[9ae9af9eb73fc3b1]::util::bug::opt_span_bug_fmt:: 22: 0x7fbcc63bbae4 - rustc_middle[9ae9af9eb73fc3b1]::util::bug::span_bug_fmt:: 23: 0x7fbcc63b964e - ::body_owned_by 24: 0x7fbcc8738eb2 - ::maybe_report_ambiguity 25: 0x7fbcc872c05b - ::report_fulfillment_errors 26: 0x7fbcc67dbbee - rustc_hir_analysis[2fa568bcc53e911e]::check::wfcheck::check_well_formed 27: 0x7fbcc5f749ce - rustc_query_system[f15f440fadbc0dc2]::query::plumbing::try_execute_query:: 28: 0x7fbcc6c9fe57 - rustc_data_structures[6c5f262034998aae]::sync::par_for_each_in::<&[rustc_hir[1fa94aaa058a1f1a]::hir::ImplItemId], ::par_impl_items::{closure#0}> 29: 0x7fbcc6c9f914 - rustc_hir_analysis[2fa568bcc53e911e]::check::wfcheck::check_mod_type_wf 30: 0x7fbcc707d231 - rustc_query_system[f15f440fadbc0dc2]::query::plumbing::try_execute_query:: 31: 0x7fbcc707cdd9 - ::check_mod_type_wf 32: 0x7fbcc6f25c37 - rustc_data_structures[6c5f262034998aae]::sync::par_for_each_in::<&[rustc_hir[1fa94aaa058a1f1a]::hir_id::OwnerId], ::par_for_each_module::{closure#0}> 33: 0x7fbcc6f259f0 - ::track_errors:: 34: 0x7fbcc6f2301f - rustc_hir_analysis[2fa568bcc53e911e]::check_crate 35: 0x7fbcc6f1d4a1 - rustc_interface[5859b4daf695f246]::passes::analysis 36: 0x7fbcc71a50c2 - rustc_query_system[f15f440fadbc0dc2]::query::plumbing::try_execute_query:: 37: 0x7fbcc71a4dd0 - ::analysis 38: 0x7fbcc70d6db6 - >>::with::::enter>::{closure#0}, core[df85f84a2bdb4263]::result::Result<(), rustc_span[24111c70308d7d50]::ErrorGuaranteed>>::{closure#0}, core[df85f84a2bdb4263]::result::Result<(), rustc_span[24111c70308d7d50]::ErrorGuaranteed>> 39: 0x7fbcc6ce27ef - ::enter::, rustc_span[24111c70308d7d50]::ErrorGuaranteed>> 40: 0x7fbcc6cdda41 - rustc_span[24111c70308d7d50]::set_source_map::, rustc_interface[5859b4daf695f246]::interface::run_compiler, rustc_driver_impl[2d97b4318b2b8966]::run_compiler::{closure#1}>::{closure#0}::{closure#0}> 41: 0x7fbcc6cdd586 - >::set::, rustc_driver_impl[2d97b4318b2b8966]::run_compiler::{closure#1}>::{closure#0}, core[df85f84a2bdb4263]::result::Result<(), rustc_span[24111c70308d7d50]::ErrorGuaranteed>> 42: 0x7fbcc6cdcc5b - std[3958f564ddc007dc]::sys_common::backtrace::__rust_begin_short_backtrace::, rustc_driver_impl[2d97b4318b2b8966]::run_compiler::{closure#1}>::{closure#0}, core[df85f84a2bdb4263]::result::Result<(), rustc_span[24111c70308d7d50]::ErrorGuaranteed>>::{closure#0}::{closure#0}, core[df85f84a2bdb4263]::result::Result<(), rustc_span[24111c70308d7d50]::ErrorGuaranteed>> 43: 0x7fbcc7320db1 - <::spawn_unchecked_, rustc_driver_impl[2d97b4318b2b8966]::run_compiler::{closure#1}>::{closure#0}, core[df85f84a2bdb4263]::result::Result<(), rustc_span[24111c70308d7d50]::ErrorGuaranteed>>::{closure#0}::{closure#0}, core[df85f84a2bdb4263]::result::Result<(), rustc_span[24111c70308d7d50]::ErrorGuaranteed>>::{closure#1} as core[df85f84a2bdb4263]::ops::function::FnOnce<()>>::call_once::{shim:vtable#0} 44: 0x7fbcc8c89255 - as core::ops::function::FnOnce>::call_once::h40268ec1e3f75121 at /rustc/696aaad58c57a589f6fb2ecff5bae2eec581cb71/library/alloc/src/boxed.rs:1976:9 45: 0x7fbcc8c89255 - as core::ops::function::FnOnce>::call_once::hb4cdee1772a16528 at /rustc/696aaad58c57a589f6fb2ecff5bae2eec581cb71/library/alloc/src/boxed.rs:1976:9 46: 0x7fbcc8c89255 - std::sys::unix::thread::Thread::new::thread_start::h71a921bd46112f49 at /rustc/696aaad58c57a589f6fb2ecff5bae2eec581cb71/library/std/src/sys/unix/thread.rs:108:17 47: 0x7fbcc465cbb5 - 48: 0x7fbcc46ded90 - 49: 0x0 - 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.70.0-nightly (696aaad58 2023-04-09) running on x86_64-unknown-linux-gnu query stack during panic: #0 [check_well_formed] checking that `` is well-formed #1 [check_mod_type_wf] checking that types are well-formed in top-level module #2 [analysis] running analysis passes on this crate end of query stack error: aborting due to 6 previous errors Some errors have detailed explanations: E0392, E0412, E0433, E0601. For more information about an error, try `rustc --explain E0392`. ```

Ezrashaw commented 1 year ago

Suspect #108879 Correction: #108960 (fd34549686d7640f3e21d079bd0e6fb71cb06e3d) (cc @compiler-errors). I'd like to work on this but I'm not sure I'll be able to figure it out.


searched nightlies: from nightly-2022-06-01 to nightly-2023-04-11 regressed nightly: nightly-2023-03-11 searched commit range: https://github.com/rust-lang/rust/compare/39f2657d1101b50f9b71ae460b762d330cc8426b...ff4b772f805ec1e1c1bd7e189ab8d5a4e3a6ef13 regressed commit: https://github.com/rust-lang/rust/commit/35a0961bbc8fba75bb863c7835b39d431ad9fc5d

bisected with cargo-bisect-rustc v0.6.6 Host triple: x86_64-unknown-linux-gnu Reproduce with: ```bash cargo bisect-rustc --regress=ice --start=2022-06-01 ```