- Notifications
You must be signed in to change notification settings - Fork 14.1k
Closed
Labels
A-GATsArea: Generic associated types (GATs)Area: Generic associated types (GATs)C-bugCategory: This is a bug.Category: This is a bug.E-needs-testCall for participation: An issue has been fixed and does not reproduce, but no test has been added.Call for participation: An issue has been fixed and does not reproduce, but no test has been added.F-generic_associated_types`#![feature(generic_associated_types)]` a.k.a. GATs`#![feature(generic_associated_types)]` a.k.a. GATsF-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.glacierICE tracked in rust-lang/glacier.ICE tracked in rust-lang/glacier.
Description
When implementing generic associated type using impl Trait, the compiler panics if the trait lifetime bound is not satisfied by duplicating the where clause.
UPDATE: seems like the compiler also panics if an appropriate where clause is included in the implementation.
Reproducible in a new cargo project on the latest nightly.
Code
#![feature(generic_associated_types)] #![feature(type_alias_impl_trait)] fn main() { println!("Hello, world!"); } trait A<'a> { type B<'b>: Clone where 'a: 'b; fn a(&'a self) -> Self::B<'a>; } struct C; impl<'a> A<'a> for C { type B<'b> = impl Clone; fn a(&'a self) -> Self::B<'a> {} } Meta
rustc --version --verbose:
rustc 1.56.0-nightly (50171c310 2021-09-01) binary: rustc commit-hash: 50171c310cd15e1b2d3723766ce64e2e4d6696fc commit-date: 2021-09-01 host: x86_64-unknown-linux-gnu release: 1.56.0-nightly LLVM version: 13.0.0 Error output
error[E0478]: lifetime bound not satisfied --> src/main.rs:19:5 | 19 | type B<'b> = impl Clone; | ^^^^^^^^^^^^^^^^^^^^^^^^ | note: lifetime parameter instantiated with the lifetime `'a` as defined on the impl at 18:6 --> src/main.rs:18:6 | 18 | impl<'a> A<'a> for C { | ^^ note: but lifetime parameter must outlive the lifetime `'b` as defined on the associated item at 19:12 --> src/main.rs:19:12 | 19 | type B<'b> = impl Clone; | ^^ thread 'rustc' panicked at 'assertion failed: self.is_free_or_static(r_a) && self.is_free_or_static(r_b)', compiler/rustc_infer/src/infer/free_regions.rs:77:9 note: run with `RUST_BACKTRACE=1` environment variable to display a backtrace error: internal compiler error: unexpected panic note: the compiler unexpectedly panicked. this is a bug. 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.56.0-nightly (50171c310 2021-09-01) running on x86_64-unknown-linux-gnu note: compiler flags: -C embed-bitcode=no -C debuginfo=2 -C incremental --crate-type bin note: some of the compiler flags provided by cargo are hidden query stack during panic: #0 [typeck] type-checking `<impl at src/main.rs:18:1: 22:2>::a` #1 [type_of] computing type of `<impl at src/main.rs:18:1: 22:2>::B::{opaque#0}` end of query stack Backtrace
error[E0478]: lifetime bound not satisfied --> src/main.rs:19:5 | 19 | type B<'b> = impl Clone; | ^^^^^^^^^^^^^^^^^^^^^^^^ | note: lifetime parameter instantiated with the lifetime `'a` as defined on the impl at 18:6 --> src/main.rs:18:6 | 18 | impl<'a> A<'a> for C { | ^^ note: but lifetime parameter must outlive the lifetime `'b` as defined on the associated item at 19:12 --> src/main.rs:19:12 | 19 | type B<'b> = impl Clone; | ^^ thread 'rustc' panicked at 'assertion failed: self.is_free_or_static(r_a) && self.is_free_or_static(r_b)', compiler/rustc_infer/src/infer/free_regions.rs:77:9 stack backtrace: 0: rust_begin_unwind at /rustc/50171c310cd15e1b2d3723766ce64e2e4d6696fc/library/std/src/panicking.rs:517:5 1: core::panicking::panic_fmt at /rustc/50171c310cd15e1b2d3723766ce64e2e4d6696fc/library/core/src/panicking.rs:101:14 2: core::panicking::panic at /rustc/50171c310cd15e1b2d3723766ce64e2e4d6696fc/library/core/src/panicking.rs:50:5 3: <rustc_infer::infer::free_regions::FreeRegionMap as rustc_infer::infer::free_regions::FreeRegionRelations>::sub_free_regions 4: <rustc_infer::infer::InferCtxt as rustc_trait_selection::opaque_types::InferCtxtExt>::constrain_opaque_types 5: rustc_typeck::check::regionck::RegionCtxt::visit_fn_body 6: rustc_typeck::check::regionck::<impl rustc_typeck::check::fn_ctxt::FnCtxt>::regionck_fn 7: rustc_infer::infer::InferCtxtBuilder::enter 8: rustc_typeck::check::typeck 9: rustc_query_system::dep_graph::graph::DepGraph<K>::with_task_impl 10: rustc_data_structures::stack::ensure_sufficient_stack 11: rustc_query_system::query::plumbing::force_query_with_job 12: rustc_query_system::query::plumbing::get_query_impl 13: <rustc_query_impl::Queries as rustc_middle::ty::query::QueryEngine>::typeck 14: rustc_typeck::collect::type_of::find_opaque_ty_constraints::ConstraintLocator::check 15: <rustc_typeck::collect::type_of::find_opaque_ty_constraints::ConstraintLocator as rustc_hir::intravisit::Visitor>::visit_impl_item 16: rustc_hir::intravisit::Visitor::visit_nested_impl_item 17: rustc_hir::intravisit::walk_impl_item_ref 18: rustc_hir::intravisit::walk_item 19: rustc_typeck::collect::type_of::type_of 20: rustc_query_system::dep_graph::graph::DepGraph<K>::with_task_impl 21: rustc_data_structures::stack::ensure_sufficient_stack 22: rustc_query_system::query::plumbing::force_query_with_job 23: rustc_query_system::query::plumbing::get_query_impl 24: <rustc_query_impl::Queries as rustc_middle::ty::query::QueryEngine>::type_of 25: rustc_typeck::check::check::check_item_type 26: rustc_middle::hir::map::Map::visit_item_likes_in_module 27: rustc_typeck::check::check::check_mod_item_types 28: rustc_query_system::dep_graph::graph::DepGraph<K>::with_task_impl 29: rustc_data_structures::stack::ensure_sufficient_stack 30: rustc_query_system::query::plumbing::force_query_with_job 31: rustc_query_system::query::plumbing::get_query_impl 32: <rustc_query_impl::Queries as rustc_middle::ty::query::QueryEngine>::check_mod_item_types 33: rustc_session::utils::<impl rustc_session::session::Session>::time 34: rustc_typeck::check_crate 35: rustc_interface::passes::analysis 36: rustc_query_system::dep_graph::graph::DepGraph<K>::with_task_impl 37: rustc_data_structures::stack::ensure_sufficient_stack 38: rustc_query_system::query::plumbing::force_query_with_job 39: rustc_query_system::query::plumbing::get_query_impl 40: <rustc_query_impl::Queries as rustc_middle::ty::query::QueryEngine>::analysis 41: rustc_interface::passes::QueryContext::enter 42: rustc_interface::queries::<impl rustc_interface::interface::Compiler>::enter 43: rustc_span::with_source_map 44: scoped_tls::ScopedKey<T>::set note: Some details are omitted, run with `RUST_BACKTRACE=full` for a verbose backtrace. error: internal compiler error: unexpected panic note: the compiler unexpectedly panicked. this is a bug. 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.56.0-nightly (50171c310 2021-09-01) running on x86_64-unknown-linux-gnu note: compiler flags: -C embed-bitcode=no -C debuginfo=2 -C incremental --crate-type bin note: some of the compiler flags provided by cargo are hidden query stack during panic: #0 [typeck] type-checking `<impl at src/main.rs:18:1: 22:2>::a` #1 [type_of] computing type of `<impl at src/main.rs:18:1: 22:2>::B::{opaque#0}` #2 [check_mod_item_types] checking item types in top-level module #3 [analysis] running analysis passes on this crate end of query stack For more information about this error, try `rustc --explain E0478`. error: could not compile `mre` due to previous error Metadata
Metadata
Assignees
Labels
A-GATsArea: Generic associated types (GATs)Area: Generic associated types (GATs)C-bugCategory: This is a bug.Category: This is a bug.E-needs-testCall for participation: An issue has been fixed and does not reproduce, but no test has been added.Call for participation: An issue has been fixed and does not reproduce, but no test has been added.F-generic_associated_types`#![feature(generic_associated_types)]` a.k.a. GATs`#![feature(generic_associated_types)]` a.k.a. GATsF-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.glacierICE tracked in rust-lang/glacier.ICE tracked in rust-lang/glacier.
Type
Projects
Status
Done