Skip to content

ICE in astconv.rs:1516 #38926

Description

@martinlindhe

The code below caused an ICE

OS: Windows 10 x64
rustc 1.16.0-nightly (7e38a89 2017-01-06)
cargo 0.17.0-nightly (40a4ce6 2017-01-06)

struct Bird {
    name: String,
    health: i32,
    hunger: i32,
}

impl Bird {
    fn new(name: &str) -> Bird {
        Bird {
            name: name.to_string(),
            health: 100,
            hunger: 0,
        }
    }
}

enum NPC {
    Bird,
}

fn main() {

    let mut spawns: Vec<NPC>;

    let n1 = NPC::Bird::new("Crow");
    spawns.push(n1);
}
 error: internal compiler error: C:\bot\slave\nightly-dist-rustc-win-msvc-64\build\src\librustc_typeck\astconv.rs:1516: unexpected definition: Variant(DefId { krate: CrateNum(0), node: DefIndex(11) => rpg_test/7686b0f37e5974e97c31c655e966887
f-exe::NPC[0]::Bird[0] })
  --> src\main.rs:25:14                                                                       
   |                                                                       
25 |     let n1 = NPC::Bird::new("Crow");                                                                       
   |              ^^^^^^^^^^^^^^                                                                       

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>', C:\bot\slave\nightly-dist-rustc-win-msvc-64\build\src\librustc_errors\lib.rs:382

stack backtrace:
   0:     0x7ffec0dffe00 - std::panicking::Location::line::h8c528bbdf4eef8a3
   1:     0x7ffec0dff282 - std::panicking::Location::line::h8c528bbdf4eef8a3
   2:     0x7ffec0e02ccd - std::panicking::rust_panic_with_hook::h7abc6e334345e341
   3:     0x7ffeb09b8521 - <unknown>
   4:     0x7ffeb09f6c59 - <unknown>
   5:     0x7ffeb09f6a8c - <unknown>
   6:     0x7ffeb0ada92d - <rustc_typeck::astconv::AstConv<'gcx, 'tcx> + 'o>::def_to_ty::hdd3051561636de79
   7:     0x7ffeb0adc144 - <rustc_typeck::astconv::AstConv<'gcx, 'tcx> + 'o>::ast_ty_to_ty::h6d011fbb4fe3b62f
   8:     0x7ffeb0ac10f7 - rustc_typeck::check::FnCtxt::resolve_ty_and_def_ufcs::hed2c4470b99f556c
   9:     0x7ffeb0aad975 - rustc_typeck::check::FnCtxt::check_struct_path::h1c31b7459eec0140
  10:     0x7ffeb0aac0b1 - rustc_typeck::check::FnCtxt::check_struct_path::h1c31b7459eec0140
  11:     0x7ffeb0a6a10d - rustc_typeck::check::callee::<impl rustc_typeck::check::FnCtxt<'a, 'gcx, 'tcx>>::check_call::h6bba70eb240c5d33
  12:     0x7ffeb0aad3f1 - rustc_typeck::check::FnCtxt::check_struct_path::h1c31b7459eec0140
  13:     0x7ffeb0aac0b1 - rustc_typeck::check::FnCtxt::check_struct_path::h1c31b7459eec0140
  14:     0x7ffeb0ac152f - rustc_typeck::check::FnCtxt::check_decl_initializer::he0752fd01b5a3086
  15:     0x7ffeb0ac167b - rustc_typeck::check::FnCtxt::check_decl_local::he6b44866425edb5a
  16:     0x7ffeb0ac19f1 - rustc_typeck::check::FnCtxt::check_stmt::ha511a4c602b59572
  17:     0x7ffeb0ac1d7e - rustc_typeck::check::FnCtxt::check_block_no_value::h4f06b402deca3d6e
  18:     0x7ffeb0aac57f - rustc_typeck::check::FnCtxt::check_struct_path::h1c31b7459eec0140
  19:     0x7ffeb0aac0b1 - rustc_typeck::check::FnCtxt::check_struct_path::h1c31b7459eec0140
  20:     0x7ffeb0a8bfd4 - <rustc_typeck::check::GatherLocalsVisitor<'a, 'gcx, 'tcx> as rustc::hir::intravisit::Visitor<'gcx>>::visit_pat::h3c24f4595d84aca5
  21:     0x7ffeb0a8a92b - rustc_typeck::check::check_drop_impls::h2d877a5ed8a5c08b
  22:     0x7ffeb0a8e581 - rustc_typeck::check::check_item_body::hec0a29f30cd03530
  23:     0x7ffeb0a871e3 - rustc_typeck::check::check_item_bodies::h061a021a39e79099
  24:     0x7ffeb0b14540 - rustc_typeck::check_crate::h018ed1843cf62dde
  25:     0x7ffec25a81ce - rustc_driver::driver::count_nodes::h761a1dba824a4f1e
  26:     0x7ffec24eacf4 - <unknown>
  27:     0x7ffec2583b7c - rustc_driver::driver::compile_input::h44e43be0fc34a1a1
  28:     0x7ffec25d58a7 - rustc_driver::run_compiler::h5e34a930c0929e5c
  29:     0x7ffec24ae1ce - <unknown>
  30:     0x7ffec0e05d11 - _rust_maybe_catch_panic
  31:     0x7ffec24dc836 - <unknown>
  32:     0x7ffec0dfd2fe - std::sys::imp::thread::Thread::new::h7a1b2b1b6bab390a
  33:     0x7ffee3ea8363 - BaseThreadInitThunk

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type

    Fields

    No fields configured for issues without a type.

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions