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: min const gen default_function_param.rs with -Zsave-analysis; hit a todo!() #80589

Closed
matthiaskrgr opened this issue Jan 1, 2021 · 8 comments · Fixed by #80599
Closed
Assignees
Labels
A-const-generics Area: const generics (parameters and arguments) 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

@matthiaskrgr
Copy link
Member

Code

code from ./src/test/ui/const-generics/min_const_generics/default_function_param.rs

fn foo<const SIZE: usize = 5>() {}
//~^ ERROR default values for const generic parameters are experimental

fn main() {}

Meta

rustc --version --verbose:

rustc 1.51.0-nightly (a609fb45e 2021-01-01)
binary: rustc
commit-hash: a609fb45efad59dfd459c76e50899be9f0583b5a
commit-date: 2021-01-01
host: x86_64-unknown-linux-gnu
release: 1.51.0-nightly

Error output

rustc ./src/test/ui/const-generics/min_const_generics/default_function_param.rs -Zsave-analysis

error[E0658]: default values for const generic parameters are experimental
 --> ./src/test/ui/const-generics/min_const_generics/default_function_param.rs:1:26
  |
1 | fn foo<const SIZE: usize = 5>() {}
  |                          ^^^
  |
  = note: see issue #44580 <https://github.com/rust-lang/rust/issues/44580> for more information
  = help: add `#![feature(const_generics_defaults)]` to the crate attributes to enable

thread 'rustc' panicked at 'not yet implemented', compiler/rustc_hir_pretty/src/lib.rs:2213:21
note: run with `RUST_BACKTRACE=1` environment variable to display a backtrace

error: internal compiler error: unexpected panic

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.51.0-nightly (a609fb45e 2021-01-01) running on x86_64-unknown-linux-gnu

note: compiler flags: -Z save-analysis

query stack during panic:
end of query stack
error: aborting due to previous error
Backtrace

error[E0658]: default values for const generic parameters are experimental
 --> ./src/test/ui/const-generics/min_const_generics/default_function_param.rs:1:26
  |
1 | fn foo<const SIZE: usize = 5>() {}
  |                          ^^^
  |
  = note: see issue #44580 <https://github.com/rust-lang/rust/issues/44580> for more information
  = help: add `#![feature(const_generics_defaults)]` to the crate attributes to enable

thread 'rustc' panicked at 'not yet implemented', compiler/rustc_hir_pretty/src/lib.rs:2213:21
stack backtrace:
   0:     0x7eff390067f7 - std::backtrace_rs::backtrace::libunwind::trace::h746c3e9529d524bc
                               at /rustc/a609fb45efad59dfd459c76e50899be9f0583b5a/library/std/src/../../backtrace/src/backtrace/libunwind.rs:90:5
   1:     0x7eff390067f7 - std::backtrace_rs::backtrace::trace_unsynchronized::h84373278bfb39e0c
                               at /rustc/a609fb45efad59dfd459c76e50899be9f0583b5a/library/std/src/../../backtrace/src/backtrace/mod.rs:66:5
   2:     0x7eff390067f7 - std::sys_common::backtrace::_print_fmt::h517324efde750597
                               at /rustc/a609fb45efad59dfd459c76e50899be9f0583b5a/library/std/src/sys_common/backtrace.rs:67:5
   3:     0x7eff390067f7 - <std::sys_common::backtrace::_print::DisplayBacktrace as core::fmt::Display>::fmt::hf594ab77fac89284
                               at /rustc/a609fb45efad59dfd459c76e50899be9f0583b5a/library/std/src/sys_common/backtrace.rs:46:22
   4:     0x7eff3907707c - core::fmt::write::h3868db8542c90941
                               at /rustc/a609fb45efad59dfd459c76e50899be9f0583b5a/library/core/src/fmt/mod.rs:1078:17
   5:     0x7eff38ff8732 - std::io::Write::write_fmt::h3f6656f045fa877f
                               at /rustc/a609fb45efad59dfd459c76e50899be9f0583b5a/library/std/src/io/mod.rs:1519:15
   6:     0x7eff3900a4c5 - std::sys_common::backtrace::_print::hda7655c057c24dcc
                               at /rustc/a609fb45efad59dfd459c76e50899be9f0583b5a/library/std/src/sys_common/backtrace.rs:49:5
   7:     0x7eff3900a4c5 - std::sys_common::backtrace::print::h546a6c8431d46287
                               at /rustc/a609fb45efad59dfd459c76e50899be9f0583b5a/library/std/src/sys_common/backtrace.rs:36:9
   8:     0x7eff3900a4c5 - std::panicking::default_hook::{{closure}}::h006dd083853faf51
                               at /rustc/a609fb45efad59dfd459c76e50899be9f0583b5a/library/std/src/panicking.rs:208:50
   9:     0x7eff3900a023 - std::panicking::default_hook::hf0f9afb1017317fc
                               at /rustc/a609fb45efad59dfd459c76e50899be9f0583b5a/library/std/src/panicking.rs:225:9
  10:     0x7eff39870d7b - rustc_driver::report_ice::h1a7ab7fc7b8fd641
  11:     0x7eff3900adc6 - std::panicking::rust_panic_with_hook::hb7a19826c029b1d6
                               at /rustc/a609fb45efad59dfd459c76e50899be9f0583b5a/library/std/src/panicking.rs:595:17
  12:     0x7eff3900a8b7 - std::panicking::begin_panic_handler::{{closure}}::hde71edcd925d0c5e
                               at /rustc/a609fb45efad59dfd459c76e50899be9f0583b5a/library/std/src/panicking.rs:495:13
  13:     0x7eff39006cbc - std::sys_common::backtrace::__rust_end_short_backtrace::h8a3c7d6cea578919
                               at /rustc/a609fb45efad59dfd459c76e50899be9f0583b5a/library/std/src/sys_common/backtrace.rs:141:18
  14:     0x7eff3900a849 - rust_begin_unwind
                               at /rustc/a609fb45efad59dfd459c76e50899be9f0583b5a/library/std/src/panicking.rs:493:5
  15:     0x7eff39073491 - core::panicking::panic_fmt::h20225113c4a2f8fd
                               at /rustc/a609fb45efad59dfd459c76e50899be9f0583b5a/library/core/src/panicking.rs:92:14
  16:     0x7eff390733dd - core::panicking::panic::h35b77276aa4b0c12
                               at /rustc/a609fb45efad59dfd459c76e50899be9f0583b5a/library/core/src/panicking.rs:50:5
  17:     0x7eff3c57f911 - rustc_hir_pretty::State::print_generic_param::hd8812d315557112e
  18:     0x7eff3c57eca7 - rustc_hir_pretty::State::print_fn::ha258831860e35fdc
  19:     0x7eff3a734d69 - rustc_hir_pretty::fn_to_string::heb16094ac8eb6cc1
  20:     0x7eff3993f151 - rustc_save_analysis::SaveContext::get_item_data::h613d670ea0200403
  21:     0x7eff39902dfd - rustc_save_analysis::dump_visitor::DumpVisitor::nest_typeck_results::h114f5114a3c28d99
  22:     0x7eff3990a099 - <rustc_save_analysis::dump_visitor::DumpVisitor as rustc_hir::intravisit::Visitor>::visit_item::he0dee11491c724ce
  23:     0x7eff399029db - rustc_hir::intravisit::Visitor::visit_nested_item::hf6f73835cb897cfb
  24:     0x7eff398ff728 - rustc_hir::intravisit::walk_mod::ha2c7e2ed768801fb
  25:     0x7eff398fd4dc - rustc_hir::intravisit::walk_crate::h5b7f70143ed60840
  26:     0x7eff39907931 - rustc_save_analysis::dump_visitor::DumpVisitor::process_crate::h301363fa601878d8
  27:     0x7eff39891c02 - rustc_middle::dep_graph::<impl rustc_query_system::dep_graph::DepKind for rustc_middle::dep_graph::dep_node::DepKind>::with_deps::hecbe1c981a3d1645
  28:     0x7eff3984416c - rustc_query_system::dep_graph::graph::DepGraph<K>::with_ignore::haf999b076cc51b06
  29:     0x7eff3988bbc0 - std::thread::local::LocalKey<T>::with::h6189453ff16a3ad6
  30:     0x7eff39825001 - rustc_middle::ty::print::pretty::with_no_trimmed_paths::hcee8e8312b0e3c9f
  31:     0x7eff3987adb0 - rustc_save_analysis::process_crate::h9c33b20cd91148c4
  32:     0x7eff39825790 - rustc_session::utils::<impl rustc_session::session::Session>::time::h29df338d6ea41b3f
  33:     0x7eff3bd427d7 - rustc_interface::queries::<impl rustc_interface::interface::Compiler>::enter::h27c18adf15a8e2d0
  34:     0x7eff3bd375f4 - rustc_span::with_source_map::ha7a34f5cae8f35d5
  35:     0x7eff3bd432ca - rustc_interface::interface::create_compiler_and_run::hadd076a85b89b30e
  36:     0x7eff3bd37c75 - rustc_span::with_session_globals::h26daa206ff282381
  37:     0x7eff3bd3e01a - std::sys_common::backtrace::__rust_begin_short_backtrace::ha90536c1bc8de518
  38:     0x7eff3bd1bb3a - core::ops::function::FnOnce::call_once{{vtable.shim}}::hbab19004a901562d
  39:     0x7eff3901afea - <alloc::boxed::Box<F,A> as core::ops::function::FnOnce<Args>>::call_once::hea1090dbdcecbf5a
                               at /rustc/a609fb45efad59dfd459c76e50899be9f0583b5a/library/alloc/src/boxed.rs:1482:9
  40:     0x7eff3901afea - <alloc::boxed::Box<F,A> as core::ops::function::FnOnce<Args>>::call_once::h8d5723d3912bd325
                               at /rustc/a609fb45efad59dfd459c76e50899be9f0583b5a/library/alloc/src/boxed.rs:1482:9
  41:     0x7eff3901afea - std::sys::unix::thread::Thread::new::thread_start::hc17a425ca2995724
                               at /rustc/a609fb45efad59dfd459c76e50899be9f0583b5a/library/std/src/sys/unix/thread.rs:71:17
  42:     0x7eff38f0b3e9 - start_thread
  43:     0x7eff38e28293 - __GI___clone
  44:                0x0 - <unknown>

error: internal compiler error: unexpected panic

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.51.0-nightly (a609fb45e 2021-01-01) running on x86_64-unknown-linux-gnu

note: compiler flags: -Z save-analysis

query stack during panic:
end of query stack
error: aborting due to previous error

For more information about this error, try `rustc --explain E0658`.

This happens since
a609fb4
cc @lqd

@matthiaskrgr matthiaskrgr 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 Jan 1, 2021
@lqd lqd self-assigned this Jan 1, 2021
@lqd
Copy link
Member

lqd commented Jan 1, 2021

Oh my, I'll fix that now. The syntax is gated but evidently the -Zsave-analysis flag can still reach into the parts which were not completed yet.


Update: Ah but I misread the code, this is actually using const generics defaults. They're not done yet, ICE-ing is expected until the feature is completed in #75384. @matthiaskrgr how did you hit that ? Were you trying to use const generics defaults or did the ICE come up unexpectedly ?

I can open a PR that will do nothing here instead of ICE-ing.

@matthiaskrgr
Copy link
Member Author

matthiaskrgr commented Jan 1, 2021

I made a small program that executes rustc on all the rust files with different flags and filters the ICEs.
The file showed up as previously unknown crash.

@camelid camelid added the A-const-generics Area: const generics (parameters and arguments) label Jan 1, 2021
@camelid
Copy link
Member

camelid commented Jan 1, 2021

On nightly-2020-12-31 (commit 44e3daf), I get a parse error with the code you provided:

error: expected one of `!`, `(`, `+`, `,`, `::`, `<`, or `>`, found `=`
 --> <anon>:1:26
  |
1 | fn foo<const SIZE: usize = 5>() {}
  |                          ^ expected one of 7 possible tokens

error: aborting due to previous error

@matthiaskrgr
Copy link
Member Author

Yes, the PR was merged ~7 hours ago, it's not in nightly yet.

@camelid
Copy link
Member

camelid commented Jan 1, 2021

Ah, things move fast :)

How did you get a build with the commit then? Did you use x.py?

@matthiaskrgr
Copy link
Member Author

There are inofficial "master" builds released for every merge commit in the repo (the latest one is then promoted to "nightly" once at some point of the day)
You can install them with https://github.com/kennytm/rustup-toolchain-install-master and run something like
cargo +master check or ~/.rustup/toolchains/master/bin/rustc afterwards.

@camelid
Copy link
Member

camelid commented Jan 1, 2021

Oh, I forgot about RTIM 😄

@lqd
Copy link
Member

lqd commented Jan 1, 2021

#80599 will remove the ICE so that only the error[E0658]: default values for const generic parameters are experimental appears

@bors bors closed this as completed in 7a1b01e Jan 2, 2021
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) 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

Successfully merging a pull request may close this issue.

3 participants