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:
@@ -43,10 +43,16 @@ pub struct TestOptions {
|
||||
pub fn run(options: Options) -> i32 {
|
||||
let input = config::Input::File(options.input.clone());
|
||||
|
||||
let crate_types = if options.proc_macro_crate {
|
||||
vec![config::CrateType::ProcMacro]
|
||||
} else {
|
||||
vec![config::CrateType::Dylib]
|
||||
};
|
||||
|
||||
let sessopts = config::Options {
|
||||
maybe_sysroot: options.maybe_sysroot.clone(),
|
||||
search_paths: options.libs.clone(),
|
||||
crate_types: vec![config::CrateType::Dylib],
|
||||
crate_types,
|
||||
cg: options.codegen_options.clone(),
|
||||
externs: options.externs.clone(),
|
||||
unstable_features: UnstableFeatures::from_environment(),
|
||||
|
||||
Reference in New Issue
Block a user