Skip to content

Cargo panics when using -Z rustdoc-scrape-examples=examples on proc-macro crates #10571

@AaronErhardt

Description

@AaronErhardt

Problem

Cargo (nightly) panics when I use -Z rustdoc-scrape-examples=examples, but only on proc-macro crates as it seems. This issue first appeared after rust-lang/rust#94926 was fixed.

The panic occurs here: https://github.com/rust-lang/cargo/blob/master/src/cargo/ops/cargo_compile.rs#L1600

Steps

  1. Clone Relm4
  2. Create docs for relm4-macros using cargo +nightly doc -Z rustdoc-scrape-examples=examples -p relm4-macros

This will likely work with any proc-macro crate though, as it does not even start to compile anything before cargo panics.

Possible Solution(s)

No response

Notes

Backtrace

thread 'main' panicked at 'called `Option::unwrap()` on a `None` value', src/tools/cargo/src/cargo/ops/cargo_compile.rs:1600:36
stack backtrace:
   0: rust_begin_unwind
             at /rustc/e7575f9670f3c837def3d186ae09366c75c7632e/library/std/src/panicking.rs:584:5
   1: core::panicking::panic_fmt
             at /rustc/e7575f9670f3c837def3d186ae09366c75c7632e/library/core/src/panicking.rs:142:14
   2: core::panicking::panic
             at /rustc/e7575f9670f3c837def3d186ae09366c75c7632e/library/core/src/panicking.rs:48:5
   3: <core::iter::adapters::map::Map<core::slice::iter::Iter<cargo::core::compiler::unit::Unit>, cargo::ops::cargo_compile::rebuild_unit_graph_shared::{closure#1}> as core::iter::traits::iterator::Iterator>::fold::<(), core::iter::traits::iterator::Iterator::for_each::call<cargo::core::compiler::unit::Unit, <alloc::vec::Vec<cargo::core::compiler::unit::Unit> as alloc::vec::spec_extend::SpecExtend<cargo::core::compiler::unit::Unit, core::iter::adapters::map::Map<core::slice::iter::Iter<cargo::core::compiler::unit::Unit>, cargo::ops::cargo_compile::rebuild_unit_graph_shared::{closure#1}>>>::spec_extend::{closure#0}>::{closure#0}>
   4: cargo::ops::cargo_compile::rebuild_unit_graph_shared
   5: cargo::ops::cargo_compile::create_bcx
   6: cargo::ops::cargo_compile::compile_ws
   7: cargo::ops::cargo_compile::compile
   8: cargo::ops::cargo_doc::doc
   9: cargo::commands::doc::exec
  10: cargo::cli::main
  11: cargo::main
note: Some details are omitted, run with `RUST_BACKTRACE=full` for a verbose backtrace.

Version

cargo 1.62.0-nightly (dba5baf 2022-04-13)
release: 1.62.0-nightly
commit-hash: dba5baf4345858c591517b24801902a062c399f8
commit-date: 2022-04-13
host: x86_64-unknown-linux-gnu
libgit2: 1.4.2 (sys:0.14.2 vendored)
libcurl: 7.80.0-DEV (sys:0.4.51+curl-7.80.0 vendored ssl:OpenSSL/1.1.1m)
os: OracleLinux 35.0.0 [64-bit]

Activity

Eh2406

Eh2406 commented on Apr 15, 2022

@Eh2406
Contributor
willcrichton

willcrichton commented on Apr 15, 2022

@willcrichton
Contributor

Ah, sorry for the remaining issue. This should already be fixed by #10343, specifically this change:

https://github.com/rust-lang/cargo/pull/10343/files#diff-98da1b66b532e50e9bca971b453ee7de96b17436de1d7ef3824c9888d55be9bbR1587

If possible, I would just like to get #10343 merged rather than fix this standalone.

added a commit that references this issue on Nov 25, 2022
178f8bf
added a commit that references this issue on Nov 25, 2022
390383e
willcrichton

willcrichton commented on Nov 25, 2022

@willcrichton
Contributor

Note: at some point this got un-fixed in #10343, so I just put up a new PR to fix it in #11423.

added a commit that references this issue on Nov 29, 2022
d28c9b8
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Metadata

Metadata

Assignees

No one assigned

    Labels

    C-bugCategory: bugZ-scrape-examplesNightly: rustdoc scrape examples

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

      Participants

      @ehuss@willcrichton@Eh2406@AaronErhardt

      Issue actions

        Cargo panics when using `-Z rustdoc-scrape-examples=examples` on proc-macro crates · Issue #10571 · rust-lang/cargo