Improve Rustdoc's handling of procedural macros
Fixes #58700 Fixes #58696 Fixes #49553 Fixes #52210 This commit removes the special rustdoc handling for proc macros, as we can now retrieve their span and attributes just like any other item. A new command-line option is added to rustdoc: `--crate-type`. This takes the same options as rustc's `--crate-type` option. However, all values other than `proc-macro` are treated the same. This allows Rustdoc to enable 'proc macro mode' when handling a proc macro crate. In compiletest, a new 'rustdoc-flags' option is added. This allows us to pass in the '--proc-macro-crate' flag in the absence of Cargo. I've opened [an additional PR to Cargo](https://github.com/rust-lang/cargo/pull/7159) to support passing in this flag. These two PRS can be merged in any order - the Cargo changes will not take effect until the 'cargo' submodule is updated in this repository.
This commit is contained in:
@@ -228,6 +228,7 @@ pub fn run_core(options: RustdocOptions) -> (clean::Crate, RenderInfo, RenderOpt
|
||||
let RustdocOptions {
|
||||
input,
|
||||
crate_name,
|
||||
proc_macro_crate,
|
||||
error_format,
|
||||
libs,
|
||||
externs,
|
||||
@@ -293,11 +294,16 @@ pub fn run_core(options: RustdocOptions) -> (clean::Crate, RenderInfo, RenderOpt
|
||||
}).collect();
|
||||
|
||||
let host_triple = TargetTriple::from_triple(config::host_triple());
|
||||
let crate_types = if proc_macro_crate {
|
||||
vec![config::CrateType::ProcMacro]
|
||||
} else {
|
||||
vec![config::CrateType::Rlib]
|
||||
};
|
||||
// plays with error output here!
|
||||
let sessopts = config::Options {
|
||||
maybe_sysroot,
|
||||
search_paths: libs,
|
||||
crate_types: vec![config::CrateType::Rlib],
|
||||
crate_types,
|
||||
lint_opts: if !display_warnings {
|
||||
lint_opts
|
||||
} else {
|
||||
|
||||
Reference in New Issue
Block a user