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 with Self in default generic type argument #59353

Closed
RustyYato opened this issue Mar 21, 2019 · 2 comments
Closed

ICE with Self in default generic type argument #59353

RustyYato opened this issue Mar 21, 2019 · 2 comments
Labels
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.

Comments

@RustyYato
Copy link
Contributor

I found this ICE when trying to generalize some of my code.

This works on the latest stable, and on playground

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

pub struct Node<NodeRef = Box<Self>>(NodeRef);

pub struct Foo(Node);

And generates the following ICE

thread 'rustc' panicked at 'Box<Any>', src/librustc_errors/lib.rs:526: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
             at src/libstd/sys/unix/backtrace/tracing/gcc_s.rs:39
   1: std::sys_common::backtrace::_print
             at src/libstd/sys_common/backtrace.rs:70
   2: std::panicking::default_hook::{{closure}}
             at src/libstd/sys_common/backtrace.rs:58
             at src/libstd/panicking.rs:200
   3: std::panicking::default_hook
             at src/libstd/panicking.rs:215
   4: rustc::util::common::panic_hook
   5: std::panicking::rust_panic_with_hook
             at src/libstd/panicking.rs:482
   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<'a, 'gcx, 'tcx> as rustc::ty::fold::TypeFolder<'gcx, 'tcx>>::fold_ty
  15: <smallvec::SmallVec<A> as core::iter::traits::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<'tcx> for &'tcx rustc::ty::TyS<'tcx>>::super_fold_with
  18: <rustc::ty::subst::SubstFolder<'a, 'gcx, 'tcx> as rustc::ty::fold::TypeFolder<'gcx, 'tcx>>::fold_ty
  19: <smallvec::SmallVec<A> as core::iter::traits::FromIterator<<A as smallvec::Array>::Item>>::from_iter
  20: rustc::ty::fold::TypeFoldable::fold_with
  21: rustc::ty::structural_impls::<impl rustc::ty::fold::TypeFoldable<'tcx> for &'tcx rustc::ty::TyS<'tcx>>::super_fold_with
  22: <rustc::ty::subst::SubstFolder<'a, 'gcx, 'tcx> as rustc::ty::fold::TypeFolder<'gcx, 'tcx>>::fold_ty
  23: <(dyn rustc_typeck::astconv::AstConv<'gcx, 'tcx> + 'o)>::create_substs_for_ast_path::{{closure}}
  24: <(dyn rustc_typeck::astconv::AstConv<'gcx, 'tcx> + 'o)>::create_substs_for_ast_path
  25: rustc::hir::PathSegment::with_generic_args
  26: <(dyn rustc_typeck::astconv::AstConv<'gcx, 'tcx> + 'o)>::ast_path_substs_for_ty
  27: <(dyn rustc_typeck::astconv::AstConv<'gcx, 'tcx> + 'o)>::ast_path_to_ty
  28: <(dyn rustc_typeck::astconv::AstConv<'gcx, 'tcx> + 'o)>::def_to_ty
  29: <(dyn rustc_typeck::astconv::AstConv<'gcx, 'tcx> + 'o)>::ast_ty_to_ty
  30: rustc_typeck::collect::type_of
  31: rustc::ty::query::__query_compute::type_of
  32: rustc::ty::query::<impl rustc::ty::query::config::QueryAccessors<'tcx> for rustc::ty::query::queries::type_of<'tcx>>::compute
  33: rustc::dep_graph::graph::DepGraph::with_task_impl
  34: rustc::ty::query::plumbing::<impl rustc::ty::context::TyCtxt<'a, 'gcx, 'tcx>>::try_get_with
  35: <rustc_typeck::outlives::implicit_infer::InferVisitor<'cx, 'tcx> as rustc::hir::itemlikevisit::ItemLikeVisitor<'tcx>>::visit_item
  36: rustc_typeck::outlives::implicit_infer::infer_predicates
  37: rustc_typeck::outlives::inferred_outlives_crate
  38: rustc::ty::query::__query_compute::inferred_outlives_crate
  39: rustc::ty::query::<impl rustc::ty::query::config::QueryAccessors<'tcx> for rustc::ty::query::queries::inferred_outlives_crate<'tcx>>::compute
  40: rustc::dep_graph::graph::DepGraph::with_task_impl
  41: rustc::ty::query::plumbing::<impl rustc::ty::context::TyCtxt<'a, 'gcx, 'tcx>>::try_get_with
  42: rustc_typeck::outlives::inferred_outlives_of
  43: rustc::ty::query::__query_compute::inferred_outlives_of
  44: rustc::ty::query::<impl rustc::ty::query::config::QueryAccessors<'tcx> for rustc::ty::query::queries::inferred_outlives_of<'tcx>>::compute
  45: rustc::dep_graph::graph::DepGraph::with_task_impl
  46: rustc::ty::query::plumbing::<impl rustc::ty::context::TyCtxt<'a, 'gcx, 'tcx>>::try_get_with
  47: rustc_typeck::collect::predicates_defined_on
  48: rustc::ty::query::__query_compute::predicates_defined_on
  49: rustc::ty::query::<impl rustc::ty::query::config::QueryAccessors<'tcx> for rustc::ty::query::queries::predicates_defined_on<'tcx>>::compute
  50: rustc::dep_graph::graph::DepGraph::with_task_impl
  51: rustc::ty::query::plumbing::<impl rustc::ty::context::TyCtxt<'a, 'gcx, 'tcx>>::try_get_with
  52: rustc_typeck::collect::predicates_of
  53: rustc::ty::query::__query_compute::predicates_of
  54: rustc::ty::query::<impl rustc::ty::query::config::QueryAccessors<'tcx> for rustc::ty::query::queries::predicates_of<'tcx>>::compute
  55: rustc::dep_graph::graph::DepGraph::with_task_impl
  56: rustc::ty::query::plumbing::<impl rustc::ty::context::TyCtxt<'a, 'gcx, 'tcx>>::try_get_with
  57: <rustc_typeck::collect::CollectItemTypesVisitor<'a, 'tcx> as rustc::hir::intravisit::Visitor<'tcx>>::visit_item
  58: rustc::hir::map::Map::visit_item_likes_in_module
  59: rustc_typeck::collect::collect_mod_item_types
  60: rustc::ty::query::<impl rustc::ty::query::config::QueryAccessors<'tcx> for rustc::ty::query::queries::collect_mod_item_types<'tcx>>::compute
  61: rustc::dep_graph::graph::DepGraph::with_task_impl
  62: rustc::ty::query::plumbing::<impl rustc::ty::context::TyCtxt<'a, 'gcx, 'tcx>>::try_get_with
  63: rustc::ty::query::plumbing::<impl rustc::ty::context::TyCtxt<'a, 'gcx, 'tcx>>::ensure_query
  64: rustc_typeck::collect::collect_item_types
  65: rustc::util::common::time
  66: rustc_typeck::check_crate
  67: <std::thread::local::LocalKey<T>>::with
  68: rustc::ty::context::TyCtxt::create_and_enter
  69: rustc_driver::driver::compile_input
  70: rustc_driver::run_compiler_with_pool
  71: <scoped_tls::ScopedKey<T>>::set
  72: rustc_driver::run_compiler
  73: <scoped_tls::ScopedKey<T>>::set
query stack during panic:
#0 [type_of] processing `Foo::0`
#1 [inferred_outlives_crate] computing the inferred outlives predicates for items in this crate
#2 [inferred_outlives_of] processing `Node`
#3 [predicates_defined_on] processing `Node`
#4 [predicates_of] processing `Node`
#5 [collect_mod_item_types] collecting item types in top-level module
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.33.0 (2aa4c46cf 2019-02-28) running on x86_64-unknown-linux-gnu

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

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

error: Could not compile `playground`.

To learn more, run the command again with --verbose.
@jonas-schievink jonas-schievink added 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. C-bug Category: This is a bug. labels Mar 22, 2019
@varkor varkor changed the title ICE ICE with Self in type alias Mar 25, 2019
@varkor varkor changed the title ICE with Self in type alias ICE with Self in generic parameter Mar 25, 2019
@varkor
Copy link
Member

varkor commented Mar 25, 2019

Even simpler:

struct Node<A = Self>(A);
type Foo = Node;

@varkor varkor changed the title ICE with Self in generic parameter ICE with Self in default generic type argument Mar 25, 2019
@Alexendoo
Copy link
Member

This was fixed by #64842, including a similar test

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
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.
Projects
None yet
Development

No branches or pull requests

4 participants