-
Notifications
You must be signed in to change notification settings - Fork 14k
Open
Labels
C-bugCategory: This is a bug.Category: This is a bug.F-type_alias_impl_trait`#[feature(type_alias_impl_trait)]``#[feature(type_alias_impl_trait)]`I-ICEIssue: The compiler panicked, giving an Internal Compilation Error (ICE) ❄️Issue: The compiler panicked, giving an Internal Compilation Error (ICE) ❄️P-lowLow priorityLow priorityT-compilerRelevant to the compiler team, which will review and decide on the PR/issue.Relevant to the compiler team, which will review and decide on the PR/issue.
Description
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
/// Given a body owner's id, returns the `BodyId` associated with it. #[track_caller] pub fn hir_body_owned_by(self, id: LocalDefId) -> &'tcx Body<'tcx> { self.hir_maybe_body_owned_by(id).unwrap_or_else(|| { let hir_id = self.local_def_id_to_hir_id(id); span_bug!( self.hir_span(hir_id), "body_owned_by: {} has no associated body", self.hir_id_to_string(hir_id) ); }) } -
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
Metadata
Metadata
Assignees
Labels
C-bugCategory: This is a bug.Category: This is a bug.F-type_alias_impl_trait`#[feature(type_alias_impl_trait)]``#[feature(type_alias_impl_trait)]`I-ICEIssue: The compiler panicked, giving an Internal Compilation Error (ICE) ❄️Issue: The compiler panicked, giving an Internal Compilation Error (ICE) ❄️P-lowLow priorityLow priorityT-compilerRelevant to the compiler team, which will review and decide on the PR/issue.Relevant to the compiler team, which will review and decide on the PR/issue.