Skip to content

ICE when attempting HRTB with GATs #79949

New issue

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

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

Already on GitHub? # to your account

Closed
vandenheuvel opened this issue Dec 11, 2020 · 4 comments · Fixed by #84379
Closed

ICE when attempting HRTB with GATs #79949

vandenheuvel opened this issue Dec 11, 2020 · 4 comments · Fixed by #84379
Labels
A-associated-items Area: Associated items (types, constants & functions) A-GATs Area: Generic associated types (GATs) A-trait-system Area: Trait system C-bug Category: This is a bug. E-needs-test Call for participation: An issue has been fixed and does not reproduce, but no test has been added. F-associated_type_bounds `#![feature(associated_type_bounds)]` 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) ❄️ regression-from-stable-to-stable Performance or correctness regression from one stable version to another. 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

@vandenheuvel
Copy link
Contributor

This happens on stable 1.48.0, beta 1.49.0-beta2 as well as the current nightly.

trait MP {
    type T<'a>;
}
struct S(String);
impl MP for S {
    type T<'a> = &'a str;
}

trait SR: MP {
    fn sr<IM>(&self) -> i32
    where
        for<'a> IM: T<T: U<<Self as MP>::T<'a>>>;
}

trait T {
    type T;
}
trait U<X> {}

Playground

error: internal compiler error: compiler/rustc_middle/src/ty/sty.rs:78:18: bound region is not anonymous

This error occurs also when the associated_type_bounds and generic_associated_types features are enabled on nighly, another playground.

Backtrace

error: internal compiler error: compiler/rustc_middle/src/ty/sty.rs:78:18: bound region is not anonymous

thread 'rustc' panicked at 'Box<Any>', compiler/rustc_errors/src/lib.rs:945:9
stack backtrace:
   0: std::panicking::begin_panic
   1: rustc_errors::HandlerInner::bug
   2: rustc_errors::Handler::bug
   3: rustc_middle::util::bug::opt_span_bug_fmt::{{closure}}
   4: rustc_middle::ty::context::tls::with_opt::{{closure}}
   5: rustc_middle::ty::context::tls::with_opt
   6: rustc_middle::util::bug::opt_span_bug_fmt
   7: rustc_middle::util::bug::bug_fmt
   8: rustc_middle::ty::sty::BoundRegion::assert_bound_var
   9: alloc::collections::btree::map::Entry<K,V>::or_insert_with
  10: rustc_middle::ty::fold::<impl rustc_middle::ty::context::TyCtxt>::replace_escaping_bound_vars::{{closure}}
  11: <rustc_middle::ty::fold::BoundVarReplacer as rustc_middle::ty::fold::TypeFolder>::fold_region
  12: rustc_middle::ty::fold::TypeFoldable::fold_with
  13: rustc_middle::ty::structural_impls::<impl rustc_middle::ty::fold::TypeFoldable for &rustc_middle::ty::TyS>::super_fold_with
  14: <rustc_middle::ty::fold::BoundVarReplacer as rustc_middle::ty::fold::TypeFolder>::fold_ty
  15: rustc_middle::ty::fold::TypeFoldable::fold_with
  16: rustc_middle::ty::fold::TypeFoldable::fold_with
  17: rustc_middle::ty::fold::TypeFoldable::fold_with
  18: rustc_middle::ty::structural_impls::fold_list
  19: rustc_middle::ty::fold::<impl rustc_middle::ty::context::TyCtxt>::replace_escaping_bound_vars
  20: <rustc_middle::infer::canonical::Canonical<V> as rustc_infer::infer::canonical::substitute::CanonicalExt<V>>::substitute
  21: rustc_infer::infer::InferCtxtBuilder::enter_with_canonical
  22: rustc_traits::evaluate_obligation::evaluate_obligation
  23: rustc_middle::ty::query::<impl rustc_query_system::query::config::QueryAccessors<rustc_middle::ty::context::TyCtxt> for rustc_middle::ty::query::queries::evaluate_obligation>::compute
  24: rustc_query_system::dep_graph::graph::DepGraph<K>::with_task_impl
  25: rustc_data_structures::stack::ensure_sufficient_stack
  26: rustc_query_system::query::plumbing::get_query_impl
  27: <rustc_infer::infer::InferCtxt as rustc_trait_selection::traits::query::evaluate_obligation::InferCtxtExt>::evaluate_obligation
  28: <rustc_infer::infer::InferCtxt as rustc_trait_selection::traits::query::evaluate_obligation::InferCtxtExt>::evaluate_obligation_no_overflow
  29: <rustc_infer::infer::InferCtxt as rustc_trait_selection::traits::query::evaluate_obligation::InferCtxtExt>::predicate_must_hold_modulo_regions
  30: rustc_typeck::check::wfcheck::receiver_is_implemented
  31: rustc_typeck::check::wfcheck::receiver_is_valid
  32: rustc_typeck::check::wfcheck::check_method_receiver
  33: rustc_infer::infer::InferCtxtBuilder::enter
  34: rustc_typeck::check::wfcheck::check_associated_item
  35: rustc_typeck::check::wfcheck::check_trait_item
  36: rustc_middle::ty::query::<impl rustc_query_system::query::config::QueryAccessors<rustc_middle::ty::context::TyCtxt> for rustc_middle::ty::query::queries::check_trait_item_well_formed>::compute
  37: rustc_query_system::dep_graph::graph::DepGraph<K>::with_task_impl
  38: rustc_data_structures::stack::ensure_sufficient_stack
  39: rustc_query_system::query::plumbing::get_query_impl
  40: rustc_query_system::query::plumbing::ensure_query_impl
  41: <std::panic::AssertUnwindSafe<F> as core::ops::function::FnOnce<()>>::call_once
  42: rustc_hir::hir::Crate::par_visit_all_item_likes
  43: rustc_session::session::Session::track_errors
  44: rustc_typeck::check_crate
  45: rustc_interface::passes::analysis
  46: rustc_middle::ty::query::<impl rustc_query_system::query::config::QueryAccessors<rustc_middle::ty::context::TyCtxt> for rustc_middle::ty::query::queries::analysis>::compute
  47: rustc_query_system::dep_graph::graph::DepGraph<K>::with_task_impl
  48: rustc_data_structures::stack::ensure_sufficient_stack
  49: rustc_query_system::query::plumbing::get_query_impl
  50: rustc_interface::passes::QueryContext::enter
  51: rustc_interface::queries::<impl rustc_interface::interface::Compiler>::enter
  52: rustc_span::with_source_map
  53: scoped_tls::ScopedKey<T>::set
note: Some details are omitted, run with `RUST_BACKTRACE=full` for a verbose 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.48.0 (7eac88abb 2020-11-16) running on x86_64-unknown-linux-gnu

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

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

query stack during panic:
#0 [evaluate_obligation] evaluating trait selection obligation `&Self: std::ops::Receiver`
#1 [check_trait_item_well_formed] checking that `SR::sr` is well-formed
#2 [analysis] running analysis passes on this crate
end of query stack
error: aborting due to 5 previous errors

@vandenheuvel vandenheuvel 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 Dec 11, 2020
@camelid camelid added A-trait-system Area: Trait system A-associated-items Area: Associated items (types, constants & functions) labels Dec 11, 2020
@rust-lang-glacier-bot rust-lang-glacier-bot added the glacier ICE tracked in rust-lang/glacier. label Dec 12, 2020
@matthiaskrgr
Copy link
Member

This ICEs since 1.46
@rustbot modify labels: +regression-from-stable-to-stable

@rustbot rustbot added regression-from-stable-to-stable Performance or correctness regression from one stable version to another. I-prioritize Issue: Indicates that prioritization has been requested for this issue. labels Dec 20, 2020
@camelid camelid added the requires-nightly This issue requires a nightly compiler in some way. label Dec 20, 2020
@camelid
Copy link
Member

camelid commented Dec 20, 2020

This ICE occurs on stable, but to actually use the feature that causes the ICE you must use nightly, so I added requires-nightly.

@camelid camelid added P-medium Medium priority and removed I-prioritize Issue: Indicates that prioritization has been requested for this issue. labels Dec 20, 2020
@camelid
Copy link
Member

camelid commented Dec 20, 2020

Assigning P-medium and removing I-prioritize as discussed in the prioritization working group.

@JohnTitor
Copy link
Member

JohnTitor commented Apr 1, 2021

Triage: This has been fixed on the latest nightly (with or without feature flags), I'm quite sure #76814 fixed it, marking as E-needs-test.

@JohnTitor JohnTitor added E-needs-test Call for participation: An issue has been fixed and does not reproduce, but no test has been added. and removed P-medium Medium priority labels Apr 1, 2021
@jackh726 jackh726 added F-generic_associated_types `#![feature(generic_associated_types)]` a.k.a. GATs F-associated_type_bounds `#![feature(associated_type_bounds)]` labels Apr 1, 2021
marmeladema added a commit to marmeladema/rust that referenced this issue Apr 20, 2021
Dylan-DPC-zz pushed a commit to Dylan-DPC-zz/rust that referenced this issue Apr 21, 2021
m-ou-se added a commit to m-ou-se/rust that referenced this issue Apr 21, 2021
@bors bors closed this as completed in e7f2033 Apr 22, 2021
@fmease fmease added the A-GATs Area: Generic associated types (GATs) label Nov 2, 2024
@fmease fmease added A-trait-system Area: Trait system and removed A-trait-system Area: Trait system labels Dec 21, 2024
# for free to join this conversation on GitHub. Already have an account? # to comment
Labels
A-associated-items Area: Associated items (types, constants & functions) A-GATs Area: Generic associated types (GATs) A-trait-system Area: Trait system C-bug Category: This is a bug. E-needs-test Call for participation: An issue has been fixed and does not reproduce, but no test has been added. F-associated_type_bounds `#![feature(associated_type_bounds)]` 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) ❄️ regression-from-stable-to-stable Performance or correctness regression from one stable version to another. 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.

8 participants