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

Rustdoc ICE with invalid intra rustdoc links #52611

Closed
yvt opened this issue Jul 22, 2018 · 4 comments
Closed

Rustdoc ICE with invalid intra rustdoc links #52611

yvt opened this issue Jul 22, 2018 · 4 comments
Labels
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. T-rustdoc Relevant to the rustdoc team, which will review and decide on the PR/issue.

Comments

@yvt
Copy link
Contributor

yvt commented Jul 22, 2018

The following code including an intra rustdoc link (#43466) crashes cargo doc ( rustc 1.29.0-nightly (874dec25e 2018-07-21)):

pub type TypeAlias = usize;

/// [broken cross-reference](TypeAlias::hoge)
pub fn some_public_item() {}

With the following output:

 Documenting my_crate_name v0.1.0 (file:///my_crate_path/my_crate_name)
error: internal compiler error: librustc_typeck/collect.rs:605: impossible case reached

thread '<unnamed>' panicked at 'Box<Any>', librustc_errors/lib.rs:557:9
stack backtrace:
   0:        0x1057e418f - std::sys::unix::backtrace::tracing::imp::unwind_backtrace::hcf8349fe897fa63a
   1:        0x1057bcd7a - std::sys_common::backtrace::print::hc274b78279f04e86
   2:        0x1057ebe73 - std::panicking::default_hook::{{closure}}::h559649071ca4adf8
   3:        0x1057ebbfc - std::panicking::default_hook::h1face3b5a352fe07
   4:        0x1057ec567 - std::panicking::rust_panic_with_hook::h4a24ff63f41e4491
   5:        0x10545a9e3 - std::panicking::begin_panic::hb3b4e0ec5512d348
   6:        0x1054565dc - rustc_errors::Handler::bug::h5e0086bc217b083f
   7:        0x103cb37e5 - rustc::session::opt_span_bug_fmt::{{closure}}::ha9978bb031dd11f8
   8:        0x103d7740c - rustc::ty::context::tls::with_opt::{{closure}}::h8d6cb447391bb8e8
   9:        0x103cb4758 - rustc::ty::context::tls::with_context_opt::h62d27409a047b21f
  10:        0x103d769f4 - rustc::ty::context::tls::with_opt::h2329e2eea4064820
  11:        0x103c2a524 - rustc::session::opt_span_bug_fmt::h68f7fa6347afcc10
  12:        0x103c2a471 - rustc::session::bug_fmt::ha3175f83d2fd7481
  13:        0x10295ed9c - rustc_typeck::collect::adt_def::h5dfd917dc1af3c10
  14:        0x103caa513 - rustc::ty::query::__query_compute::adt_def::hc61482ce28b518db
  15:        0x103d77bce - rustc::ty::query::<impl rustc::ty::query::config::QueryAccessors<'tcx> for rustc::ty::query::queries::adt_def<'tcx>>::compute::h8efb93d059bba9b7
  16:        0x103b947be - rustc::dep_graph::graph::DepGraph::with_task_impl::h8224618827541074
  17:        0x103d26505 - rustc::ty::context::tls::with_related_context::h5a3fb8a4ab1cb4a6
  18:        0x103e634f1 - rustc::ty::query::plumbing::<impl rustc::ty::context::TyCtxt<'a, 'gcx, 'tcx>>::force_query_with_job::hc774e6a77bed00a2
  19:        0x103f047a5 - rustc::ty::query::plumbing::<impl rustc::ty::context::TyCtxt<'a, 'gcx, 'tcx>>::get_query::h91e1c033d60db51b
  20:        0x103f74251 - rustc::ty::query::<impl rustc::ty::context::TyCtxt<'a, 'tcx, 'lcx>>::adt_def::hc753efab5ec9b088
  21:        0x101d98ce1 - rustdoc::clean::resolve::h064b9f991dec1289
  22:        0x101f40140 - <[syntax::ast::Attribute] as rustdoc::clean::Clean<rustdoc::clean::Attributes>>::clean::h1280074b449e8ef6
  23:        0x101d703da - <rustdoc::doctree::Function as rustdoc::clean::Clean<rustdoc::clean::Item>>::clean::hd24feff5180643a1
  24:        0x101e36a89 - <alloc::vec::Vec<T> as alloc::vec::SpecExtend<T, I>>::spec_extend::h4873bf57266aed7b
  25:        0x101d6f780 - <rustdoc::doctree::Module as rustdoc::clean::Clean<rustdoc::clean::Item>>::clean::hfa56c6ec84a0fad6
  26:        0x101d6eaa0 - <rustdoc::visit_ast::RustdocVisitor<'a, 'tcx, 'rcx> as rustdoc::clean::Clean<rustdoc::clean::Crate>>::clean::hb505941fd365de06
  27:        0x101d78a25 - rustdoc::core::run_core::{{closure}}::{{closure}}::h2554b93fbfd8c6da
  28:        0x101d65560 - rustc::ty::context::tls::enter_context::h8f956fd3652c2ae0
  29:        0x101d3009c - <std::thread::local::LocalKey<T>>::with::hef786ae88d33cd4b
  30:        0x101f631ba - rustc::ty::context::TyCtxt::create_and_enter::h7cf93880cc7015c4
  31:        0x101e0b3f9 - rustdoc::core::run_core::{{closure}}::he0b0f25298972ae7
  32:        0x101e0865f - rustdoc::core::run_core::h828fe8bce5a57617
  33:        0x101dddf7c - <scoped_tls::ScopedKey<T>>::set::h633ed2611e15d386
  34:        0x101f655b2 - syntax::with_globals::h04795d255090029c
  35:        0x101d50e99 - <std::panic::AssertUnwindSafe<F> as core::ops::function::FnOnce<()>>::call_once::h705fbad8fa6e1908
  36:        0x101d2b31d - std::panicking::try::do_call::h746a094a3cb63158
  37:        0x1057f8bbe - __rust_maybe_catch_panic
  38:        0x101ddca2e - rustc_driver::monitor::h67b9e3e5157c1aac
  39:        0x101f6f31f - rustdoc::rust_input::hac3bfc9eb4508126
  40:        0x101f6d798 - rustdoc::main_args::hed174c4fe9b47bb0
  41:        0x101ddfe2f - <scoped_tls::ScopedKey<T>>::set::hb0c5b0cee373eba1
  42:        0x101f6566d - syntax::with_globals::h1a242def3fb86fc2
  43:        0x101d2b27d - std::panicking::try::do_call::h54d7b1301bf90714
  44:        0x1057f8bbe - __rust_maybe_catch_panic
  45:        0x101d40389 - <F as alloc::boxed::FnBox<A>>::call_box::hadeefd2a5638fe74
  46:        0x1057bba6b - std::sys::unix::thread::Thread::new::thread_start::hdf37fcc49f83810c
  47:     0x7fff7e9a4660 - _pthread_body
  48:     0x7fff7e9a450c - _pthread_start

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.29.0-nightly (874dec25e 2018-07-21) running on x86_64-apple-darwin

error: Could not document `my_crate_name`.

Caused by:
  process didn't exit successfully: `rustdoc --crate-name my_crate_name src/lib.rs -o /my_crate_path/my_crate_name/target/doc -L dependency=/my_crate_path/my_crate_name/target/debug/deps` (exit code: 1)

Meta

rustc --version --verbose:

rustc 1.29.0-nightly (874dec25e 2018-07-21)
binary: rustc
commit-hash: 874dec25ed4c08d36f17d396b6872ca50313fc8e
commit-date: 2018-07-21
host: x86_64-apple-darwin
release: 1.29.0-nightly
LLVM version: 7.0
@estebank estebank added I-ICE Issue: The compiler panicked, giving an Internal Compilation Error (ICE) ❄️ A-docs Area: documentation for any part of the project, including the compiler, standard library, and tools labels Jul 24, 2018
@GuillaumeGomez GuillaumeGomez added T-rustdoc Relevant to the rustdoc team, which will review and decide on the PR/issue. and removed A-docs Area: documentation for any part of the project, including the compiler, standard library, and tools labels Jul 28, 2018
@GuillaumeGomez
Copy link
Member

I think it's actually the @rust-lang/compiler which should handle this bug since it's coming from TyCtxt.

@GuillaumeGomez GuillaumeGomez added the T-compiler Relevant to the compiler team, which will review and decide on the PR/issue. label Jul 28, 2018
@varkor
Copy link
Member

varkor commented Jul 28, 2018

As far as I can tell the issue is that when rustdoc is looking up an associated item here:
https://github.com/rust-lang/rust/blob/a8b9e678772f04614288b5f8fe44001c7626ab70/src/librustdoc/clean/mod.rs#L1198-L1199
It includes Def::TyAlias. But later in the else branch of this condition:
https://github.com/rust-lang/rust/blob/a8b9e678772f04614288b5f8fe44001c7626ab70/src/librustdoc/clean/mod.rs#L1215-L1223
It calls adt_def, which does not handle type aliases:
https://github.com/rust-lang/rust/blob/a8b9e678772f04614288b5f8fe44001c7626ab70/src/librustc_typeck/collect.rs#L605
rustdoc should be dereferencing the type alias to the type it is aliasing and calling adt_def on that.

@GuillaumeGomez
Copy link
Member

Thanks @varkor! I'll take a look into it.

@eddyb
Copy link
Member

eddyb commented Jul 29, 2018

You want to match on tcx.type_of(did) and probably not interact with adt_def at all.

Mark-Simulacrum added a commit to Mark-Simulacrum/rust that referenced this issue Jul 30, 2018
GuillaumeGomez added a commit to GuillaumeGomez/rust that referenced this issue Jul 31, 2018
Mark-Simulacrum added a commit to Mark-Simulacrum/rust that referenced this issue Aug 1, 2018
Mark-Simulacrum added a commit to Mark-Simulacrum/rust that referenced this issue Aug 1, 2018
pietroalbini added a commit to pietroalbini/rust that referenced this issue Aug 1, 2018
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) ❄️ T-compiler Relevant to the compiler team, which will review and decide on the PR/issue. T-rustdoc Relevant to the rustdoc team, which will review and decide on the PR/issue.
Projects
None yet
Development

No branches or pull requests

5 participants