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 panic while documenting impl trait in argument position #50358

Closed
KodrAus opened this Issue May 1, 2018 · 1 comment

Comments

Projects
None yet
2 participants
@KodrAus
Copy link

KodrAus commented May 1, 2018

The problem

I'm hitting a panic from an assertion when attempting to document a library with a nested impl trait in argument position. In the repro the method a hits the assertion and panics, whereas b passes and documents successfully.

Output

$ cargo doc --no-deps
 Documenting doc-impl-trait-repro v0.1.0 (file:///Users/user/dev/doc-impl-trait-repro)
thread '<unnamed>' panicked at 'assertion failed: cx.impl_trait_bounds.borrow().is_empty()', librustdoc/clean/mod.rs:4050:5
stack backtrace:
   0: std::sys::unix::backtrace::tracing::imp::unwind_backtrace
   1: std::sys_common::backtrace::print
   2: std::panicking::default_hook::{{closure}}
   3: std::panicking::default_hook
   4: std::panicking::rust_panic_with_hook
   5: std::panicking::begin_panic
   6: rustdoc::clean::enter_impl_trait
   7: <rustc::hir::ImplItem as rustdoc::clean::Clean<rustdoc::clean::Item>>::clean
   8: <alloc::vec::Vec<T> as alloc::vec::SpecExtend<T, I>>::from_iter
   9: <rustdoc::doctree::Impl as rustdoc::clean::Clean<alloc::vec::Vec<rustdoc::clean::Item>>>::clean
  10: <alloc::vec::Vec<T> as alloc::vec::SpecExtend<T, I>>::spec_extend
  11: <rustdoc::doctree::Module as rustdoc::clean::Clean<rustdoc::clean::Item>>::clean
  12: <rustdoc::visit_ast::RustdocVisitor<'a, 'tcx, 'rcx> as rustdoc::clean::Clean<rustdoc::clean::Crate>>::clean
  13: rustdoc::core::run_core::{{closure}}
  14: rustc::ty::context::tls::enter_global
  15: rustc::ty::context::TyCtxt::create_and_enter
  16: rustc_driver::driver::phase_3_run_analysis_passes
  17: rustdoc::core::run_core
  18: <scoped_tls::ScopedKey<T>>::set
  19: syntax::with_globals
  20: <std::panic::AssertUnwindSafe<F> as core::ops::function::FnOnce<()>>::call_once
  21: std::panicking::try::do_call
  22: __rust_maybe_catch_panic
  23: rustc_driver::monitor
  24: rustdoc::rust_input
  25: rustdoc::main_args
  26: <scoped_tls::ScopedKey<T>>::set
  27: syntax::with_globals
  28: std::panicking::try::do_call
  29: __rust_maybe_catch_panic
  30: <F as alloc::boxed::FnBox<A>>::call_box
  31: std::sys_common::thread::start_thread
  32: std::sys::unix::thread::Thread::new::thread_start
  33: _pthread_body
  34: _pthread_start

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.27.0-nightly (79252ff4e 2018-04-29) running on x86_64-apple-darwin

error: Could not document `doc-impl-trait-repro`.

Caused by:
  process didn't exit successfully: `rustdoc --crate-name doc_impl_trait_repro src/lib.rs -o /Users/user/dev/doc-impl-trait-repro/target/doc -L dependency=/Users/user/dev/doc-impl-trait-repro/target/debug/deps` (exit code: 101)

Repro

use std::io::Read;

struct D<R>(R);

struct A;
impl A {
    // thread '<unnamed>' panicked at 'assertion failed: cx.impl_trait_bounds.borrow().is_empty()', librustdoc/clean/mod.rs:4050:5
    fn a(&self, d: impl IntoIterator<Item = D<impl Read>>) -> Result<(), ()> { unimplemented!() }

    // ok
    fn b(&self, d: impl IntoIterator<Item = D<()>>) -> Result<(), ()> { unimplemented!() }
}

Meta

rustc 1.27.0-nightly (79252ff4e 2018-04-29)
binary: rustc
commit-hash: 79252ff4e25d82f9fe856cb66f127b79cdace163
commit-date: 2018-04-29
host: x86_64-apple-darwin
release: 1.27.0-nightly
LLVM version: 6.0
@pietroalbini

This comment has been minimized.

Copy link
Member

pietroalbini commented May 1, 2018

This would also be nice to backport into beta.

bors added a commit that referenced this issue May 5, 2018

Auto merge of #50419 - sinkuu:rustdoc_nested_impl_trait, r=QuietMisdr…
…eavus

rustdoc: Resolve nested `impl Trait`s

Fixes #50358.

Populates `cx.impl_trait_bounds` incrementally while `clean`ing generic params, so that a synthetic type-parameter can refer to previous ones.

cc #50366

@bors bors closed this in #50419 May 5, 2018

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment