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

Compiler panics when documenting sub-crate with links to types of super-crate on latest nightly #54100

Closed
Lythenas opened this issue Sep 10, 2018 · 7 comments · Fixed by #57846
Labels
I-ICE Issue: The compiler panicked, giving an Internal Compilation Error (ICE) ❄️

Comments

@Lythenas
Copy link

When I run cargo doc on this repo (branch refactor-datatypes) I receive an internal compiler error.

Everything works fine on stable (cargo +stable doc). Also everything works if I remove the links in the doc comments.

Meta

rustc --version --verbose:

rustc 1.30.0-nightly (2d4e34ca8 2018-09-09)
binary: rustc
commit-hash: 2d4e34ca8bb1369f7e0eea4cb50e6faa0827a6e5
commit-date: 2018-09-09
host: x86_64-unknown-linux-gnu
release: 1.30.0-nightly
LLVM version: 8.0

Backtrace:

 Documenting rust-orgmode-derive v0.1.0 (file:///home/ms/Repositories/rust-orgmode/rust-orgmode-derive)
thread '<unnamed>' panicked at 'called `Option::unwrap()` on a `None` value', libcore/option.rs:345:21
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:211
   3: std::panicking::default_hook
             at libstd/panicking.rs:227
   4: std::panicking::rust_panic_with_hook
             at libstd/panicking.rs:477
   5: std::panicking::continue_panic_fmt
             at libstd/panicking.rs:391
   6: rust_begin_unwind
             at libstd/panicking.rs:326
   7: core::panicking::panic_fmt
             at libcore/panicking.rs:77
   8: core::panicking::panic
             at libcore/panicking.rs:52
   9: rustc_metadata::cstore::CStore::get_crate_data
  10: rustc_metadata::cstore_impl::<impl rustc_metadata::cstore::CStore>::load_macro_untracked
  11: rustc_resolve::build_reduced_graph::<impl rustc_resolve::Resolver<'a, 'cl>>::get_macro
  12: rustdoc::passes::collect_intra_doc_links::macro_resolve
             at librustdoc/passes/collect_intra_doc_links.rs:407
  13: <rustdoc::passes::collect_intra_doc_links::LinkCollector<'a, 'tcx, 'rcx, 'cstore> as rustdoc::fold::DocFolder>::fold_item
             at librustdoc/passes/collect_intra_doc_links.rs:318
  14: <alloc::vec::Vec<T> as alloc::vec::SpecExtend<T, I>>::from_iter
             at librustdoc/fold.rs:50
             at /checkout/src/libcore/iter/mod.rs:1640
             at /checkout/src/liballoc/vec.rs:1860
  15: <alloc::vec::Vec<T> as alloc::vec::SpecExtend<T, I>>::from_iter
  16: rustdoc::fold::DocFolder::fold_inner_recur
             at /checkout/src/liballoc/vec.rs:1772
             at /checkout/src/libcore/iter/iterator.rs:1415
             at librustdoc/fold.rs:112
             at librustdoc/fold.rs:39
  17: rustdoc::fold::DocFolder::fold_item_recur
             at librustdoc/fold.rs:102
  18: <rustdoc::passes::collect_intra_doc_links::LinkCollector<'a, 'tcx, 'rcx, 'cstore> as rustdoc::fold::DocFolder>::fold_item
             at librustdoc/passes/collect_intra_doc_links.rs:387
  19: rustdoc::passes::collect_intra_doc_links::collect_intra_doc_links
             at librustdoc/fold.rs:117
             at /checkout/src/libcore/option.rs:622
             at librustdoc/fold.rs:117
             at librustdoc/passes/collect_intra_doc_links.rs:40
  20: rustdoc::core::run_core::{{closure}}::{{closure}}
             at librustdoc/core.rs:595
  21: rustc::ty::context::tls::enter_context
             at /checkout/src/librustc_driver/driver.rs:1349
             at /checkout/src/librustc/ty/context.rs:1959
             at /checkout/src/librustc/ty/context.rs:1927
             at /checkout/src/librustc/ty/context.rs:1866
             at /checkout/src/librustc/ty/context.rs:1926
  22: <std::thread::local::LocalKey<T>>::with
             at /checkout/src/librustc/ty/context.rs:1958
             at /checkout/src/librustc/ty/context.rs:1916
             at /checkout/src/libstd/thread/local.rs:294
             at /checkout/src/libstd/thread/local.rs:248
             at /checkout/src/librustc/ty/context.rs:1908
             at /checkout/src/libstd/thread/local.rs:294
             at /checkout/src/libstd/thread/local.rs:248
  23: rustc::ty::context::TyCtxt::create_and_enter
             at /checkout/src/librustc/ty/context.rs:1900
             at /checkout/src/librustc/ty/context.rs:1938
             at /checkout/src/librustc/ty/context.rs:1244
  24: rustc_driver::driver::phase_3_run_analysis_passes
             at /checkout/src/librustc_driver/driver.rs:1257
  25: <scoped_tls::ScopedKey<T>>::set
             at librustdoc/core.rs:478
             at /checkout/src/librustc_driver/driver.rs:74
             at /cargo/registry/src/github.com-1ecc6299db9ec823/scoped-tls-0.1.2/src/lib.rs:155
  26: rustdoc::core::run_core
             at /checkout/src/librustc_driver/driver.rs:73
             at librustdoc/core.rs:389
  27: <scoped_tls::ScopedKey<T>>::set
             at librustdoc/lib.rs:704
             at /cargo/registry/src/github.com-1ecc6299db9ec823/scoped-tls-0.1.2/src/lib.rs:155
             at /checkout/src/libsyntax/lib.rs:108
             at /cargo/registry/src/github.com-1ecc6299db9ec823/scoped-tls-0.1.2/src/lib.rs:155
  28: syntax::with_globals
             at /checkout/src/libsyntax/lib.rs:107
  29: <std::panic::AssertUnwindSafe<F> as core::ops::function::FnOnce<()>>::call_once
             at librustdoc/lib.rs:700
             at /checkout/src/librustc_driver/lib.rs:1660
             at /checkout/src/libstd/panic.rs:313
  30: std::panicking::try::do_call
             at /checkout/src/libstd/panicking.rs:310
  31: __rust_maybe_catch_panic
             at libpanic_unwind/lib.rs:103
  32: rustc_driver::monitor
             at /checkout/src/libstd/panicking.rs:289
             at /checkout/src/libstd/panic.rs:392
             at /checkout/src/librustc_driver/lib.rs:1574
             at /checkout/src/librustc_driver/lib.rs:1585
             at /checkout/src/librustc_driver/lib.rs:1659
  33: rustdoc::rust_input
             at librustdoc/lib.rs:700
  34: rustdoc::main_args
             at librustdoc/lib.rs:606
             at librustdoc/lib.rs:561
  35: <scoped_tls::ScopedKey<T>>::set
             at librustdoc/lib.rs:114
             at /checkout/src/libcore/option.rs:414
             at librustdoc/lib.rs:114
             at /cargo/registry/src/github.com-1ecc6299db9ec823/scoped-tls-0.1.2/src/lib.rs:155
             at /checkout/src/libsyntax/lib.rs:108
             at /cargo/registry/src/github.com-1ecc6299db9ec823/scoped-tls-0.1.2/src/lib.rs:155

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

note: rustc 1.30.0-nightly (2d4e34ca8 2018-09-09) running on x86_64-unknown-linux-gnu

error: Could not document `rust-orgmode-derive`.

Caused by:
  process didn't exit successfully: `rustdoc --crate-name rust_orgmode_derive rust-orgmode-derive/src/lib.rs -o /home/ms/Repositories/rust-orgmode/target/doc -L dependency=/home/ms/Repositories/rust-orgmode/target/debug/deps --extern proc_macro2=/home/ms/Repositories/rust-orgmode/target/debug/deps/libproc_macro2-2a0be5cad0cff56a.rmeta --extern quote=/home/ms/Repositories/rust-orgmode/target/debug/deps/libquote-e88e473e5c853f90.rmeta --extern syn=/home/ms/Repositories/rust-orgmode/target/debug/deps/libsyn-2a9b333a8e49d3d1.rmeta` (exit code: 1)
@memoryruins memoryruins added the I-ICE Issue: The compiler panicked, giving an Internal Compilation Error (ICE) ❄️ label Sep 11, 2018
@Lythenas
Copy link
Author

I removed the links in the latest commits so I can document on nightly. The latest commit that still contains the links is: Lythenas/rust-orgmode@b1c65e8

@Lythenas
Copy link
Author

I experimented a little more and found the following:

When I have a doc comment with one link everything works:

/// ...
/// [`SharedBehavior`]
/// ...

Also when specifying the link target it works:

/// ...
/// [`SharedBehavior`]
/// ...
/// [`SharedBehavior`]: ../rust_orgmode/types/trait.SharedBehavior.html

When there is more than one link in one doc comment the compiler panics:

/// ...
/// [`SharedBehavior`]
/// [`HasAffiliatedKeywords`]
/// ...

Even when one of them has a link target:

/// ...
/// [`SharedBehavior`]
/// [`HasAffiliatedKeywords`]
/// ...
/// [`SharedBehavior`]: ../rust_orgmode/types/trait.SharedBehavior.html

But it works when both links have a target:

/// ...
/// [`SharedBehavior`]
/// [`HasAffiliatedKeywords`]
/// ...
/// [`SharedBehavior`]: ../rust_orgmode/types/trait.SharedBehavior.html
/// [`HasAffiliatedKeywords`]: ../rust_orgmode/types/trait.HasAffiliatedKeywords.html

Also this does not happen in the main crate only in the sub-crate. I followed the proc macro guide in the book and created a subfolder named "rust-orgmode-derive. And in the Cargo.toml of the main crate I added rust-orgmode-derive = { path = "rust-orgmode-derive" } to the dependencies.

@QuietMisdreavus
Copy link
Member

I just tried to document that commit you linked with rustdoc 1.33.0-nightly (b92552d55 2019-01-06), and it did not give the same ICE. It looks like this issue has been fixed?

@Lythenas
Copy link
Author

With the above commit I still get the same error using rustc 1.33.0-nightly (4c2be9c97 2019-01-22).

@QuietMisdreavus
Copy link
Member

I'm afraid i'm not seeing it. Is this the right commit?

$ cargo +nightly-2019-01-23 rustdoc
 Documenting rust-orgmode v0.1.0 (/home/misdreavus/clones/rust-orgmode)
error: macro attributes must be placed before `#[derive]`
   --> src/types.rs:337:5
    |
337 |     #[shared_behavior]
    |     ^^^^^^^^^^^^^^^^^^

error: Compilation failed, aborting rustdoc

error: Could not document `rust-orgmode`.

Caused by:
  process didn't exit successfully: `rustdoc --crate-name rust_orgmode src/lib.rs --color always -o /home/misdreavus/clones/rust-orgmode/target/doc -L dependency=/home/misdreavus/clones/rust-orgmode/target/debug/deps --extern chrono=/home/misdreavus/clones/rust-orgmode/target/debug/deps/libchrono-af84f74b14cc1ea4.rmeta --extern failure=/home/misdreavus/clones/rust-orgmode/target/debug/deps/libfailure-13c12b1584de9b63.rmeta --extern failure_derive=/home/misdreavus/clones/rust-orgmode/target/debug/deps/libfailure_derive-4ee6c3df09cefde1.so --extern itertools=/home/misdreavus/clones/rust-orgmode/target/debug/deps/libitertools-1eac39dcb8e2c9f2.rmeta --extern lazy_static=/home/misdreavus/clones/rust-orgmode/target/debug/deps/liblazy_static-41d603f7ffea7a88.rmeta --extern nom=/home/misdreavus/clones/rust-orgmode/target/debug/deps/libnom-77224f728ad9d909.rmeta --extern regex=/home/misdreavus/clones/rust-orgmode/target/debug/deps/libregex-b88256a3f94d06b2.rmeta --extern rust_orgmode_derive=/home/misdreavus/clones/rust-orgmode/target/debug/deps/librust_orgmode_derive-83a3597b783b8ae9.so` (exit code: 1)

$ rustc +nightly-2019-01-23 --version
rustc 1.33.0-nightly (4c2be9c97 2019-01-22)

$ git status
HEAD detached at b1c65e8
nothing to commit, working tree clean

@QuietMisdreavus
Copy link
Member

Aha! I looked again and it turns out i'm documenting the wrong crate.

$ cargo +nightly-2019-01-23 rustdoc -p rust-orgmode-derive
    Checking unicode-xid v0.1.0
    Checking proc-macro2 v0.4.17
    Checking quote v0.6.8
    Checking syn v0.15.3
 Documenting rust-orgmode-derive v0.1.0 (/home/misdreavus/clones/rust-orgmode/rust-orgmode-derive)
thread 'rustc' panicked at 'called `Option::unwrap()` on a `None` value', src/libcore/option.rs:345: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/blob/master/CONTRIBUTING.md#bug-reports

note: rustc 1.33.0-nightly (4c2be9c97 2019-01-22) running on x86_64-unknown-linux-gnu

error: Could not document `rust-orgmode-derive`.

Caused by:
  process didn't exit successfully: `rustdoc --crate-name rust_orgmode_derive rust-orgmode-derive/src/lib.rs --color always -o /home/misdreavus/clones/rust-orgmode/target/doc -L dependency=/home/misdreavus/clones/rust-orgmode/target/debug/deps --extern proc_macro2=/home/misdreavus/clones/rust-orgmode/target/debug/deps/libproc_macro2-7d0cb2f69b5e6e7d.rmeta --extern quote=/home/misdreavus/clones/rust-orgmode/target/debug/deps/libquote-9877f9e0a5ea1a89.rmeta --extern syn=/home/misdreavus/clones/rust-orgmode/target/debug/deps/libsyn-97f0413104af47b5.rmeta` (exit code: 1)

It looks like #57846 fixes this issue as well!

@Lythenas
Copy link
Author

Sorry I forgot to mention that you have to swap two lines to get it to compile. Because now you have to put attributes before derive, which was not the case when I wrote this.

But thanks for fixing this 👍

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
I-ICE Issue: The compiler panicked, giving an Internal Compilation Error (ICE) ❄️
Projects
None yet
Development

Successfully merging a pull request may close this issue.

3 participants