ICE: `body_owned_by: HirId ... has no associated body`
Opened this issue · 1 comments
cushionbadak commented
Code
#![feature(type_alias_impl_trait)]
pub type Opaque = impl std::future::Future;
trait Foo<const N: Opaque> {
fn do_x(&self) -> [Opaque; N];
}
struct Bar;
impl Foo<3> for Bar {
fn do_x(&self) -> [u8; 3] {
[0u8; 3]
}
}
fn main() {}A mutant of glacier2's fixed/131101.rs
I'm not sure which part of Opaque is important to trigger ICE.
Meta
rustc --version --verbose:
rustc 1.93.0-nightly (c90bcb957 2025-11-06)
binary: rustc
commit-hash: c90bcb9571b7aab0d8beaa2ce8a998ffaf079d38
commit-date: 2025-11-06
host: x86_64-apple-darwin
release: 1.93.0-nightly
LLVM version: 21.1.3
Error output
Command: rustc
error: `Opaque` is forbidden as the type of a const generic parameter
--> 04.rs:5:20
|
5 | trait Foo<const N: Opaque> {
| ^^^^^^
|
= note: the only supported types are integers, `bool`, and `char`
error[E0308]: mismatched types
--> 04.rs:11:10
|
3 | pub type Opaque = impl std::future::Future;
| ------------------------ the expected future
...
11 | impl Foo<3> for Bar {
| ^ expected future, found integer
|
= note: expected opaque type `Opaque`
found type `{integer}`
error: unconstrained opaque type
--> 04.rs:3:19
|
3 | pub type Opaque = impl std::future::Future;
| ^^^^^^^^^^^^^^^^^^^^^^^^
|
= note: `Opaque` must be used in combination with a concrete type within the same crate
error: internal compiler error: compiler/rustc_middle/src/hir/map.rs:271:13: body_owned_by: HirId(DefId(0:7 ~ 04[4c3e]::Foo::do_x).0) (trait method `do_x` in Foo::do_x) has no associated body
--> 04.rs:6:5
|
6 | fn do_x(&self) -> [Opaque; N];
| ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
thread 'rustc' (5789627) panicked at compiler/rustc_middle/src/hir/map.rs:271:13:
Box<dyn Any>
Backtrace
thread 'rustc' (5789627) panicked at compiler/rustc_middle/src/hir/map.rs:271:13:
Box<dyn Any>
stack backtrace:
0: std::panicking::begin_panic::<rustc_errors::ExplicitBug>
1: <rustc_errors::diagnostic::BugAbort as rustc_errors::diagnostic::EmissionGuarantee>::emit_producing_guarantee
2: <rustc_errors::DiagCtxtHandle>::span_bug::<rustc_span::span_encoding::Span, alloc::string::String>
3: rustc_middle::util::bug::opt_span_bug_fmt::<rustc_span::span_encoding::Span>::{closure#0}
4: rustc_middle::ty::context::tls::with_opt::<rustc_middle::util::bug::opt_span_bug_fmt<rustc_span::span_encoding::Span>::{closure#0}, !>::{closure#0}
5: rustc_middle::ty::context::tls::with_context_opt::<rustc_middle::ty::context::tls::with_opt<rustc_middle::util::bug::opt_span_bug_fmt<rustc_span::span_encoding::Span>::{closure#0}, !>::{closure#0}, !>
6: rustc_middle::util::bug::span_bug_fmt::<rustc_span::span_encoding::Span>
7: <rustc_middle::ty::context::TyCtxt>::hir_body_owned_by
8: rustc_ty_utils::opaque_types::opaque_types_defined_by
[... omitted 1 frame ...]
9: <rustc_trait_selection::error_reporting::TypeErrCtxt>::note_and_explain_type_err
10: <rustc_trait_selection::error_reporting::TypeErrCtxt>::note_type_err
11: <rustc_trait_selection::error_reporting::TypeErrCtxt>::report_selection_error
12: <rustc_trait_selection::error_reporting::TypeErrCtxt>::report_fulfillment_errors
13: rustc_hir_analysis::check::wfcheck::check_associated_item
14: rustc_hir_analysis::check::check::check_item_type
15: rustc_hir_analysis::check::wfcheck::check_well_formed
[... omitted 1 frame ...]
16: rustc_hir_analysis::check::wfcheck::check_type_wf
[... omitted 1 frame ...]
17: rustc_hir_analysis::check_crate
18: rustc_interface::passes::analysis
[... omitted 1 frame ...]
19: rustc_interface::passes::create_and_enter_global_ctxt::<core::option::Option<rustc_interface::queries::Linker>, rustc_driver_impl::run_compiler::{closure#0}::{closure#2}>
20: rustc_interface::interface::run_compiler::<(), rustc_driver_impl::run_compiler::{closure#0}>::{closure#1}
note: Some details are omitted, run with `RUST_BACKTRACE=full` for a verbose backtrace.
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 `/Users/jb/Library/CloudStorage/Dropbox/Desk/2503_rustc_ice/20251106 ice 보고용/rustc-ice-2025-11-07T05_02_09-64882.txt` to your bug report
query stack during panic:
#0 [opaque_types_defined_by] computing the opaque types defined by `Foo::do_x`
#1 [check_well_formed] checking that `Foo::do_x` is well-formed
#2 [check_type_wf] checking that types are well-formed
#3 [analysis] running analysis passes on crate `04`
end of query stack
error: aborting due to 4 previous errors
For more information about this error, try `rustc --explain E0308`.
Notes
-
ICE location:
compiler/rustc_middle/src/hir/map.rs Line-271
rust/compiler/rustc_middle/src/hir/map.rs
Lines 266 to 277 in c90bcb9
-
Duplication Check
- I searched for ICE issues with "body_owned_by", (Github issue page with query)
- issue-122552 is opened with identical ICE report, but none of the code in that issue cause ICE in current compiler version.
@rustbot label +F-type_alias_impl_trait
cushionbadak commented
cargo-bisect-rustc --start=2024-01-01 --end=2025-11-07 --regress ice --preserve --script rustc -- 148622.rs
********************************************************************************
Regression in nightly-2024-07-20
********************************************************************************
fetching https://static.rust-lang.org/dist/2024-07-19/channel-rust-nightly-git-commit-hash.txt
nightly manifest 2024-07-19: 40 B / 40 B [================================================================================================================================================] 100.00 % 720.91 KB/s converted 2024-07-19 to 5affbb17153bc69a9d5d8d2faa4e399a014a211e
fetching https://static.rust-lang.org/dist/2024-07-20/channel-rust-nightly-git-commit-hash.txt
nightly manifest 2024-07-20: 40 B / 40 B [================================================================================================================================================] 100.00 % 721.31 KB/s converted 2024-07-20 to 9057c3ffec44926d5e149dc13ff3ce1613b69cce
looking for regression commit between 2024-07-19 and 2024-07-20
fetching (via remote github) commits from max(5affbb17153bc69a9d5d8d2faa4e399a014a211e, 2024-07-17) to 9057c3ffec44926d5e149dc13ff3ce1613b69cce
ending github query because we found starting sha: 5affbb17153bc69a9d5d8d2faa4e399a014a211e
get_commits_between returning commits, len: 8
commit[0] 2024-07-18: Auto merge of #127924 - matthiaskrgr:rollup-1gn6afv, r=matthiaskrgr
commit[1] 2024-07-19: Auto merge of #127936 - matthiaskrgr:rollup-ci0eg7k, r=tgross35
commit[2] 2024-07-19: Auto merge of #125915 - camelid:const-arg-refactor, r=BoxyUwU
commit[3] 2024-07-19: Auto merge of #127956 - tgross35:rollup-8ten7pk, r=tgross35
commit[4] 2024-07-19: Auto merge of #127957 - matthiaskrgr:rollup-1u5ivck, r=matthiaskrgr
commit[5] 2024-07-19: Auto merge of #127969 - matthiaskrgr:rollup-nhxmwhn, r=matthiaskrgr
commit[6] 2024-07-19: Auto merge of #127982 - matthiaskrgr:rollup-nzyvphj, r=matthiaskrgr
commit[7] 2024-07-19: Auto merge of #127968 - fmease:upd-jsondocck-directive-style, r=GuillaumeGomez
ERROR: no CI builds available between 5affbb17153bc69a9d5d8d2faa4e399a014a211e and 9057c3ffec44926d5e149dc13ff3ce1613b69cce within last 167 days