Skip to content

impl Future used across crate boundaries produces an error #41297

Closed
@Limeth

Description

@Limeth

Compilation of crate docs (at the beginning of lib.rs) failed when running env RUST_BACKTRACE=full cargo test -- --nocapture.

I tried this code:

//! An API for http://ip-api.com/ written in the Rust language.
//!
//! This library lets you request information about an IP address.
//! It uses `futures` to deliver the result.
//!
//! You will need the `tokio_core` create in order to use this library.
//! # Examples
//!
//! ```
//! # extern crate futures;
//! # extern crate tokio_core;
//! # extern crate ip_api;
//! use std::net::{IpAddr, Ipv4Addr};
//! use tokio_core::reactor::Core;
//! use futures::future::Future;
//! use ip_api::IpApi;
//!
//! # #[allow(unused_variables)]
//! # fn main() {
//! let mut core = Core::new().unwrap();
//! let handle = core.handle();
//! let ip_api = IpApi::new(handle);
//! let future = ip_api.request(Some(IpAddr::V4(Ipv4Addr::new(8, 8, 8, 8))))
//!     .map(|result| {
//!         println!("{:?}", result);
//!     });
//!
//! core.run(future).unwrap();
//! # }
//! ```

(see lib.rs for the whole file, successfully compiled)

I expected to see this happen: A successful compilation, or an error message displayed.

Meta

rustc 1.18.0-nightly (c58c928e6 2017-04-11)
binary: rustc
commit-hash: c58c928e658d2e45f816fd05796a964aa83759da
commit-date: 2017-04-11
host: x86_64-unknown-linux-gnu
release: 1.18.0-nightly
LLVM version: 3.9

Log

    Finished dev [unoptimized + debuginfo] target(s) in 5.55 secs
     Running target/debug/deps/ip_api-b628445a6205873b

running 1 test
test tests::it_works ... ok

test result: ok. 1 passed; 0 failed; 0 ignored; 0 measured

   Doc-tests ip-api

running 2 tests
error: internal compiler error: /checkout/src/librustc_trans/collector.rs:668: Cannot create local trans-item for DefId { krate: CrateNum(26), node: DefIndex(23) => ip_api/b6a065cc65916384c1a936b4d0f34bb4::get_string[0] }

thread 'rustc' panicked at 'Box<Any>', /checkout/src/librustc_errors/lib.rs:416
stack backtrace:
   0:     0x7f0464cff0f3 - std::sys::imp::backtrace::tracing::imp::unwind_backtrace::hab274209b3900f9c
                               at /checkout/src/libstd/sys/unix/backtrace/tracing/gcc_s.rs:49
   1:     0x7f0464cf97d4 - std::sys_common::backtrace::_print::h8f655fc4b25b9b70
                               at /checkout/src/libstd/sys_common/backtrace.rs:71
   2:     0x7f0464d0d047 - std::panicking::default_hook::{{closure}}::hd0f0fde26cdd4a91
                               at /checkout/src/libstd/sys_common/backtrace.rs:60
                               at /checkout/src/libstd/panicking.rs:355
   3:     0x7f0464d0cbac - std::panicking::default_hook::h123df66825ae8c79
                               at /checkout/src/libstd/panicking.rs:365
   4:     0x7f0464d0d51b - std::panicking::rust_panic_with_hook::h3635757261b59272
                               at /checkout/src/libstd/panicking.rs:549
   5:     0x7f045d7f2e27 - std::panicking::begin_panic::h7bb0c7bba9a436bf
   6:     0x7f045d80cb79 - rustc_errors::Handler::bug::h45cc5a767a46e974
   7:     0x7f0461c0138a - rustc::session::opt_span_bug_fmt::{{closure}}::hfbfe9f66fec7d051
   8:     0x7f0461c00dc7 - rustc::session::opt_span_bug_fmt::h4aac6d7f7dbc3512
   9:     0x7f0461c00a22 - rustc::session::bug_fmt::h0bea60fd591127eb
  10:     0x7f0463a51de1 - rustc_trans::collector::should_trans_locally::h4656782e9eb00175
  11:     0x7f0463a51a5b - rustc_trans::collector::visit_instance_use::h4f153b416289b87f
  12:     0x7f0463a5173d - <rustc_trans::collector::MirNeighborCollector<'a, 'tcx> as rustc::mir::visit::Visitor<'tcx>>::visit_terminator_kind::h101e5aee6ff39360
  13:     0x7f04639e6b88 - rustc::mir::visit::Visitor::visit_mir::hcbffa68f7c70641d
  14:     0x7f0463a534b8 - rustc_trans::collector::collect_neighbours::hd2f5dd549eec023d
  15:     0x7f0463a4faef - rustc_trans::collector::collect_items_rec::h6c7176696c5743fe
  16:     0x7f0463a4fdcf - rustc_trans::collector::collect_items_rec::h6c7176696c5743fe
  17:     0x7f0463a4fdcf - rustc_trans::collector::collect_items_rec::h6c7176696c5743fe
  18:     0x7f0463a4fdcf - rustc_trans::collector::collect_items_rec::h6c7176696c5743fe
  19:     0x7f0463a4fdcf - rustc_trans::collector::collect_items_rec::h6c7176696c5743fe
  20:     0x7f0463a4fdcf - rustc_trans::collector::collect_items_rec::h6c7176696c5743fe
  21:     0x7f0463a4fdcf - rustc_trans::collector::collect_items_rec::h6c7176696c5743fe
  22:     0x7f0463a4fdcf - rustc_trans::collector::collect_items_rec::h6c7176696c5743fe
  23:     0x7f0463a4fdcf - rustc_trans::collector::collect_items_rec::h6c7176696c5743fe
  24:     0x7f0463a4fdcf - rustc_trans::collector::collect_items_rec::h6c7176696c5743fe
  25:     0x7f0463a4fdcf - rustc_trans::collector::collect_items_rec::h6c7176696c5743fe
  26:     0x7f0463a4fdcf - rustc_trans::collector::collect_items_rec::h6c7176696c5743fe
  27:     0x7f0463a4fdcf - rustc_trans::collector::collect_items_rec::h6c7176696c5743fe
  28:     0x7f0463a4fdcf - rustc_trans::collector::collect_items_rec::h6c7176696c5743fe
  29:     0x7f0463a4fdcf - rustc_trans::collector::collect_items_rec::h6c7176696c5743fe
  30:     0x7f0463a4c526 - rustc_trans::base::collect_and_partition_translation_items::{{closure}}::h63d2a00c3084c991
  31:     0x7f0463a47970 - rustc_trans::base::collect_and_partition_translation_items::hadb2691f60818418
  32:     0x7f0463a3bcbb - rustc_trans::base::trans_crate::hace7d592cac048a9
  33:     0x7f046461d1c9 - rustc_driver::driver::phase_4_translate_to_llvm::h904e3fc572f42e2d
  34:     0x7f04645db2b8 - rustc_driver::driver::compile_input::{{closure}}::hc476f85d4e1ed8fa
  35:     0x7f046460fbf5 - rustc_driver::driver::phase_3_run_analysis_passes::{{closure}}::ha83538a03579857c
  36:     0x7f046454a4a2 - rustc::ty::context::TyCtxt::create_and_enter::hd9482ac47b3dbb7c
  37:     0x7f0464603b2b - rustc_driver::driver::phase_3_run_analysis_passes::hfea44285662197cc
  38:     0x7f04645d11ef - rustc_driver::driver::compile_input::hc74994fea2a7b3d8
  39:     0x7f0465030893 - std::panicking::try::do_call::he2b177adc905cdbd
  40:     0x7f0464d1654a - __rust_maybe_catch_panic
                               at /checkout/src/libpanic_unwind/lib.rs:98
  41:     0x7f04651aa01b - rustdoc::test::runtest::h0596586cc6ee1092
  42:     0x7f046502ff97 - std::panicking::try::do_call::h5e36b666e0a8d2a1
  43:     0x7f0464d1654a - __rust_maybe_catch_panic
                               at /checkout/src/libpanic_unwind/lib.rs:98
  44:     0x7f046507a594 - <F as alloc::boxed::FnBox<A>>::call_box::h161bb4f304a420a4
  45:     0x7f0464d0be14 - std::sys::imp::thread::Thread::new::thread_start::h1b316ba1f093c5a7
                               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
  46:     0x7f045cd516b9 - start_thread
  47:     0x7f04649ba82c - clone
  48:                0x0 - <unknown>
thread 'rustc' panicked at 'couldn't compile the test', /checkout/src/librustdoc/test.rs:270
stack backtrace:
   0:     0x7f0464cff0f3 - std::sys::imp::backtrace::tracing::imp::unwind_backtrace::hab274209b3900f9c
                               at /checkout/src/libstd/sys/unix/backtrace/tracing/gcc_s.rs:49
   1:     0x7f0464cf97d4 - std::sys_common::backtrace::_print::h8f655fc4b25b9b70
                               at /checkout/src/libstd/sys_common/backtrace.rs:71
   2:     0x7f0464d0d047 - std::panicking::default_hook::{{closure}}::hd0f0fde26cdd4a91
                               at /checkout/src/libstd/sys_common/backtrace.rs:60
                               at /checkout/src/libstd/panicking.rs:355
   3:     0x7f0464d0cbac - std::panicking::default_hook::h123df66825ae8c79
                               at /checkout/src/libstd/panicking.rs:365
   4:     0x7f0464d0d51b - std::panicking::rust_panic_with_hook::h3635757261b59272
                               at /checkout/src/libstd/panicking.rs:549
   5:     0x7f046502fc6f - std::panicking::begin_panic::h6a220d6e24d23e61
   6:     0x7f04651ab858 - rustdoc::test::runtest::h0596586cc6ee1092
   7:     0x7f046502ff97 - std::panicking::try::do_call::h5e36b666e0a8d2a1
   8:     0x7f0464d1654a - __rust_maybe_catch_panic
                               at /checkout/src/libpanic_unwind/lib.rs:98
   9:     0x7f046507a594 - <F as alloc::boxed::FnBox<A>>::call_box::h161bb4f304a420a4
  10:     0x7f0464d0be14 - std::sys::imp::thread::Thread::new::thread_start::h1b316ba1f093c5a7
                               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
  11:     0x7f045cd516b9 - start_thread
  12:     0x7f04649ba82c - clone
  13:                0x0 - <unknown>
test src/lib.rs -  (line 9) ... FAILED
test src/lib.rs - IpApi (line 92) ... ok

failures:

failures:
    src/lib.rs -  (line 9)

test result: FAILED. 1 passed; 1 failed; 0 ignored; 0 measured

error: test failed, to rerun pass '--doc'

Edit: Minimal case by @alexcrichton

// foo.rs
#![crate_type = "lib"]
#![feature(conservative_impl_trait)]

fn bar() {}

pub fn foo() -> impl FnMut() {
    || {
        bar()
    }
}

// bar.rs
extern crate foo;

fn main() {
    foo::foo()();
}

producer the error when built using

$ rustc +nightly foo.rs
$ rustc +nightly bar.rs -L .

Metadata

Metadata

Assignees

Labels

A-impl-traitArea: `impl Trait`. Universally / existentially quantified anonymous types with static dispatch.C-bugCategory: This is a bug.I-ICEIssue: The compiler panicked, giving an Internal Compilation Error (ICE) ❄️P-highHigh priorityT-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