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

Use intra-doc links in core::macros #75927

Merged
merged 1 commit into from
Aug 28, 2020

Conversation

camelid
Copy link
Member

@camelid camelid commented Aug 25, 2020

Part of #75080.

Also cleaned up some things.

@rustbot modify labels: A-intra-doc-links T-doc T-rustdoc

@rustbot rustbot added A-intra-doc-links Area: Intra-doc links, the ability to link to items in docs by name A-docs Area: documentation for any part of the project, including the compiler, standard library, and tools T-rustdoc Relevant to the rustdoc team, which will review and decide on the PR/issue. labels Aug 25, 2020
@rust-highfive
Copy link
Collaborator

r? @cramertj

(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 Aug 25, 2020
@camelid
Copy link
Member Author

camelid commented Aug 25, 2020

NOTE: the intra-doc links in panic.md must be checked by hand before this is merged. I'll need to get my local build going :)

From @jyn514:

If you can get rustdoc to create the links for markdown files, I think it's fine to convert them too, but I'd want to make sure the pass is actually being run and the links aren't silently being ignored.

@jyn514 jyn514 removed the T-rustdoc Relevant to the rustdoc team, which will review and decide on the PR/issue. label Aug 26, 2020
@jyn514
Copy link
Member

jyn514 commented Aug 26, 2020

I decided that T-rustdoc isn't very helpful for these - the other labels are still great though :)
#75917 (comment)

@camelid
Copy link
Member Author

camelid commented Aug 26, 2020

Makes sense to me :)

Copy link
Member

@jyn514 jyn514 left a comment

Choose a reason for hiding this comment

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

This uses doc(include = "panic.md"), so it should work fine when included. I'm all for verifying that though :)

#[doc(include = "panic.md")]

library/core/src/macros/mod.rs Outdated Show resolved Hide resolved
library/core/src/macros/panic.md Outdated Show resolved Hide resolved
library/core/src/macros/panic.md Outdated Show resolved Hide resolved
library/core/src/macros/panic.md Outdated Show resolved Hide resolved
@camelid
Copy link
Member Author

camelid commented Aug 26, 2020

Hmm, why is this happening?

 error: `[format]` cannot be resolved, ignoring it.
 --> library/core/src/macros/mod.rs:1:1
  |
1 | #[doc(include = "panic.md")]
  | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^
  |
  = note: `-D intra-doc-link-resolution-failure` implied by `-D warnings`
  = note: the link appears in this line:
          
          [`format!`] syntax for building a string.
           ^^^^^^^^^
  = help: to escape `[` and `]` characters, just add '\' before them like `\[` or `\]`

error: `[format]` cannot be resolved, ignoring it.
   --> library/core/src/macros/mod.rs:729:39
    |
729 |     /// All other formatting macros ([`format!`], [`write!`], [`println!`], etc) are
    |                                       ^^^^^^^^^ cannot be resolved, ignoring
    |
    = help: to escape `[` and `]` characters, just add '\' before them like `\[` or `\]`

 error: `[println]` cannot be resolved, ignoring it.
   --> library/core/src/macros/mod.rs:729:64
    |
729 |     /// All other formatting macros ([`format!`], [`write!`], [`println!`], etc) are
    |                                                                ^^^^^^^^^^ cannot be resolved, ignoring
    |
    = help: to escape `[` and `]` characters, just add '\' before them like `\[` or `\]`

error: aborting due to 3 previous errors

@jyn514
Copy link
Member

jyn514 commented Aug 26, 2020

format is in alloc, because it allocates: https://doc.rust-lang.org/src/alloc/macros.rs.html#105-110. println is std-only because it does IO: https://doc.rust-lang.org/src/std/macros.rs.html#94-99

@camelid camelid force-pushed the intra-doc-links-for-core-macros branch from 89949c4 to 99704e7 Compare August 26, 2020 00:34
Copy link
Member

@jyn514 jyn514 left a comment

Choose a reason for hiding this comment

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

r=me with nit addressed and CI passing

library/core/src/macros/panic.md Outdated Show resolved Hide resolved
@jyn514
Copy link
Member

jyn514 commented Aug 26, 2020

error: `[Box]` cannot be resolved, ignoring it.
error: `[Any]` cannot be resolved, ignoring it.
error: `[format]` cannot be resolved, ignoring it.

Oops, my fault, sorry.

@camelid
Copy link
Member Author

camelid commented Aug 26, 2020

Do I have to use a non-intra-doc link for Box since it requires allocation?

@jyn514
Copy link
Member

jyn514 commented Aug 26, 2020

Do I have to use a non-intra-doc link for Box since it requires allocation?

Yes, Any is in core though: https://doc.rust-lang.org/core/any/trait.Any.html

@camelid
Copy link
Member Author

camelid commented Aug 26, 2020

That's what I thought. Should be all done now!

@jyn514
Copy link
Member

jyn514 commented Aug 26, 2020

Do you mind squashing the commits?

Also cleaned up some things and added a few more links.
@camelid camelid force-pushed the intra-doc-links-for-core-macros branch from e11acd5 to 511ee05 Compare August 26, 2020 01:46
@camelid
Copy link
Member Author

camelid commented Aug 26, 2020

Squashed! :)

@jyn514
Copy link
Member

jyn514 commented Aug 26, 2020

@bors r+ rollup

Finally good to go 😆

@bors
Copy link
Contributor

bors commented Aug 26, 2020

📌 Commit 511ee05 has been approved by jyn514

@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 Aug 26, 2020
Comment on lines +27 to +28
[ounwrap]: Option::unwrap
[runwrap]: Result::unwrap
Copy link
Contributor

@pickfire pickfire Aug 26, 2020

Choose a reason for hiding this comment

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

Why not just make the original version Option::unwrap and Result::unwrap by tweaking the text a bit?

Copy link
Member

@jyn514 jyn514 Aug 26, 2020

Choose a reason for hiding this comment

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

Let's make that a follow-up PR, this one's been through enough 😆

Copy link
Contributor

Choose a reason for hiding this comment

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

I forgot my the last time I commented on a PR that needs a follow up PR, I wanted to go back to that but I forgot which PR is it.

Copy link
Member

Choose a reason for hiding this comment

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

@pickfire
Copy link
Contributor

@pickfire clean up text when this is merged.

bors added a commit to rust-lang-ci/rust that referenced this pull request Aug 28, 2020
…albini

Rollup of 12 pull requests

Successful merges:

 - rust-lang#75330 (Improve rendering of crate features via doc(cfg))
 - rust-lang#75927 (Use intra-doc links in `core::macros`)
 - rust-lang#75941 (Clean up E0761 explanation)
 - rust-lang#75943 (Fix potential UB in align_offset doc examples)
 - rust-lang#75946 (Error use explicit intra-doc link and fix text)
 - rust-lang#75955 (Use intra-doc links in `core::future::future` and `core::num::dec2flt`)
 - rust-lang#75967 (Fix typo in `std::hint::black_box` docs)
 - rust-lang#75972 (Fix ICE due to carriage return w/ multibyte char)
 - rust-lang#75989 (Rename rustdoc/test -> rustdoc/doctest)
 - rust-lang#75996 (fix wording in release notes)
 - rust-lang#75998 (Add InstrProfilingPlatformFuchsia.c to profiler_builtins)
 - rust-lang#76000 (Adds --bless support to test/run-make-fulldeps)

Failed merges:

r? @ghost
@bors bors merged commit 521b205 into rust-lang:master Aug 28, 2020
@cuviper cuviper added this to the 1.48.0 milestone Nov 17, 2023
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
A-docs Area: documentation for any part of the project, including the compiler, standard library, and tools A-intra-doc-links Area: Intra-doc links, the ability to link to items in docs by name 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.

8 participants