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

unexpected definition: PrimTy(TyChar) #38292

Closed
tcourdy opened this issue Dec 11, 2016 · 2 comments · Fixed by #38375
Closed

unexpected definition: PrimTy(TyChar) #38292

tcourdy opened this issue Dec 11, 2016 · 2 comments · Fixed by #38375

Comments

@tcourdy
Copy link

tcourdy commented Dec 11, 2016

I am new to rust so perhaps I am doing something wrong in the initialization of my struct.

I am trying to initialize a winapi::tlhelp32::PROCESSENTRY32 struct the following way:

let mut pe32 = tlhelp32::PROCESSENTRY32{ dwSize: mem::size_of::<tlhelp32::PROCESSENTRY32>() as u32, cntUsage: -1, th32ProcessID: -1, th32DefaultHeapID: -1, th32ModuleID: -1, cntThreads: -1, th32ParentProcessID: -1, pcPriClassBase: -1, dwFlags: -1, szExeFile: [char; 260] };

However, I receive the following compilation error:

`error: internal compiler error: ../src/librustc_typeck\check/mod.rs:4396: unexpected definition: PrimTy(TyChar)

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 'Box', ../src/librustc_errors/lib.rs:423
stack backtrace:
0: 0x7fffe44b02ea - std::panicking::Location::line::h9363ce800e842170
1: 0x7fffe44af774 - std::panicking::Location::line::h9363ce800e842170
2: 0x7fffe44b31cd - std::panicking::rust_panic_with_hook::hc790e47d4ecc86cd
3: 0x7fffe2992670 -
4: 0x7fffe29ab09e - rustc_errors::Handler::bug::h620f7270292f0095
5: 0x7fffd7805e25 - rustc::session::bug_fmt::he2d2f00a4afa9d1e
6: 0x7fffd7805c5a - rustc::session::bug_fmt::he2d2f00a4afa9d1e
7: 0x7fffd78053cc - rustc::session::bug_fmt::he2d2f00a4afa9d1e
8: 0x7fffd8af9d1a - rustc_typeck::check::FnCtxt::instantiate_value_path::h4229ac945aebfa55
9: 0x7fffd8ae4356 - rustc_typeck::check::FnCtxt::check_struct_path::h1ff2872963f8985c
10: 0x7fffd8ae2d81 - rustc_typeck::check::FnCtxt::check_struct_path::h1ff2872963f8985c
11: 0x7fffd8ae3204 - rustc_typeck::check::FnCtxt::check_struct_path::h1ff2872963f8985c
12: 0x7fffd8ae2d81 - rustc_typeck::check::FnCtxt::check_struct_path::h1ff2872963f8985c
13: 0x7fffd8ae0485 - rustc_typeck::check::FnCtxt::impl_self_ty::h097381977b228682
14: 0x7fffd8ae5dd2 - rustc_typeck::check::FnCtxt::check_struct_path::h1ff2872963f8985c
15: 0x7fffd8ae2d81 - rustc_typeck::check::FnCtxt::check_struct_path::h1ff2872963f8985c
16: 0x7fffd8af7cef - rustc_typeck::check::FnCtxt::check_decl_initializer::h43ea4d26b2a62ae8
17: 0x7fffd8af7e3b - rustc_typeck::check::FnCtxt::check_decl_local::h15d42ee7f4d79e8d
18: 0x7fffd8af8187 - rustc_typeck::check::FnCtxt::check_stmt::h155d968e61fdfae6
19: 0x7fffd8af84be - rustc_typeck::check::FnCtxt::check_block_no_value::h3ac235dc3eaa76c3
20: 0x7fffd8ae326e - rustc_typeck::check::FnCtxt::check_struct_path::h1ff2872963f8985c
21: 0x7fffd8ae2d81 - rustc_typeck::check::FnCtxt::check_struct_path::h1ff2872963f8985c
22: 0x7fffd8ac2c1d - <rustc_typeck::coherence::orphan::OrphanChecker<'cx, 'tcx> as rustc::hir::itemlikevisit::ItemLikeVisitor<'v>>::visit_impl_item::habbc901b4cfa4531
23: 0x7fffd8ac0f57 - rustc_typeck::check::check_drop_impls::hb6e6926f4342f9e2
24: 0x7fffd8ac52e1 - rustc_typeck::check::check_item_body::h1e039ede2f960fb9
25: 0x7fffd8abdbbd - rustc_typeck::check::check_item_bodies::hd22adb7703cc56d7
26: 0x7fffd8b4a500 - rustc_typeck::check_crate::h92f6bdfe03b6afba
27: 0x7fffe4b1c98e - rustc_driver::driver::count_nodes::h84f03318ea2320a8
28: 0x7fffe4a75bcf -
29: 0x7fffe4af8932 - rustc_driver::driver::compile_input::h8e119234b60571d5
30: 0x7fffe4b49f27 - rustc_driver::run_compiler::h57c4f233cd1a0c04
31: 0x7fffe4a2da1e -
32: 0x7fffe44b5bf1 - _rust_maybe_catch_panic
33: 0x7fffe4a57794 -
34: 0x7fffe44ad86e - std::sys::imp::thread::Thread::new::hd990f5dcc0d4bad9
35: 0x7ff819858363 - BaseThreadInitThunk`

My rust compiler version is:

rustc 1.15.0-nightly (daf8c1dfc 2016-12-05) binary: rustc commit-hash: daf8c1dfce3b448fc581cc319f64632ec22bd0e1 commit-date: 2016-12-05 host: x86_64-pc-windows-msvc release: 1.15.0-nightly LLVM version: 3.9

Thank you.

@petrochenkov
Copy link
Contributor

@tcourdy
This is a bug, it affects only 1.15 nightly, and it's already fixed in #38154, but the fix is not merged yet.
The error is here - szExeFile: [char; 260], this code uses type char as an initialization value for the array elements, it needs to use some value instead, e.g. [0; 260].
Duplicate of #38155.

(It's an off-topic, but you should probably prefer PROCESSENTRY32W to PROCESSENTRY32, Rust doesn't have good support for legacy encodings from the box and prefers Unicode when interacting with WinAPI. In this case szExeFile will have type [u16; 260])

@steveklabnik
Copy link
Member

Closing as a duplicate, thanks!

bors added a commit that referenced this issue Dec 15, 2016
Fix regression in resolution of primitive types

Fix often encountered ICE.
Extracted from #38154
Fixes #38155, fixes #38188, fixes #38277, fixes #38280, fixes #38292, fixes #38311, fixes #38344, fixes #38363, fixes #38372 (duplicates)

r? @jseyfried or @eddyb or @nrc
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging a pull request may close this issue.

3 participants