Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Assertion failed: import.imported_module.get().is_none() #85992

Closed
ralpha opened this issue Jun 4, 2021 · 4 comments · Fixed by #113168
Closed

Assertion failed: import.imported_module.get().is_none() #85992

ralpha opened this issue Jun 4, 2021 · 4 comments · Fixed by #113168
Assignees
Labels
A-macros Area: All kinds of macros (custom derive, macro_rules!, proc macros, ..) C-bug Category: This is a bug. E-needs-mcve Call for participation: This issue has a repro, but needs a Minimal Complete and Verifiable Example I-ICE Issue: The compiler panicked, giving an Internal Compilation Error (ICE) ❄️ T-compiler Relevant to the compiler team, which will review and decide on the PR/issue.

Comments

@ralpha
Copy link

ralpha commented Jun 4, 2021

Code

Exact code unknown code.
The error was generated by using cargo check.
Rerunning after cargo clean did not fix this.

Did not resolve this yet at the time of writing this.
This might be related to: #83336

But I think this was because I compiles first and got this error:

error: internal compiler error: expansion entered force mode without producing any errors
 --> controllers/src/server/launch_errors.rs:6:13
  |
6 |             error!("{}", err);
  |             ^^^^^^^^^^^^^^^^^^
  |
  = note: delayed at compiler/rustc_expand/src/expand.rs:460:34

This was expected to give an error (needed to be log::error!(...) )

Full backtrace on the fist check:

thread 'rustc' panicked at 'assertion failed: import.imported_module.get().is_none()', compiler/rustc_resolve/src/imports.rs:960:21
note: run with `RUST_BACKTRACE=1` environment variable to display a backtrace

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/issues/new?labels=C-bug%2C+I-ICE%2C+T-compiler&template=ice.md

note: rustc 1.54.0-nightly (b663c0f4f 2021-05-29) running on x86_64-unknown-linux-gnu

note: compiler flags: -C embed-bitcode=no -C debuginfo=2 -C incremental --crate-type lib

note: some of the compiler flags provided by cargo are hidden

query stack during panic:
end of query stack
error: internal compiler error: expansion entered force mode without producing any errors
 --> controllers/src/server/launch_errors.rs:6:13
  |
6 |             error!("{}", err);
  |             ^^^^^^^^^^^^^^^^^^
  |
  = note: delayed at compiler/rustc_expand/src/expand.rs:460:34

thread 'rustc' panicked at 'no errors encountered even though `delay_span_bug` issued', compiler/rustc_errors/src/lib.rs:1021:13
stack backtrace:
   0:     0x7f76d393a060 - std::backtrace_rs::backtrace::libunwind::trace::ha3c9a071e276aa0f
                               at /rustc/b663c0f4f6ff84a8c9df0f708e1f8d628330d973/library/std/src/../../backtrace/src/backtrace/libunwind.rs:90:5
   1:     0x7f76d393a060 - std::backtrace_rs::backtrace::trace_unsynchronized::ha4cae02438775bee
                               at /rustc/b663c0f4f6ff84a8c9df0f708e1f8d628330d973/library/std/src/../../backtrace/src/backtrace/mod.rs:66:5
   2:     0x7f76d393a060 - std::sys_common::backtrace::_print_fmt::h7a4100df230ddc18
                               at /rustc/b663c0f4f6ff84a8c9df0f708e1f8d628330d973/library/std/src/sys_common/backtrace.rs:67:5
   3:     0x7f76d393a060 - <std::sys_common::backtrace::_print::DisplayBacktrace as core::fmt::Display>::fmt::h90c5a98ac3ece013
                               at /rustc/b663c0f4f6ff84a8c9df0f708e1f8d628330d973/library/std/src/sys_common/backtrace.rs:46:22
   4:     0x7f76d39a7a8c - core::fmt::write::h7aa6cd0067dca82a
                               at /rustc/b663c0f4f6ff84a8c9df0f708e1f8d628330d973/library/core/src/fmt/mod.rs:1110:17
   5:     0x7f76d392b8e5 - std::io::Write::write_fmt::h2fe56180f3d20a2a
                               at /rustc/b663c0f4f6ff84a8c9df0f708e1f8d628330d973/library/std/src/io/mod.rs:1588:15
   6:     0x7f76d393debb - std::sys_common::backtrace::_print::hfde54a51698eed27
                               at /rustc/b663c0f4f6ff84a8c9df0f708e1f8d628330d973/library/std/src/sys_common/backtrace.rs:49:5
   7:     0x7f76d393debb - std::sys_common::backtrace::print::h2cdb1fdb4dae15b4
                               at /rustc/b663c0f4f6ff84a8c9df0f708e1f8d628330d973/library/std/src/sys_common/backtrace.rs:36:9
   8:     0x7f76d393debb - std::panicking::default_hook::{{closure}}::h6b7f85bf6255ae64
                               at /rustc/b663c0f4f6ff84a8c9df0f708e1f8d628330d973/library/std/src/panicking.rs:208:50
   9:     0x7f76d393d991 - std::panicking::default_hook::h6033f351925c444f
                               at /rustc/b663c0f4f6ff84a8c9df0f708e1f8d628330d973/library/std/src/panicking.rs:225:9
  10:     0x7f76d410d72d - rustc_driver::report_ice::hedef9fb40338a23b
  11:     0x7f76bf86d323 - <alloc::boxed::Box<F,A> as core::ops::function::Fn<Args>>::call::hacacf077fc128abd
                               at /rustc/b663c0f4f6ff84a8c9df0f708e1f8d628330d973/library/alloc/src/boxed.rs:1589:9
  12:     0x7f76bf866708 - proc_macro::bridge::client::<impl proc_macro::bridge::Bridge>::enter::{{closure}}::{{closure}}::h06c8f662d5992f73
                               at /rustc/b663c0f4f6ff84a8c9df0f708e1f8d628330d973/library/proc_macro/src/bridge/client.rs:320:21
  13:     0x7f76d393e6c6 - std::panicking::rust_panic_with_hook::hde05f051c0c95c4a
                               at /rustc/b663c0f4f6ff84a8c9df0f708e1f8d628330d973/library/std/src/panicking.rs:626:17
  14:     0x7f76d393e1a7 - std::panicking::begin_panic_handler::{{closure}}::h49a1ef32b3e38727
                               at /rustc/b663c0f4f6ff84a8c9df0f708e1f8d628330d973/library/std/src/panicking.rs:519:13
  15:     0x7f76d393a55c - std::sys_common::backtrace::__rust_end_short_backtrace::hed2471df08b67583
                               at /rustc/b663c0f4f6ff84a8c9df0f708e1f8d628330d973/library/std/src/sys_common/backtrace.rs:141:18
  16:     0x7f76d393e109 - rust_begin_unwind
                               at /rustc/b663c0f4f6ff84a8c9df0f708e1f8d628330d973/library/std/src/panicking.rs:515:5
  17:     0x7f76d3906fcb - std::panicking::begin_panic_fmt::hf6913515f24c4986
                               at /rustc/b663c0f4f6ff84a8c9df0f708e1f8d628330d973/library/std/src/panicking.rs:457:5
  18:     0x7f76d6579629 - rustc_errors::HandlerInner::flush_delayed::h3322626edccdc88d
  19:     0x7f76d65780dd - <rustc_errors::HandlerInner as core::ops::drop::Drop>::drop::he175ba8469a915c4
  20:     0x7f76d5c09f56 - core::ptr::drop_in_place<rustc_session::parse::ParseSess>::h5c63f86f5df3788a
  21:     0x7f76d5c0c45e - <alloc::rc::Rc<T> as core::ops::drop::Drop>::drop::h11c57329750d41f3
  22:     0x7f76d5c1ce6d - core::ptr::drop_in_place<rustc_interface::interface::Compiler>::hb8a82cba31a9cf29
  23:     0x7f76d5c12798 - rustc_span::with_session_globals::h6569bbb8a4ea9d61
  24:     0x7f76d5c368ff - std::sys_common::backtrace::__rust_begin_short_backtrace::h428dbdd434c4f112
  25:     0x7f76d5c0d7b5 - core::ops::function::FnOnce::call_once{{vtable.shim}}::hb7785b7f871527db
  26:     0x7f76d394abb7 - <alloc::boxed::Box<F,A> as core::ops::function::FnOnce<Args>>::call_once::h79456d14677dd3c1
                               at /rustc/b663c0f4f6ff84a8c9df0f708e1f8d628330d973/library/alloc/src/boxed.rs:1575:9
  27:     0x7f76d394abb7 - <alloc::boxed::Box<F,A> as core::ops::function::FnOnce<Args>>::call_once::h5c40c73501d779c0
                               at /rustc/b663c0f4f6ff84a8c9df0f708e1f8d628330d973/library/alloc/src/boxed.rs:1575:9
  28:     0x7f76d394abb7 - std::sys::unix::thread::Thread::new::thread_start::h55fc0fe77abc7cf7
                               at /rustc/b663c0f4f6ff84a8c9df0f708e1f8d628330d973/library/std/src/sys/unix/thread.rs:71:17
  29:     0x7f76d368b6db - start_thread
  30:     0x7f76d2fa871f - __clone
  31:                0x0 - <unknown>

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/issues/new?labels=C-bug%2C+I-ICE%2C+T-compiler&template=ice.md

note: rustc 1.54.0-nightly (b663c0f4f 2021-05-29) running on x86_64-unknown-linux-gnu

note: compiler flags: -C embed-bitcode=no -C debuginfo=2 -C incremental --crate-type lib

note: some of the compiler flags provided by cargo are hidden

query stack during panic:
end of query stack
thread panicked while panicking. aborting.
error: could not compile `controllers`

Meta

rustc --version --verbose:

rustc 1.54.0-nightly (b663c0f4f 2021-05-29)
binary: rustc
commit-hash: b663c0f4f6ff84a8c9df0f708e1f8d628330d973
commit-date: 2021-05-29
host: x86_64-unknown-linux-gnu
release: 1.54.0-nightly
LLVM version: 12.0.1

Problem persists after updating to last nightly:

rustc 1.54.0-nightly (cc77ba46f 2021-06-03)
binary: rustc
commit-hash: cc77ba46fcb2d288aa01554b48cd586c5827c3dd
commit-date: 2021-06-03
host: x86_64-unknown-linux-gnu
release: 1.54.0-nightly
LLVM version: 12.0.1

Error output

thread 'rustc' panicked at 'assertion failed: import.imported_module.get().is_none()', compiler/rustc_resolve/src/imports.rs:960:21
stack backtrace:
<see below>
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/issues/new?labels=C-bug%2C+I-ICE%2C+T-compiler&template=ice.md

note: rustc 1.54.0-nightly (b663c0f4f 2021-05-29) running on x86_64-unknown-linux-gnu

note: compiler flags: -C embed-bitcode=no -C debuginfo=2 -C incremental --crate-type lib

note: some of the compiler flags provided by cargo are hidden

query stack during panic:
end of query stack
error: could not compile `controllers`
Backtrace (After trying to recheck it)

stack backtrace:
   0:     0x7f00b46a2060 - std::backtrace_rs::backtrace::libunwind::trace::ha3c9a071e276aa0f
                               at /rustc/b663c0f4f6ff84a8c9df0f708e1f8d628330d973/library/std/src/../../backtrace/src/backtrace/libunwind.rs:90:5
   1:     0x7f00b46a2060 - std::backtrace_rs::backtrace::trace_unsynchronized::ha4cae02438775bee
                               at /rustc/b663c0f4f6ff84a8c9df0f708e1f8d628330d973/library/std/src/../../backtrace/src/backtrace/mod.rs:66:5
   2:     0x7f00b46a2060 - std::sys_common::backtrace::_print_fmt::h7a4100df230ddc18
                               at /rustc/b663c0f4f6ff84a8c9df0f708e1f8d628330d973/library/std/src/sys_common/backtrace.rs:67:5
   3:     0x7f00b46a2060 - <std::sys_common::backtrace::_print::DisplayBacktrace as core::fmt::Display>::fmt::h90c5a98ac3ece013
                               at /rustc/b663c0f4f6ff84a8c9df0f708e1f8d628330d973/library/std/src/sys_common/backtrace.rs:46:22
   4:     0x7f00b470fa8c - core::fmt::write::h7aa6cd0067dca82a
                               at /rustc/b663c0f4f6ff84a8c9df0f708e1f8d628330d973/library/core/src/fmt/mod.rs:1110:17
   5:     0x7f00b46938e5 - std::io::Write::write_fmt::h2fe56180f3d20a2a
                               at /rustc/b663c0f4f6ff84a8c9df0f708e1f8d628330d973/library/std/src/io/mod.rs:1588:15
   6:     0x7f00b46a5ebb - std::sys_common::backtrace::_print::hfde54a51698eed27
                               at /rustc/b663c0f4f6ff84a8c9df0f708e1f8d628330d973/library/std/src/sys_common/backtrace.rs:49:5
   7:     0x7f00b46a5ebb - std::sys_common::backtrace::print::h2cdb1fdb4dae15b4
                               at /rustc/b663c0f4f6ff84a8c9df0f708e1f8d628330d973/library/std/src/sys_common/backtrace.rs:36:9
   8:     0x7f00b46a5ebb - std::panicking::default_hook::{{closure}}::h6b7f85bf6255ae64
                               at /rustc/b663c0f4f6ff84a8c9df0f708e1f8d628330d973/library/std/src/panicking.rs:208:50
   9:     0x7f00b46a5991 - std::panicking::default_hook::h6033f351925c444f
                               at /rustc/b663c0f4f6ff84a8c9df0f708e1f8d628330d973/library/std/src/panicking.rs:225:9
  10:     0x7f00b4e7572d - rustc_driver::report_ice::hedef9fb40338a23b
  11:     0x7f00a055b323 - <alloc::boxed::Box<F,A> as core::ops::function::Fn<Args>>::call::hacacf077fc128abd
                               at /rustc/b663c0f4f6ff84a8c9df0f708e1f8d628330d973/library/alloc/src/boxed.rs:1589:9
  12:     0x7f00a0554708 - proc_macro::bridge::client::<impl proc_macro::bridge::Bridge>::enter::{{closure}}::{{closure}}::h06c8f662d5992f73
                               at /rustc/b663c0f4f6ff84a8c9df0f708e1f8d628330d973/library/proc_macro/src/bridge/client.rs:320:21
  13:     0x7f00b46a66c6 - std::panicking::rust_panic_with_hook::hde05f051c0c95c4a
                               at /rustc/b663c0f4f6ff84a8c9df0f708e1f8d628330d973/library/std/src/panicking.rs:626:17
  14:     0x7f00b46a6177 - std::panicking::begin_panic_handler::{{closure}}::h49a1ef32b3e38727
                               at /rustc/b663c0f4f6ff84a8c9df0f708e1f8d628330d973/library/std/src/panicking.rs:517:13
  15:     0x7f00b46a255c - std::sys_common::backtrace::__rust_end_short_backtrace::hed2471df08b67583
                               at /rustc/b663c0f4f6ff84a8c9df0f708e1f8d628330d973/library/std/src/sys_common/backtrace.rs:141:18
  16:     0x7f00b46a6109 - rust_begin_unwind
                               at /rustc/b663c0f4f6ff84a8c9df0f708e1f8d628330d973/library/std/src/panicking.rs:515:5
  17:     0x7f00b4671081 - core::panicking::panic_fmt::hbe99dddd3092ba3c
                               at /rustc/b663c0f4f6ff84a8c9df0f708e1f8d628330d973/library/core/src/panicking.rs:92:14
  18:     0x7f00b4670fcd - core::panicking::panic::h3de4db67bd397eb3
                               at /rustc/b663c0f4f6ff84a8c9df0f708e1f8d628330d973/library/core/src/panicking.rs:50:5
  19:     0x7f00b6cbd840 - rustc_resolve::imports::ImportResolver::finalize_import::h76c75e107025e2e2
  20:     0x7f00b6cbc264 - rustc_resolve::imports::ImportResolver::finalize_imports::he85ec07cc64ca3c8
  21:     0x7f00b6c82a3d - rustc_session::utils::<impl rustc_session::session::Session>::time::h9854589b3d4dd27d
  22:     0x7f00b6c9bdd8 - rustc_resolve::Resolver::resolve_crate::h96defa47057f9e60
  23:     0x7f00b69a7772 - rustc_interface::passes::configure_and_expand_inner::h366bd5d9705caf86
  24:     0x7f00b69a4e7f - rustc_interface::passes::configure_and_expand::{{closure}}::hdcd19ae0ae2f6622
  25:     0x7f00b69a1de9 - rustc_data_structures::box_region::PinnedGenerator<I,A,R>::new::ha9961759bbb719c4
  26:     0x7f00b69a6a01 - rustc_interface::passes::configure_and_expand::hd360f21cdf4b8ebb
  27:     0x7f00b69b31f2 - rustc_interface::queries::Queries::expansion::hefd4b02c09a3d726
  28:     0x7f00b6979189 - rustc_span::with_session_globals::h6569bbb8a4ea9d61
  29:     0x7f00b699e8ff - std::sys_common::backtrace::__rust_begin_short_backtrace::h428dbdd434c4f112
  30:     0x7f00b69757b5 - core::ops::function::FnOnce::call_once{{vtable.shim}}::hb7785b7f871527db
  31:     0x7f00b46b2bb7 - <alloc::boxed::Box<F,A> as core::ops::function::FnOnce<Args>>::call_once::h79456d14677dd3c1
                               at /rustc/b663c0f4f6ff84a8c9df0f708e1f8d628330d973/library/alloc/src/boxed.rs:1575:9
  32:     0x7f00b46b2bb7 - <alloc::boxed::Box<F,A> as core::ops::function::FnOnce<Args>>::call_once::h5c40c73501d779c0
                               at /rustc/b663c0f4f6ff84a8c9df0f708e1f8d628330d973/library/alloc/src/boxed.rs:1575:9
  33:     0x7f00b46b2bb7 - std::sys::unix::thread::Thread::new::thread_start::h55fc0fe77abc7cf7
                               at /rustc/b663c0f4f6ff84a8c9df0f708e1f8d628330d973/library/std/src/sys/unix/thread.rs:71:17
  34:     0x7f00b43f36db - start_thread
  35:     0x7f00b3d1071f - __clone
  36:                0x0 - <unknown>

@ralpha ralpha added C-bug Category: This is a bug. I-ICE Issue: The compiler panicked, giving an Internal Compilation Error (ICE) ❄️ T-compiler Relevant to the compiler team, which will review and decide on the PR/issue. labels Jun 4, 2021
@jonas-schievink jonas-schievink added A-macros Area: All kinds of macros (custom derive, macro_rules!, proc macros, ..) E-needs-mcve Call for participation: This issue has a repro, but needs a Minimal Complete and Verifiable Example labels Jun 4, 2021
@ralpha
Copy link
Author

ralpha commented Jun 4, 2021

I just found out the problem exists because of:

pub use crate::server::rocket;

If I comment out that line it will not report an internal error anymore.
I had a function rocket() but I also use the crate rocket
I now renamed the function but still getting errors.

So it is likely because of a ambiguity issue.
Trying to reproduce it in minimal code example, but not yet been able to do so.

@ralpha
Copy link
Author

ralpha commented Jun 7, 2021

After some testing a narrowed it down to the following:
Cargo.toml:

[package]
name = "test_ice"
version = "0.1.0"
authors = ["username"]
edition = "2018"
publish = false

[dependencies]
diesel = { version = "1.4.6",   default-features = false }
diesel_migrations = { version = "1.4.0", default-features = false }
rocket = { version = "0.4.10",   default-features = false }
rocket_contrib = { version = "0.4.10",   default-features = false, features = ["diesel_postgres_pool"] }

lib.rs:

use diesel::Connection;
use rocket_contrib::database;

#[database("test_db")]
pub struct TestDb(diesel::PgConnection);

use crate::rocket;

My guess why this fails:
The #[database("test_db")] macro uses rocket inside of it. But when I try to export this it can not find it.

commenting out/removing any line will give a normal compile error.
I hope this helps to find out the problem.
The error always happens and can thus be reliably reproduced.
I tested this on latest nightly too:

rustc 1.54.0-nightly (35fff69d0 2021-06-06)
binary: rustc
commit-hash: 35fff69d043b1c0f5c29894e7f4b0da8b039c131
commit-date: 2021-06-06
host: x86_64-unknown-linux-gnu
release: 1.54.0-nightly
LLVM version: 12.0.1

@petrochenkov petrochenkov self-assigned this Jun 7, 2021
@bvanjoi
Copy link
Contributor

bvanjoi commented Jun 28, 2023

reduced:

// code.rs

issue_85992_extern_1::m!();

use crate::issue_85992_extern_2;

fn main() {}
// issue_85992_extern_1.rs
#[macro_export]
macro_rules! m {
   () => {
        use issue_85992_extern_2::Outcome;
   }
}
// issue_85992_extern_2.rs
// nothing

@bvanjoi
Copy link
Contributor

bvanjoi commented Jun 28, 2023

Hi @petrochenkov, can you assign it to me? I would like to give it a try and solve it.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
A-macros Area: All kinds of macros (custom derive, macro_rules!, proc macros, ..) C-bug Category: This is a bug. E-needs-mcve Call for participation: This issue has a repro, but needs a Minimal Complete and Verifiable Example I-ICE Issue: The compiler panicked, giving an Internal Compilation Error (ICE) ❄️ T-compiler Relevant to the compiler team, which will review and decide on the PR/issue.
Projects
None yet
Development

Successfully merging a pull request may close this issue.

4 participants