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

ICE: body_owned_by: HirId(DefId...) (trait method 'line_stream' in X::line_stream) has no associated body #122552

Open
matthiaskrgr opened this issue Mar 15, 2024 · 1 comment
Labels
A-hir Area: The high-level intermediate representation (HIR) C-bug Category: This is a bug. I-ICE Issue: The compiler panicked, giving an Internal Compilation Error (ICE) ❄️ S-bug-has-test Status: This bug is tracked inside the repo by a `known-bug` test. S-has-mcve Status: A Minimal Complete and Verifiable Example has been found for this issue T-compiler Relevant to the compiler team, which will review and decide on the PR/issue.

Comments

@matthiaskrgr
Copy link
Member

matthiaskrgr commented Mar 15, 2024

auto-reduced (treereduce-rust):

trait X {
    fn line_stream<'a, Repr>() -> Self::LineStreamFut<{ async {} }, Repr>;
}

struct Y;

original (from tests/ui/generic-associated-types/issue-89008.rs)

//@ check-pass
//@ edition:2021

#![feature(impl_trait_in_assoc_type)]

use std::future::Future;
use std::marker::PhantomData;

trait Stream {
    type Item;
}

struct Empty<T> {
    _phantom: PhantomData<T>,
}

impl<T> Stream for Empty<T> {
    type Y = T;
}

trait X {
    type LineStream<'a, Item>: Future<Output = Self::LineStream<'a, Repr>> where Self: 'a;
    type LineStreamFut<'a, Repr>: Future<Output = Self::LineStream<'a, Repr>> where Self: 'a;
    fn line_stream<'a, Repr>(&'Future self) -> Self::LineStreamFut<{
        async { Empty { _phantom: PhantomData } }
    }, Repr>;
}

struct Y;

impl X for Y {
    type LineStream<'a, Repr> = impl Stream<Item = Repr>;
    type LineStreamFut<'a, Repr> = impl Future<Output = Self::LineStreamFut<'a, Repr>>;
    fn line_stream<'a, Repr>(&'a self) -> Self::LineStreamFut<'Future, Repr> {
        async { Empty { _phantom: PhantomData } }
    }
}

fn main() {}

Version information

rustc 1.78.0-nightly (d7723b219 2024-03-15)
binary: rustc
commit-hash: d7723b21910075a3c38c2b6e64b2467394c93724
commit-date: 2024-03-15
host: x86_64-unknown-linux-gnu
release: 1.78.0-nightly
LLVM version: 18.1.0

Command:
/home/matthias/.rustup/toolchains/master/bin/rustc --edition=2021

Program output

error[E0601]: `main` function not found in crate `mvce`
 --> /tmp/icemaker_global_tempdir.Jnafaa1kOqV9/rustc_testrunner_tmpdir_reporting.3Nd0rNs4h03z/mvce.rs:5:10
  |
5 | struct Y;
  |          ^ consider adding a `main` function to `/tmp/icemaker_global_tempdir.Jnafaa1kOqV9/rustc_testrunner_tmpdir_reporting.3Nd0rNs4h03z/mvce.rs`

error[E0220]: associated type `LineStreamFut` not found for `Self`
 --> /tmp/icemaker_global_tempdir.Jnafaa1kOqV9/rustc_testrunner_tmpdir_reporting.3Nd0rNs4h03z/mvce.rs:2:41
  |
2 |     fn line_stream<'a, Repr>() -> Self::LineStreamFut<{ async {} }, Repr>;
  |                                         ^^^^^^^^^^^^^ associated type `LineStreamFut` not found

error: internal compiler error: compiler/rustc_middle/src/hir/map/mod.rs:317:13: body_owned_by: HirId(DefId(0:4 ~ mvce[4ebf]::X::line_stream).0) (trait method `line_stream` in X::line_stream) has no associated body
 --> /tmp/icemaker_global_tempdir.Jnafaa1kOqV9/rustc_testrunner_tmpdir_reporting.3Nd0rNs4h03z/mvce.rs:2:5
  |
2 |     fn line_stream<'a, Repr>() -> Self::LineStreamFut<{ async {} }, Repr>;
  |     ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^

thread 'rustc' panicked at compiler/rustc_middle/src/util/bug.rs:34:50:
Box<dyn Any>
stack backtrace:
   0:     0x7f8227f8c912 - std::backtrace_rs::backtrace::libunwind::trace::h2da6c6ec1776ed1b
                               at /rustc/d7723b21910075a3c38c2b6e64b2467394c93724/library/std/src/../../backtrace/src/backtrace/libunwind.rs:105:5
   1:     0x7f8227f8c912 - std::backtrace_rs::backtrace::trace_unsynchronized::h0cb696e9cf0107ba
                               at /rustc/d7723b21910075a3c38c2b6e64b2467394c93724/library/std/src/../../backtrace/src/backtrace/mod.rs:66:5
   2:     0x7f8227f8c912 - std::sys_common::backtrace::_print_fmt::hfb11ed7a7d38a028
                               at /rustc/d7723b21910075a3c38c2b6e64b2467394c93724/library/std/src/sys_common/backtrace.rs:68:5
   3:     0x7f8227f8c912 - <std::sys_common::backtrace::_print::DisplayBacktrace as core::fmt::Display>::fmt::h1048d052a888b26c
                               at /rustc/d7723b21910075a3c38c2b6e64b2467394c93724/library/std/src/sys_common/backtrace.rs:44:22
   4:     0x7f8227fddc8c - core::fmt::rt::Argument::fmt::hcf8265a03a389e34
                               at /rustc/d7723b21910075a3c38c2b6e64b2467394c93724/library/core/src/fmt/rt.rs:142:9
   5:     0x7f8227fddc8c - core::fmt::write::hd12c3a84e62e1cec
                               at /rustc/d7723b21910075a3c38c2b6e64b2467394c93724/library/core/src/fmt/mod.rs:1153:17
   6:     0x7f8227f8180f - std::io::Write::write_fmt::h236993be0d5d91de
                               at /rustc/d7723b21910075a3c38c2b6e64b2467394c93724/library/std/src/io/mod.rs:1843:15
   7:     0x7f8227f8c6e4 - std::sys_common::backtrace::_print::he44e9b7b149d34c3
                               at /rustc/d7723b21910075a3c38c2b6e64b2467394c93724/library/std/src/sys_common/backtrace.rs:47:5
   8:     0x7f8227f8c6e4 - std::sys_common::backtrace::print::h6f8e8e3b9f052551
                               at /rustc/d7723b21910075a3c38c2b6e64b2467394c93724/library/std/src/sys_common/backtrace.rs:34:9
   9:     0x7f8227f8f3eb - std::panicking::default_hook::{{closure}}::h321d04c9179dccca
  10:     0x7f8227f8f143 - std::panicking::default_hook::hd949d1362c2e5565
                               at /rustc/d7723b21910075a3c38c2b6e64b2467394c93724/library/std/src/panicking.rs:292:9
  11:     0x7f822afa68ef - std[8d86c5c35c0bd7fb]::panicking::update_hook::<alloc[b74d3dbad420fbd6]::boxed::Box<rustc_driver_impl[724f095572d73222]::install_ice_hook::{closure#0}>>::{closure#0}
  12:     0x7f8227f8fb50 - <alloc::boxed::Box<F,A> as core::ops::function::Fn<Args>>::call::h4f6c988be7bdee68
                               at /rustc/d7723b21910075a3c38c2b6e64b2467394c93724/library/alloc/src/boxed.rs:2034:9
  13:     0x7f8227f8fb50 - std::panicking::rust_panic_with_hook::hb71de646be3b3469
                               at /rustc/d7723b21910075a3c38c2b6e64b2467394c93724/library/std/src/panicking.rs:783:13
  14:     0x7f822afd2f64 - std[8d86c5c35c0bd7fb]::panicking::begin_panic::<rustc_errors[5a36eb2cca520bb2]::ExplicitBug>::{closure#0}
  15:     0x7f822afcfa06 - std[8d86c5c35c0bd7fb]::sys_common::backtrace::__rust_end_short_backtrace::<std[8d86c5c35c0bd7fb]::panicking::begin_panic<rustc_errors[5a36eb2cca520bb2]::ExplicitBug>::{closure#0}, !>
  16:     0x7f822afcaee6 - std[8d86c5c35c0bd7fb]::panicking::begin_panic::<rustc_errors[5a36eb2cca520bb2]::ExplicitBug>
  17:     0x7f822afdc221 - <rustc_errors[5a36eb2cca520bb2]::diagnostic::BugAbort as rustc_errors[5a36eb2cca520bb2]::diagnostic::EmissionGuarantee>::emit_producing_guarantee
  18:     0x7f822b3ba91f - <rustc_errors[5a36eb2cca520bb2]::DiagCtxt>::span_bug::<rustc_span[6c3fee00dc2a924e]::span_encoding::Span, alloc[b74d3dbad420fbd6]::string::String>
  19:     0x7f822b45f97d - rustc_middle[35d2191f4cbfc53b]::util::bug::opt_span_bug_fmt::<rustc_span[6c3fee00dc2a924e]::span_encoding::Span>::{closure#0}
  20:     0x7f822b44350a - rustc_middle[35d2191f4cbfc53b]::ty::context::tls::with_opt::<rustc_middle[35d2191f4cbfc53b]::util::bug::opt_span_bug_fmt<rustc_span[6c3fee00dc2a924e]::span_encoding::Span>::{closure#0}, !>::{closure#0}
  21:     0x7f822b4433a8 - rustc_middle[35d2191f4cbfc53b]::ty::context::tls::with_context_opt::<rustc_middle[35d2191f4cbfc53b]::ty::context::tls::with_opt<rustc_middle[35d2191f4cbfc53b]::util::bug::opt_span_bug_fmt<rustc_span[6c3fee00dc2a924e]::span_encoding::Span>::{closure#0}, !>::{closure#0}, !>
  22:     0x7f822b45f8c4 - rustc_middle[35d2191f4cbfc53b]::util::bug::span_bug_fmt::<rustc_span[6c3fee00dc2a924e]::span_encoding::Span>
  23:     0x7f822c6ca89d - rustc_ty_utils[9405cf9b2d0254d8]::opaque_types::opaque_types_defined_by
  24:     0x7f822c6c8ab5 - rustc_query_impl[5406894609d381a6]::plumbing::__rust_begin_short_backtrace::<rustc_query_impl[5406894609d381a6]::query_impl::opaque_types_defined_by::dynamic_query::{closure#2}::{closure#0}, rustc_middle[35d2191f4cbfc53b]::query::erase::Erased<[u8; 8usize]>>
  25:     0x7f822c40ff2e - rustc_query_system[40cbee46219fc421]::query::plumbing::try_execute_query::<rustc_query_impl[5406894609d381a6]::DynamicConfig<rustc_query_system[40cbee46219fc421]::query::caches::VecCache<rustc_span[6c3fee00dc2a924e]::def_id::LocalDefId, rustc_middle[35d2191f4cbfc53b]::query::erase::Erased<[u8; 8usize]>>, false, false, false>, rustc_query_impl[5406894609d381a6]::plumbing::QueryCtxt, false>
  26:     0x7f822d010510 - rustc_query_impl[5406894609d381a6]::query_impl::opaque_types_defined_by::get_query_non_incr::__rust_end_short_backtrace
  27:     0x7f822d0105e4 - <rustc_middle[35d2191f4cbfc53b]::traits::DefiningAnchor>::bind
  28:     0x7f822b0b6d07 - rustc_hir_analysis[c56ac84798d79461]::check::check::check_coroutine_obligations
  29:     0x7f822b7d44e7 - rustc_query_impl[5406894609d381a6]::plumbing::__rust_begin_short_backtrace::<rustc_query_impl[5406894609d381a6]::query_impl::check_coroutine_obligations::dynamic_query::{closure#2}::{closure#0}, rustc_middle[35d2191f4cbfc53b]::query::erase::Erased<[u8; 1usize]>>
  30:     0x7f822c604db2 - rustc_query_system[40cbee46219fc421]::query::plumbing::try_execute_query::<rustc_query_impl[5406894609d381a6]::DynamicConfig<rustc_query_system[40cbee46219fc421]::query::caches::VecCache<rustc_span[6c3fee00dc2a924e]::def_id::LocalDefId, rustc_middle[35d2191f4cbfc53b]::query::erase::Erased<[u8; 1usize]>>, false, false, false>, rustc_query_impl[5406894609d381a6]::plumbing::QueryCtxt, false>
  31:     0x7f822b7d93c1 - rustc_query_impl[5406894609d381a6]::query_impl::check_coroutine_obligations::get_query_non_incr::__rust_end_short_backtrace
  32:     0x7f822c999f17 - rustc_interface[62605c20d0dc0fef]::passes::analysis
  33:     0x7f822c998425 - rustc_query_impl[5406894609d381a6]::plumbing::__rust_begin_short_backtrace::<rustc_query_impl[5406894609d381a6]::query_impl::analysis::dynamic_query::{closure#2}::{closure#0}, rustc_middle[35d2191f4cbfc53b]::query::erase::Erased<[u8; 1usize]>>
  34:     0x7f822d006165 - rustc_query_system[40cbee46219fc421]::query::plumbing::try_execute_query::<rustc_query_impl[5406894609d381a6]::DynamicConfig<rustc_query_system[40cbee46219fc421]::query::caches::SingleCache<rustc_middle[35d2191f4cbfc53b]::query::erase::Erased<[u8; 1usize]>>, false, false, false>, rustc_query_impl[5406894609d381a6]::plumbing::QueryCtxt, false>
  35:     0x7f822d005ec9 - rustc_query_impl[5406894609d381a6]::query_impl::analysis::get_query_non_incr::__rust_end_short_backtrace
  36:     0x7f822cd5e284 - rustc_interface[62605c20d0dc0fef]::interface::run_compiler::<core[d25ee0c10dd6dc91]::result::Result<(), rustc_span[6c3fee00dc2a924e]::ErrorGuaranteed>, rustc_driver_impl[724f095572d73222]::run_compiler::{closure#0}>::{closure#0}
  37:     0x7f822d223805 - std[8d86c5c35c0bd7fb]::sys_common::backtrace::__rust_begin_short_backtrace::<rustc_interface[62605c20d0dc0fef]::util::run_in_thread_with_globals<rustc_interface[62605c20d0dc0fef]::util::run_in_thread_pool_with_globals<rustc_interface[62605c20d0dc0fef]::interface::run_compiler<core[d25ee0c10dd6dc91]::result::Result<(), rustc_span[6c3fee00dc2a924e]::ErrorGuaranteed>, rustc_driver_impl[724f095572d73222]::run_compiler::{closure#0}>::{closure#0}, core[d25ee0c10dd6dc91]::result::Result<(), rustc_span[6c3fee00dc2a924e]::ErrorGuaranteed>>::{closure#0}, core[d25ee0c10dd6dc91]::result::Result<(), rustc_span[6c3fee00dc2a924e]::ErrorGuaranteed>>::{closure#0}::{closure#0}, core[d25ee0c10dd6dc91]::result::Result<(), rustc_span[6c3fee00dc2a924e]::ErrorGuaranteed>>
  38:     0x7f822d223632 - <<std[8d86c5c35c0bd7fb]::thread::Builder>::spawn_unchecked_<rustc_interface[62605c20d0dc0fef]::util::run_in_thread_with_globals<rustc_interface[62605c20d0dc0fef]::util::run_in_thread_pool_with_globals<rustc_interface[62605c20d0dc0fef]::interface::run_compiler<core[d25ee0c10dd6dc91]::result::Result<(), rustc_span[6c3fee00dc2a924e]::ErrorGuaranteed>, rustc_driver_impl[724f095572d73222]::run_compiler::{closure#0}>::{closure#0}, core[d25ee0c10dd6dc91]::result::Result<(), rustc_span[6c3fee00dc2a924e]::ErrorGuaranteed>>::{closure#0}, core[d25ee0c10dd6dc91]::result::Result<(), rustc_span[6c3fee00dc2a924e]::ErrorGuaranteed>>::{closure#0}::{closure#0}, core[d25ee0c10dd6dc91]::result::Result<(), rustc_span[6c3fee00dc2a924e]::ErrorGuaranteed>>::{closure#1} as core[d25ee0c10dd6dc91]::ops::function::FnOnce<()>>::call_once::{shim:vtable#0}
  39:     0x7f8227f991e5 - <alloc::boxed::Box<F,A> as core::ops::function::FnOnce<Args>>::call_once::hab5d072bb143d8fe
                               at /rustc/d7723b21910075a3c38c2b6e64b2467394c93724/library/alloc/src/boxed.rs:2020:9
  40:     0x7f8227f991e5 - <alloc::boxed::Box<F,A> as core::ops::function::FnOnce<Args>>::call_once::he1f566ad483a8fda
                               at /rustc/d7723b21910075a3c38c2b6e64b2467394c93724/library/alloc/src/boxed.rs:2020:9
  41:     0x7f8227f991e5 - std::sys::pal::unix::thread::Thread::new::thread_start::h23d47a8da771b95c
                               at /rustc/d7723b21910075a3c38c2b6e64b2467394c93724/library/std/src/sys/pal/unix/thread.rs:108:17
  42:     0x7f8227d8155a - <unknown>
  43:     0x7f8227dfea3c - <unknown>
  44:                0x0 - <unknown>

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.78.0-nightly (d7723b219 2024-03-15) running on x86_64-unknown-linux-gnu

note: compiler flags: -Z dump-mir-dir=dir

query stack during panic:
#0 [opaque_types_defined_by] computing the opaque types defined by `X::line_stream`
#1 [check_coroutine_obligations] verify auto trait bounds for coroutine interior type `X::line_stream::{constant#0}::{closure#0}`
#2 [analysis] running analysis passes on this crate
end of query stack
error: aborting due to 3 previous errors

Some errors have detailed explanations: E0220, E0601.
For more information about an error, try `rustc --explain E0220`.

@matthiaskrgr matthiaskrgr added 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. C-bug Category: This is a bug. labels Mar 15, 2024
@rustbot rustbot added the needs-triage This issue may need triage. Remove it if it has been sufficiently triaged. label Mar 15, 2024
@matthiaskrgr
Copy link
Member Author

#121796 cc @oli-obk

@jieyouxu jieyouxu added S-has-mcve Status: A Minimal Complete and Verifiable Example has been found for this issue A-hir Area: The high-level intermediate representation (HIR) and removed needs-triage This issue may need triage. Remove it if it has been sufficiently triaged. labels Mar 15, 2024
@matthiaskrgr matthiaskrgr added the S-bug-has-test Status: This bug is tracked inside the repo by a `known-bug` test. label Apr 15, 2024
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
A-hir Area: The high-level intermediate representation (HIR) C-bug Category: This is a bug. I-ICE Issue: The compiler panicked, giving an Internal Compilation Error (ICE) ❄️ S-bug-has-test Status: This bug is tracked inside the repo by a `known-bug` test. S-has-mcve Status: A Minimal Complete and Verifiable Example has been found for this issue T-compiler Relevant to the compiler team, which will review and decide on the PR/issue.
Projects
None yet
Development

No branches or pull requests

3 participants