Skip to content

Compiler panic when running 'cargo check' with missing crate #40757

Closed
@dbrgn

Description

@dbrgn

With both current stable and nightly...

$ rustup update nightly
$ rustup override set nightly
$ rustc --version
rustc 1.17.0-nightly (8c4f2c64c 2017-03-22)

...when compiling this crate...

[package]
name = "crash"
version = "0.1.0"

[dependencies]
diesel = { version = "0.11.0", features = ["postgres", "chrono"] }
diesel_codegen = { version = "0.11.0", features = ["postgres"] }
// src/main.rs
#[macro_use] extern crate diesel;
#[macro_use] extern crate diesel_codegen;
extern crate chrono;

use chrono::{DateTime, UTC};

#[derive(Queryable, Debug)]
struct Foo {
    bar: u32,
    date: DateTime<UTC>,
}

fn main() {
    println!("Hello, world!");
}

...the compiler crashes on cargo check:

$ cargo check
   Compiling crash v0.1.0 (file:///tmp/crash)
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 'called `Option::unwrap()` on a `None` value', /checkout/src/libcore/option.rs:329
note: Run with `RUST_BACKTRACE=1` for a backtrace.

error: Could not compile `crash`.

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

Here's the backtrace:

thread 'rustc' panicked at 'called `Option::unwrap()` on a `None` value', /checkout/src/libcore/option.rs:329
note: Some details are omitted, run with `RUST_BACKTRACE=full` for a verbose backtrace.
stack backtrace:
   0: rustc_metadata::creader::CrateLoader::resolve_crate
   1: <rustc_metadata::creader::CrateLoader<'a> as rustc::middle::cstore::CrateLoader>::process_item
   2: rustc_resolve::build_reduced_graph::<impl rustc_resolve::Resolver<'a>>::build_reduced_graph_for_item
   3: <rustc_resolve::build_reduced_graph::BuildReducedGraphVisitor<'a, 'b> as syntax::visit::Visitor<'a>>::visit_item
   4: <rustc_resolve::build_reduced_graph::BuildReducedGraphVisitor<'a, 'b> as syntax::visit::Visitor<'a>>::visit_item
   5: rustc_resolve::macros::<impl syntax::ext::base::Resolver for rustc_resolve::Resolver<'a>>::visit_expansion
   6: syntax::ext::expand::MacroExpander::collect_invocations
   7: syntax::ext::expand::MacroExpander::expand
   8: syntax::ext::expand::MacroExpander::expand_crate
   9: rustc_driver::driver::phase_2_configure_and_expand::{{closure}}
  10: rustc_driver::driver::phase_2_configure_and_expand
  11: rustc_driver::driver::compile_input
  12: rustc_driver::run_compiler
  13: std::panicking::try::do_call
  14: __rust_maybe_catch_panic
             at /checkout/src/libpanic_unwind/lib.rs:98
  15: <F as alloc::boxed::FnBox<A>>::call_box
  16: std::sys::imp::thread::Thread::new::thread_start
             at /checkout/src/liballoc/boxed.rs:650
             at /checkout/src/libstd/sys_common/thread.rs:21
             at /checkout/src/libstd/sys/unix/thread.rs:84
  17: start_thread
  18: clone

The problem does not happen when using cargo run:

$ cargo run
   Compiling crash v0.1.0 (file:///tmp/crash)
error[E0463]: can't find crate for `chrono`
 --> src/main.rs:3:1
  |
3 | extern crate chrono;
  | ^^^^^^^^^^^^^^^^^^^^ can't find crate

error: aborting due to previous error

error: Could not compile `crash`.

Might be related to #40755.

Metadata

Metadata

Assignees

No one assigned

    Labels

    I-ICEIssue: The compiler panicked, giving an Internal Compilation Error (ICE) ❄️T-compilerRelevant to the compiler team, which will review and decide on the PR/issue.

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions