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

(rustdoc) [src] link for types defined by macros shows invocation, not defintion #78908

Merged
merged 1 commit into from
Nov 11, 2020

Conversation

liketechnik
Copy link
Contributor

@liketechnik liketechnik commented Nov 9, 2020

Previously the [src] link on types defined by a macro pointed to the macro definition.

This pr makes the Clean-Implementation for Spans aware of macro defined types, so that the link points to the invocation instead.

I'm not totally sure if it's okay to add the 'macro awareness' in the Clean-Implementation, because it erases that knowledge for all following code. Maybe it would be more sensible to add the check only for the link generation at

fn src_href(&self, item: &clean::Item, cache: &Cache) -> Option<String> {

Closes #39726.

@rust-highfive
Copy link
Collaborator

r? @GuillaumeGomez

(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 Nov 9, 2020
@GuillaumeGomez
Copy link
Member

I'm not totally sure if it's okay to add the 'macro awareness' in the Clean-Implementation, because it erases that knowledge for all following code.

I don't see why not? :)

@jyn514 jyn514 added A-macros Area: All kinds of macros (custom derive, macro_rules!, proc macros, ..) T-rustdoc Relevant to the rustdoc team, which will review and decide on the PR/issue. labels Nov 9, 2020
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.

Could you also add some tests for the new behavior? They'd go in src/test/rustdoc; there's examples there and instructions in https://rustc-dev-guide.rust-lang.org/rustdoc-internals.html#dotting-is-and-crossing-ts.

src/librustdoc/clean/mod.rs Outdated Show resolved Hide resolved
@jyn514 jyn514 assigned jyn514 and unassigned GuillaumeGomez Nov 9, 2020
@jyn514
Copy link
Member

jyn514 commented Nov 9, 2020

Actually, it looks like just updating the existing tests should be enough:

---- [rustdoc] rustdoc/external-macro-src.rs stdout ----
------------------------------------------
12: @has check failed
	`XPATH PATTERN` did not match
	// @has - '//a[@href="https://example.com/src/external_macro_src/external-macro-src.rs.html#8"]' '[src]'
13: @has check failed
	`XPATH PATTERN` did not match
	// @has - '//a[@href="https://example.com/src/external_macro_src/external-macro-src.rs.html#9-13"]' '[src]'
14: @has check failed
	`XPATH PATTERN` did not match
	// @has - '//a[@href="https://example.com/src/external_macro_src/external-macro-src.rs.html#10-12"]' '[src]'

Encountered 3 errors

------------------------------------------


---- [rustdoc] rustdoc/issue-26606.rs stdout ----

error: htmldocck failed!
status: exit code: 1
command: "/usr/bin/python2.7" "/checkout/src/etc/htmldocck.py" "/checkout/obj/build/x86_64-unknown-linux-gnu/test/rustdoc/issue-26606" "/checkout/src/test/rustdoc/issue-26606.rs"
stdout:
------------------------------------------

------------------------------------------
stderr:
------------------------------------------
10: @has check failed
	`XPATH PATTERN` did not match
	// @has - '//a/@href' '../src/issue_26606_macro/issue-26606-macro.rs.html#3'

Encountered 1 errors

------------------------------------------


---- [rustdoc] rustdoc/thread-local-src.rs stdout ----

error: htmldocck failed!
status: exit code: 1
command: "/usr/bin/python2.7" "/checkout/src/etc/htmldocck.py" "/checkout/obj/build/x86_64-unknown-linux-gnu/test/rustdoc/thread-local-src" "/checkout/src/test/rustdoc/thread-local-src.rs"
stdout:
------------------------------------------

------------------------------------------
stderr:
------------------------------------------
5: @has check failed
	`XPATH PATTERN` did not match
	// @has foo/constant.FOO.html '//a/@href' 'https://doc.rust-lang.org/nightly/src/std/'

Encountered 1 errors

------------------------------------------



failures:
    [rustdoc] rustdoc/external-macro-src.rs
    [rustdoc] rustdoc/issue-26606.rs
    [rustdoc] rustdoc/thread-local-src.rs

Previously the [src] link on types defined by a macro
pointed to the macro definition.
This commit makes the Clean-Implementation for Spans
aware of macro defined types,
so that the link points to the invocation instead.
@liketechnik liketechnik marked this pull request as ready for review November 10, 2020 00:44
@jyn514
Copy link
Member

jyn514 commented Nov 10, 2020

@bors r+

Thanks for working on this! I actually wanted this just tonight while looking at documentation :)

@bors
Copy link
Contributor

bors commented Nov 10, 2020

📌 Commit 7beb0da 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 Nov 10, 2020
bors added a commit to rust-lang-ci/rust that referenced this pull request Nov 11, 2020
…as-schievink

Rollup of 14 pull requests

Successful merges:

 - rust-lang#76765 (Make it more clear what an about async fn's returns when referring to what it returns)
 - rust-lang#78574 (Use check-pass instead of build-pass in regions ui test suite)
 - rust-lang#78669 (Use check-pass instead of build-pass in some consts ui test suits)
 - rust-lang#78847 (Assert that a return place is not used for indexing during integration)
 - rust-lang#78854 (Workaround for "could not fully normalize" ICE )
 - rust-lang#78875 (rustc_target: Further cleanup use of target options)
 - rust-lang#78887 (Add comments to explain memory usage optimization)
 - rust-lang#78890 (comment attribution fix)
 - rust-lang#78896 (Clarified description of write! macro)
 - rust-lang#78897 (Add missing newline to error message of the default OOM hook)
 - rust-lang#78898 (add regression test for rust-lang#78892)
 - rust-lang#78908 ((rustdoc) [src] link for types defined by macros shows invocation, not defintion)
 - rust-lang#78910 (Fix links to stabilized versions of some intrinsics)
 - rust-lang#78912 (Add macro test for min-const-generics)

Failed merges:

r? `@ghost`
`@rustbot` modify labels: rollup
@bors bors merged commit a5f549e into rust-lang:master Nov 11, 2020
@rustbot rustbot added this to the 1.49.0 milestone Nov 11, 2020
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
A-macros Area: All kinds of macros (custom derive, macro_rules!, proc macros, ..) S-waiting-on-bors Status: Waiting on bors to run and complete tests. Bors will change the label on completion. T-rustdoc Relevant to the rustdoc team, which will review and decide on the PR/issue.
Projects
None yet
Development

Successfully merging this pull request may close these issues.

Clicking 'src' in rustdoc for a type defined by a macro should show invocation, not macro definition
6 participants