Closed LlewVallis closed 3 years ago
I ran into this issue just now, reproducible code:
use core::iter;
pub trait ToIter<T> {
type Iter<'b>: Iterator<Item = &'b T>
where
T: 'b;
fn iter(&self) -> Self::Iter<'_>;
}
pub struct DrainRange<'a, T>(&'a T);
impl<'a, T> ToIter<T> for DrainRange<'a, T> {
type Iter<'b>
where
T: 'b,
= iter::FromFn<impl FnMut() -> Option<&'b T>>;
fn iter(&self) -> Self::Iter<'_> {
unimplemented!()
}
}
fn main() {}
(note: this crashes on stable as well)
rust-lang/rust#87200
No longer ICEs since #89229
GATs issue triage: not blocking. Fixed; needs test.
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
Meta
rustc --version --verbose
:Error output
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:::sub_free_regions
4: ::constrain_opaque_types
5: rustc_typeck::check::regionck::RegionCtxt::visit_fn_body
6: rustc_typeck::check::regionck::::regionck_fn
7: rustc_infer::infer::InferCtxtBuilder::enter
8: rustc_typeck::check::typeck
9: rustc_query_system::dep_graph::graph::DepGraph::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: ::typeck
14: rustc_typeck::collect::type_of::find_opaque_ty_constraints::ConstraintLocator::check
15: ::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::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: ::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::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: ::check_mod_item_types
33: rustc_session::utils::::time
34: rustc_typeck::check_crate
35: rustc_interface::passes::analysis
36: rustc_query_system::dep_graph::graph::DepGraph::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: ::analysis
41: rustc_interface::passes::QueryContext::enter
42: rustc_interface::queries::::enter
43: rustc_span::with_source_map
44: scoped_tls::ScopedKey::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 `::a`
#1 [type_of] computing type of `::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
```