Skip to content

thread 'rustc' panicked at 'No def'n found for DefId #27815

Closed
@schultyy

Description

@schultyy

I was developing a new module for a small project:

//tests/command_parser_test.rs

#[path="../src/command_parser.rs"]
mod command_parser;

#[test]
fn parses_non_sudo_without_args() {
    let cmd_str = "ls";

    let cmd = command_parser::parse(cmd_str);

    assert_eq!(cmd.sudo, false);
    assert_eq!(cmd.command, "ls");
    assert_eq!(cmd.args, []);
}
//src/command_parser.rs
mod Command;

pub fn parse(arguments: String) -> Command::Command {
    return Command{
        sudo: false,
        command: String::new(),
        args: []
    };
}
//src/command.rs
pub struct Command {
    sudo: bool,
    command: String,
    args: Vec<String>
}

I expected to see either a compiler error or a failing test. I'm currently learning the language, so that's why the code might 100% reflect best practices or is not correct.

Instead the following happend:

▶ cargo test
   Compiling sokan v0.1.0 (file:///Users/janschulte/projects/sokan)
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 def'n found for DefId { krate: 0, node: 6 }command_parser::Command in tcx.tcache', ../src/librustc/middle/ty.rs:5513


Could not compile `sokan`.

To learn more, run the command again with --verbose.

With RUST_BACKTRACE=1:

▶ RUST_BACKTRACE=1 cargo test
   Compiling sokan v0.1.0 (file:///Users/janschulte/projects/sokan)
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 'No def'n found for DefId { krate: 0, node: 6 }command_parser::Command in tcx.tcache', ../src/librustc/middle/ty.rs:5513

stack backtrace:
   1:        0x10c9fe7b5 - sys::backtrace::write::hf5ea20500b66cd24uns
   2:        0x10ca07013 - panicking::on_panic::hbe02cb0d925cad49iGw
   3:        0x10c9c2dd2 - rt::unwind::begin_unwind_inner::h12ba0ba9dffdecc2uow
   4:        0x10c9c3b29 - rt::unwind::begin_unwind_fmt::hadf0dbf11d345ebfAnw
   5:        0x109dba6c4 - middle::ty::lookup_item_type::h4ca93c3cefa396687Ca
   6:        0x109a2357f - check::check_expr_with_unifier::h13136853694612127998
   7:        0x109a37d9c - check::check_expr_with_unifier::h17134099806292258680
   8:        0x109a47d58 - check::check_stmt::h3b6a8003dad3fd00bhs
   9:        0x1099f7a18 - check::check_block_with_expected::h6e216c80ce807e01mls
  10:        0x1099d9c81 - check::check_fn::h8b46dfec97d603addXn
  11:        0x1099f1fe0 - check::check_bare_fn::h88c035244660e365WMn
  12:        0x1099efdc7 - check::check_item_body::h9873e3da412bca20ydo
  13:        0x1099f0212 - visit::walk_item::h2899112994373683709
  14:        0x1099f1bed - check::check_item_types::h63240bfbe991be87tKn
  15:        0x109aafcd9 - check_crate::h117ec0c1269afe619fD
  16:        0x1092f5d16 - driver::phase_3_run_analysis_passes::closure.15766
  17:        0x1092f4204 - middle::ty::with_ctxt::h14728011725879770170
  18:        0x1092ef00a - driver::phase_3_run_analysis_passes::h16713467199444562124
  19:        0x1092d2107 - driver::compile_input::hb6d2be5b0fa2247fTba
  20:        0x1093ae13f - run_compiler::h21d74b88eec3fe3bx7b
  21:        0x1093ab9f3 - boxed::F.FnBox<A>::call_box::h1689969825914258414
  22:        0x1093ab1b7 - rt::unwind::try::try_fn::h11273853850686318048
  23:        0x10ca91cc8 - rust_try_inner
  24:        0x10ca91cb5 - rust_try
  25:        0x10c9f0c95 - rt::unwind::try::inner_try::h480e3107f6a4b5b9nkw
  26:        0x1093ab3e8 - boxed::F.FnBox<A>::call_box::h888215220722514405
  27:        0x10ca05a9d - sys::thread::Thread::new::thread_start::hdb3d925f69c5da4aHIv
  28:     0x7fff91ee6267 - _pthread_body
  29:     0x7fff91ee61e4 - _pthread_start

Could not compile `sokan`.

To learn more, run the command again with --verbose.

Metadata

Metadata

Assignees

No one assigned

    Labels

    I-ICEIssue: The compiler panicked, giving an Internal Compilation Error (ICE) ❄️

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions