Closed
Description
The following scenario used to work fine 1.25.0:
echo '
pub fn hello_world()
{
println!("hello world");
}
' > bar.rs
echo '
extern crate bar;
pub fn foo()
{
bar::hello_world();
}
' > foo.rs
rustc --crate-type rlib --emit metadata bar.rs
rustc --crate-type rlib --emit llvm-bc bar.rs
rustc --crate-type rlib --emit llvm-bc foo.rs -L .
This would create two .bc files that could be linked together into a program, but when I try this on 1.26.{0,1,2} the compiler crashes like so:
error: internal compiler error: librustc_mir/monomorphize/collector.rs:746: Cannot create local mono-item for DefId(11/0:3 ~ bar[8787]::hello_world[0])
thread 'rustc' panicked at 'Box<Any>', librustc_errors/lib.rs:543:9
note: Some details are omitted, run with `RUST_BACKTRACE=full` for a verbose backtrace.
stack backtrace:
0: std::sys::unix::backtrace::tracing::imp::unwind_backtrace
at libstd/sys/unix/backtrace/tracing/gcc_s.rs:49
1: std::sys_common::backtrace::print
at libstd/sys_common/backtrace.rs:71
at libstd/sys_common/backtrace.rs:59
2: std::panicking::default_hook::{{closure}}
at libstd/panicking.rs:207
3: std::panicking::default_hook
at libstd/panicking.rs:223
4: core::ops::function::Fn::call
5: std::panicking::rust_panic_with_hook
at libstd/panicking.rs:403
6: std::panicking::begin_panic
7: rustc_errors::Handler::bug
8: rustc::session::opt_span_bug_fmt::{{closure}}
9: rustc::ty::context::tls::with_opt::{{closure}}
10: <std::thread::local::LocalKey<T>>::try_with
11: <std::thread::local::LocalKey<T>>::with
12: rustc::ty::context::tls::with
13: rustc::ty::context::tls::with_opt
14: rustc::session::opt_span_bug_fmt
15: rustc::session::bug_fmt
16: rustc_mir::monomorphize::collector::should_monomorphize_locally
17: rustc_mir::monomorphize::collector::visit_instance_use
18: <rustc_mir::monomorphize::collector::MirNeighborCollector<'a, 'tcx> as rustc::mir::visit::Visitor<'tcx>>::visit_terminator_kind
19: rustc_mir::monomorphize::collector::collect_items_rec
20: rustc_mir::monomorphize::collector::collect_crate_mono_items
21: rustc::util::common::time
22: rustc_trans::base::collect_and_partition_translation_items
23: rustc::dep_graph::graph::DepGraph::with_task_impl
24: rustc_errors::Handler::track_diagnostics
25: rustc::ty::maps::plumbing::<impl rustc::ty::context::TyCtxt<'a, 'gcx, 'tcx>>::cycle_check
26: rustc::ty::maps::<impl rustc::ty::maps::queries::collect_and_partition_translation_items<'tcx>>::force
27: rustc::ty::maps::<impl rustc::ty::maps::queries::collect_and_partition_translation_items<'tcx>>::try_get
28: rustc::ty::maps::TyCtxtAt::collect_and_partition_translation_items
29: rustc::ty::maps::<impl rustc::ty::context::TyCtxt<'a, 'tcx, 'lcx>>::collect_and_partition_translation_items
30: rustc_trans::base::trans_crate
31: <rustc_trans::LlvmTransCrate as rustc_trans_utils::trans_crate::TransCrate>::trans_crate
32: rustc::util::common::time
33: rustc_driver::driver::phase_4_translate_to_llvm
34: rustc_driver::driver::compile_input::{{closure}}
35: <std::thread::local::LocalKey<T>>::with
36: <std::thread::local::LocalKey<T>>::with
37: rustc::ty::context::TyCtxt::create_and_enter
38: rustc_driver::driver::compile_input
39: rustc_driver::run_compiler_impl
40: syntax::with_globals
error: aborting due to previous error
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: rustc 1.26.2 (594fb253c 2018-06-01) running on x86_64-unknown-linux-gnu
note: compiler flags: --crate-type rlib