Skip to content

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

Closed
@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]

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

    Development

    No branches or pull requests

    Issue actions