Skip to content

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

Closed

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.

Activity

  1. added
    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.
    on Mar 23, 2017
  2. abonander commented on Mar 25, 2017

    @abonander
    Contributor

    Should have been fixed with #40542, please try again with a newer nightly (when one is available) and let me know if it still happens.

  3. dbrgn commented on Mar 25, 2017

    @dbrgn
    ContributorAuthor

    @abonander just tested it on current nightly (3da4023 2017-03-24), bug seems fixed! Thank you! ✨

  4. mkollaro commented on Mar 25, 2017

    @mkollaro

    I got this issue with cargo check on stable Rust. I was removing a dependency, but forgot to delete extern crate X from main.rs, while I already deleted it from Cargo.toml. The cargo check command panics because of this, but cargo build doesn't have the issue and correctly complained that I don't have crate X.

    Using rustc 1.16.0 (30cf806 2017-03-10) and cargo-0.17.0-nightly (f9e5481 2017-03-03).

    thread 'rustc' panicked at 'called `Option::unwrap()` on a `None` value', /buildslave/rust-buildbot/slave/stable-dist-rustc-linux/build/src/libcore/option.rs:323
    stack backtrace:
       1:     0x7f8643d0540c - std::sys::imp::backtrace::tracing::imp::write::hf33ae72d0baa11ed
                            at /buildslave/rust-buildbot/slave/stable-dist-rustc-linux/build/src/libstd/sys/unix/backtrace/tracing/gcc_s.rs:42
       2:     0x7f8643d139ae - std::panicking::default_hook::{{closure}}::h59672b733cc6a455
                            at /buildslave/rust-buildbot/slave/stable-dist-rustc-linux/build/src/libstd/panicking.rs:351
       3:     0x7f8643d13553 - std::panicking::default_hook::h1670459d2f3f8843
                            at /buildslave/rust-buildbot/slave/stable-dist-rustc-linux/build/src/libstd/panicking.rs:361
       4:     0x7f8643d13e4b - std::panicking::rust_panic_with_hook::hcf0ddb069e7beee7
                            at /buildslave/rust-buildbot/slave/stable-dist-rustc-linux/build/src/libstd/panicking.rs:555
       5:     0x7f8643d13ce4 - std::panicking::begin_panic::hd6eb68e27bdf6140
                            at /buildslave/rust-buildbot/slave/stable-dist-rustc-linux/build/src/libstd/panicking.rs:517
       6:     0x7f8643d13c09 - std::panicking::begin_panic_fmt::hfea5965948b877f8
                            at /buildslave/rust-buildbot/slave/stable-dist-rustc-linux/build/src/libstd/panicking.rs:501
       7:     0x7f8643d13b97 - rust_begin_unwind
                            at /buildslave/rust-buildbot/slave/stable-dist-rustc-linux/build/src/libstd/panicking.rs:477
       8:     0x7f8643d50edd - core::panicking::panic_fmt::hc0f6d7b2c300cdd9
                            at /buildslave/rust-buildbot/slave/stable-dist-rustc-linux/build/src/libcore/panicking.rs:69
       9:     0x7f8643d50e14 - core::panicking::panic::h7abeb5b818ec354e
                            at /buildslave/rust-buildbot/slave/stable-dist-rustc-linux/build/src/libcore/panicking.rs:49
      10:     0x7f86419d8876 - rustc_metadata::creader::CrateLoader::resolve_crate::h6e72600e2dd6f65b
      11:     0x7f86419df98f - <rustc_metadata::creader::CrateLoader<'a> as rustc::middle::cstore::CrateLoader>::process_item::h3593d13570805f47
      12:     0x7f86411ff8b0 - rustc_resolve::build_reduced_graph::<impl rustc_resolve::Resolver<'a>>::build_reduced_graph_for_item::h3cc2f08d7828c563
      13:     0x7f864120667f - <rustc_resolve::build_reduced_graph::BuildReducedGraphVisitor<'a, 'b> as syntax::visit::Visitor<'a>>::visit_item::h775ca4c5a23a8667
      14:     0x7f8641206b7f - <rustc_resolve::build_reduced_graph::BuildReducedGraphVisitor<'a, 'b> as syntax::visit::Visitor<'a>>::visit_item::h775ca4c5a23a8667
      15:     0x7f86411fa5bf - rustc_resolve::macros::<impl syntax::ext::base::Resolver for rustc_resolve::Resolver<'a>>::visit_expansion::hc836a3e7268abdbf
      16:     0x7f863d69877a - syntax::ext::expand::MacroExpander::collect_invocations::h32417ac98c0c9be1
      17:     0x7f863d697140 - syntax::ext::expand::MacroExpander::expand::h695353fd58aabfd3
      18:     0x7f863d696ba5 - syntax::ext::expand::MacroExpander::expand_crate::h9811866201c8237a
      19:     0x7f86440a00dc - rustc_driver::driver::phase_2_configure_and_expand::{{closure}}::h231d639b5d33e30c
      20:     0x7f86440977f5 - rustc_driver::driver::phase_2_configure_and_expand::hd9965365e42d7a90
      21:     0x7f864409043a - rustc_driver::driver::compile_input::hd9f060ee16a643fb
      22:     0x7f86440dc844 - rustc_driver::run_compiler::h762802568c0e140e
      23:     0x7f8643fe8edb - std::panicking::try::do_call::h935e2f773deaf841
      24:     0x7f8643d1cc8a - __rust_maybe_catch_panic
                            at /buildslave/rust-buildbot/slave/stable-dist-rustc-linux/build/src/libpanic_unwind/lib.rs:98
      25:     0x7f8644011112 - <F as alloc::boxed::FnBox<A>>::call_box::he43811d1f6894655
      26:     0x7f8643d12804 - std::sys::imp::thread::Thread::new::thread_start::he668872ac11287ba
                            at /buildslave/rust-buildbot/slave/stable-dist-rustc-linux/build/src/liballoc/boxed.rs:624
                            at /buildslave/rust-buildbot/slave/stable-dist-rustc-linux/build/src/libstd/sys_common/thread.rs:21
                            at /buildslave/rust-buildbot/slave/stable-dist-rustc-linux/build/src/libstd/sys/unix/thread.rs:84
      27:     0x7f863c7d0183 - start_thread
      28:     0x7f86439c037c - clone
      29:                0x0 - <unknown>
    
  5. dbrgn commented on Mar 25, 2017

    @dbrgn
    ContributorAuthor

    @mkollaro try upgrading to nightly 2017-03-24 (rustup update nightly).

  6. mkollaro commented on Mar 25, 2017

    @mkollaro

    Got fixed 5 seconds before I added my comment...well it doesn't really trouble me, I can use cargo check once I remove the extern crate that shouldn't have been there.

    For those who hit against this issue before it lands in stable: just run cargo build, fix the error, then run cargo check again.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

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