ICE: encountered errors when checking RPITIT refinement (resolution)
in rustc_hir_analysis/src/check/compare_impl_item/refine.rs
#126670
Closed
Description
Code
(hand-reduced)
pub trait A {}
pub trait Mirror {
type Assoc: ?Sized;
}
impl<T: ?Sized> Mirror for dyn A {
type Assoc = T;
}
pub trait First {
async fn first() -> <dyn A + 'static as Mirror>::Assoc;
}
impl First for dyn A {
async fn first() {}
}
fn main() {}
(original)
pub trait A {}
pub trait B: A {}
pub trait Mirror {
type Assoc: ?Sized;
}
impl<T: ?Sized> Mirror for A {
type Assoc = T;
}
pub fn foo<'a>(x: &'a <dyn A + 'static as Mirror>::Assoc) -> &'a <dyn B + 'static as Mirror>::Assoc {
static
}
#![feature(async_fn_in_trait)]
fn main() {
let _ = async {
A.first().await.second().await;
};
}
pub trait First {
type Second: Second;
async fn first(self) -> <dyn A + 'static as Mirror>::Assoc;
}
struct A;
impl First for A {
type Second = A;
async fn first(self) -> Self::Second {
A
}
}
pub trait Second {
async fn second(self);
}
impl<C> Second for C
where
C: First,
{
async fn second(self) {
self.first().await.second().await;
}
}
Meta
rustc --version --verbose
:
rustc 1.81.0-nightly (8fcd4dd08 2024-06-18)
binary: rustc
commit-hash: 8fcd4dd08e2ba3e922d917d819ba0be066bdb005
commit-date: 2024-06-18
host: x86_64-apple-darwin
release: 1.81.0-nightly
LLVM version: 18.1.7
Error output
Command: rustc --edition=2021
- I put the option
--edition=2021
to remove "async fn" error, but I guess it is not an essential option to trigger ICE.
error[E0207]: the type parameter `T` is not constrained by the impl trait, self type, or predicates
--> r_rpitit_0773A37F.rs:6:6
|
6 | impl<T: ?Sized> Mirror for dyn A {
| ^ unconstrained type parameter
Backtrace
error: internal compiler error: encountered errors when checking RPITIT refinement (resolution)
thread 'rustc' panicked at compiler/rustc_hir_analysis/src/check/compare_impl_item/refine.rs:177:19:
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_hir_analysis::check::compare_impl_item::refine::check_refining_return_position_impl_trait_in_trait
3: rustc_hir_analysis::check::check::check_impl_items_against_trait
4: rustc_hir_analysis::check::check::check_item_type
5: rustc_hir_analysis::check::wfcheck::check_well_formed
[... omitted 1 frame ...]
6: rustc_middle::query::plumbing::query_ensure_error_guaranteed::<rustc_query_system::query::caches::VecCache<rustc_hir::hir_id::OwnerId, rustc_middle::query::erase::Erased<[u8; 1]>>, ()>
7: rustc_hir_analysis::check::wfcheck::check_mod_type_wf
[... omitted 1 frame ...]
8: rustc_hir_analysis::check_crate
9: rustc_interface::passes::run_required_analyses
10: rustc_interface::passes::analysis
[... omitted 1 frame ...]
11: <rustc_interface::queries::QueryResult<&rustc_middle::ty::context::GlobalCtxt>>::enter::<core::result::Result<(), rustc_span::ErrorGuaranteed>, rustc_driver_impl::run_compiler::{closure#0}::{closure#1}::{closure#3}>
12: rustc_interface::interface::run_compiler::<core::result::Result<(), rustc_span::ErrorGuaranteed>, 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 `/Volumes/T7/workspace/240615_100chaos_tree_combine_typ/icefiles/rustc-ice-2024-06-19T07_28_40-72547.txt` to your bug report
query stack during panic:
#0 [check_well_formed] checking that `<impl at r_rpitit_0773A37F.rs:14:1: 14:21>` 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 2 previous errors
For more information about this error, try `rustc --explain E0207`.
Note
- ICE location:
compiler/rustc_hir_analysis/src/check/compare_impl_item/refine.rs#L177
rust/compiler/rustc_hir_analysis/src/check/compare_impl_item/refine.rs
Lines 173 to 178 in 8fcd4dd