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

error: could not document crate: the compiler unexpectedly panicked: Option::unwrap #113656

Closed
GlenDC opened this issue Jul 13, 2023 · 16 comments
Closed
Assignees
Labels
C-bug Category: This is a bug. F-async_fn_in_trait Static async fn in traits I-ICE Issue: The compiler panicked, giving an Internal Compilation Error (ICE) ❄️ requires-nightly This issue requires a nightly compiler in some way. T-compiler Relevant to the compiler team, which will review and decide on the PR/issue.

Comments

@GlenDC
Copy link
Contributor

GlenDC commented Jul 13, 2023

Code

plabayo/tower-async#3

cargo doc --all-features --no-deps

Meta

rustc --version --verbose:

rustc 1.73.0-nightly (33a2c2487 2023-07-12)
binary: rustc
commit-hash: 33a2c2487ac5d9927830ea4c1844335c6b9f77db
commit-date: 2023-07-12
host: aarch64-apple-darwin
release: 1.73.0-nightly
LLVM version: 16.0.5

Error output

thread 'rustc' panicked at 'called `Option::unwrap()` on a `None` value', compiler/rustc_middle/src/ty/context.rs:1992:55
stack backtrace:
   0:        0x106157004 - <std::sys_common::backtrace::_print::DisplayBacktrace as core::fmt::Display>::fmt::h17fbf7579ae86419
   1:        0x1061aa848 - core::fmt::write::h6a381f1b94dba748
   2:        0x10614c7d4 - std::io::Write::write_fmt::h9921d5e1090430da
   3:        0x106156e5c - std::sys_common::backtrace::print::h9817d600ffeaf6c8
   4:        0x1061599d8 - std::panicking::default_hook::{{closure}}::h8c3f2b0031696090
   5:        0x106159768 - std::panicking::default_hook::h7714acc03988e3ee
   6:        0x10e6f8d90 - rustc_driver_impl[d56341fc5c51f265]::install_ice_hook::{closure#0}
   7:        0x10615a158 - std::panicking::rust_panic_with_hook::hf9235be880082a1b
   8:        0x106159ef0 - std::panicking::begin_panic_handler::{{closure}}::h043421705cb7e053
   9:        0x1061573e4 - std::sys_common::backtrace::__rust_end_short_backtrace::hcaaa78d658729a77
  10:        0x106159c98 - _rust_begin_unwind
  11:        0x1061d5898 - core::panicking::panic_fmt::hd00c7ee5120551d2
  12:        0x1061d5908 - core::panicking::panic::h3f147b0ed6e04209
  13:        0x112513d38 - <rustc_middle[bff711bfa54051d4]::ty::context::TyCtxt>::local_def_id_to_hir_id
  14:        0x112515a84 - <rustc_middle[bff711bfa54051d4]::ty::context::TyCtxt>::get_attrs_unchecked
  15:        0x104e39cc8 - <rustdoc[e90c5fbd30d2e89e]::clean::types::Item>::from_def_id_and_parts
  16:        0x104e43838 - rustdoc[e90c5fbd30d2e89e]::clean::clean_middle_assoc_item
  17:        0x104daf164 - <alloc[cf80ddf7ca971645]::vec::Vec<rustdoc[e90c5fbd30d2e89e]::clean::types::Item> as alloc[cf80ddf7ca971645]::vec::spec_from_iter::SpecFromIter<rustdoc[e90c5fbd30d2e89e]::clean::types::Item, core[8fc90c3cfe95ab91]::iter::adapters::map::Map<core[8fc90c3cfe95ab91]::iter::adapters::map::Map<core[8fc90c3cfe95ab91]::iter::adapters::map::Map<core[8fc90c3cfe95ab91]::slice::iter::Iter<(rustc_span[e78de648ac3325]::symbol::Symbol, rustc_middle[bff711bfa54051d4]::ty::assoc::AssocItem)>, <rustc_data_structures[e4173aa44f1ff681]::sorted_map::index_map::SortedIndexMultiMap<u32, rustc_span[e78de648ac3325]::symbol::Symbol, rustc_middle[bff711bfa54051d4]::ty::assoc::AssocItem>>::iter::{closure#0}>, <rustc_middle[bff711bfa54051d4]::ty::assoc::AssocItems>::in_definition_order::{closure#0}>, <rustdoc[e90c5fbd30d2e89e]::clean::blanket_impl::BlanketImplFinder>::get_blanket_impls::{closure#0}>>>::from_iter
  18:        0x104f70bac - <rustdoc[e90c5fbd30d2e89e]::clean::blanket_impl::BlanketImplFinder>::get_blanket_impls
  19:        0x104ea84e8 - rustdoc[e90c5fbd30d2e89e]::clean::utils::get_auto_trait_and_blanket_impls
  20:        0x1050278cc - <rustdoc[e90c5fbd30d2e89e]::passes::collect_trait_impls::SyntheticImplCollector as rustdoc[e90c5fbd30d2e89e]::visit::DocVisitor>::visit_item
  21:        0x10502799c - <rustdoc[e90c5fbd30d2e89e]::passes::collect_trait_impls::SyntheticImplCollector as rustdoc[e90c5fbd30d2e89e]::visit::DocVisitor>::visit_item
  22:        0x10502799c - <rustdoc[e90c5fbd30d2e89e]::passes::collect_trait_impls::SyntheticImplCollector as rustdoc[e90c5fbd30d2e89e]::visit::DocVisitor>::visit_item
  23:        0x10502d414 - <rustdoc[e90c5fbd30d2e89e]::passes::collect_trait_impls::SyntheticImplCollector as rustdoc[e90c5fbd30d2e89e]::visit::DocVisitor>::visit_crate
  24:        0x104f4b2e0 - <rustc_session[ce8949554eee81d4]::session::Session>::time::<alloc[cf80ddf7ca971645]::vec::Vec<rustdoc[e90c5fbd30d2e89e]::clean::types::Item>, rustdoc[e90c5fbd30d2e89e]::passes::collect_trait_impls::collect_trait_impls::{closure#0}>
  25:        0x105025b90 - rustdoc[e90c5fbd30d2e89e]::passes::collect_trait_impls::collect_trait_impls
  26:        0x104f4b5d8 - <rustc_session[ce8949554eee81d4]::session::Session>::time::<rustdoc[e90c5fbd30d2e89e]::clean::types::Crate, rustdoc[e90c5fbd30d2e89e]::core::run_global_ctxt::{closure#7}>
  27:        0x104fdf1e4 - rustdoc[e90c5fbd30d2e89e]::core::run_global_ctxt
  28:        0x104f4cfa0 - <rustc_session[ce8949554eee81d4]::session::Session>::time::<(rustdoc[e90c5fbd30d2e89e]::clean::types::Crate, rustdoc[e90c5fbd30d2e89e]::config::RenderOptions, rustdoc[e90c5fbd30d2e89e]::formats::cache::Cache), rustdoc[e90c5fbd30d2e89e]::main_args::{closure#1}::{closure#0}::{closure#0}::{closure#0}>
  29:        0x104e0cfa8 - <rustc_middle[bff711bfa54051d4]::ty::context::GlobalCtxt>::enter::<rustdoc[e90c5fbd30d2e89e]::main_args::{closure#1}::{closure#0}::{closure#0}, core[8fc90c3cfe95ab91]::result::Result<(), rustc_span[e78de648ac3325]::ErrorGuaranteed>>
  30:        0x104e0bf38 - <rustc_interface[da9eebe4b94e9b68]::interface::Compiler>::enter::<rustdoc[e90c5fbd30d2e89e]::main_args::{closure#1}::{closure#0}, core[8fc90c3cfe95ab91]::result::Result<(), rustc_span[e78de648ac3325]::ErrorGuaranteed>>
  31:        0x104fc481c - rustc_span[e78de648ac3325]::set_source_map::<core[8fc90c3cfe95ab91]::result::Result<(), rustc_span[e78de648ac3325]::ErrorGuaranteed>, rustc_interface[da9eebe4b94e9b68]::interface::run_compiler<core[8fc90c3cfe95ab91]::result::Result<(), rustc_span[e78de648ac3325]::ErrorGuaranteed>, rustdoc[e90c5fbd30d2e89e]::main_args::{closure#1}>::{closure#0}::{closure#0}>
  32:        0x105007224 - <scoped_tls[39e68ee64317e29a]::ScopedKey<rustc_span[e78de648ac3325]::SessionGlobals>>::set::<rustc_interface[da9eebe4b94e9b68]::interface::run_compiler<core[8fc90c3cfe95ab91]::result::Result<(), rustc_span[e78de648ac3325]::ErrorGuaranteed>, rustdoc[e90c5fbd30d2e89e]::main_args::{closure#1}>::{closure#0}, core[8fc90c3cfe95ab91]::result::Result<(), rustc_span[e78de648ac3325]::ErrorGuaranteed>>
  33:        0x104e2cad4 - std[21df5b7df6bfc5c1]::sys_common::backtrace::__rust_begin_short_backtrace::<rustc_interface[da9eebe4b94e9b68]::util::run_in_thread_pool_with_globals<rustc_interface[da9eebe4b94e9b68]::interface::run_compiler<core[8fc90c3cfe95ab91]::result::Result<(), rustc_span[e78de648ac3325]::ErrorGuaranteed>, rustdoc[e90c5fbd30d2e89e]::main_args::{closure#1}>::{closure#0}, core[8fc90c3cfe95ab91]::result::Result<(), rustc_span[e78de648ac3325]::ErrorGuaranteed>>::{closure#0}::{closure#0}, core[8fc90c3cfe95ab91]::result::Result<(), rustc_span[e78de648ac3325]::ErrorGuaranteed>>
  34:        0x104e912ac - <<std[21df5b7df6bfc5c1]::thread::Builder>::spawn_unchecked_<rustc_interface[da9eebe4b94e9b68]::util::run_in_thread_pool_with_globals<rustc_interface[da9eebe4b94e9b68]::interface::run_compiler<core[8fc90c3cfe95ab91]::result::Result<(), rustc_span[e78de648ac3325]::ErrorGuaranteed>, rustdoc[e90c5fbd30d2e89e]::main_args::{closure#1}>::{closure#0}, core[8fc90c3cfe95ab91]::result::Result<(), rustc_span[e78de648ac3325]::ErrorGuaranteed>>::{closure#0}::{closure#0}, core[8fc90c3cfe95ab91]::result::Result<(), rustc_span[e78de648ac3325]::ErrorGuaranteed>>::{closure#1} as core[8fc90c3cfe95ab91]::ops::function::FnOnce<()>>::call_once::{shim:vtable#0}
  35:        0x106162b18 - std::sys::unix::thread::Thread::new::thread_start::h87100702c1037b48
  36:        0x189a83fa8 - __pthread_joiner_wake

error: the compiler unexpectedly panicked. this is a bug.

note: we would appreciate a bug report: https://github.com/rust-lang/rust/issues/new?labels=C-bug%2C+I-ICE%2C+T-rustdoc&template=ice.md

note: rustc 1.73.0-nightly (33a2c2487 2023-07-12) running on aarch64-apple-darwin

note: compiler flags: --crate-type lib

note: some of the compiler flags provided by cargo are hidden

query stack during panic:
end of query stack
error: could not document `tower-async`
Backtrace

    Checking zstd-safe v5.0.2+zstd.1.5.2
    Checking h2 v0.3.20
    Checking tower-async-bridge v0.1.0 (/Users/glendc/code/github.com/plabayo/tower-async/tower-async-bridge)
 Documenting tower-async-bridge v0.1.0 (/Users/glendc/code/github.com/plabayo/tower-async/tower-async-bridge)
 Documenting tower-async v0.1.0 (/Users/glendc/code/github.com/plabayo/tower-async/tower-async)
    Checking zstd v0.11.2+zstd.1.5.2
thread 'rustc' panicked at 'called `Option::unwrap()` on a `None` value', compiler/rustc_middle/src/ty/context.rs:1992:55
stack backtrace:
   0: _rust_begin_unwind
   1: core::panicking::panic_fmt
   2: core::panicking::panic
   3: <rustc_middle::ty::context::TyCtxt>::local_def_id_to_hir_id
   4: <rustc_middle::ty::context::TyCtxt>::get_attrs_unchecked
   5: <rustdoc::clean::types::Item>::from_def_id_and_parts
   6: rustdoc::clean::clean_middle_assoc_item
   7: <alloc::vec::Vec<rustdoc::clean::types::Item> as alloc::vec::spec_from_iter::SpecFromIter<rustdoc::clean::types::Item, core::iter::adapters::map::Map<core::iter::adapters::map::Map<core::iter::adapters::map::Map<core::slice::iter::Iter<(rustc_span::symbol::Symbol, rustc_middle::ty::assoc::AssocItem)>, <rustc_data_structures::sorted_map::index_map::SortedIndexMultiMap<u32, rustc_span::symbol::Symbol, rustc_middle::ty::assoc::AssocItem>>::iter::{closure#0}>, <rustc_middle::ty::assoc::AssocItems>::in_definition_order::{closure#0}>, <rustdoc::clean::blanket_impl::BlanketImplFinder>::get_blanket_impls::{closure#0}>>>::from_iter
   8: <rustdoc::clean::blanket_impl::BlanketImplFinder>::get_blanket_impls
   9: rustdoc::clean::utils::get_auto_trait_and_blanket_impls
  10: <rustdoc::passes::collect_trait_impls::SyntheticImplCollector as rustdoc::visit::DocVisitor>::visit_item
  11: <rustdoc::passes::collect_trait_impls::SyntheticImplCollector as rustdoc::visit::DocVisitor>::visit_item
  12: <rustdoc::passes::collect_trait_impls::SyntheticImplCollector as rustdoc::visit::DocVisitor>::visit_item
  13: <rustdoc::passes::collect_trait_impls::SyntheticImplCollector as rustdoc::visit::DocVisitor>::visit_crate
  14: <rustc_session::session::Session>::time::<alloc::vec::Vec<rustdoc::clean::types::Item>, rustdoc::passes::collect_trait_impls::collect_trait_impls::{closure#0}>
  15: rustdoc::passes::collect_trait_impls::collect_trait_impls
  16: <rustc_session::session::Session>::time::<rustdoc::clean::types::Crate, rustdoc::core::run_global_ctxt::{closure#7}>
  17: rustdoc::core::run_global_ctxt
  18: <rustc_session::session::Session>::time::<(rustdoc::clean::types::Crate, rustdoc::config::RenderOptions, rustdoc::formats::cache::Cache), rustdoc::main_args::{closure#1}::{closure#0}::{closure#0}::{closure#0}>
  19: <rustc_middle::ty::context::GlobalCtxt>::enter::<rustdoc::main_args::{closure#1}::{closure#0}::{closure#0}, core::result::Result<(), rustc_span::ErrorGuaranteed>>
  20: <rustc_interface::interface::Compiler>::enter::<rustdoc::main_args::{closure#1}::{closure#0}, core::result::Result<(), rustc_span::ErrorGuaranteed>>
  21: rustc_span::set_source_map::<core::result::Result<(), rustc_span::ErrorGuaranteed>, rustc_interface::interface::run_compiler<core::result::Result<(), rustc_span::ErrorGuaranteed>, rustdoc::main_args::{closure#1}>::{closure#0}::{closure#0}>
  22: <scoped_tls::ScopedKey<rustc_span::SessionGlobals>>::set::<rustc_interface::interface::run_compiler<core::result::Result<(), rustc_span::ErrorGuaranteed>, rustdoc::main_args::{closure#1}>::{closure#0}, core::result::Result<(), rustc_span::ErrorGuaranteed>>
note: Some details are omitted, run with `RUST_BACKTRACE=full` for a verbose backtrace.

error: the compiler unexpectedly panicked. this is a bug.

note: we would appreciate a bug report: https://github.com/rust-lang/rust/issues/new?labels=C-bug%2C+I-ICE%2C+T-rustdoc&template=ice.md

note: rustc 1.73.0-nightly (33a2c2487 2023-07-12) running on aarch64-apple-darwin

note: compiler flags: --crate-type lib

note: some of the compiler flags provided by cargo are hidden

query stack during panic:
end of query stack
error: could not document `tower-async`

Caused by:
  process didn't exit successfully: `/Users/glendc/.rustup/toolchains/nightly-aarch64-apple-darwin/bin/rustdoc --edition=2021 --crate-type lib --crate-name tower_async tower-async/src/lib.rs -o /Users/glendc/code/github.com/plabayo/tower-async/target/doc --cfg 'feature="__common"' --cfg 'feature="filter"' --cfg 'feature="full"' --cfg 'feature="futures-core"' --cfg 'feature="futures-util"' --cfg 'feature="make"' --cfg 'feature="retry"' --cfg 'feature="timeout"' --cfg 'feature="tokio"' --cfg 'feature="util"' --error-format=json --json=diagnostic-rendered-ansi,artifacts,future-incompat --diagnostic-width=210 -C metadata=fa310f585a74fa57 -L dependency=/Users/glendc/code/github.com/plabayo/tower-async/target/debug/deps --extern futures_core=/Users/glendc/code/github.com/plabayo/tower-async/target/debug/deps/libfutures_core-a706d4840a164764.rmeta --extern futures_util=/Users/glendc/code/github.com/plabayo/tower-async/target/debug/deps/libfutures_util-3a9e07db016127ca.rmeta --extern tokio=/Users/glendc/code/github.com/plabayo/tower-async/target/debug/deps/libtokio-f0470835392b88a2.rmeta --extern tower_async_layer=/Users/glendc/code/github.com/plabayo/tower-async/target/debug/deps/libtower_async_layer-dbae86b51ae84235.rmeta --extern tower_async_service=/Users/glendc/code/github.com/plabayo/tower-async/target/debug/deps/libtower_async_service-05577435daedac43.rmeta --crate-version 0.1.0` (exit status: 101)
warning: build failed, waiting for other jobs to finish...

@GlenDC GlenDC 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 Jul 13, 2023
@rustbot rustbot added the needs-triage This issue may need triage. Remove it if it has been sufficiently triaged. label Jul 13, 2023
@GlenDC
Copy link
Contributor Author

GlenDC commented Jul 13, 2023

This is a new issue by the way. I cannot remember what version exactly, but previously I was using a version of around 07-07 and that was working for me fine. I only noticed this error as my CI which uses whatever latest nightly got this error for the doc test. Trying it with latest nightly myself locally gives me 100% this failure as well, but only for cargo doc. All other cargo commands work fine.

E.g. cargo run, cargo test, cargo clippy, etc etc... these all work fine.

@albertlarsan68
Copy link
Member

albertlarsan68 commented Jul 13, 2023

Bisection result:

searched nightlies: from nightly-2023-07-09 to nightly-2023-07-13
regressed nightly: nightly-2023-07-11
searched commit range: 1065d87...8ca44ef
regressed commit: 8ca44ef (#112988)

bisected with cargo-bisect-rustc v0.6.6

Host triple: x86_64-unknown-linux-gnu
Reproduce with:

cargo bisect-rustc --regress=ice -- doc --all-features --no-deps

cc @spastorino

@compiler-errors compiler-errors added requires-nightly This issue requires a nightly compiler in some way. F-async_fn_in_trait Static async fn in traits and removed needs-triage This issue may need triage. Remove it if it has been sufficiently triaged. labels Jul 13, 2023
@GlenDC
Copy link
Contributor Author

GlenDC commented Jul 13, 2023

Is there something you or anyone need more from me on this one by the way?

@GlenDC
Copy link
Contributor Author

GlenDC commented Jul 14, 2023

FYI, for now I pinned my toolchain to nightly-2023-07-08 and that makes it work for my dev machine, as well as my CI. So I am not blocked on this. If you do need me for more input or information, do let me know. And thank you for everything.

@compiler-errors
Copy link
Member

No, I'll take a look at this today and hopefully have a fix up soon. Thanks, @GlenDC.

@compiler-errors compiler-errors self-assigned this Jul 14, 2023
@spastorino
Copy link
Member

We're accessing hir for RPITITs in this case in ...

    // FIXME(@lcnr): Remove this function.
    pub fn get_attrs_unchecked(self, did: DefId) -> &'tcx [ast::Attribute] {
        if let Some(did) = did.as_local() {
            self.hir().attrs(self.hir().local_def_id_to_hir_id(did))
        } else {
            self.item_attrs(did)
        }
    }

Likely we want a check for self.is_impl_trait_in_trait(did) to avoid doing so.

@GlenDC
Copy link
Contributor Author

GlenDC commented Jul 17, 2023

This might also be the reason why docs are for now failing at docs.rs.I guess?

https://docs.rs/crate/tower-async/latest

Screenshot 2023-07-18 at 00 30 25

@GlenDC
Copy link
Contributor Author

GlenDC commented Jul 18, 2023

This is the url to the build log btw: https://docs.rs/crate/tower-async/0.1.0/builds/863682 (you can also access it from the linked docs.rs crate doc page). Too bad I cannot select the toolchain with https://docs.rs/about/metadata that would fix it for that use case as well.

@GlenDC
Copy link
Contributor Author

GlenDC commented Jul 27, 2023

Can I help with fixing this issue? If someone can mentor me I do not mind picking it up?

@compiler-errors
Copy link
Member

Sorry, I'm working on it. I was experimenting with a bit more thorough fix, but that fell through the cracks since I was traveling the past few weeks.

@GlenDC
Copy link
Contributor Author

GlenDC commented Jul 27, 2023

Ah yes, no worries. No pressure. In that case I’ll wait patiently. Do let me know if I can be of any more meaning now or later, as I’m pretty invested in these functionalities.

@compiler-errors
Copy link
Member

compiler-errors commented Sep 7, 2023

This issue got fixed, right? I can't reproduce it (using plabayo/tower-async#bd868b123eeb4fc65ea066fb107e3e41c306b4b3 from your repo).

@compiler-errors
Copy link
Member

(closing, please reopen if it's in-fact not fixed. I think @fmease inadvertently fixed this in #113956).

@GlenDC
Copy link
Contributor Author

GlenDC commented Sep 7, 2023

Can the docs.rs version of https://docs.rs/crate/tower-async/0.1.1 be recompile for me? Or do I need to request that as a separate issue somewhere else @compiler-errors ?

@fmease
Copy link
Member

fmease commented Sep 7, 2023

I'm not on the docs.rs team (only on the rustdoc-contributors team) and therefore don't know their procedures. However, after having read https://docs.rs/about/builds#failures-and-rebuilds it seems to me that you can request a rebuild after a bug in docs.rs rustdoc has been fixed … by opening an issue in rust-lang/docs.rs, maybe. You might want to try that :)

@GlenDC
Copy link
Contributor Author

GlenDC commented Sep 7, 2023

Thanks I have opened an issue in the right repo, rust-lang/docs.rs#2215.

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. F-async_fn_in_trait Static async fn in traits I-ICE Issue: The compiler panicked, giving an Internal Compilation Error (ICE) ❄️ requires-nightly This issue requires a nightly compiler in some way. T-compiler Relevant to the compiler team, which will review and decide on the PR/issue.
Projects
Development

No branches or pull requests

6 participants