Skip to content
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

Improve documentation for built-in macros #62243

Merged
merged 6 commits into from
Jul 7, 2019
Merged

Conversation

petrochenkov
Copy link
Contributor

This is the libcore part of #62086.
Right now the only effect is improved documentation.

The changes in the last few commits are required to make the libcore change compile successfully.

@rust-highfive
Copy link
Collaborator

r? @aidanhs

(rust_highfive has picked a reviewer for you, use r? to override)

@rust-highfive rust-highfive added the S-waiting-on-review Status: Awaiting review from the assignee but also interested parties. label Jun 29, 2019
@petrochenkov
Copy link
Contributor Author

r? @eddyb

@rust-highfive rust-highfive assigned eddyb and unassigned aidanhs Jun 29, 2019
@@ -4008,7 +4008,7 @@ impl<'a> LoweringContext<'a> {
let attrs = self.lower_attrs(&i.attrs);
if let ItemKind::MacroDef(ref def) = i.node {
if !def.legacy || attr::contains_name(&i.attrs, sym::macro_export) ||
attr::contains_name(&i.attrs, sym::rustc_doc_only_macro) {
attr::contains_name(&i.attrs, sym::rustc_builtin_macro) {
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Is this needed anymore? The macro_rules! -> macro change would mean !def.legacy is now true.

Copy link
Contributor Author

@petrochenkov petrochenkov Jul 1, 2019

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

No, this is no longer needed (UPD: for libcore, it's still needed for libstd).

@@ -410,7 +410,7 @@ mod builtin {
///
/// [`panic!`]: ../std/macro.panic.html
#[stable(feature = "compile_error_macro", since = "1.20.0")]
#[rustc_doc_only_macro]
#[rustc_builtin_macro]
macro_rules! compile_error {
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Oh, these are unchanged. What needs to happen before these can just be reexports of the libcore ones?

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

rustc_builtin_macro stubs acting like the real macros.

#62086 removes the duplicate macros from libstd, but also pub uses their libcore versions from libstd's root (for documentation).
...And stub macros pub used in libstd root break all the dependent crates that inject #[macro_use] extern crate std during rustdoc build.

Alternatively, some doc attribute for selectively documenting private items would also solve the problem (pub use could be replaced with #[doc(force)] use then).

(sym::rustc_allow_const_fn_ptr, Whitelisted, template!(Word), Gated(Stability::Unstable,
sym::rustc_attrs,
"internal implementation detail",
cfg_fn!(rustc_attrs))),
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Oh, you whitelisted all the existing rustc_* attributes?

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Yep.
If an attribute is not defined/registered in any way, then it goes through the "feature(custom_attribute) fallback" (#29642), something I want to remove from resolve (#61660, #57921).

Also, it's just useful for documentation.
#62133 does the same thing.

@eddyb
Copy link
Member

eddyb commented Jul 1, 2019

@bors r+

@bors
Copy link
Contributor

bors commented Jul 1, 2019

📌 Commit c959d7338b3f47bcbdc89f75cdf357c6b3e2f0df has been approved by eddyb

@bors bors added S-waiting-on-bors Status: Waiting on bors to run and complete tests. Bors will change the label on completion. and removed S-waiting-on-review Status: Awaiting review from the assignee but also interested parties. labels Jul 1, 2019
@bors
Copy link
Contributor

bors commented Jul 5, 2019

☔ The latest upstream changes (presumably #62419) made this pull request unmergeable. Please resolve the merge conflicts.

@bors bors added S-waiting-on-author Status: This is awaiting some action (such as code changes or more information) from the author. and removed S-waiting-on-bors Status: Waiting on bors to run and complete tests. Bors will change the label on completion. labels Jul 5, 2019
@petrochenkov
Copy link
Contributor Author

@bors r=eddyb

@bors
Copy link
Contributor

bors commented Jul 5, 2019

📌 Commit 848b2d2 has been approved by eddyb

@bors bors removed the S-waiting-on-author Status: This is awaiting some action (such as code changes or more information) from the author. label Jul 5, 2019
@petrochenkov
Copy link
Contributor Author

Failed in #62442 (comment)

Ugh, unstable diagnostic output.

@petrochenkov
Copy link
Contributor Author

unstable diagnostic output.

Order in which mir_const_qualif visits items somehow depends on macro loading order.
I didn't investigate that in detail, but I changed the last commit to not load macros in check_reserved_macro_name unless absolutely necessary instead, thus restoring the old macro loading order.

@bors r=eddyb

@bors
Copy link
Contributor

bors commented Jul 6, 2019

📌 Commit 3274507 has been approved by eddyb

@bors bors added S-waiting-on-bors Status: Waiting on bors to run and complete tests. Bors will change the label on completion. and removed S-waiting-on-author Status: This is awaiting some action (such as code changes or more information) from the author. labels Jul 6, 2019
Centril added a commit to Centril/rust that referenced this pull request Jul 6, 2019
Improve documentation for built-in macros

This is the `libcore` part of rust-lang#62086.
Right now the only effect is improved documentation.

The changes in the last few commits are required to make the `libcore` change compile successfully.
bors added a commit that referenced this pull request Jul 6, 2019
Rollup of 6 pull requests

Successful merges:

 - #60081 (Refactor unicode.py script)
 - #61862 (Make the Weak::{into,as}_raw methods)
 - #62243 (Improve documentation for built-in macros)
 - #62422 (Remove some uses of mem::uninitialized)
 - #62432 (Update rustfmt to 1.3.2)
 - #62436 (normalize use of backticks/lowercase in compiler messages for librustc_mir)

Failed merges:

r? @ghost
Centril added a commit to Centril/rust that referenced this pull request Jul 6, 2019
Improve documentation for built-in macros

This is the `libcore` part of rust-lang#62086.
Right now the only effect is improved documentation.

The changes in the last few commits are required to make the `libcore` change compile successfully.
bors added a commit that referenced this pull request Jul 6, 2019
Rollup of 5 pull requests

Successful merges:

 - #60081 (Refactor unicode.py script)
 - #61862 (Make the Weak::{into,as}_raw methods)
 - #62243 (Improve documentation for built-in macros)
 - #62422 (Remove some uses of mem::uninitialized)
 - #62436 (normalize use of backticks/lowercase in compiler messages for librustc_mir)

Failed merges:

r? @ghost
@bors bors merged commit 3274507 into rust-lang:master Jul 7, 2019
@bors
Copy link
Contributor

bors commented Jul 7, 2019

⌛ Testing commit 3274507 with merge b0bd5f2...

@petrochenkov petrochenkov deleted the macrodoc branch July 8, 2019 13:34
@pietroalbini
Copy link
Member

@bors r-

@bors bors added S-waiting-on-author Status: This is awaiting some action (such as code changes or more information) from the author. and removed S-waiting-on-bors Status: Waiting on bors to run and complete tests. Bors will change the label on completion. labels Jul 15, 2019
@pietroalbini
Copy link
Member

@bors retry

@bors bors added S-waiting-on-bors Status: Waiting on bors to run and complete tests. Bors will change the label on completion. and removed S-waiting-on-author Status: This is awaiting some action (such as code changes or more information) from the author. labels Jul 15, 2019
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
S-waiting-on-bors Status: Waiting on bors to run and complete tests. Bors will change the label on completion.
Projects
None yet
Development

Successfully merging this pull request may close these issues.

7 participants