-
Notifications
You must be signed in to change notification settings - Fork 2.4k
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
Pass --crate-type to rustdoc #7159
Pass --crate-type to rustdoc #7159
Conversation
r? @nrc (rust_highfive has picked a reviewer for you, use r? to override) |
The test failure is caused by cargo passing |
Thanks for the report! For our own CI some version detection or feature detection will need to be done to get the test working on stable, but otherwise seems fine to add as soon as this is stable in rustdoc! |
Fixes rust-lang#58700 Fixes rust-lang#58696 Fixes rust-lang#49553 Fixes rust-lang#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](rust-lang/cargo#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.
1b39fdc
to
f8923a8
Compare
As discussed on the corresponding rustc PR, we are now using the Unfortunately, this causes an enormous number of CI failures, since every test involving rustdoc will try to pass the (currently unsupported) @alexcrichton: What do you think is the best way of dealing with this? |
…final, r=petrochenkov Improve Rustdoc's handling of procedural macros Fixes rust-lang#58700 Fixes rust-lang#58696 Fixes rust-lang#49553 Fixes rust-lang#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](rust-lang/cargo#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.
…final, r=petrochenkov Improve Rustdoc's handling of procedural macros Fixes rust-lang#58700 Fixes rust-lang#58696 Fixes rust-lang#49553 Fixes rust-lang#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](rust-lang/cargo#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.
As suggested by @eddyb, I've modified this PR to only pass |
3b8e5d7
to
3e73daa
Compare
This PR is no longer blocked - in fact, it is blocking the rustc PR. |
This looks good to me, thanks! Could this also add nightly-only tests which assert that the right flags are passed? |
I'm concerned about the performance implications of how this detects the flag support. It adds 50-80ms to every cargo invocation. It also runs twice unnecessarily. Perhaps it be called once, and only if executing rustdoc? And if |
Oh oops sorry I figured this was using the same logic as |
@alexcrichton: Those tests would need to be done in a follow-up PR - right now, they will never pass, since the corresponding rustc PR is blocked on this PR. |
@Aaron1011 oh sorry I'm assuming that this lands in rustc first, then we land this in Cargo, then the Cargo submodule is updated. That way when we add nightly-only tests we'll be able to ensure this works before we land it. |
@ehuss @alexcrichton: I've modified the PR to cache the result of checking for However, I think it's better to always run the check, not just when documenting a proc macro crate. The idea behind supporting |
@alexcrichton: Unfortunately, it's not possible to land the rustc PR first, unless we make changes to it that would be immediately reverted. Rustdoc now runs all of the normal proc-macro checking logic that rustc does, which will error if a proc macro is declared in a non-proc-macro crate. Without Cargo passing |
Hm I'm not sure if that can be done regardless? That's a breaking change to rustdoc, right? |
@alexcrichton: Technically, it is a breaking change. However:
|
Yes I understand your points, but that's fits the shape of every single breaking change we could land to Rust. Typically they have low impact, they're easy to fix, and they fix bugs. That being said we don't accept breaking changes in rust-lang/rust. There are users, albeit not the majority, running There's various strategies of handling breaking changes in rust-lang/rust to phase out behavior over time, and if that's what's required here then that should be employed rather than one breaking change. |
@alexcrichton: Fair enough. I've changed the rustc PR to emit a warning when |
…trochenkov 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](rust-lang/cargo#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.
ef8b8cd
to
5bc05b4
Compare
@alexcrichton I've modified the PR to check (and cache) the output of |
Thanks! Looks good to me, but instead of an |
@alexcrichton That would cause us to run |
Because it's cached I think that's fine, and this should be gracefully handling errors already if it turns out that rustdoc has issues. |
Ah, so one concern with running rustdoc where we weren't before is that e.g. in rustbuild we'll not always have a rustdoc around; to be clear that's not really a blocking concern here though since we can work around that (probably by faking --version output or so), just wanted to give a brief heads up. I think there's no platform today where we do ship a rustc and don't ship rustdoc so we should be fine in that respect. |
@Mark-Simulacrum: Note that it's fine for rustdoc to not exist - this will be interpreted as rustdoc not supporting |
@bors: r+ |
📌 Commit b68e854 has been approved by |
…lexcrichton Pass --crate-type to rustdoc This supports the [corresponding rustc PR](rust-lang/rust#62855). To enable rustdoc to properly document macros, we pass a new flag '--proc-macro-crate' when documenting a proc-macro crate. This causes rustdoc to enable the proc-macro compiler logic that runs when rustc is building a proc-macro crate. This flag is essentially a more restricted version of '--crate-type=proc-macro'. I didn't think it was necessary to pass the full '--crate-type' flag to rustdoc, when only two options would ever be used (proc-macro vs anything else).
☀️ Test successful - checks-azure |
This pulls in rust-lang/cargo#7159, which ensures that documenting proc macros works correctly.
Update Cargo This pulls in rust-lang/cargo#7159, which ensures that documenting proc macros works correctly.
This pulls in rust-lang/cargo#7159, which ensures that documenting proc macros works correctly.
Update Cargo This pulls in rust-lang/cargo#7159, which ensures that documenting proc macros works correctly.
This supports the corresponding rustc PR. To enable rustdoc to properly
document macros, we pass a new flag '--proc-macro-crate' when
documenting a proc-macro crate. This causes rustdoc to enable the
proc-macro compiler logic that runs when rustc is building a proc-macro
crate.
This flag is essentially a more restricted version of
'--crate-type=proc-macro'. I didn't think it was necessary to pass the
full '--crate-type' flag to rustdoc, when only two options would ever be
used (proc-macro vs anything else).