Skip to content

ICE with static function pointer to generic instantiation of enum constructor #13972

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
Kimundi opened this issue May 6, 2014 · 6 comments
Closed
Labels
I-ICE Issue: The compiler panicked, giving an Internal Compilation Error (ICE) ❄️

Comments

@Kimundi
Copy link
Member

Kimundi commented May 6, 2014

Testcase:

static BLOCK_ENUM_CONSTRUCTOR: fn(uint) -> Option<uint> = Some;

fn main() {}

Output:

error: internal compiler error: adt::represent_type called on non-ADT type
note: the compiler hit an unexpected failure path. this is a bug.
note: we would appreciate a bug report: http://static.rust-lang.org/doc/master/complement-bugreport.html
note: run with `RUST_BACKTRACE=1` for a backtrace
task 'rustc' failed at '~Any', /build/rust-git/src/rust/src/libsyntax/diagnostic.rs:155
@erickt
Copy link
Contributor

erickt commented May 11, 2014

This errors with this stack trace:

ice.rs:1:1: 1:64 warning: code is never used: `BLOCK_ENUM_CONSTRUCTOR`, #[warn(dead_code)] on by default
ice.rs:1 static BLOCK_ENUM_CONSTRUCTOR: fn(uint) -> Option<uint> = Some;
         ^~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
error: internal compiler error: adt::represent_type called on non-ADT type
note: the compiler hit an unexpected failure path. this is a bug.
note: we would appreciate a bug report: http://static.rust-lang.org/doc/master/complement-bugreport.html
note: run with `RUST_BACKTRACE=1` for a backtrace
task 'rustc' failed at 'Box<Any>', /Users/erickt/rust/rust-master/src/libsyntax/diagnostic.rs:155
stack backtrace:
   1:        0x110b685b5 - rt::backtrace::imp::write::hae9e0c8649bd0651E1F::v0.11.pre
   2:        0x110ad56ae - rt::unwind::begin_unwind_inner::hd5684ca19e9518eaIBF::v0.11.pre
   3:        0x11020faf5 - rt::unwind::begin_unwind::h6760631091188135926::v0.11.pre
   4:        0x1102103ab - diagnostic::Handler::bug::h31b3a7870496b98ae0b::v0.11.pre
   5:        0x10ddd21d8 - driver::session::Session::bug::hd05ef4561dcdac8a04j::v0.11.pre
   6:        0x10de1bcae - middle::trans::adt::represent_type::he7d194c42dced15dwKC::v0.11.pre
   7:        0x10de815fa - middle::trans::consts::const_expr_unadjusted::h08b31cc93b7529213Uj::v0.11.pre
   8:        0x10de7decd - middle::trans::consts::const_expr::h450bc707188aded1dFj::v0.11.pre
   9:        0x10ddcfedf - middle::trans::base::get_item_val::h037ac9bd804c5f8ckQp::v0.11.pre
  10:        0x10de7fd05 - middle::trans::consts::trans_const::h2f0e3312daf9b7baPsk::v0.11.pre
  11:        0x10ddce415 - middle::trans::base::trans_item::hae404c2fd6d891036vp::v0.11.pre
  12:        0x10deba7c1 - middle::trans::base::trans_crate::hf95e38f62840fed6Vhq::v0.11.pre
  13:        0x10e5dc534 - driver::driver::phase_4_translate_to_llvm::hdd1377f79c12d83e8li::v0.11.pre
  14:        0x10e5e01e5 - driver::driver::compile_input::h2c3dbe74f799efa1gEi::v0.11.pre
  15:        0x10e606211 - run_compiler::h6db406e36b756e80saq::v0.11.pre
  16:        0x10e61dd8d - main_args::closure.93972
  17:        0x10e61c502 - monitor::closure.93850
  18:        0x10e61705b - task::TaskBuilder::try::closure.93616
  19:        0x1101aeb6c - task::spawn_opts::closure.7397
  20:        0x110b5fc18 - rt::task::Task::run::closure.28413
  21:        0x110b80b7c - rust_try
  22:        0x110b5fa97 - rt::task::Task::run::hf99ca2c1546bbfb0XqD::v0.11.pre
  23:        0x1101ae9ef - task::spawn_opts::closure.7369
  24:        0x110b66f16 - rt::thread::thread_start::h61d07f070734480188D::v0.11.pre
  25:     0x7fff90436899 - _pthread_body
  26:     0x7fff9043672a - _pthread_struct_init

Which is very similar to the one in #10176.

@Twisol
Copy link

Twisol commented Jan 4, 2015

/cc @eddyb

@steveklabnik
Copy link
Member

This compiles just fine today.

@jdm jdm added the E-needs-test Call for participation: An issue has been fixed and does not reproduce, but no test has been added. label Jan 16, 2015
@eddyb eddyb removed the E-needs-test Call for participation: An issue has been fixed and does not reproduce, but no test has been added. label Jan 17, 2015
@eddyb
Copy link
Member

eddyb commented Jan 17, 2015

@steveklabnik Thanks! There's a bunch of globals-related issues that @Twisol cc'd me on because of #20295 which might have fixed them, but I don't know any easy way to find them again.
@jdm There's already a test for all of these in src/test/run-pass/const-polymorphic-paths.rs.

@Eh2406
Copy link
Contributor

Eh2406 commented Sep 3, 2017

There is a FIXME related to this issue,
https://github.com/rust-lang/rust/blob/master/src/test/run-pass/const-block.rs#L61
Now that the issue is closed can the FIXME be fix, or made more specific?

@eddyb
Copy link
Member

eddyb commented Sep 4, 2017

@Eh2406 The FIXME is wrong, it has nothing to do with this issue.
EDIT: maybe it's about the BLOCK_ENUM_CONSTRUCTOR above it?

pietroalbini added a commit to pietroalbini/rust that referenced this issue Jul 20, 2018
Remove duplicate E0396 tests

Resolves FIXME rust-lang#13973 (erroneously marked as rust-lang#13972). A test for E0396 already exists in `test/ui/const-deref-ptr.rs`.
pietroalbini added a commit to pietroalbini/rust that referenced this issue Jul 20, 2018
Remove duplicate E0396 tests

Resolves FIXME rust-lang#13973 (erroneously marked as rust-lang#13972). A test for E0396 already exists in `test/ui/const-deref-ptr.rs`.
kennytm added a commit to kennytm/rust that referenced this issue Jul 20, 2018
Remove duplicate E0396 tests

Resolves FIXME rust-lang#13973 (erroneously marked as rust-lang#13972). A test for E0396 already exists in `test/ui/const-deref-ptr.rs`.
bors pushed a commit to rust-lang-ci/rust that referenced this issue Jan 28, 2025
…13972)

I ran Clippy on some projects after upgrading to 1.84, which found a
[needless use of
`as_bytes()`](rust-lang/rust-clippy#13437). It
made me notice that the code was also using `bytes()` needlessly in
other places. This PR improves on the `as_bytes()` lint to also lint
`bytes()`.

----

changelog: none
# for free to join this conversation on GitHub. Already have an account? # to comment
Labels
I-ICE Issue: The compiler panicked, giving an Internal Compilation Error (ICE) ❄️
Projects
None yet
Development

No branches or pull requests

8 participants