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

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

Closed
dtolnay opened this issue Dec 18, 2022 · 1 comment · Fixed by #11497
Closed
Labels
C-bug Category: bug

Comments

@dtolnay
Copy link
Member

dtolnay commented Dec 18, 2022

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]
@willcrichton
Copy link
Contributor

willcrichton commented Dec 18, 2022

Thanks for the report @dtolnay I will investigate this today. Your minimal example did not reproduce the issue on my machine, but I cloning the automod repo and running did. I could reproduce the error and will fix it soon.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
C-bug Category: bug
Projects
None yet
Development

Successfully merging a pull request may close this issue.

2 participants