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

rustc panic when running cargo doc in AutoTraitFinder::find_auto_trait_generics #72213

Closed
alexheretic opened this issue May 14, 2020 · 6 comments · Fixed by #75205
Closed

rustc panic when running cargo doc in AutoTraitFinder::find_auto_trait_generics #72213

alexheretic opened this issue May 14, 2020 · 6 comments · Fixed by #75205
Assignees
Labels
A-traits Area: Trait system C-bug Category: This is a bug. I-ICE Issue: The compiler panicked, giving an Internal Compilation Error (ICE) ❄️ P-high High priority 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

@alexheretic
Copy link
Member

rustc panic when running cargo doc. The crate otherwise seems to test, run & work fine.

Steps to reproduce

Meta

rustc --version --verbose:

rustc 1.43.1 (8d69840ab 2020-05-04)
binary: rustc
commit-hash: 8d69840ab92ea7f4d323420088dd8c9775f180cd
commit-date: 2020-05-04
host: x86_64-unknown-linux-gnu
release: 1.43.1
LLVM version: 9.0

Error output

thread 'rustc' panicked at 'Unable to fulfill trait DefId(2:1922 ~ core[cba4]::marker[0]::Unpin[0]) for 'lines::Lines<'a, 'b, L, F, S>': [FulfillmentError(Obligation(predicate=Binder(ProjectionPredicate(ProjectionTy { substs: [S], item_def_id: DefId(2:4774 ~ core[cba4]::iter[0]::traits[0]::iterator[0]::Iterator[0]::Item[0]) }, section::SectionText<'_>)), depth=3),Ambiguity)]', <::std::macros::panic macros>:5:6
Backtrace

stack backtrace:
   0:     0x7f0aaae0de84 - backtrace::backtrace::libunwind::trace::h5d52ba5f20882f09
                               at /cargo/registry/src/github.com-1ecc6299db9ec823/backtrace-0.3.44/src/backtrace/libunwind.rs:86
   1:     0x7f0aaae0de84 - backtrace::backtrace::trace_unsynchronized::hceee092869668a74
                               at /cargo/registry/src/github.com-1ecc6299db9ec823/backtrace-0.3.44/src/backtrace/mod.rs:66
   2:     0x7f0aaae0de84 - std::sys_common::backtrace::_print_fmt::ha312c2904605e4d5
                               at src/libstd/sys_common/backtrace.rs:78
   3:     0x7f0aaae0de84 - <std::sys_common::backtrace::_print::DisplayBacktrace as core::fmt::Display>::fmt::h5b9981092140b727
                               at src/libstd/sys_common/backtrace.rs:59
   4:     0x7f0aaae4687c - core::fmt::write::h5f6d7d8de88b4173
                               at src/libcore/fmt/mod.rs:1063
   5:     0x7f0aaadffba3 - std::io::Write::write_fmt::h893169117de3cc15
                               at src/libstd/io/mod.rs:1426
   6:     0x7f0aaae12cb5 - std::sys_common::backtrace::_print::h8ab61d4120f7a335
                               at src/libstd/sys_common/backtrace.rs:62
   7:     0x7f0aaae12cb5 - std::sys_common::backtrace::print::h8aae19fbb153bf2a
                               at src/libstd/sys_common/backtrace.rs:49
   8:     0x7f0aaae12cb5 - std::panicking::default_hook::{{closure}}::h1ee5b7d8b6f83429
                               at src/libstd/panicking.rs:204
   9:     0x7f0aaae12a02 - std::panicking::default_hook::hd6c32c13403f9210
                               at src/libstd/panicking.rs:224
  10:     0x7f0aaae13312 - std::panicking::rust_panic_with_hook::h1f2449d529a25f22
                               at src/libstd/panicking.rs:470
  11:     0x7f0aaae12efb - rust_begin_unwind
                               at src/libstd/panicking.rs:378
  12:     0x7f0aaae12e6b - std::panicking::begin_panic_fmt::h7c14cf40a8be97ee
                               at src/libstd/panicking.rs:332
  13:     0x555ec9c66980 - rustc_infer::traits::auto_trait::AutoTraitFinder::find_auto_trait_generics::{{closure}}::{{closure}}::h23db3ac7fd6e843f
  14:     0x555ec9cb8091 - rustc::ty::context::GlobalCtxt::enter_local::hfe81f864ff343900
  15:     0x555ec9c46955 - rustc_infer::traits::auto_trait::AutoTraitFinder::find_auto_trait_generics::h36f309d537b9b31c
  16:     0x555ec9d17313 - core::ops::function::impls::<impl core::ops::function::FnMut<A> for &mut F>::call_mut::h326df7d27ac162b5
  17:     0x555ec9cf5e35 - <alloc::vec::Vec<T> as alloc::vec::SpecExtend<T,I>>::from_iter::h7b5dcf28f857e9fa
  18:     0x555ec9b179d5 - rustdoc::clean::utils::get_auto_trait_and_blanket_impls::h30f520b33c4ebe41
  19:     0x555ec9b26fd2 - <rustdoc::passes::collect_trait_impls::SyntheticImplCollector as rustdoc::fold::DocFolder>::fold_item::h09f2b172cfcdd88b
  20:     0x555ec9cece7e - <alloc::vec::Vec<T> as alloc::vec::SpecExtend<T,I>>::from_iter::hcda28ada9930131c
  21:     0x555ec9b1976c - rustdoc::fold::DocFolder::fold_inner_recur::h1ebc268f1a5af5b2
  22:     0x555ec9b26ccd - <rustdoc::passes::collect_trait_impls::SyntheticImplCollector as rustdoc::fold::DocFolder>::fold_item::h09f2b172cfcdd88b
  23:     0x555ec9cece7e - <alloc::vec::Vec<T> as alloc::vec::SpecExtend<T,I>>::from_iter::hcda28ada9930131c
  24:     0x555ec9b1976c - rustdoc::fold::DocFolder::fold_inner_recur::h1ebc268f1a5af5b2
  25:     0x555ec9b26ccd - <rustdoc::passes::collect_trait_impls::SyntheticImplCollector as rustdoc::fold::DocFolder>::fold_item::h09f2b172cfcdd88b
  26:     0x555ec9b249a8 - rustdoc::passes::collect_trait_impls::collect_trait_impls::hb96a767adeb24e06
  27:     0x555ec9b42a5d - rustc::ty::context::tls::enter_global::hbf719a8808dffc33
  28:     0x555ec9d15c61 - rustc_interface::interface::run_compiler_in_existing_thread_pool::hbfb381d6a6b1c5d8
  29:     0x555ec9cc006c - rustdoc::core::run_core::h3e13637dfb5154dd
  30:     0x555ec9b292d0 - <std::panic::AssertUnwindSafe<F> as core::ops::function::FnOnce<()>>::call_once::ha269444829893481
  31:     0x555ec9b6457b - std::panicking::try::do_call::h3fc76fb3531c3219
  32:     0x7f0aaae246b7 - __rust_maybe_catch_panic
                               at src/libpanic_unwind/lib.rs:86
  33:     0x555ec9b2a34b - rustc_driver::catch_fatal_errors::h7a280b9cdf28f352
  34:     0x555ec9af56fd - rustdoc::main_options::h42dedd41a78b0329
  35:     0x555ec9b60a57 - scoped_tls::ScopedKey<T>::set::ha6b8c3cc8b8d950f
  36:     0x555ec9cb99e4 - rustc_ast::attr::with_globals::he8fa93d7ebdc5344
  37:     0x555ec9ac5492 - std::sys_common::backtrace::__rust_begin_short_backtrace::h291078985b95d359
  38:     0x7f0aaae246b7 - __rust_maybe_catch_panic
                               at src/libpanic_unwind/lib.rs:86
  39:     0x555ec9b66ca6 - core::ops::function::FnOnce::call_once{{vtable.shim}}::hc250b6ab2be39f01
  40:     0x7f0aaadef64f - <alloc::boxed::Box<F> as core::ops::function::FnOnce<A>>::call_once::h36e46972b1b7f7b7
                               at /rustc/8d69840ab92ea7f4d323420088dd8c9775f180cd/src/liballoc/boxed.rs:1017
  41:     0x7f0aaae22fbd - <alloc::boxed::Box<F> as core::ops::function::FnOnce<A>>::call_once::hdde89c32ce6999de
                               at /rustc/8d69840ab92ea7f4d323420088dd8c9775f180cd/src/liballoc/boxed.rs:1017
  42:     0x7f0aaae22fbd - std::sys_common::thread::start_thread::h5ae3fdd4dad03dd5
                               at src/libstd/sys_common/thread.rs:13
  43:     0x7f0aaae22fbd - std::sys::unix::thread::Thread::new::thread_start::h76b2403b2434c4c0
                               at src/libstd/sys/unix/thread.rs:80
  44:     0x7f0aaad4c422 - start_thread
  45:     0x7f0aaac5fb83 - __GI___clone
  46:                0x0 - <unknown>
error: Could not document `glyph_brush_layout`

@alexheretic alexheretic added C-bug Category: This is a bug. 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. labels May 14, 2020
@jonas-schievink jonas-schievink added T-rustdoc Relevant to the rustdoc team, which will review and decide on the PR/issue. A-traits Area: Trait system labels May 14, 2020
@hellow554
Copy link
Contributor

hellow554 commented May 15, 2020

somewhat minified:

struct Lines<'a, L>
where
    L: Iterator<Item = &'a ()>,
{
    words: std::iter::Peekable<Words<'a, L>>,
}

struct Words<'a, L> {
    _m: std::marker::PhantomData<&'a L>,
}   

impl<'a, L> Iterator for Words<'a, L>
where
    L: Iterator<Item = &'a ()>,
{
    type Item = ();
    
    fn next(&mut self) -> Option<Self::Item> {
        unimplemented!()
    }
}

@hellow554
Copy link
Contributor

hellow554 commented May 15, 2020

Somewhat interesting:

nightly-2018-01-17 gives me:

 ✗ cargo doc  
 Documenting foo v0.1.0 (file:///tmp/tmp.NxnOdGgulp/foo)
error[E0309]: the parameter type `L` may not live long enough
 --> src/lib.rs:9:5
  |
8 | struct Words<'a, L> {
  |                  - help: consider adding an explicit lifetime bound `L: 'a`...
9 |     _m: std::marker::PhantomData<&'a L>,
  |     ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
  |
note: ...so that the reference type `&'a L` does not outlive the data it points at
 --> src/lib.rs:9:5
  |
9 |     _m: std::marker::PhantomData<&'a L>,
  |     ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^

and cargo check as gives me the same error message.

On nightly-2019-01-17 on the other hand cargo doc panics and cargo check does not complain any more:

✗ cargo check
    Checking foo v0.1.0 (/tmp/tmp.NxnOdGgulp/foo)
warning: struct is never constructed: `Lines`
 --> src/lib.rs:1:1
  |
1 | / struct Lines<'a, L>
2 | | where
3 | |     L: Iterator<Item = &'a ()>,
4 | | {
5 | |     words: std::iter::Peekable<Words<'a, L>>,
6 | | }
  | |_^
  |
  = note: #[warn(dead_code)] on by default

warning: struct is never constructed: `Words`
 --> src/lib.rs:8:1
  |
8 | struct Words<'a, L> {
  | ^^^^^^^^^^^^^^^^^^^

Edit: nightly-2018-12-01 gives me exactly no output. No warning, no ICE. That is weird as well...

@hellow554
Copy link
Contributor

Regression in nightly-2018-12-08 (14997d5...4a45578) (nightly-2018-12-07 is not available)

The "no output" regression (from rejecting the program as such and giving no output at all) is in nightly-2018-09-13 (2f1547c...f2302da)

@jonas-schievink
Copy link
Contributor

The latter is an intended change caused by #53793

@alexheretic
Copy link
Member Author

This is still occurring, the panic seems to come from this line in AutoTraitFinder::find_auto_trait_generics.

Updated info:

rustc --version --verbose:

rustc 1.45.1 (c367798cf 2020-07-26)
binary: rustc
commit-hash: c367798cfd3817ca6ae908ce675d1d99242af148
commit-date: 2020-07-26
host: x86_64-unknown-linux-gnu
release: 1.45.1
LLVM version: 10.0

Error output

thread 'rustc' panicked at 'Unable to fulfill trait DefId(2:1944 ~ core[6c88]::marker[0]::Unpin[0]) for 'lines::Lines<'a, 'b, L, F, S>': [FulfillmentError(Obligation(predicate=Binder(ProjectionPredicate(ProjectionTy { substs: [S], item_def_id: DefId(2:4966 ~ core[6c88]::iter[0]::traits[0]::iterator[0]::Iterator[0]::Item[0]) }, section::SectionText<'_>)), depth=3),Ambiguity)]', /rustc/c367798cfd3817ca6ae908ce675d1d99242af148/src/libstd/macros.rs:16:9
Backtrace

thread 'rustc' panicked at 'Unable to fulfill trait DefId(2:1944 ~ core[6c88]::marker[0]::Unpin[0]) for 'lines::Lines<'a, 'b, L, F, S>': [FulfillmentError(Obligation(predicate=Binder(ProjectionPredicate(ProjectionTy { substs: [S], item_def_id: DefId(2:4966 ~ core[6c88]::iter[0]::traits[0]::iterator[0]::Iterator[0]::Item[0]) }, section::SectionText<'_>)), depth=3),Ambiguity)]', /rustc/c367798cfd3817ca6ae908ce675d1d99242af148/src/libstd/macros.rs:16:9
stack backtrace:
   0: backtrace::backtrace::libunwind::trace
             at /cargo/registry/src/github.com-1ecc6299db9ec823/backtrace-0.3.46/src/backtrace/libunwind.rs:86
   1: backtrace::backtrace::trace_unsynchronized
             at /cargo/registry/src/github.com-1ecc6299db9ec823/backtrace-0.3.46/src/backtrace/mod.rs:66
   2: std::sys_common::backtrace::_print_fmt
             at src/libstd/sys_common/backtrace.rs:78
   3: <std::sys_common::backtrace::_print::DisplayBacktrace as core::fmt::Display>::fmt
             at src/libstd/sys_common/backtrace.rs:59
   4: core::fmt::write
             at src/libcore/fmt/mod.rs:1076
   5: std::io::Write::write_fmt
             at src/libstd/io/mod.rs:1537
   6: std::sys_common::backtrace::_print
             at src/libstd/sys_common/backtrace.rs:62
   7: std::sys_common::backtrace::print
             at src/libstd/sys_common/backtrace.rs:49
   8: std::panicking::default_hook::{{closure}}
             at src/libstd/panicking.rs:198
   9: std::panicking::default_hook
             at src/libstd/panicking.rs:218
  10: std::panicking::rust_panic_with_hook
             at src/libstd/panicking.rs:486
  11: rust_begin_unwind
             at src/libstd/panicking.rs:388
  12: std::panicking::begin_panic_fmt
             at src/libstd/panicking.rs:342
  13: rustc_trait_selection::traits::auto_trait::AutoTraitFinder::find_auto_trait_generics::{{closure}}::{{closure}}
  14: rustc_middle::ty::context::GlobalCtxt::enter_local
  15: rustc_trait_selection::traits::auto_trait::AutoTraitFinder::find_auto_trait_generics
  16: core::ops::function::impls::<impl core::ops::function::FnMut<A> for &mut F>::call_mut
  17: <alloc::vec::Vec<T> as alloc::vec::SpecExtend<T,I>>::from_iter
  18: rustdoc::clean::utils::get_auto_trait_and_blanket_impls
  19: <rustdoc::passes::collect_trait_impls::SyntheticImplCollector as rustdoc::fold::DocFolder>::fold_item
  20: <alloc::vec::Vec<T> as alloc::vec::SpecExtend<T,I>>::from_iter
  21: rustdoc::fold::DocFolder::fold_inner_recur
  22: <rustdoc::passes::collect_trait_impls::SyntheticImplCollector as rustdoc::fold::DocFolder>::fold_item
  23: <alloc::vec::Vec<T> as alloc::vec::SpecExtend<T,I>>::from_iter
  24: rustdoc::fold::DocFolder::fold_inner_recur
  25: <rustdoc::passes::collect_trait_impls::SyntheticImplCollector as rustdoc::fold::DocFolder>::fold_item
  26: rustdoc::passes::collect_trait_impls::collect_trait_impls
  27: rustc_middle::ty::context::tls::enter_global
  28: rustc_interface::interface::run_compiler_in_existing_thread_pool
  29: <std::panic::AssertUnwindSafe<F> as core::ops::function::FnOnce<()>>::call_once
  30: rustc_driver::catch_fatal_errors
  31: rustdoc::main_options
  32: scoped_tls::ScopedKey<T>::set
  33: rustc_ast::attr::with_globals
note: Some details are omitted, run with `RUST_BACKTRACE=full` for a verbose backtrace.
error: Could not document `glyph_brush_layout`.

@alexheretic alexheretic changed the title rustc panic when running cargo doc: Unable to fulfill trait DefId(2:1922 rustc panic when running cargo doc in AutoTraitFinder::find_auto_trait_generics Aug 1, 2020
@jonas-schievink jonas-schievink added the I-prioritize Issue: Indicates that prioritization has been requested for this issue. label Aug 1, 2020
@spastorino
Copy link
Member

Assigning P-high as discussed as part of the Prioritization Working Group procedure and removing I-prioritize.

@spastorino spastorino added P-high High priority and removed I-prioritize Issue: Indicates that prioritization has been requested for this issue. labels Aug 5, 2020
@Aaron1011 Aaron1011 self-assigned this Aug 5, 2020
bors added a commit to rust-lang-ci/rust that referenced this issue Aug 12, 2020
…nikomatsakis

Handle projection predicates in the param env for auto-trait docs

Fixes rust-lang#72213

Any predicates in the param env are guaranteed to hold, so we don't need
to do any additional processing of them if we come across them as
sub-obligations of a different predicate. This allows us to avoid adding
the same predicate to the computed ParamEnv multiple times (but with
different regions each time), which causes an ambiguity error during
fulfillment.
@bors bors closed this as completed in ab766f0 Aug 12, 2020
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
A-traits Area: Trait system C-bug Category: This is a bug. I-ICE Issue: The compiler panicked, giving an Internal Compilation Error (ICE) ❄️ P-high High priority 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

Successfully merging a pull request may close this issue.

5 participants