Skip to content

-Zrustdoc-scrape-examples crash if a package contains proc-macro library and example crate #11496

Closed
@dtolnay

Description

@dtolnay

Problem

rust-lang/docs.rs#1954 enabled -Zrustdoc-scrape-examples, which caused docs of the automod crate to fail to build.

https://docs.rs/crate/automod/1.0.5/builds/703499

thread 'main' panicked at 'called `Option::unwrap()` on a `None` value', src/tools/cargo/src/cargo/ops/cargo_compile/mod.rs:595:21
note: run with `RUST_BACKTRACE=1` environment variable to display a backtrace

Steps

# Cargo.toml

[package]
name = "repro"
version = "0.0.0"
edition = "2021"

[lib]
proc-macro = true
// src/lib.rs (empty)
// examples/ex.rs

fn main() {}
$ cargo +nightly-2022-12-18 rustdoc -Zrustdoc-scrape-examples
thread 'main' panicked at 'called `Option::unwrap()` on a `None` value', src/tools/cargo/src/cargo/ops/cargo_compile/mod.rs:595:21
note: run with `RUST_BACKTRACE=1` environment variable to display a backtrace

If the library crate is not a proc macro, or if there is no example crate included in the package, then it does not crash.

Possible Solution(s)

No response

Notes

FYI @willcrichton

Version

cargo 1.68.0-nightly (cc0a32087 2022-12-14)
release: 1.68.0-nightly
commit-hash: cc0a320879c17207bbfb96b5d778e28a2c62030d
commit-date: 2022-12-14
host: x86_64-unknown-linux-gnu
libgit2: 1.5.0 (sys:0.15.0 vendored)
libcurl: 7.86.0-DEV (sys:0.4.59+curl-7.86.0 vendored ssl:OpenSSL/1.1.1q)
os: Ubuntu 22.04 (jammy) [64-bit]

Metadata

Metadata

Assignees

No one assigned

    Labels

    C-bugCategory: bug

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions