Repository navigation
ICE when equating TAIT and RPIT in canonical queries #108498
Copy link
Copy link
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) ❄️T-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.T-typesRelevant to the types team, which will review and decide on the PR/issue.Relevant to the types team, which will review and decide on the PR/issue.fixed-by-next-solverFixed by the next-generation trait solver, `-Znext-solver`.Fixed by the next-generation trait solver, `-Znext-solver`.glacierICE tracked in rust-lang/glacier.ICE tracked in rust-lang/glacier.
Description
Code
#![feature(type_alias_impl_trait)]
type Opaque = impl Sized;
fn get_rpit() -> impl Clone {}
fn query(_: impl FnOnce() -> Opaque) {}
fn test() -> Opaque {
query(get_rpit);
get_rpit()
}While trying to prove the predicate <get_rpit as FnOnce>::Output == Opaque, we end up equating get_rpit::opaque#0 == Opaque::opaque#0. Because inside canonical queries we know nothing about the defining scope (DefiningAnchor::Bubble), we register the hidden type as get_rpit::opaque := Opaque::opaque instead of Opaque::opaque := get_rpit::opaque.
Cc @oli-obk.
Meta
Nightly version: 1.69.0-nightly (2023-02-25 34e6673)
Error output
Backtrace
warning: type alias `Opaque` is never used
--> src/lib.rs:3:6
|
3 | type Opaque = impl Sized;
| ^^^^^^
|
= note: `#[warn(dead_code)]` on by default
warning: function `get_rpit` is never used
--> src/lib.rs:5:4
|
5 | fn get_rpit() -> impl Clone {}
| ^^^^^^^^
warning: function `query` is never used
--> src/lib.rs:7:4
|
7 | fn query(_: impl FnOnce() -> Opaque) {}
| ^^^^^
warning: function `test` is never used
--> src/lib.rs:9:4
|
9 | fn test() -> Opaque {
| ^^^^
error: internal compiler error: no errors encountered even though `delay_span_bug` issued
error: internal compiler error: VecMap([(OpaqueTypeKey { def_id: DefId(0:8 ~ playground[4e8e]::get_rpit::{opaque#0}), substs: [] }, OpaqueTypeDecl { hidden_type: OpaqueHiddenType { span: no-location (#0), ty: Opaque }, origin: FnReturn(DefId(0:4 ~ playground[4e8e]::get_rpit)) })])
|
= note: delayed at 0: <rustc_errors::HandlerInner>::emit_diagnostic
1: <rustc_errors::Handler>::delay_span_bug::<rustc_span::span_encoding::Span, &alloc::string::String>
2: core::ptr::drop_in_place::<rustc_infer::infer::InferCtxt>
3: <rustc_infer::infer::InferCtxtBuilder as rustc_trait_selection::infer::InferCtxtBuilderExt>::enter_canonical_trait_query::<rustc_middle::ty::ParamEnvAnd<rustc_middle::traits::query::type_op::ProvePredicate>, (), rustc_traits::type_op::type_op_prove_predicate::{closure#0}>
4: rustc_query_system::query::plumbing::get_query::<rustc_query_impl::queries::type_op_prove_predicate, rustc_query_impl::plumbing::QueryCtxt, rustc_middle::dep_graph::dep_node::DepKind>
5: <rustc_middle::ty::ParamEnvAnd<rustc_middle::traits::query::type_op::ProvePredicate> as rustc_trait_selection::traits::query::type_op::TypeOp>::fully_perform
6: <rustc_borrowck::type_check::TypeChecker>::normalize_and_prove_instantiated_predicates
7: <rustc_borrowck::type_check::TypeVerifier as rustc_middle::mir::visit::Visitor>::visit_constant
8: <rustc_borrowck::type_check::TypeVerifier as rustc_middle::mir::visit::Visitor>::visit_body
9: rustc_borrowck::type_check::type_check
10: rustc_borrowck::nll::compute_regions
11: rustc_borrowck::do_mir_borrowck
12: rustc_borrowck::mir_borrowck
13: rustc_query_system::query::plumbing::try_execute_query::<rustc_query_impl::queries::mir_borrowck, rustc_query_impl::plumbing::QueryCtxt>
14: <rustc_query_impl::Queries as rustc_middle::ty::query::QueryEngine>::mir_borrowck
15: <rustc_hir_analysis::collect::type_of::find_opaque_ty_constraints_for_tait::ConstraintLocator>::check
16: <rustc_hir_analysis::collect::type_of::find_opaque_ty_constraints_for_tait::ConstraintLocator as rustc_hir::intravisit::Visitor>::visit_nested_item
17: rustc_hir::intravisit::walk_mod::<rustc_hir_analysis::collect::type_of::find_opaque_ty_constraints_for_tait::ConstraintLocator>
18: rustc_hir_analysis::collect::type_of::find_opaque_ty_constraints_for_tait
19: rustc_hir_analysis::collect::type_of::type_of
20: rustc_query_system::query::plumbing::get_query::<rustc_query_impl::queries::type_of, rustc_query_impl::plumbing::QueryCtxt, rustc_middle::dep_graph::dep_node::DepKind>
21: rustc_hir_analysis::check::check::check_mod_item_types
22: rustc_query_system::query::plumbing::try_execute_query::<rustc_query_impl::queries::check_mod_item_types, rustc_query_impl::plumbing::QueryCtxt>
23: <rustc_query_impl::Queries as rustc_middle::ty::query::QueryEngine>::check_mod_item_types
24: <rustc_middle::hir::map::Map>::for_each_module::<rustc_hir_analysis::check_crate::{closure#6}::{closure#0}>
25: rustc_hir_analysis::check_crate
26: rustc_interface::passes::analysis
27: rustc_query_system::query::plumbing::try_execute_query::<rustc_query_impl::queries::analysis, rustc_query_impl::plumbing::QueryCtxt>
28: <rustc_query_impl::Queries as rustc_middle::ty::query::QueryEngine>::analysis
29: <rustc_middle::ty::context::GlobalCtxt>::enter::<rustc_driver_impl::run_compiler::{closure#1}::{closure#2}::{closure#4}, core::result::Result<(), rustc_errors::ErrorGuaranteed>>
30: <rustc_interface::interface::Compiler>::enter::<rustc_driver_impl::run_compiler::{closure#1}::{closure#2}, core::result::Result<core::option::Option<rustc_interface::queries::Linker>, rustc_errors::ErrorGuaranteed>>
31: rustc_span::with_source_map::<core::result::Result<(), rustc_errors::ErrorGuaranteed>, rustc_interface::interface::run_compiler<core::result::Result<(), rustc_errors::ErrorGuaranteed>, rustc_driver_impl::run_compiler::{closure#1}>::{closure#0}::{closure#0}>
32: std::sys_common::backtrace::__rust_begin_short_backtrace::<rustc_interface::util::run_in_thread_pool_with_globals<rustc_interface::interface::run_compiler<core::result::Result<(), rustc_errors::ErrorGuaranteed>, rustc_driver_impl::run_compiler::{closure#1}>::{closure#0}, core::result::Result<(), rustc_errors::ErrorGuaranteed>>::{closure#0}::{closure#0}, core::result::Result<(), rustc_errors::ErrorGuaranteed>>
33: <<std::thread::Builder>::spawn_unchecked_<rustc_interface::util::run_in_thread_pool_with_globals<rustc_interface::interface::run_compiler<core::result::Result<(), rustc_errors::ErrorGuaranteed>, rustc_driver_impl::run_compiler::{closure#1}>::{closure#0}, core::result::Result<(), rustc_errors::ErrorGuaranteed>>::{closure#0}::{closure#0}, core::result::Result<(), rustc_errors::ErrorGuaranteed>>::{closure#1} as core::ops::function::FnOnce<()>>::call_once::{shim:vtable#0}
34: <alloc::boxed::Box<F,A> as core::ops::function::FnOnce<Args>>::call_once
at /rustc/34e6673a0473e90ef01a18eb575392c9e3859747/library/alloc/src/boxed.rs:1988:9
35: <alloc::boxed::Box<F,A> as core::ops::function::FnOnce<Args>>::call_once
at /rustc/34e6673a0473e90ef01a18eb575392c9e3859747/library/alloc/src/boxed.rs:1988:9
36: std::sys::unix::thread::Thread::new::thread_start
at /rustc/34e6673a0473e90ef01a18eb575392c9e3859747/library/std/src/sys/unix/thread.rs:108:17
37: start_thread
38: clone
error: internal compiler error: broken MIR in DefId(0:6 ~ playground[4e8e]::test) (NoSolution): could not prove Binder(ProjectionPredicate(AliasTy { substs: [fn() -> impl std::clone::Clone {get_rpit}, ()], def_id: DefId(2:2923 ~ core[df15]::ops::function::FnOnce::Output) }, Term::Ty(Opaque)), [])
|
= note: delayed at 0: <rustc_errors::HandlerInner>::emit_diagnostic
1: <rustc_errors::Handler>::delay_span_bug::<rustc_span::span_encoding::Span, &str>
2: <rustc_borrowck::type_check::TypeChecker>::normalize_and_prove_instantiated_predicates
3: <rustc_borrowck::type_check::TypeVerifier as rustc_middle::mir::visit::Visitor>::visit_constant
4: <rustc_borrowck::type_check::TypeVerifier as rustc_middle::mir::visit::Visitor>::visit_body
5: rustc_borrowck::type_check::type_check
6: rustc_borrowck::nll::compute_regions
7: rustc_borrowck::do_mir_borrowck
8: rustc_borrowck::mir_borrowck
9: rustc_query_system::query::plumbing::try_execute_query::<rustc_query_impl::queries::mir_borrowck, rustc_query_impl::plumbing::QueryCtxt>
10: <rustc_query_impl::Queries as rustc_middle::ty::query::QueryEngine>::mir_borrowck
11: <rustc_hir_analysis::collect::type_of::find_opaque_ty_constraints_for_tait::ConstraintLocator>::check
12: <rustc_hir_analysis::collect::type_of::find_opaque_ty_constraints_for_tait::ConstraintLocator as rustc_hir::intravisit::Visitor>::visit_nested_item
13: rustc_hir::intravisit::walk_mod::<rustc_hir_analysis::collect::type_of::find_opaque_ty_constraints_for_tait::ConstraintLocator>
14: rustc_hir_analysis::collect::type_of::find_opaque_ty_constraints_for_tait
15: rustc_hir_analysis::collect::type_of::type_of
16: rustc_query_system::query::plumbing::get_query::<rustc_query_impl::queries::type_of, rustc_query_impl::plumbing::QueryCtxt, rustc_middle::dep_graph::dep_node::DepKind>
17: rustc_hir_analysis::check::check::check_mod_item_types
18: rustc_query_system::query::plumbing::try_execute_query::<rustc_query_impl::queries::check_mod_item_types, rustc_query_impl::plumbing::QueryCtxt>
19: <rustc_query_impl::Queries as rustc_middle::ty::query::QueryEngine>::check_mod_item_types
20: <rustc_middle::hir::map::Map>::for_each_module::<rustc_hir_analysis::check_crate::{closure#6}::{closure#0}>
21: rustc_hir_analysis::check_crate
22: rustc_interface::passes::analysis
23: rustc_query_system::query::plumbing::try_execute_query::<rustc_query_impl::queries::analysis, rustc_query_impl::plumbing::QueryCtxt>
24: <rustc_query_impl::Queries as rustc_middle::ty::query::QueryEngine>::analysis
25: <rustc_middle::ty::context::GlobalCtxt>::enter::<rustc_driver_impl::run_compiler::{closure#1}::{closure#2}::{closure#4}, core::result::Result<(), rustc_errors::ErrorGuaranteed>>
26: <rustc_interface::interface::Compiler>::enter::<rustc_driver_impl::run_compiler::{closure#1}::{closure#2}, core::result::Result<core::option::Option<rustc_interface::queries::Linker>, rustc_errors::ErrorGuaranteed>>
27: rustc_span::with_source_map::<core::result::Result<(), rustc_errors::ErrorGuaranteed>, rustc_interface::interface::run_compiler<core::result::Result<(), rustc_errors::ErrorGuaranteed>, rustc_driver_impl::run_compiler::{closure#1}>::{closure#0}::{closure#0}>
28: std::sys_common::backtrace::__rust_begin_short_backtrace::<rustc_interface::util::run_in_thread_pool_with_globals<rustc_interface::interface::run_compiler<core::result::Result<(), rustc_errors::ErrorGuaranteed>, rustc_driver_impl::run_compiler::{closure#1}>::{closure#0}, core::result::Result<(), rustc_errors::ErrorGuaranteed>>::{closure#0}::{closure#0}, core::result::Result<(), rustc_errors::ErrorGuaranteed>>
29: <<std::thread::Builder>::spawn_unchecked_<rustc_interface::util::run_in_thread_pool_with_globals<rustc_interface::interface::run_compiler<core::result::Result<(), rustc_errors::ErrorGuaranteed>, rustc_driver_impl::run_compiler::{closure#1}>::{closure#0}, core::result::Result<(), rustc_errors::ErrorGuaranteed>>::{closure#0}::{closure#0}, core::result::Result<(), rustc_errors::ErrorGuaranteed>>::{closure#1} as core::ops::function::FnOnce<()>>::call_once::{shim:vtable#0}
30: <alloc::boxed::Box<F,A> as core::ops::function::FnOnce<Args>>::call_once
at /rustc/34e6673a0473e90ef01a18eb575392c9e3859747/library/alloc/src/boxed.rs:1988:9
31: <alloc::boxed::Box<F,A> as core::ops::function::FnOnce<Args>>::call_once
at /rustc/34e6673a0473e90ef01a18eb575392c9e3859747/library/alloc/src/boxed.rs:1988:9
32: std::sys::unix::thread::Thread::new::thread_start
at /rustc/34e6673a0473e90ef01a18eb575392c9e3859747/library/std/src/sys/unix/thread.rs:108:17
33: start_thread
34: clone
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.69.0-nightly (34e6673a0 2023-02-25) running on x86_64-unknown-linux-gnu
note: compiler flags: --crate-type lib -C embed-bitcode=no -C codegen-units=1 -C debuginfo=2
note: some of the compiler flags provided by cargo are hidden
query stack during panic:
end of query stack
warning: `playground` (lib) generated 4 warnings
error: could not compile `playground`; 4 warnings emitted
@rustbot label F-type_alias_impl_trait T-types
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) ❄️T-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.T-typesRelevant to the types team, which will review and decide on the PR/issue.Relevant to the types team, which will review and decide on the PR/issue.fixed-by-next-solverFixed by the next-generation trait solver, `-Znext-solver`.Fixed by the next-generation trait solver, `-Znext-solver`.glacierICE tracked in rust-lang/glacier.ICE tracked in rust-lang/glacier.
Type
Projects
- StatusShow more project fieldsDone
Activity
compiler-errors commentedon Feb 26, 2023
This would require some more design and stuff -- but I wonder if, when we relate an opaque with another opaque in a DefiningAnchor::Bubble scope, we should emit some other sort of opaque type constraint, like
OpaqueEq(LHS, RHS), that isn't just LHS := RHS. Then when we instantiate it in some other infcx, we'll choose whether LHS := RHS or RHS := LHS depending on what the defining anchor of that one is.oli-obk commentedon Feb 28, 2023
yea, that was always the plan, but it seemed too niche to put the effort in for now
Add some ICEs
Add some ICEs
Auto merge of rust-lang#114586 - oli-obk:patch_tait_rpit_order_check,…
Auto merge of #114586 - oli-obk:patch_tait_rpit_order_check, r=lcnr,c…
aliemjay commentedon Oct 8, 2023
Reopened because the fix was incomplete. See #116530
Auto merge of rust-lang#122077 - oli-obk:eager_opaque_checks4, r=<try>
Auto merge of rust-lang#122077 - oli-obk:eager_opaque_checks4, r=<try>
Auto merge of #114586 - oli-obk:patch_tait_rpit_order_check, r=lcnr,c…
Auto merge of rust-lang#122077 - oli-obk:eager_opaque_checks4, r=lcnr
Auto merge of #114586 - oli-obk:patch_tait_rpit_order_check, r=lcnr,c…