Skip to content

ICE: impl Foo for [u8; usize::BYTES] #28586

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

Closed
benw opened this issue Sep 22, 2015 · 6 comments
Closed

ICE: impl Foo for [u8; usize::BYTES] #28586

benw opened this issue Sep 22, 2015 · 6 comments
Labels
A-associated-items Area: Associated items (types, constants & functions) E-easy Call for participation: Easy difficulty. Experience needed to fix: Not much. Good first issue. E-mentor Call for participation: This issue has a mentor. Use #t-compiler/help on Zulip for discussion. E-needs-test Call for participation: An issue has been fixed and does not reproduce, but no test has been added.

Comments

@benw
Copy link

benw commented Sep 22, 2015

I tried this code:

pub trait Foo {}
impl Foo for [u8; usize::BYTES] {}

I expected to see this happen: great success

Instead, this happened: error: internal compiler error: unexpected panic

Meta

rustc --version --verbose:

rustc 1.4.0-nightly (6873b9fee 2015-09-13)
binary: rustc
commit-hash: 6873b9fee4af732fe81d54fdcedbd31201e3edf0
commit-date: 2015-09-13
host: x86_64-apple-darwin
release: 1.4.0-nightly

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/blob/master/CONTRIBUTING.md#bug-reports
thread 'rustc' panicked at 'path not fully resolved: PathResolution { base_def: DefPrimTy(TyUint(usize)), last_private: LastMod(AllPublic), depth: 1 }', ../src/librustc/middle/def.rs:82

stack backtrace:
   1:        0x1121128d0 - sys::backtrace::tracing::imp::write::heea627b667abca63Y3s
   2:        0x11210fcfb - panicking::on_panic::hdbb29ca470ba8d91wSw
   3:        0x1120da292 - sys_common::unwind::begin_unwind_inner::h96272d8b0ab240cfv6r
   4:        0x1120dad6d - sys_common::unwind::begin_unwind_fmt::h9afcfd3cbded904aB5r
   5:        0x10ed9d260 - middle::const_eval::eval_const_expr_partial::h09b300ea76947f73LTk
   6:        0x10e87b052 - astconv::ast_ty_to_ty::hea6c277082e3ec36Hjx
   7:        0x10e8d365b - collect::convert_item::had78e6f690b64d6668y
   8:        0x10e8cf086 - collect::collect_item_types::h0cdd1ad21711c8b7Cky
   9:        0x10e91b84d - check_crate::hec1ce520a39b9d455BE
  10:        0x10e08f9ea - driver::phase_3_run_analysis_passes::closure.21862
  11:        0x10e07162a - middle::ty::ctxt<'tcx>::create_and_enter::h16774090565533553846
  12:        0x10e06ce35 - driver::phase_3_run_analysis_passes::h7058980529217618503
  13:        0x10e04d825 - driver::compile_input::hb180f9b5439d25130ba
  14:        0x10e1b22a0 - run_compiler::hed85d66f90e035a8qqc
  15:        0x10e1afb99 - boxed::F.FnBox<A>::call_box::h2035540886510390739
  16:        0x10e1af592 - sys_common::unwind::try::try_fn::h1377311635092239657
  17:        0x11210f638 - __rust_try
  18:        0x112103c60 - sys_common::unwind::try::inner_try::hcc9e69ddf677c559T2r
  19:        0x10e1af742 - boxed::F.FnBox<A>::call_box::h6878960542759305751
  20:        0x1121185dd - sys::thread::Thread::new::thread_start::h149e6b462b5fd2cfpqw
  21:     0x7fff99141059 - _pthread_body
  22:     0x7fff99140fd6 - _pthread_start
@bluss
Copy link
Member

bluss commented Sep 22, 2015

It will compile if you add this:

#![feature(num_bits_bytes)]
use std::usize;

This turns usize::BYTES into a regular path -> const lookup instead of an associated const. (Associated const usize::BYTES does not exist, by the way).

But it's still a good bug report, don't close it!

@bluss bluss added the A-associated-items Area: Associated items (types, constants & functions) label Sep 22, 2015
@bluss
Copy link
Member

bluss commented Sep 22, 2015

Similar to issue #24947.

@ghost
Copy link

ghost commented Sep 24, 2015

Another test-case:

struct FixedArray<T, ArraySize> { data: [T; ArraySize::Size] }

fn main() {}

with

rustc 1.5.0-dev (ecbd8c3b4 2015-09-22)
binary: rustc
commit-hash: ecbd8c3b43d7d992938f7214b3bab1c017669e59
commit-date: 2015-09-22
host: x86_64-unknown-linux-gnu
release: 1.5.0-dev

results of rustc main.rs :

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/blob/master/CONTRIBUTING.md#bug-reports
note: run with `RUST_BACKTRACE=1` for a backtrace
thread 'rustc' panicked at 'no path elem for NodeTyParam(TyParam { ident: ArraySize#0, id: 10, bounds: [], default: None, span: main.rs:2:22: 2:31 })', src/librustc/front/map/mod.rs:488

results of RUST_BACKTRACE=1 rustc main.rs:

Segmentation fault (core dumped)

with backtrace from gdb - similar to the stack backtrace reported in this issue:

#0  0x0000000000001000 in ?? ()
#1  0x00007f36a58f567a in backtrace_pcinfo (state=0x7f36a6359000, pc=139872682138457, 
    callback=0x7f36a5885a00 <sys_common::gnu::libbacktrace::print::pcinfo_cb::h29c7688dfe185d9fyht>, 
    error_callback=0x7f36a58859f0 <sys_common::gnu::libbacktrace::print::error_cb::h9d640c5e5585541eJgt>, data=0x7f369d7ed170)
    at /var/tmp/portage/dev-lang/rust-9999/work/rust-9999/src/libbacktrace/fileline.c:176
#2  0x00007f36a588610c in sys::backtrace::tracing::imp::write::trace_fn::h3227ea145b706b5bSst ()
   from /usr/lib64/rust-9999/libstd-gentoo-git.so
#3  0x00007f369f8b75c9 in _Unwind_Backtrace (
    trace=0x7f36a5885cb0 <sys::backtrace::tracing::imp::write::trace_fn::h3227ea145b706b5bSst>, trace_argument=0x7f369d7ed518)
    at /var/tmp/portage/sys-devel/gcc-5.2.0/work/gcc-5.2.0/libgcc/unwind.inc:295
#4  0x00007f36a5885b5a in sys::backtrace::tracing::imp::write::h82b779db8318b1850qt () from /usr/lib64/rust-9999/libstd-gentoo-git.so
#5  0x00007f36a5883287 in panicking::on_panic::h5d10db3f19f75694zqx () from /usr/lib64/rust-9999/libstd-gentoo-git.so
#6  0x00007f36a584fbdf in sys_common::unwind::begin_unwind_inner::h021af668201d101f3es ()
   from /usr/lib64/rust-9999/libstd-gentoo-git.so
#7  0x00007f36a5850619 in sys_common::unwind::begin_unwind_fmt::h6ae185d70e9749249ds ()
   from /usr/lib64/rust-9999/libstd-gentoo-git.so
#8  0x00007f36a34ae205 in front::map::Map$LT$$u27$ast$GT$::get_path_elem::hcac69fe7ff0a5591Sfb ()
   from /usr/lib64/rust-9999/librustc-gentoo-git.so
#9  0x00007f36a3768af8 in front::map::Map$LT$$u27$ast$GT$::with_path_next::h7677687426421862442 ()
   from /usr/lib64/rust-9999/librustc-gentoo-git.so
#10 0x00007f36a36070ea in middle::ty::ctxt$LT$$u27$tcx$GT$::item_path_str::h093d7dc118b8ded1nUf ()
   from /usr/lib64/rust-9999/librustc-gentoo-git.so
#11 0x00007f36a3605edc in middle::def_id::DefId.fmt..Debug::fmt::h084461e0056999ebtRo ()
   from /usr/lib64/rust-9999/librustc-gentoo-git.so
#12 0x00007f36a58eb226 in fmt::write::h4db63ca58df27bafp0W () from /usr/lib64/rust-9999/libstd-gentoo-git.so
#13 0x00007f36a58c3e31 in fmt::builders::DebugTuple$LT$$u27$a$C$$u20$$u27$b$GT$::field::h434f658db5f3c7ecRnW ()
   from /usr/lib64/rust-9999/libstd-gentoo-git.so
#14 0x00007f36a35961b0 in middle::def::Def...std..fmt..Debug::fmt::h95a2b86eebd51a73Fon ()
   from /usr/lib64/rust-9999/librustc-gentoo-git.so
#15 0x00007f36a58eb226 in fmt::write::h4db63ca58df27bafp0W () from /usr/lib64/rust-9999/libstd-gentoo-git.so
#16 0x00007f36a58c3905 in fmt::builders::DebugStruct$LT$$u27$a$C$$u20$$u27$b$GT$::field::he7df159292fb73ecXiW ()
   from /usr/lib64/rust-9999/libstd-gentoo-git.so
#17 0x00007f36a3606e12 in fmt::_$RF$$u27$a$u20$T.Debug::fmt::h9876525571199719911 () from /usr/lib64/rust-9999/librustc-gentoo-git.so
#18 0x00007f36a58eb226 in fmt::write::h4db63ca58df27bafp0W () from /usr/lib64/rust-9999/libstd-gentoo-git.so
#19 0x00007f36a58505bb in sys_common::unwind::begin_unwind_fmt::h6ae185d70e9749249ds ()
   from /usr/lib64/rust-9999/libstd-gentoo-git.so
#20 0x00007f36a35a82b1 in middle::const_eval::eval_const_expr_partial::h77eb81c891e44397Nyk ()
   from /usr/lib64/rust-9999/librustc-gentoo-git.so
#21 0x00007f36a443099d in astconv::ast_ty_to_ty::h446730aafa9ba3b32ox () from /usr/lib64/rust-9999/librustc_typeck-gentoo-git.so
#22 0x00007f36a449c199 in collect::convert_field::h079a992ee3267235d5y () from /usr/lib64/rust-9999/librustc_typeck-gentoo-git.so
#23 0x00007f36a4488ab0 in collect::convert_item::h6dd288f7ad9918efTdz () from /usr/lib64/rust-9999/librustc_typeck-gentoo-git.so
#24 0x00007f36a4483a88 in collect::collect_item_types::hdc4b9b528a28e1a1ppy ()
   from /usr/lib64/rust-9999/librustc_typeck-gentoo-git.so
#25 0x00007f36a44d1b9c in check_crate::hc33dccfaaa753e70ZGE () from /usr/lib64/rust-9999/librustc_typeck-gentoo-git.so
#26 0x00007f36a5da2acf in driver::phase_3_run_analysis_passes::closure.21555 ()
   from /usr/lib64/rust-9999/librustc_driver-gentoo-git.so
#27 0x00007f36a5d851ed in middle::ty::context::ctxt$LT$$u27$tcx$GT$::create_and_enter::h14912410508915335040 ()
   from /usr/lib64/rust-9999/librustc_driver-gentoo-git.so
#28 0x00007f36a5d809a2 in driver::phase_3_run_analysis_passes::h6812549652698182288 ()
   from /usr/lib64/rust-9999/librustc_driver-gentoo-git.so
#29 0x00007f36a5d612f4 in driver::compile_input::h14af076c634191100ba () from /usr/lib64/rust-9999/librustc_driver-gentoo-git.so
#30 0x00007f36a5ec6d3c in run_compiler::h89a832461de3e8ab3qc () from /usr/lib64/rust-9999/librustc_driver-gentoo-git.so
#31 0x00007f36a5ec45a7 in boxed::F.FnBox$LT$A$GT$::call_box::h4415565791460127255 ()
   from /usr/lib64/rust-9999/librustc_driver-gentoo-git.so
#32 0x00007f36a5ec3eb5 in sys_common::unwind::try::try_fn::h17089024600160099748 ()
   from /usr/lib64/rust-9999/librustc_driver-gentoo-git.so
#33 0x00007f36a5882b89 in __rust_try () from /usr/lib64/rust-9999/libstd-gentoo-git.so
#34 0x00007f36a58773cf in sys_common::unwind::try::inner_try::h9d46b930d0260ed7Dbs () from /usr/lib64/rust-9999/libstd-gentoo-git.so
#35 0x00007f36a5ec404f in boxed::F.FnBox$LT$A$GT$::call_box::h8089523330245650700 ()
   from /usr/lib64/rust-9999/librustc_driver-gentoo-git.so
#36 0x00007f36a588ae34 in sys::thread::Thread::new::thread_start::h0a7752ba7c557a49oJw ()
   from /usr/lib64/rust-9999/libstd-gentoo-git.so
#37 0x00007f369fdc2484 in start_thread (arg=0x7f369d7ff700) at pthread_create.c:334
#38 0x00007f36a55145cd in clone () at ../sysdeps/unix/sysv/linux/x86_64/clone.S:109

bltavares pushed a commit to bltavares/glacier that referenced this issue Oct 28, 2015
bltavares pushed a commit to bltavares/glacier that referenced this issue Oct 28, 2015
@steveklabnik
Copy link
Member

It looks like this no longer ICEs rust-lang/glacier#85

@steveklabnik steveklabnik added E-easy Call for participation: Easy difficulty. Experience needed to fix: Not much. Good first issue. E-needs-test Call for participation: An issue has been fixed and does not reproduce, but no test has been added. E-mentor Call for participation: This issue has a mentor. Use #t-compiler/help on Zulip for discussion. labels Oct 29, 2015
@bluss
Copy link
Member

bluss commented Oct 30, 2015

@steveklabnik your code never ICE'd, because it has use usize::BYTES. The ICE happens when it looks at an associated type on usize.

@bluss
Copy link
Member

bluss commented Oct 30, 2015

The code should be

pub trait Foo {}
impl Foo for [u8; usize::BYTES] {}

fn main() { }

but it is indeed fixed to be an error, not an ICE now.

bors added a commit that referenced this issue Nov 17, 2015
@bors bors closed this as completed in 58e2baa Nov 17, 2015
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
A-associated-items Area: Associated items (types, constants & functions) E-easy Call for participation: Easy difficulty. Experience needed to fix: Not much. Good first issue. E-mentor Call for participation: This issue has a mentor. Use #t-compiler/help on Zulip for discussion. E-needs-test Call for participation: An issue has been fixed and does not reproduce, but no test has been added.
Projects
None yet
Development

No branches or pull requests

3 participants