-
Notifications
You must be signed in to change notification settings - Fork 13.1k
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
Support proc macros in intra doc link resolution #73183
Merged
Merged
Changes from all commits
Commits
Show all changes
5 commits
Select commit
Hold shift + click to select a range
4eda3f7
intra-doc macro resolution should also handle proc macros
Manishearth e003c3e
Add test for proc macro resolution in intra doc links
Manishearth 27dcb4a
Avoid collisions between traits and their derive macros
Manishearth 1784655
Don't print bang diagnostics for derives
Manishearth 34c6b38
Add tests for macro@ and derive@
Manishearth File filter
Filter by extension
Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,35 @@ | ||
// force-host | ||
// no-prefer-dynamic | ||
// compile-flags: --crate-type proc-macro | ||
|
||
#![crate_type="proc-macro"] | ||
#![crate_name="intra_link_proc_macro_macro"] | ||
|
||
extern crate proc_macro; | ||
|
||
use proc_macro::TokenStream; | ||
|
||
#[proc_macro_derive(DeriveA)] | ||
pub fn a_derive(input: TokenStream) -> TokenStream { | ||
input | ||
} | ||
|
||
#[proc_macro_derive(DeriveB)] | ||
pub fn b_derive(input: TokenStream) -> TokenStream { | ||
input | ||
} | ||
|
||
#[proc_macro_derive(DeriveTrait)] | ||
pub fn trait_derive(input: TokenStream) -> TokenStream { | ||
input | ||
} | ||
|
||
#[proc_macro_attribute] | ||
pub fn attr_a(input: TokenStream, _args: TokenStream) -> TokenStream { | ||
input | ||
} | ||
|
||
#[proc_macro_attribute] | ||
pub fn attr_b(input: TokenStream, _args: TokenStream) -> TokenStream { | ||
input | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,27 @@ | ||
// aux-build:intra-link-proc-macro-macro.rs | ||
// build-aux-docs | ||
#![deny(intra_doc_link_resolution_failure)] | ||
|
||
extern crate intra_link_proc_macro_macro; | ||
|
||
|
||
pub use intra_link_proc_macro_macro::{DeriveA, attr_a}; | ||
use intra_link_proc_macro_macro::{DeriveB, attr_b}; | ||
|
||
// @has intra_link_proc_macro/struct.Foo.html | ||
// @has - '//a/@href' '../intra_link_proc_macro/derive.DeriveA.html' | ||
// @has - '//a/@href' '../intra_link_proc_macro/attr.attr_a.html' | ||
// @has - '//a/@href' '../intra_link_proc_macro/trait.DeriveTrait.html' | ||
// @has - '//a/@href' '../intra_link_proc_macro_macro/derive.DeriveB.html' | ||
// @has - '//a/@href' '../intra_link_proc_macro_macro/attr.attr_b.html' | ||
/// Link to [DeriveA], [attr_a], [DeriveB], [attr_b], [DeriveTrait] | ||
Manishearth marked this conversation as resolved.
Show resolved
Hide resolved
|
||
pub struct Foo; | ||
|
||
// @has intra_link_proc_macro/struct.Bar.html | ||
// @has - '//a/@href' '../intra_link_proc_macro/derive.DeriveA.html' | ||
// @has - '//a/@href' '../intra_link_proc_macro/attr.attr_a.html' | ||
/// Link to [deriveA](derive@DeriveA) [attr](macro@attr_a) | ||
pub struct Bar; | ||
|
||
// this should not cause ambiguity errors | ||
pub trait DeriveTrait {} |
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I'm wondering: is there any reason behind supporting
derive@
too? (Not against it, just curious)There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
People don't typically consider custom derives to be macros, so asking them to use
macro@
seems weird.macro@
still will work (this is true of all of the disambiguators, they don't do anything other than selecting the namespace)