Closed
Description
The following code builds successfully but causes a compiler panic when running cargo doc
:
src/lib.rs
extern crate proc_macro;
/// [function_name]
#[proc_macro_attribute]
pub fn function_name(_attr: proc_macro::TokenStream, item: proc_macro::TokenStream) -> proc_macro::TokenStream {
item
}
Cargo.toml
[package]
name = "causes-rustdoc-panic"
version = "0.1.0"
[lib]
proc-macro = true
Compiler error
thread '<unnamed>' panicked at 'called `Option::unwrap()` on a `None` value', libcore/option.rs:355:21
Toolchain
rustc 1.31.0-nightly (4bd4e4130 2018-10-25) running on x86_64-unknown-linux-gnu
Changing function_name
to another name, either in the doc comment or the actual function name (but not both), causes cargo doc
to succeed with a warning that the link cannot be resolved, as expected.
Using a normal public function in a non-proc_macro library also does not cause a panic, e.g.
/// [function_name]
#[inline]
pub fn function_name(_attr: u8, item: u8) -> u8 {
item
}