-
Notifications
You must be signed in to change notification settings - Fork 12.9k
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
impl Future used across crate boundaries produces an error #41297
Comments
Use
Please correct me if I'm wrong. So add
However, I wonder if this is still an issue to be fix? Also to note, I believe the reason for the error because doc code failed. If it passed, this error wouldn't be shown. |
Here is a link that reference to what I just mention about |
I don't want to disable the tests, though. I do like that it checks whether the code in the doc works. |
Yes, it is, because an ICE is always a bug. |
Looks like the "standard" impl-trait reachability problems - the ICE occurs because |
Does someone have an idea how I could bypass this ICE? (I have it in regular code, not in a doctest). I've been trying various work-arounds for 40 minutes now and am totally blocked by it. |
Same thing happens if you comment out |
@Limeth @arielb1 I believe this is not just about doctests, but happens occasionally when // foo/src/lib.rs
#![feature(conservative_impl_trait)]
extern crate futures;
use futures::{Future, future};
pub struct Foo;
impl Foo {
fn id(self) -> Self {
self
}
pub fn new() -> impl Future<Item = Self, Error = ()> + 'static {
future::lazy(|| future::ok(Foo.id()))
}
} // bar/src/main.rs
extern crate foo;
extern crate tokio_core;
fn main() {
let mut core = tokio_core::reactor::Core::new().unwrap();
core.run(foo::Foo::new()).unwrap();
} $ cargo run # in bar/
error: internal compiler error: /checkout/src/librustc_trans/collector.rs:657: Cannot create local trans-item for DefId { krate: CrateNum(11), node: DefIndex(9) => foo/c66423d::{{impl}}[0]::id[0] }
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.20.0-nightly (445077963 2017-06-20) running on x86_64-unknown-linux-gnu
note: run with `RUST_BACKTRACE=1` for a backtrace
thread 'rustc' panicked at 'Box<Any>', /checkout/src/librustc_errors/lib.rs:478
note: Some details are omitted, run with `RUST_BACKTRACE=full` for a verbose backtrace.
stack backtrace:
0: std::sys::imp::backtrace::tracing::imp::unwind_backtrace
at /checkout/src/libstd/sys/unix/backtrace/tracing/gcc_s.rs:49
1: std::sys_common::backtrace::_print
at /checkout/src/libstd/sys_common/backtrace.rs:71
2: std::panicking::default_hook::{{closure}}
at /checkout/src/libstd/sys_common/backtrace.rs:60
at /checkout/src/libstd/panicking.rs:355
3: std::panicking::default_hook
at /checkout/src/libstd/panicking.rs:365
4: std::panicking::rust_panic_with_hook
at /checkout/src/libstd/panicking.rs:549
5: std::panicking::begin_panic
6: rustc_errors::Handler::bug
7: rustc::session::opt_span_bug_fmt::{{closure}}
8: rustc::session::opt_span_bug_fmt
9: rustc::session::bug_fmt
10: rustc_trans::collector::should_trans_locally
11: rustc_trans::collector::visit_instance_use
12: <rustc_trans::collector::MirNeighborCollector<'a, 'tcx> as rustc::mir::visit::Visitor<'tcx>>::visit_terminator_kind
13: rustc::mir::visit::Visitor::visit_mir
14: rustc_trans::collector::collect_items_rec
15: rustc_trans::collector::collect_items_rec
16: rustc_trans::collector::collect_items_rec
17: rustc_trans::collector::collect_items_rec
18: rustc_trans::collector::collect_items_rec
19: rustc_trans::collector::collect_items_rec
20: rustc_trans::collector::collect_items_rec
21: rustc_trans::collector::collect_items_rec
22: rustc_trans::collector::collect_items_rec
23: rustc_trans::collector::collect_items_rec
24: rustc_trans::collector::collect_items_rec
25: rustc_trans::collector::collect_items_rec
26: rustc_trans::collector::collect_items_rec
27: rustc_trans::base::collect_and_partition_translation_items::{{closure}}
28: rustc_trans::base::trans_crate
29: rustc_driver::driver::phase_4_translate_to_llvm
30: rustc_driver::driver::compile_input::{{closure}}
31: rustc_driver::driver::phase_3_run_analysis_passes::{{closure}}
32: rustc_driver::driver::phase_3_run_analysis_passes
33: rustc_driver::driver::compile_input
34: rustc_driver::run_compiler
error: Could not compile `bar`. |
Thank you for the thorough examination. |
@Limeth happy to help! You may want to update the issue title though? |
For convenience, the tracking issue for |
Do we have a reproducible, relatively minimal test case here? Seems like that is the first goal. |
triage: P-medium |
triage: P-high we do after all want to stabilize impl trait and use it for exactly this use case =) |
@nikomatsakis the smallest code example I could come up with to reproduce is the one in #41297 (comment), but it unfortunately pulls in both futures and tokio :/ |
@jonhoo I think it's enough, because, remember, from the compiler's point of view, futures are just stranger iterators. Here it looks like necessary elements involve a monomorphic closure calling a monomorphic private function. What happens if you put |
@eddyb Both |
See in particular rust-lang/rust#41297 (comment). This change should be reverted once a fix for that issue lands.
#43135 is a duplicate, and has a test case described there; can someone work on this? |
I have what I believe is a minimal case for this: // 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()();
}
|
This should be E-needstest. I confirmed the fix for my code, and I assume this is resolved. Ref: #43857 |
Not sure it's completely resolved. I have a lib crate A and a bin crate B that uses A. A has two functions that hit this - When I changed When I also converted This is with 2017-08-15's nightly so it has #43857 |
Sure it is very slow, and probably a separate issue. I think #43787 is related, but anyway this issue should be kept to track only the ICE. |
I'm not sure if your comparison makes sense. I have totally no confidence if #43787 is related or not, and "aborting after 5min" and "completed in 20min" sounds same to me. |
"Aborting after 5min" was the experiment from 6 hours ago. After I confirmed that the local build finished compiling in 20 mins, I reran the build using 2017-08-15 nightly and it's still running as of 40 mins. So yes, changing the one line described in the comment in #43787 did have an effect. It's not a complete fix (it shouldn't be taking 20 mins to compile) which is why I said it's some combination of the slowdown + this impl trait issue. |
I think giving a reproduce case (not necessarily short) to the compiler team would help as they would profile and narrow the problem down. Do you have a specific revision in public repository? |
https://github.com/Arnavion/fac-rs/commits/master - compiles Edit: Just to quantify "never finishes compiling" - it didn't finish even after being left for 6 hours overnight. |
@Arnavion can you run with RUST_LOG=trace and paste the line where it starts hanging? |
I had a similar issue. See #40839 (comment) |
@Arnavion can you open a separate issue perhaps on that problem? |
Closing for now, since the main problem here is fixed. @Arnavion if you can open a separate issue with a complete description of the problems you encountered, would be much appreciated! |
@nikomatsakis Not needed. #43999 already fixes it. |
Now that rust-lang/rust#41297 has been closed by rust-lang/rust#43857, this hack is no longer needed to make the code compile.
See in particular rust-lang/rust#41297 (comment). This change should be reverted once a fix for that issue lands.
Now that rust-lang/rust#41297 has been closed by rust-lang/rust#43857, this hack is no longer needed to make the code compile.
Compilation of crate docs (at the beginning of
lib.rs
) failed when runningenv RUST_BACKTRACE=full cargo test -- --nocapture
.I tried this code:
(see lib.rs for the whole file, successfully compiled)
I expected to see this happen: A successful compilation, or an error message displayed.
Meta
Log
Edit: Minimal case by @alexcrichton
producer the error when built using
The text was updated successfully, but these errors were encountered: