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 const generics in array definition: unexpected const parent path def #60650

Closed
IsaacWoods opened this issue May 8, 2019 · 0 comments · Fixed by #60710
Closed

ICE with const generics in array definition: unexpected const parent path def #60650

IsaacWoods opened this issue May 8, 2019 · 0 comments · Fixed by #60710
Assignees
Labels
A-const-generics Area: const generics (parameters and arguments) 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

@IsaacWoods
Copy link
Contributor

IsaacWoods commented May 8, 2019

The following code snippet (playground link):

#![feature(const_generics)]

struct Foo<const NUM_BYTES: usize>(pub [u8; NUM_BYTES]);

fn main() {
    let foo = Foo::<3>([1, 2, 3]);
}

ICEs with the following error:

   Compiling playground v0.0.1 (/playground)
warning: the feature `const_generics` is incomplete and may cause the compiler to crash
 --> src/main.rs:1:12
  |
1 | #![feature(const_generics)]
  |            ^^^^^^^^^^^^^^

error: internal compiler error: src/librustc_typeck/collect.rs:1407: unexpected const parent path def Def(Ctor(Struct, Fn), DefId(0/1:9 ~ playground[c276]::Foo[0]::{{constructor}}[0]))

thread 'rustc' panicked at 'Box<Any>', src/librustc_errors/lib.rs:637: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:71
   2: std::panicking::default_hook::{{closure}}
             at src/libstd/sys_common/backtrace.rs:59
             at src/libstd/panicking.rs:197
   3: std::panicking::default_hook
             at src/libstd/panicking.rs:211
   4: rustc::util::common::panic_hook
   5: std::panicking::rust_panic_with_hook
             at src/libstd/panicking.rs:478
   6: std::panicking::begin_panic
   7: rustc_errors::Handler::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::bug_fmt
  14: rustc_typeck::collect::checked_type_of
  15: rustc_typeck::collect::type_of
  16: rustc::ty::query::<impl rustc::ty::query::config::QueryAccessors for rustc::ty::query::queries::type_of>::compute
  17: rustc::dep_graph::graph::DepGraph::with_task_impl
  18: rustc::ty::query::plumbing::<impl rustc::ty::context::TyCtxt>::get_query
  19: rustc::ty::instance::Instance::resolve
  20: <rustc::traits::project::AssociatedTypeNormalizer as rustc::ty::fold::TypeFolder>::fold_const
  21: <smallvec::SmallVec<A> as core::iter::traits::collect::FromIterator<<A as smallvec::Array>::Item>>::from_iter
  22: rustc::ty::fold::TypeFoldable::fold_with
  23: rustc::ty::structural_impls::<impl rustc::ty::fold::TypeFoldable for &rustc::ty::TyS>::super_fold_with
  24: <rustc::traits::project::AssociatedTypeNormalizer as rustc::ty::fold::TypeFolder>::fold_ty
  25: rustc::traits::project::normalize
  26: rustc_typeck::check::FnCtxt::instantiate_value_path
  27: rustc_typeck::check::FnCtxt::check_expr_kind
  28: rustc_typeck::check::FnCtxt::check_expr_with_expectation_and_needs
  29: rustc_typeck::check::callee::<impl rustc_typeck::check::FnCtxt>::check_call
  30: rustc_typeck::check::FnCtxt::check_expr_kind
  31: rustc_typeck::check::FnCtxt::check_expr_with_expectation_and_needs
  32: rustc_typeck::check::FnCtxt::check_decl_initializer
  33: rustc_typeck::check::FnCtxt::check_decl_local
  34: rustc_typeck::check::FnCtxt::check_stmt
  35: rustc_typeck::check::FnCtxt::check_block_with_expected
  36: rustc_typeck::check::FnCtxt::check_expr_kind
  37: rustc_typeck::check::FnCtxt::check_expr_with_expectation_and_needs
  38: rustc_typeck::check::FnCtxt::check_return_expr
  39: rustc_typeck::check::check_fn
  40: rustc::ty::context::GlobalCtxt::enter_local
  41: rustc_typeck::check::typeck_tables_of
  42: rustc::ty::query::__query_compute::typeck_tables_of
  43: rustc::ty::query::<impl rustc::ty::query::config::QueryAccessors for rustc::ty::query::queries::typeck_tables_of>::compute
  44: rustc::dep_graph::graph::DepGraph::with_task_impl
  45: rustc::ty::query::plumbing::<impl rustc::ty::context::TyCtxt>::get_query
  46: rustc::ty::<impl rustc::ty::context::TyCtxt>::par_body_owners
  47: rustc_typeck::check::typeck_item_bodies
  48: rustc::ty::query::__query_compute::typeck_item_bodies
  49: rustc::ty::query::<impl rustc::ty::query::config::QueryAccessors for rustc::ty::query::queries::typeck_item_bodies>::compute
  50: rustc::dep_graph::graph::DepGraph::with_task_impl
  51: rustc::ty::query::plumbing::<impl rustc::ty::context::TyCtxt>::get_query
  52: rustc::util::common::time
  53: rustc_typeck::check_crate
  54: rustc_interface::passes::analysis
  55: rustc::ty::query::__query_compute::analysis
  56: rustc::ty::query::<impl rustc::ty::query::config::QueryAccessors for rustc::ty::query::queries::analysis>::compute
  57: rustc::dep_graph::graph::DepGraph::with_task_impl
  58: rustc::ty::query::plumbing::<impl rustc::ty::context::TyCtxt>::get_query
  59: rustc::ty::context::tls::enter_global
  60: rustc_interface::passes::BoxedGlobalCtxt::access::{{closure}}
  61: rustc_interface::passes::create_global_ctxt::{{closure}}
  62: rustc_interface::passes::BoxedGlobalCtxt::enter
  63: rustc_interface::interface::run_compiler_in_existing_thread_pool
  64: std::thread::local::LocalKey<T>::with
  65: scoped_tls::ScopedKey<T>::set
query stack during panic:
#0 [type_of] processing `main::{{constant}}#0`
#1 [typeck_tables_of] processing `main`
#2 [typeck_item_bodies] type-checking all item bodies
#3 [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 (cfdc84a00 2019-05-07) running on x86_64-unknown-linux-gnu

note: compiler flags: -C codegen-units=1 -C debuginfo=2 --crate-type bin
@Centril Centril added A-const-generics Area: const generics (parameters and arguments) 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 May 8, 2019
Centril added a commit to Centril/rust that referenced this issue May 13, 2019
… r=matthewjasper

Use `delay_span_bug` for error cases when checking `AnonConst` parent

Fixes rust-lang#60704.
Fixes rust-lang#60650.
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
A-const-generics Area: const generics (parameters and arguments) 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.

3 participants