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

ICE: enum Foo<T=Self> { }: type parameter T/#0 (T/0) out of range when substituting #61918

Closed
ConnorGray opened this issue Jun 17, 2019 · 1 comment

Comments

@ConnorGray
Copy link

The following code triggers an ICE:

enum MyVariants<T=Self> { }

struct Use(MyVariants)

Related issues: #33070, #61808, #59956

rustc version

rustc 1.36.0-nightly (d628c2e 2019-05-05)
binary: rustc
commit-hash: d628c2e
commit-date: 2019-05-05
host: x86_64-apple-darwin
release: 1.36.0-nightly
LLVM version: 8.0

Playground link

https://play.rust-lang.org/?version=stable&mode=debug&edition=2018&gist=7cab718ccb3318a61d01decb71e0d7ce

Backtrace

error: internal compiler error: src/librustc/ty/subst.rs:569: type parameter `T/#0` (T/0) out of range when substituting (root type=Some(MyVariants<T>)) substs=[]
 --> test.rs:3:12
  |
3 | struct Use(MyVariants);
  |            ^^^^^^^^^^

thread 'rustc' panicked at 'Box<Any>', src/librustc_errors/lib.rs:578:9
note: Some details are omitted, run with `RUST_BACKTRACE=full` for a verbose backtrace.
stack backtrace:
   0: std::sys::unix::backtrace::tracing::imp::unwind_backtrace
   1: std::sys_common::backtrace::_print
   2: std::panicking::default_hook::{{closure}}
   3: std::panicking::default_hook
   4: rustc::util::common::panic_hook
   5: std::panicking::rust_panic_with_hook
   6: std::panicking::begin_panic
   7: rustc_errors::Handler::span_bug
   8: rustc::util::bug::opt_span_bug_fmt::{{closure}}
   9: rustc::ty::context::tls::with_opt::{{closure}}
  10: rustc::ty::context::tls::with_context_opt
  11: rustc::ty::context::tls::with_opt
  12: rustc::util::bug::opt_span_bug_fmt
  13: rustc::util::bug::span_bug_fmt
  14: <rustc::ty::subst::SubstFolder as rustc::ty::fold::TypeFolder>::fold_ty
  15: <smallvec::SmallVec<A> as core::iter::traits::collect::FromIterator<<A as smallvec::Array>::Item>>::from_iter
  16: rustc::ty::fold::TypeFoldable::fold_with
  17: rustc::ty::structural_impls::<impl rustc::ty::fold::TypeFoldable for &rustc::ty::TyS>::super_fold_with
  18: <rustc::ty::subst::SubstFolder as rustc::ty::fold::TypeFolder>::fold_ty
  19: <dyn +rustc_typeck::astconv::AstConv>::create_substs_for_ast_path::{{closure}}
  20: <dyn +rustc_typeck::astconv::AstConv>::create_substs_for_ast_path
  21: rustc::hir::PathSegment::with_generic_args
  22: <dyn +rustc_typeck::astconv::AstConv>::ast_path_substs_for_ty
  23: <dyn +rustc_typeck::astconv::AstConv>::res_to_ty
  24: <dyn +rustc_typeck::astconv::AstConv>::ast_ty_to_ty
  25: rustc_typeck::collect::checked_type_of
  26: rustc_typeck::collect::type_of
  27: rustc::ty::query::__query_compute::type_of
  28: rustc::ty::query::<impl rustc::ty::query::config::QueryAccessors for rustc::ty::query::queries::type_of>::compute
  29: rustc::dep_graph::graph::DepGraph::with_task_impl
  30: rustc::ty::query::plumbing::<impl rustc::ty::context::TyCtxt>::get_query
  31: <rustc_typeck::outlives::implicit_infer::InferVisitor as rustc::hir::itemlikevisit::ItemLikeVisitor>::visit_item
  32: rustc::hir::Crate::visit_all_item_likes
  33: rustc_typeck::outlives::inferred_outlives_crate
  34: rustc::ty::query::__query_compute::inferred_outlives_crate
  35: rustc::ty::query::<impl rustc::ty::query::config::QueryAccessors for rustc::ty::query::queries::inferred_outlives_crate>::compute
  36: rustc::dep_graph::graph::DepGraph::with_task_impl
  37: rustc::ty::query::plumbing::<impl rustc::ty::context::TyCtxt>::get_query
  38: rustc_typeck::outlives::inferred_outlives_of
  39: rustc::ty::query::__query_compute::inferred_outlives_of
  40: rustc::ty::query::<impl rustc::ty::query::config::QueryAccessors for rustc::ty::query::queries::inferred_outlives_of>::compute
  41: rustc::dep_graph::graph::DepGraph::with_task_impl
  42: rustc::ty::query::plumbing::<impl rustc::ty::context::TyCtxt>::get_query
  43: rustc_typeck::collect::predicates_defined_on
  44: rustc::ty::query::__query_compute::predicates_defined_on
  45: rustc::ty::query::<impl rustc::ty::query::config::QueryAccessors for rustc::ty::query::queries::predicates_defined_on>::compute
  46: rustc::dep_graph::graph::DepGraph::with_task_impl
  47: rustc::ty::query::plumbing::<impl rustc::ty::context::TyCtxt>::get_query
  48: rustc_typeck::collect::predicates_of
  49: rustc::ty::query::__query_compute::predicates_of
  50: rustc::ty::query::<impl rustc::ty::query::config::QueryAccessors for rustc::ty::query::queries::predicates_of>::compute
  51: rustc::dep_graph::graph::DepGraph::with_task_impl
  52: rustc::ty::query::plumbing::<impl rustc::ty::context::TyCtxt>::get_query
  53: <rustc_typeck::collect::CollectItemTypesVisitor as rustc::hir::intravisit::Visitor>::visit_item
  54: rustc::hir::map::Map::visit_item_likes_in_module
  55: rustc_typeck::collect::collect_mod_item_types
  56: rustc::ty::query::__query_compute::collect_mod_item_types
  57: rustc::ty::query::<impl rustc::ty::query::config::QueryAccessors for rustc::ty::query::queries::collect_mod_item_types>::compute
  58: rustc::dep_graph::graph::DepGraph::with_task_impl
  59: rustc::ty::query::plumbing::<impl rustc::ty::context::TyCtxt>::get_query
  60: rustc_typeck::check_crate::{{closure}}::{{closure}}
  61: rustc::util::common::time
  62: rustc_typeck::check_crate
  63: rustc_interface::passes::analysis
  64: rustc::ty::query::__query_compute::analysis
  65: rustc::ty::query::<impl rustc::ty::query::config::QueryAccessors for rustc::ty::query::queries::analysis>::compute
  66: rustc::dep_graph::graph::DepGraph::with_task_impl
  67: rustc::ty::query::plumbing::<impl rustc::ty::context::TyCtxt>::get_query
  68: rustc::ty::context::tls::enter_global
  69: rustc_interface::passes::BoxedGlobalCtxt::access::{{closure}}
  70: rustc_interface::passes::create_global_ctxt::{{closure}}
  71: rustc_interface::passes::BoxedGlobalCtxt::enter
  72: rustc_interface::interface::run_compiler_in_existing_thread_pool
  73: std::thread::local::LocalKey<T>::with
  74: scoped_tls::ScopedKey<T>::set
  75: syntax::with_globals
query stack during panic:
#0 [type_of] processing `Use::0`
#1 [inferred_outlives_crate] computing the inferred outlives predicates for items in this crate
#2 [inferred_outlives_of] processing `MyVariants`
#3 [predicates_defined_on] processing `MyVariants`
#4 [predicates_of] processing `MyVariants`
#5 [collect_mod_item_types] collecting item types in top-level module
#6 [analysis] running analysis passes on this crate
end of query stack
error: aborting due to previous error


note: the compiler unexpectedly panicked. this is a bug.

note: we would appreciate a bug report: https://github.com/rust-lang/rust/blob/master/CONTRIBUTING.md#bug-reports

note: rustc 1.36.0-nightly (d628c2e64 2019-05-05) running on x86_64-apple-darwin
@jonas-schievink
Copy link
Contributor

Duplicate of #59956 (comment)

@jonas-schievink jonas-schievink marked this as a duplicate of #59956 Jun 17, 2019
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

2 participants