Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

GAT ICE: cannot relate bound region #101020

Closed
Aiden2207 opened this issue Aug 26, 2022 · 0 comments · Fixed by #101022
Closed

GAT ICE: cannot relate bound region #101020

Aiden2207 opened this issue Aug 26, 2022 · 0 comments · Fixed by #101022
Assignees
Labels
A-GATs Area: Generic associated types (GATs) C-bug Category: This is a bug. F-generic_associated_types `#![feature(generic_associated_types)]` a.k.a. GATs glacier ICE tracked in rust-lang/glacier. I-ICE Issue: The compiler panicked, giving an Internal Compilation Error (ICE) ❄️ T-compiler Relevant to the compiler team, which will review and decide on the PR/issue.

Comments

@Aiden2207
Copy link

Code

#![feature(generic_associated_types)]
pub trait LendingIterator {
    type Item<'a>
    where
        Self: 'a;

    fn consume<F>(self, _f: F)
    where
        Self: Sized,
        for<'a> Self::Item<'a>: FuncInput<'a, Self::Item<'a>>,
    {
    }
}

impl<I: LendingIterator + ?Sized> LendingIterator for &mut I {
    type Item<'a> = I::Item<'a> where Self: 'a;
}
struct EmptyIter;
impl LendingIterator for EmptyIter {
    type Item<'a> = &'a mut () where Self:'a;
}
pub trait FuncInput<'a, F>
where
    F: Foo<Self>,
    Self: Sized,
{
}
impl<'a, T, F: 'a> FuncInput<'a, F> for T where F: Foo<T> {}
trait Foo<T> {}

fn map_test() {
    (&mut EmptyIter).consume(()); 
}

Meta

rustc --version --verbose:

rustc 1.65.0-nightly (addacb587 2022-08-24)
binary: rustc
commit-hash: addacb5878b9970ebc1665768a05cb601e7aea15
commit-date: 2022-08-24
host: x86_64-pc-windows-msvc
release: 1.65.0-nightly
LLVM version: 15.0.0

Note that on the playground (nightly-2022-08-16) the correct error message is produced instead of an ICE.

Error output

error: internal compiler error: compiler\rustc_infer\src\infer\region_constraints\mod.rs:568:17: cannot relate bound region: ReLateBound(DebruijnIndex(0), BoundRegion { var: 0, kind: BrNamed(DefId(0:8 ~ lending_iter[ce9f]::LendingIterator::consume::'a), 'a) }) <= '_#1r

thread 'rustc' panicked at 'Box<dyn Any>', /rustc/addacb5878b9970ebc1665768a05cb601e7aea15\compiler\rustc_errors\src\lib.rs:1393:9
stack backtrace:
   0:     0x7ffc8d3f8e06 - <std::sys_common::backtrace::_print::DisplayBacktrace as core::fmt::Display>::fmt::h498cb4722507e676
   1:     0x7ffc8d43470b - core::fmt::write::h92849121e8600c03
   2:     0x7ffc8d3eb9fa - <std::io::IoSlice as core::fmt::Debug>::fmt::h44e2382549910bc0
   3:     0x7ffc8d3fc584 - std::panicking::default_hook::h355dddac3d40a601
   4:     0x7ffc8d3fc1ba - std::panicking::default_hook::h355dddac3d40a601
   5:     0x7ffc6d382c92 - rustc_driver[f5adbe72392c62a3]::describe_lints
   6:     0x7ffc8d3fcf82 - std::panicking::rust_panic_with_hook::h7acd234e4dc18959     
   7:     0x7ffc6f4d4e63 - <rustc_infer[da0f39f7a067bf92]::infer::outlives::test_type_match::Match as rustc_middle[2b86214b3f6145ee]::ty::relate::TypeRelation>::consts       
   8:     0x7ffc6f4d1f59 - <rustc_infer[da0f39f7a067bf92]::infer::type_variable::TyVidEqKey as core[5929f349696a0fef]::fmt::Debug>::fmt
   9:     0x7ffc6f510cc9 - <rustc_infer[da0f39f7a067bf92]::infer::combine::ConstInferUnifier as rustc_middle[2b86214b3f6145ee]::ty::relate::TypeRelation>::tys
  10:     0x7ffc6f510cb9 - <rustc_infer[da0f39f7a067bf92]::infer::combine::ConstInferUnifier as rustc_middle[2b86214b3f6145ee]::ty::relate::TypeRelation>::tys
  11:     0x7ffc6f5104cf - <rustc_infer[da0f39f7a067bf92]::infer::combine::ConstInferUnifier as rustc_middle[2b86214b3f6145ee]::ty::relate::TypeRelation>::tys
  12:     0x7ffc6f510342 - <rustc_infer[da0f39f7a067bf92]::infer::combine::ConstInferUnifier as rustc_middle[2b86214b3f6145ee]::ty::relate::TypeRelation>::tys
  13:     0x7ffc6f4ed722 - <rustc_infer[da0f39f7a067bf92]::traits::project::ProjectionCacheEntry as core[5929f349696a0fef]::fmt::Debug>::fmt
  14:     0x7ffc6f4ed2a8 - <rustc_infer[da0f39f7a067bf92]::traits::project::ProjectionCacheEntry as core[5929f349696a0fef]::fmt::Debug>::fmt
  15:     0x7ffc6f4ed266 - <rustc_infer[da0f39f7a067bf92]::traits::project::ProjectionCacheEntry as core[5929f349696a0fef]::fmt::Debug>::fmt
  16:     0x7ffc6d175dcb - <rustc_infer[da0f39f7a067bf92]::infer::region_constraints::RegionConstraintCollector>::make_eqregion
  17:     0x7ffc6d1af5c2 - <rustc_middle[2b86214b3f6145ee]::ty::sty::ProjectionTy as rustc_infer[da0f39f7a067bf92]::infer::at::ToTrace>::to_trace
  18:     0x7ffc6d15ae3e - <rustc_infer[da0f39f7a067bf92]::infer::equate::Equate as rustc_middle[2b86214b3f6145ee]::ty::relate::TypeRelation>::tys
  19:     0x7ffc6d104e60 - <rustc_trait_selection[42d038ab64403654]::traits::query::normalize::QueryNormalizer as rustc_middle[2b86214b3f6145ee]::ty::fold::FallibleTypeFolder>::try_fold_ty
  20:     0x7ffc6f4427af - <&[rustc_hir[1e1037240eda7a15]::hir::GenericParam] as rustc_trait_selection[42d038ab64403654]::traits::error_reporting::suggestions::NextTypeParamName>::next_type_param_name
  21:     0x7ffc6f448803 - <rustc_infer[da0f39f7a067bf92]::infer::InferCtxt as rustc_trait_selection[42d038ab64403654]::traits::error_reporting::suggestions::InferCtxtExt>::suggest_dereferences
  22:     0x7ffc6f46070d - <rustc_infer[da0f39f7a067bf92]::infer::InferCtxt as rustc_trait_selection[42d038ab64403654]::traits::error_reporting::InferCtxtExt>::report_selection_error
  23:     0x7ffc6f46d713 - <rustc_infer[da0f39f7a067bf92]::infer::InferCtxt as rustc_trait_selection[42d038ab64403654]::traits::error_reporting::InferCtxtPrivExt>::report_fulfillment_error
  24:     0x7ffc6f45c97e - <rustc_infer[da0f39f7a067bf92]::infer::InferCtxt as rustc_trait_selection[42d038ab64403654]::traits::error_reporting::InferCtxtExt>::report_fulfillment_errors
  25:     0x7ffc6c8059a4 - <rustc_typeck[dafac4f190e2a07c]::check::fn_ctxt::FnCtxt>::demand_coerce_diag
  26:     0x7ffc6c7b65fd - <rustc_typeck[dafac4f190e2a07c]::check::fn_ctxt::FnCtxt>::demand_coerce
  27:     0x7ffc6c7d7cbb - <rustc_typeck[dafac4f190e2a07c]::check::fn_ctxt::FnCtxt>::structurally_resolved_type
  28:     0x7ffc6c7ff078 - <rustc_typeck[dafac4f190e2a07c]::check::fn_ctxt::FnCtxt>::demand_coerce_diag
  29:     0x7ffc6c7b65fd - <rustc_typeck[dafac4f190e2a07c]::check::fn_ctxt::FnCtxt>::demand_coerce
  30:     0x7ffc6c7e710c - <rustc_typeck[dafac4f190e2a07c]::check::fn_ctxt::FnCtxt>::check_stmt
  31:     0x7ffc6c7e7b37 - <rustc_typeck[dafac4f190e2a07c]::check::fn_ctxt::FnCtxt>::check_stmt
  32:     0x7ffc6c7fdb83 - <rustc_typeck[dafac4f190e2a07c]::check::fn_ctxt::FnCtxt>::demand_coerce_diag
  33:     0x7ffc6c7b65fd - <rustc_typeck[dafac4f190e2a07c]::check::fn_ctxt::FnCtxt>::demand_coerce
  34:     0x7ffc6c7b9190 - <rustc_typeck[dafac4f190e2a07c]::check::fn_ctxt::FnCtxt>::demand_coerce
  35:     0x7ffc6c879946 - <rustc_typeck[dafac4f190e2a07c]::check::inherited::Inherited>::register_predicate
  36:     0x7ffc6c83989c - rustc_typeck[dafac4f190e2a07c]::check::rvalue_scopes::resolve_rvalue_scopes
  37:     0x7ffc6c85a857 - <rustc_typeck[dafac4f190e2a07c]::check::UnsafetyState>::recurse
  38:     0x7ffc6b6de798 - <rustc_span[7be80b5dc77ad545]::hygiene::ExpnId as rustc_serialize[eeb66c00494392f7]::serialize::Decodable<rustc_query_impl[56bab2eb465dd4c3]::on_disk_cache::CacheDecoder>>::decode
  39:     0x7ffc6b81c51e - <&rustc_index[9c945373e6cac357]::vec::IndexVec<rustc_middle[2b86214b3f6145ee]::mir::Promoted, rustc_middle[2b86214b3f6145ee]::mir::Body> as rustc_serialize[eeb66c00494392f7]::serialize::Decodable<rustc_query_impl[56bab2eb465dd4c3]::on_disk_cache::CacheDecoder>>::decode
  40:     0x7ffc6cd56503 - <rustc_span[7be80b5dc77ad545]::symbol::Symbol as rustc_serialize[eeb66c00494392f7]::serialize::Encodable<rustc_query_impl[56bab2eb465dd4c3]::on_disk_cache::CacheEncoder>>::encode
  41:     0x7ffc6ccbeee2 - <rustc_query_impl[56bab2eb465dd4c3]::Queries as rustc_middle[2b86214b3f6145ee]::ty::query::QueryEngine>::as_any
  42:     0x7ffc6c85fc15 - <rustc_typeck[dafac4f190e2a07c]::check::inherited::Inherited>::register_predicate
  43:     0x7ffc6b4d6361 - rustc_typeck[dafac4f190e2a07c]::check::provide
  44:     0x7ffc6b6e02be - <rustc_span[7be80b5dc77ad545]::hygiene::ExpnId as rustc_serialize[eeb66c00494392f7]::serialize::Decodable<rustc_query_impl[56bab2eb465dd4c3]::on_disk_cache::CacheDecoder>>::decode
  45:     0x7ffc6b83c50d - <&rustc_index[9c945373e6cac357]::vec::IndexVec<rustc_middle[2b86214b3f6145ee]::mir::Promoted, rustc_middle[2b86214b3f6145ee]::mir::Body> as rustc_serialize[eeb66c00494392f7]::serialize::Decodable<rustc_query_impl[56bab2eb465dd4c3]::on_disk_cache::CacheDecoder>>::decode
  46:     0x7ffc6b78fe34 - <&rustc_index[9c945373e6cac357]::vec::IndexVec<rustc_middle[2b86214b3f6145ee]::mir::Promoted, rustc_middle[2b86214b3f6145ee]::mir::Body> as rustc_serialize[eeb66c00494392f7]::serialize::Decodable<rustc_query_impl[56bab2eb465dd4c3]::on_disk_cache::CacheDecoder>>::decode
  47:     0x7ffc6b7d453c - <&rustc_index[9c945373e6cac357]::vec::IndexVec<rustc_middle[2b86214b3f6145ee]::mir::Promoted, rustc_middle[2b86214b3f6145ee]::mir::Body> as rustc_serialize[eeb66c00494392f7]::serialize::Decodable<rustc_query_impl[56bab2eb465dd4c3]::on_disk_cache::CacheDecoder>>::decode
  48:     0x7ffc6b49cc6a - <rustc_typeck[dafac4f190e2a07c]::check::fn_ctxt::FnCtxt>::write_user_type_annotation
  49:     0x7ffc6b465c23 - rustc_typeck[dafac4f190e2a07c]::check_crate
  50:     0x7ffc6acaaa95 - rustc_interface[22cafcfb0a37eae3]::passes::analysis
  51:     0x7ffc6b6dfdae - <rustc_span[7be80b5dc77ad545]::hygiene::ExpnId as rustc_serialize[eeb66c00494392f7]::serialize::Decodable<rustc_query_impl[56bab2eb465dd4c3]::on_disk_cache::CacheDecoder>>::decode
  52:     0x7ffc6b836833 - <&rustc_index[9c945373e6cac357]::vec::IndexVec<rustc_middle[2b86214b3f6145ee]::mir::Promoted, rustc_middle[2b86214b3f6145ee]::mir::Body> as rustc_serialize[eeb66c00494392f7]::serialize::Decodable<rustc_query_impl[56bab2eb465dd4c3]::on_disk_cache::CacheDecoder>>::decode
  53:     0x7ffc6b77fb4f - <&rustc_index[9c945373e6cac357]::vec::IndexVec<rustc_middle[2b86214b3f6145ee]::mir::Promoted, rustc_middle[2b86214b3f6145ee]::mir::Body> as rustc_serialize[eeb66c00494392f7]::serialize::Decodable<rustc_query_impl[56bab2eb465dd4c3]::on_disk_cache::CacheDecoder>>::decode
  54:     0x7ffc6b80589d - <&rustc_index[9c945373e6cac357]::vec::IndexVec<rustc_middle[2b86214b3f6145ee]::mir::Promoted, rustc_middle[2b86214b3f6145ee]::mir::Body> as rustc_serialize[eeb66c00494392f7]::serialize::Decodable<rustc_query_impl[56bab2eb465dd4c3]::on_disk_cache::CacheDecoder>>::decode
  55:     0x7ffc6ac6c506 - <unknown>
  56:     0x7ffc6ac46cc8 - <unknown>
  57:     0x7ffc6ac4312a - <unknown>
  58:     0x7ffc6ac47e63 - <unknown>
  59:     0x7ffc6ac7e1c7 - rustc_driver[f5adbe72392c62a3]::args::arg_expand_all        
  60:     0x7ffc6ac464d9 - <unknown>
  61:     0x7ffc6ac6d6cd - <unknown>
  62:     0x7ffc8d40dc1c - std::sys::windows::thread::Thread::new::ha49a10ef5abed6d8   
  63:     0x7ffd1a37244d - BaseThreadInitThunk
  64:     0x7ffd1b40df78 - RtlUserThreadStart

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.65.0-nightly (addacb587 2022-08-24) running on x86_64-pc-windows-msvc    

note: compiler flags: --crate-type lib -C embed-bitcode=no -C debuginfo=2 -C incremental

note: some of the compiler flags provided by cargo are hidden

query stack during panic:
#0 [typeck] type-checking `map_test`
#1 [typeck_item_bodies] type-checking all item bodies
#2 [analysis] running analysis passes on this crate
end of query stack
@Aiden2207 Aiden2207 added C-bug Category: This is a bug. I-ICE Issue: The compiler panicked, giving an Internal Compilation Error (ICE) ❄️ T-compiler Relevant to the compiler team, which will review and decide on the PR/issue. labels Aug 26, 2022
@compiler-errors compiler-errors self-assigned this Aug 26, 2022
@jackh726 jackh726 added the F-generic_associated_types `#![feature(generic_associated_types)]` a.k.a. GATs label Aug 27, 2022
@rust-lang-glacier-bot rust-lang-glacier-bot added the glacier ICE tracked in rust-lang/glacier. label Aug 28, 2022
matthiaskrgr added a commit to matthiaskrgr/rust that referenced this issue Aug 30, 2022
…ckh726

Erase late bound regions before comparing types in `suggest_dereferences`

Fixes rust-lang#101020
@bors bors closed this as completed in 1ea8496 Aug 30, 2022
@fmease fmease added the A-GATs Area: Generic associated types (GATs) label Nov 2, 2024
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
A-GATs Area: Generic associated types (GATs) C-bug Category: This is a bug. F-generic_associated_types `#![feature(generic_associated_types)]` a.k.a. GATs glacier ICE tracked in rust-lang/glacier. I-ICE Issue: The compiler panicked, giving an Internal Compilation Error (ICE) ❄️ T-compiler Relevant to the compiler team, which will review and decide on the PR/issue.
Projects
None yet
Development

Successfully merging a pull request may close this issue.

5 participants