Skip to content

entry id not found when using copy and serde_derive #37795

Closed
@xrl

Description

@xrl

My cargo build is failing with a panic, directing me here to post information.

I tried this code:

guid.rs:

pub type GuidPrefix = [u8; 12];

#[derive(Default, Debug, PartialEq, Copy, Clone)]
pub struct Guid {
    pub guid_prefix: GuidPrefix,
    pub entity_id: EntityId
}


impl Guid {
    pub fn new() -> Self {
        Guid {
            guid_prefix: [0; 12],
            entity_id: EntityId {
                entity_key: [0; 3],
                entity_kind: EntityKind::UserUnknown
            }
        }
    }
}

entity_id.rs:

#[derive(Default, Debug, PartialEq, Copy, Clone, Deserialize, Serialize)]
pub struct EntityId {
    pub entity_key: [u8; 3],
    pub entity_kind: EntityKind,
}

I expected to see this happen: no panics

Instead, this happened: panic

Meta

rustc --version --verbose:

$ rustc --version --verbose
rustc 1.15.0-nightly (0ed951993 2016-11-14)
binary: rustc
commit-hash: 0ed951993fb5721a303ca5fa743543dd9f3f6b10
commit-date: 2016-11-14
host: x86_64-apple-darwin
release: 1.15.0-nightly
LLVM version: 3.9

Backtrace:

LP-XLANGE-OSX:rtps xlange$ RUST_BACKTRACE=1 cargo build
   Compiling rtps v0.2.4 (file:///Users/xlange/code/rust/rtps)
error[E0428]: a value named `_IMPL_SERIALIZE_FOR_EntityId` has already been defined in this module
  --> src/common_types/entity_id.rs:66:63
   |
66 | #[derive(Default, Debug, PartialEq, Copy, Clone, Deserialize, Serialize)]
   |                                                  -----------  ^^^^^^^^^ already defined
   |                                                  |
   |                                                  previous definition of `_IMPL_SERIALIZE_FOR_EntityId` here

error[E0428]: a type named `EntityId` has already been defined in this module
  --> src/common_types/entity_id.rs:67:1
   |
66 | #[derive(Default, Debug, PartialEq, Copy, Clone, Deserialize, Serialize)]
   |                                                               --------- previous definition of `EntityId` here
67 | pub struct EntityId {
   | ^ already defined

error[E0428]: a value named `_IMPL_SERIALIZE_FOR_FragmentNumberSet` has already been defined in this module
 --> src/common_types/fragment_number.rs:3:38
  |
3 | #[derive(PartialEq,Debug,Deserialize,Serialize,Copy,Clone)]
  |                          ----------- ^^^^^^^^^ already defined
  |                          |
  |                          previous definition of `_IMPL_SERIALIZE_FOR_FragmentNumberSet` here

error[E0428]: a type named `FragmentNumberSet` has already been defined in this module
 --> src/common_types/fragment_number.rs:4:1
  |
3 | #[derive(PartialEq,Debug,Deserialize,Serialize,Copy,Clone)]
  |                                      --------- previous definition of `FragmentNumberSet` here
4 | pub struct FragmentNumberSet {
  | ^ already defined

error[E0428]: a type named `ArcBuffer` has already been defined in this module
 --> src/common_types/rc_buffer.rs:7:1
  |
6 | #[derive(Debug, Clone, PartialEq, Serialize)]
  |                                   --------- previous definition of `ArcBuffer` here
7 | pub struct ArcBuffer {
  | ^ already defined

error[E0428]: a value named `_IMPL_DESERIALIZE_FOR_SequenceNumberSet` has already been defined in this module
 --> src/common_types/sequence_number.rs:7:36
  |
7 | #[derive(PartialEq,Debug,Serialize,Deserialize,Copy,Clone,Default)]
  |                          --------- ^^^^^^^^^^^ already defined
  |                          |
  |                          previous definition of `_IMPL_DESERIALIZE_FOR_SequenceNumberSet` here

error[E0428]: a type named `SequenceNumberSet` has already been defined in this module
  --> src/common_types/sequence_number.rs:8:1
   |
7  | #[derive(PartialEq,Debug,Serialize,Deserialize,Copy,Clone,Default)]
   |                                    ----------- previous definition of `SequenceNumberSet` here
8  | pub struct SequenceNumberSet {
   | ^ already defined

error[E0428]: a value named `_IMPL_SERIALIZE_FOR_Timestamp` has already been defined in this module
 --> src/common_types/timestamp.rs:1:38
  |
1 | #[derive(PartialEq,Debug,Deserialize,Serialize,Clone,Copy)]
  |                          ----------- ^^^^^^^^^ already defined
  |                          |
  |                          previous definition of `_IMPL_SERIALIZE_FOR_Timestamp` here

error[E0428]: a type named `Timestamp` has already been defined in this module
 --> src/common_types/timestamp.rs:2:1
  |
1 | #[derive(PartialEq,Debug,Deserialize,Serialize,Clone,Copy)]
  |                                      --------- previous definition of `Timestamp` here
2 | pub struct Timestamp {
  | ^ already defined

error[E0428]: a type named `Message` has already been defined in this module
  --> src/message/mod.rs:10:1
   |
9  | #[derive(Deserialize,Debug,PartialEq)]
   |          ----------- previous definition of `Message` here
10 | pub struct Message {
   | ^ already defined

error[E0428]: a type named `Submessage` has already been defined in this module
 --> src/submessage.rs:7:1
  |
6 | #[derive(Deserialize, Debug, PartialEq)]
  |          ----------- previous definition of `Submessage` here
7 | pub struct Submessage {
  | ^ already defined

error[E0432]: unresolved import `super::super::super::sync::Monitor`
 --> src/entity/traits/history_cache_trait.rs:4:5
  |
4 | use super::super::super::sync::Monitor;
  |     ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ no `Monitor` in `sync`

error[E0432]: unresolved import `super::super::super::sync::Monitor`
  --> src/entity/reader/stateless_reader.rs:14:5
   |
14 | use super::super::super::sync::Monitor;
   |     ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ no `Monitor` in `sync`

error[E0204]: the trait `Copy` may not be implemented for this type
 --> src/common_types/guid.rs:5:37
  |
5 | #[derive(Default, Debug, PartialEq, Copy, Clone)]
  |                                     ^^^^ field `entity_id` does not implement `Copy`

error: internal compiler error: ../src/librustc_metadata/decoder.rs:490: entry: id not found: DefIndex(1) in crate "serde_derive" with number 13

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<Any>', ../src/librustc_errors/lib.rs:424
stack backtrace:
   1:        0x10553f4ea - std::sys::imp::backtrace::tracing::imp::write::h944c02ac40aee2d7
   2:        0x10554c77f - std::panicking::default_hook::{{closure}}::h6875a2976258b020
   3:        0x10554c32d - std::panicking::default_hook::h88ffbc5922643264
   4:        0x10554cc46 - std::panicking::rust_panic_with_hook::ha5aed1dfc0e220e3
   5:        0x102cd4f2a - std::panicking::begin_panic::h264cdc75d51b518b
   6:        0x102ce5d34 - rustc_errors::Handler::bug::h620f7270292f0095
   7:        0x102040ecc - rustc::session::opt_span_bug_fmt::{{closure}}::h4a9b70c3df8b4b3a
   8:        0x102040cd9 - rustc::session::opt_span_bug_fmt::h7d83586c6e2c7ae6
   9:        0x10204085a - rustc::session::bug_fmt::he2d2f00a4afa9d1e
  10:        0x101578b73 - rustc_metadata::decoder::<impl rustc_metadata::cstore::CrateMetadata>::entry::h5e3d8114267e9116
  11:        0x1015814ab - rustc_metadata::cstore_impl::<impl rustc::middle::cstore::CrateStore<'tcx> for rustc_metadata::cstore::CStore>::visibility::h2949b511f18961ee
  12:        0x101589f66 - rustc_metadata::cstore_impl::<impl rustc::middle::cstore::CrateStore<'tcx> for rustc_metadata::cstore::CStore>::visible_parent_map::hab53861eb74bce8d
  13:        0x10208a1c4 - rustc::ty::item_path::<impl rustc::ty::context::TyCtxt<'a, 'gcx, 'tcx>>::push_item_path::haa7f7a9afda5f72a
  14:        0x1020d62d5 - rustc::util::ppaux::parameterized::h7bcfb1fd3d8a947a
  15:        0x105590cb5 - core::fmt::write::h01739b8f12f355f9
  16:        0x102072c4c - rustc::traits::specialize::specialization_graph::Graph::insert::h62250bf0632d4218
  17:        0x1020a6d12 - rustc::ty::trait_def::TraitDef::add_impl_for_specialization::h39896639aba068c7
  18:        0x101371b67 - <rustc_typeck::coherence::overlap::OverlapChecker<'cx, 'tcx> as rustc::hir::intravisit::Visitor<'v>>::visit_item::h5ba64bfdace3da91
  19:        0x10137aaab - rustc_typeck::coherence::check_coherence::h7b433ad2f4520d1a
  20:        0x1013816a1 - rustc_typeck::check_crate::h4045752b69a796e8
  21:        0x100e1e1ac - rustc_driver::driver::phase_3_run_analysis_passes::{{closure}}::h97a3a12d948df547
  22:        0x100e1b37d - rustc_driver::driver::phase_3_run_analysis_passes::hb0ad9de18d423e67
  23:        0x100e02bc5 - rustc_driver::driver::compile_input::h8e119234b60571d5
  24:        0x100e48229 - rustc_driver::run_compiler::hbdfc4f84e2e0f4b9
  25:        0x100d67988 - std::panicking::try::do_call::hf679f17bf3b43b0b
  26:        0x10554f1fa - __rust_maybe_catch_panic
  27:        0x100d8baaf - <F as alloc::boxed::FnBox<A>>::call_box::h506fb5d7b8891cd4
  28:        0x10554b8d4 - std::sys::imp::thread::Thread::new::thread_start::h8084b1107992ae5b
  29:     0x7fff9169c99c - _pthread_body
  30:     0x7fff9169c919 - _pthread_start

error: Could not compile `rtps`.

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions