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 panic when trying to build docs #50159

Closed
Pauan opened this issue Apr 22, 2018 · 5 comments · Fixed by #55318
Closed

rustdoc panic when trying to build docs #50159

Pauan opened this issue Apr 22, 2018 · 5 comments · Fixed by #55318
Assignees
Labels
C-bug Category: This is a bug. I-ICE Issue: The compiler panicked, giving an Internal Compilation Error (ICE) ❄️ T-rustdoc Relevant to the rustdoc team, which will review and decide on the PR/issue.

Comments

@Pauan
Copy link

Pauan commented Apr 22, 2018

When I tried to build docs for my signals library, I got a panic.

Here is the reduced test case:

pub trait IntoSignal {
    type Signal: Signal<Item = Self::Item>;
    type Item;
}

impl<A> IntoSignal for A where A: Signal {
    type Signal = Self;
    type Item = A::Item;
}

pub trait Signal {
    type Item;
}

pub struct Map<A, B> {
    signal: A,
    callback: B,
}

impl<A, B, C> Signal for Map<A, B>
    where A: Signal,
          B: FnMut(A::Item) -> C {
    type Item = C;
}

pub struct Flatten<A: Signal> where A::Item: IntoSignal {
    signal: Option<A>,
    inner: Option<<A::Item as IntoSignal>::Signal>,
}

impl<A> Signal for Flatten<A>
    where A: Signal,
          A::Item: IntoSignal {
    type Item = <<A as Signal>::Item as IntoSignal>::Item;
}

pub struct Switch<A, B, C>
    where A: Signal,
          B: IntoSignal,
          C: FnMut(A::Item) -> B {
    inner: Flatten<Map<A, C>>,
}

impl<A, B, C> Signal for Switch<A, B, C>
    where A: Signal,
          B: IntoSignal,
          C: FnMut(A::Item) -> B {
    type Item = <B::Signal as Signal>::Item;
}

With the above code, when I run cargo doc --release I get this panic:

thread '<unnamed>' panicked at 'Unable to fulfill trait DefId(2/0:887 ~ core[accb]::marker[0]::Send[0]) for 'Switch<A, B, C>': [FulfillmentError(Obligation(predicate=Binder(TraitPredicate(<<B as IntoSignal>::Signal as std::marker::Send>)),depth=3),Unimplemented)]', librustdoc\clean\auto_trait.rs:401:17
stack backtrace:
   0: <std::collections::hash::map::DefaultHasher as core::fmt::Debug>::fmt
   1: std::stdsimd::arch::detect::os::check_for
   2: std::panicking::take_hook
   3: std::panicking::take_hook
   4: std::panicking::rust_panic_with_hook
   5: std::panicking::begin_panic_fmt
   6: <unknown>
   7: <unknown>
   8: <unknown>
   9: <unknown>
  10: <unknown>
  11: <unknown>
  12: <unknown>
  13: <unknown>
  14: <unknown>
  15: <unknown>
  16: <unknown>
  17: <unknown>
  18: <unknown>
  19: <unknown>
  20: <unknown>
  21: <unknown>
  22: <unknown>
  23: <unknown>
  24: <unknown>
  25: <unknown>
  26: <unknown>
  27: <unknown>
  28: <unknown>
  29: _rust_maybe_catch_panic
  30: <unknown>
  31: <<std::sys_common::remutex::ReentrantMutex<T> as core::fmt::Debug>::fmt::LockedPlaceholder as core::fmt::Debug>::fmt
  32: std::sys::windows::thread::Thread::new
  33: BaseThreadInitThunk
  34: RtlUserThreadStart
error: Could not document `reduced-test`.

Caused by:
  process didn't exit successfully: `rustdoc --crate-name reduced_test src\lib.rs -o C:\Users\Pauan\Shared Folders\NixOS\reduced-test\target\doc -L dependency=C:\Users\Pauan\Shared Folders\NixOS\reduced-test\target\release\deps` (exit code: 101)

Meta

rustc 1.27.0-nightly (ac3c228 2018-04-18)
binary: rustc
commit-hash: ac3c228
commit-date: 2018-04-18
host: x86_64-pc-windows-msvc
release: 1.27.0-nightly
LLVM version: 6.0

@pietroalbini pietroalbini added T-rustdoc Relevant to the rustdoc team, which will review and decide on the PR/issue. I-ICE Issue: The compiler panicked, giving an Internal Compilation Error (ICE) ❄️ T-dev-tools-rustdoc C-bug Category: This is a bug. labels Apr 24, 2018
@GuillaumeGomez
Copy link
Member

Strange... Will take a look as soon as possible.

@GuillaumeGomez GuillaumeGomez self-assigned this Apr 25, 2018
@GuillaumeGomez
Copy link
Member

So the call is performed here. I'll need help from @nikomatsakis (or anyone in the @rust-lang/compiler team who knows about the FulfillmentContext type) in order to fix this issue.

@dtolnay
Copy link
Member

dtolnay commented Aug 13, 2018

Reduced further:

pub trait Signal {
    type Item;
}

pub trait Signal2 {
    type Item2;
}

// Impl Signal2 for all impls of Signal
impl<B, C> Signal2 for B where B: Signal<Item = C> {
    type Item2 = C;
}

pub struct Switch<B: Signal> {
    pub inner: <B as Signal2>::Item2,
}

@Aaron1011
Copy link
Member

I'd like to work on this.

Aaron1011 added a commit to Aaron1011/rust that referenced this issue Oct 24, 2018
Fixes rust-lang#50159

This commit makes several improvements to AutoTraitFinder:

* Call infcx.resolve_type_vars_if_possible before processing new
predicates. This ensures that we eliminate inference variables wherever
possible.
* Process all nested obligations we get from a vtable, not just ones
with depth=1.
  * The 'depth=1' check was a hack to work around issues processing
certain predicates. The other changes in this commit allow us to
properly process all predicates that we encounter, so the check is no
longer necessary,
* Ensure that we only display predicates *without* inference variables
to the user, and only attempt to unify predicates that *have* an
inference variable as their type.

Additionally, the internal helper method is_of_param now operates
directly on a type, rather than taking a Substs. This allows us to use
the 'self_ty' method, rather than directly dealing with Substs.
bors added a commit that referenced this issue Nov 27, 2018
Ensure that Rustdoc discovers all necessary auto trait bounds

Fixes #50159

This commit makes several improvements to AutoTraitFinder:

* Call infcx.resolve_type_vars_if_possible before processing new
predicates. This ensures that we eliminate inference variables wherever
possible.
* Process all nested obligations we get from a vtable, not just ones
with depth=1.
  * The 'depth=1' check was a hack to work around issues processing
certain predicates. The other changes in this commit allow us to
properly process all predicates that we encounter, so the check is no
longer necessary,
* Ensure that we only display predicates *without* inference variables
to the user, and only attempt to unify predicates that *have* an
inference variable as their type.

Additionally, the internal helper method is_of_param now operates
directly on a type, rather than taking a Substs. This allows us to use
the 'self_ty' method, rather than directly dealing with Substs.
Aaron1011 added a commit to Aaron1011/rust that referenced this issue Nov 29, 2018
Fixes rust-lang#50159

This commit makes several improvements to AutoTraitFinder:

* Call infcx.resolve_type_vars_if_possible before processing new
predicates. This ensures that we eliminate inference variables wherever
possible.
* Process all nested obligations we get from a vtable, not just ones
with depth=1.
  * The 'depth=1' check was a hack to work around issues processing
certain predicates. The other changes in this commit allow us to
properly process all predicates that we encounter, so the check is no
longer necessary,
* Ensure that we only display predicates *without* inference variables
to the user, and only attempt to unify predicates that *have* an
inference variable as their type.

Additionally, the internal helper method is_of_param now operates
directly on a type, rather than taking a Substs. This allows us to use
the 'self_ty' method, rather than directly dealing with Substs.
bors added a commit that referenced this issue Dec 6, 2018
…matsakis

Ensure that Rustdoc discovers all necessary auto trait bounds

Fixes #50159

This commit makes several improvements to AutoTraitFinder:

* Call infcx.resolve_type_vars_if_possible before processing new
predicates. This ensures that we eliminate inference variables wherever
possible.
* Process all nested obligations we get from a vtable, not just ones
with depth=1.
  * The 'depth=1' check was a hack to work around issues processing
certain predicates. The other changes in this commit allow us to
properly process all predicates that we encounter, so the check is no
longer necessary,
* Ensure that we only display predicates *without* inference variables
to the user, and only attempt to unify predicates that *have* an
inference variable as their type.

Additionally, the internal helper method is_of_param now operates
directly on a type, rather than taking a Substs. This allows us to use
the 'self_ty' method, rather than directly dealing with Substs.
@Pauan
Copy link
Author

Pauan commented Dec 21, 2018

@GuillaumeGomez @dtolnay @Aaron1011 Thank you so much! I verified that with the latest Rust Nightly I no longer get any errors.

pietroalbini pushed a commit to pietroalbini/rust that referenced this issue Jan 3, 2019
Fixes rust-lang#50159

This commit makes several improvements to AutoTraitFinder:

* Call infcx.resolve_type_vars_if_possible before processing new
predicates. This ensures that we eliminate inference variables wherever
possible.
* Process all nested obligations we get from a vtable, not just ones
with depth=1.
  * The 'depth=1' check was a hack to work around issues processing
certain predicates. The other changes in this commit allow us to
properly process all predicates that we encounter, so the check is no
longer necessary,
* Ensure that we only display predicates *without* inference variables
to the user, and only attempt to unify predicates that *have* an
inference variable as their type.

Additionally, the internal helper method is_of_param now operates
directly on a type, rather than taking a Substs. This allows us to use
the 'self_ty' method, rather than directly dealing with Substs.
Aaron1011 added a commit to Aaron1011/rust that referenced this issue Jan 4, 2019
Fixes rust-lang#50159

This commit makes several improvements to AutoTraitFinder:

* Call infcx.resolve_type_vars_if_possible before processing new
predicates. This ensures that we eliminate inference variables wherever
possible.
* Process all nested obligations we get from a vtable, not just ones
with depth=1.
  * The 'depth=1' check was a hack to work around issues processing
certain predicates. The other changes in this commit allow us to
properly process all predicates that we encounter, so the check is no
longer necessary,
* Ensure that we only display predicates *without* inference variables
to the user, and only attempt to unify predicates that *have* an
inference variable as their type.

Additionally, the internal helper method is_of_param now operates
directly on a type, rather than taking a Substs. This allows us to use
the 'self_ty' method, rather than directly dealing with Substs.
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
C-bug Category: This is a bug. I-ICE Issue: The compiler panicked, giving an Internal Compilation Error (ICE) ❄️ T-rustdoc Relevant to the rustdoc team, which will review and decide on the PR/issue.
Projects
None yet
Development

Successfully merging a pull request may close this issue.

6 participants