Skip to content

Panic with GATs during lexical region resolve #88360

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

Closed
hlb8122 opened this issue Aug 26, 2021 · 0 comments · Fixed by #88846
Closed

Panic with GATs during lexical region resolve #88360

hlb8122 opened this issue Aug 26, 2021 · 0 comments · Fixed by #88846
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) ❄️ requires-nightly This issue requires a nightly compiler in some way. T-compiler Relevant to the compiler team, which will review and decide on the PR/issue.

Comments

@hlb8122
Copy link

hlb8122 commented Aug 26, 2021

Code

#![feature(generic_associated_types)]

trait GatTrait {
    type Gat<'a>;
    
    fn test(&self) -> Self::Gat<'_>;
}

trait SuperTrait<T>
where
    for<'a> Self: GatTrait<Gat<'a> = &'a T>,
{
    fn copy(&self) -> Self::Gat<'_> where T: Copy {
        *self.test()
    }
}

https://play.rust-lang.org/?version=nightly&mode=debug&edition=2018&gist=3ee6652c9d7ef9f1bd9658a44e0e1215

Note that this does not panic if we actually write correct Rust and switch to fn copy(&self) -> T.

Meta

rustc --version --verbose:

rustc 1.56.0-nightly (0afc20860 2021-08-25)

Error output

error: internal compiler error: compiler/rustc_infer/src/infer/lexical_region_resolve/mod.rs:498:17: cannot relate region: LUB(ReErased, ReEmpty(U0))

thread 'rustc' panicked at 'Box<dyn Any>', compiler/rustc_errors/src/lib.rs:1145:9
note: run with `RUST_BACKTRACE=1` environment variable to display a backtrace

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 (0afc20860 2021-08-25) running on x86_64-unknown-linux-gnu

note: compiler flags: -C embed-bitcode=no -C codegen-units=1 -C debuginfo=2 --crate-type lib

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

query stack during panic:
#0 [typeck] type-checking `SuperTrait::copy`
#1 [typeck_item_bodies] type-checking all item bodies
end of query stack
For more information about this error, try `rustc --explain E0308`.
error: could not compile `playground` due to previous error
Backtrace

stack backtrace:
   0: std::panicking::begin_panic
   1: std::panic::panic_any
   2: rustc_errors::HandlerInner::bug
   3: rustc_errors::Handler::bug
   4: rustc_middle::ty::context::tls::with_opt
   5: rustc_middle::util::bug::opt_span_bug_fmt
   6: rustc_middle::util::bug::bug_fmt
   7: rustc_infer::infer::lexical_region_resolve::LexicalResolver::lub_concrete_regions
   8: rustc_infer::infer::lexical_region_resolve::LexicalResolver::expand_node
   9: rustc_infer::infer::lexical_region_resolve::LexicalResolver::infer_variable_values
  10: rustc_infer::infer::lexical_region_resolve::resolve
  11: rustc_infer::infer::InferCtxt::resolve_regions_and_report_errors
  12: rustc_typeck::check::regionck::<impl rustc_typeck::check::fn_ctxt::FnCtxt>::regionck_fn
  13: rustc_infer::infer::InferCtxtBuilder::enter
  14: rustc_typeck::check::typeck
  15: rustc_query_system::dep_graph::graph::DepGraph<K>::with_task_impl
  16: rustc_data_structures::stack::ensure_sufficient_stack
  17: rustc_query_system::query::plumbing::force_query_with_job
  18: rustc_query_system::query::plumbing::get_query_impl
  19: <rustc_query_impl::Queries as rustc_middle::ty::query::QueryEngine>::typeck
  20: rustc_middle::ty::<impl rustc_middle::ty::context::TyCtxt>::par_body_owners
  21: rustc_typeck::check::typeck_item_bodies
  22: rustc_query_system::dep_graph::graph::DepGraph<K>::with_task_impl
  23: rustc_query_system::dep_graph::graph::DepGraph<K>::with_task
  24: rustc_query_system::query::plumbing::force_query_with_job
  25: rustc_query_system::query::plumbing::get_query_impl
  26: <rustc_query_impl::Queries as rustc_middle::ty::query::QueryEngine>::typeck_item_bodies
  27: rustc_session::utils::<impl rustc_session::session::Session>::time
  28: rustc_typeck::check_crate
  29: rustc_interface::passes::analysis
  30: rustc_middle::dep_graph::<impl rustc_query_system::dep_graph::DepKind for rustc_middle::dep_graph::dep_node::DepKind>::with_deps
  31: rustc_query_system::dep_graph::graph::DepGraph<K>::with_task_impl
  32: rustc_query_system::dep_graph::graph::DepGraph<K>::with_eval_always_task
  33: rustc_data_structures::stack::ensure_sufficient_stack
  34: rustc_query_system::query::plumbing::force_query_with_job
  35: rustc_query_system::query::plumbing::get_query_impl
  36: <rustc_query_impl::Queries as rustc_middle::ty::query::QueryEngine>::analysis
  37: rustc_interface::passes::QueryContext::enter
  38: rustc_interface::queries::<impl rustc_interface::interface::Compiler>::enter
  39: rustc_span::with_source_map
  40: scoped_tls::ScopedKey<T>::set

@hlb8122 hlb8122 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, 2021
@jonas-schievink jonas-schievink added the F-generic_associated_types `#![feature(generic_associated_types)]` a.k.a. GATs label Aug 26, 2021
@hlb8122 hlb8122 changed the title Compiler panic with GATs during lexical region resolve Panic with GATs during lexical region resolve Sep 3, 2021
matthiaskrgr added a commit to matthiaskrgr/glacier that referenced this issue Sep 5, 2021
@rust-lang-glacier-bot rust-lang-glacier-bot added the glacier ICE tracked in rust-lang/glacier. label Sep 5, 2021
@camelid camelid added the requires-nightly This issue requires a nightly compiler in some way. label Sep 11, 2021
@bors bors closed this as completed in 77f4143 Sep 22, 2021
@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) ❄️ requires-nightly This issue requires a nightly compiler in some way. 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