Skip to content

let a: Vec<&str, "aaa"> = Vec::new(); emits internal compiler error #58811

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
rchaser53 opened this issue Feb 28, 2019 · 3 comments
Closed

let a: Vec<&str, "aaa"> = Vec::new(); emits internal compiler error #58811

rchaser53 opened this issue Feb 28, 2019 · 3 comments
Assignees
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

@rchaser53
Copy link
Contributor

The below code emits unexpectedly panicked in 1.34.0-nightly(2019-02-27).

let a: Vec<&str, "aaa"> = Vec::new();

Error message:

error: internal compiler error: src/librustc_typeck/collect.rs:1321: unexpected const parent in type_of_def_id(): Ty(type(Vec<&str, >))

thread 'rustc' panicked at 'Box<Any>', src/librustc_errors/lib.rs:620:9
note: Run with `RUST_BACKTRACE=1` environment variable to display a backtrace.
error: aborting due to previous error

Playground link:
https://play.rust-lang.org/?version=nightly&mode=debug&edition=2018&gist=916dc66418a31a3a104e88b0e070b6c8

@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 Feb 28, 2019
@oli-obk
Copy link
Contributor

oli-obk commented Feb 28, 2019

cc @varkor

@hellow554
Copy link
Contributor

nightly-2019-02-01 (no-ice):

error: expected one of `>`, identifier, lifetime, or type, found `"aaa"`
 --> src/main.rs:2:22
  |
2 |     let a: Vec<&str, "aaa"> = Vec::new();
  |         --           ^^^^^ expected one of `>`, identifier, lifetime, or type here
  |         ||
  |         |help: use `=` if you meant to assign
  |         while parsing the type for `a`

error: expected one of `!`, `.`, `::`, `;`, `?`, `{`, or an operator, found `,`
 --> src/main.rs:2:20
  |
2 |     let a: Vec<&str, "aaa"> = Vec::new();
  |                    ^ expected one of 7 possible tokens here

nightly-2019-02-15 (no ICE):

error: const generics in any position are currently unsupported
 --> src/main.rs:2:22
  |
2 |     let a: Vec<&str, "aaa"> = Vec::new();
  |                      ^^^^^

nightly-2019-02-21 (ICE):

error: internal compiler error: src/librustc_typeck/collect.rs:1320: unexpected const parent in type_of_def_id(): Ty(type(Vec<&str, >))

thread 'rustc' panicked at 'Box<Any>', src/librustc_errors/lib.rs:620:9
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::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::type_of
  15: rustc::ty::query::__query_compute::type_of
  16: rustc::ty::query::<impl rustc::ty::query::config::QueryAccessors<'tcx> for rustc::ty::query::queries::type_of<'tcx>>::compute
  17: rustc::dep_graph::graph::DepGraph::with_task_impl
  18: rustc::ty::query::plumbing::<impl rustc::ty::context::TyCtxt<'a, 'gcx, 'tcx>>::get_query
  19: rustc::ty::context::GlobalCtxt::enter_local
  20: rustc_typeck::check::typeck_tables_of
  21: rustc::ty::query::__query_compute::typeck_tables_of
  22: rustc::ty::query::<impl rustc::ty::query::config::QueryAccessors<'tcx> for rustc::ty::query::queries::typeck_tables_of<'tcx>>::compute
  23: rustc::dep_graph::graph::DepGraph::with_task_impl
  24: rustc::ty::query::plumbing::<impl rustc::ty::context::TyCtxt<'a, 'gcx, 'tcx>>::get_query
  25: rustc::ty::<impl rustc::ty::context::TyCtxt<'a, 'gcx, 'tcx>>::par_body_owners
  26: rustc_typeck::check::typeck_item_bodies
  27: rustc::ty::query::__query_compute::typeck_item_bodies
  28: rustc::ty::query::<impl rustc::ty::query::config::QueryAccessors<'tcx> for rustc::ty::query::queries::typeck_item_bodies<'tcx>>::compute
  29: rustc::dep_graph::graph::DepGraph::with_task_impl
  30: rustc::ty::query::plumbing::<impl rustc::ty::context::TyCtxt<'a, 'gcx, 'tcx>>::get_query
  31: rustc::util::common::time
  32: rustc_typeck::check_crate
  33: <std::thread::local::LocalKey<T>>::with
  34: rustc::ty::context::TyCtxt::create_and_enter
  35: rustc_driver::driver::compile_input
  36: rustc_driver::run_compiler_with_pool
  37: <scoped_tls::ScopedKey<T>>::set
  38: rustc_driver::run_compiler
  39: syntax::with_globals
  40: __rust_maybe_catch_panic
             at src/libpanic_unwind/lib.rs:87
  41: <F as alloc::boxed::FnBox<A>>::call_box
  42: std::sys::unix::thread::Thread::new::thread_start
             at /rustc/f66e4697ae286985ddefc53c3a047614568458bb/src/liballoc/boxed.rs:749
             at src/libstd/sys_common/thread.rs:14
             at src/libstd/sys/unix/thread.rs:81
  43: start_thread
  44: __clone
query stack during panic:
#0 [type_of] processing `main::{{constant}}`
#1 [typeck_tables_of] processing `main::{{constant}}`
#2 [typeck_item_bodies] type-checking all item bodies
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.34.0-nightly (f66e4697a 2019-02-20) running on x86_64-unknown-linux-gnu

So the bug was introduced between 146aa60...f66e469

@varkor
Copy link
Member

varkor commented Mar 2, 2019

This is fall out from the recent const generics changes. I'll be simpler to fix when #58583 has been merged.

@varkor varkor self-assigned this Mar 2, 2019
pietroalbini added a commit to pietroalbini/rust that referenced this issue Mar 8, 2019
…trochenkov

Add a test for invalid const arguments

Closes rust-lang#58811.
# for free to join this conversation on GitHub. Already have an account? # 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

5 participants