-
Notifications
You must be signed in to change notification settings - Fork 12.7k
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: Cleanup handling of associated items for intra-doc links #83849
Merged
Merged
Changes from all commits
Commits
Show all changes
3 commits
Select commit
Hold shift + click to select a range
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
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 |
---|---|---|
@@ -1,19 +1,27 @@ | ||
warning: public documentation for `DocMe` links to private item `DontDocMe` | ||
--> $DIR/private.rs:5:11 | ||
--> $DIR/private.rs:7:11 | ||
| | ||
LL | /// docs [DontDocMe] [DontDocMe::f] | ||
LL | /// docs [DontDocMe] [DontDocMe::f] [DontDocMe::x] | ||
| ^^^^^^^^^ this item is private | ||
| | ||
= note: `#[warn(rustdoc::private_intra_doc_links)]` on by default | ||
= note: this link resolves only because you passed `--document-private-items`, but will break without | ||
|
||
warning: public documentation for `DocMe` links to private item `DontDocMe::f` | ||
--> $DIR/private.rs:5:23 | ||
--> $DIR/private.rs:7:23 | ||
| | ||
LL | /// docs [DontDocMe] [DontDocMe::f] | ||
LL | /// docs [DontDocMe] [DontDocMe::f] [DontDocMe::x] | ||
| ^^^^^^^^^^^^ this item is private | ||
| | ||
= note: this link resolves only because you passed `--document-private-items`, but will break without | ||
|
||
warning: 2 warnings emitted | ||
warning: public documentation for `DocMe` links to private item `DontDocMe::x` | ||
--> $DIR/private.rs:7:38 | ||
| | ||
LL | /// docs [DontDocMe] [DontDocMe::f] [DontDocMe::x] | ||
| ^^^^^^^^^^^^ this item is private | ||
| | ||
= note: this link resolves only because you passed `--document-private-items`, but will break without | ||
|
||
warning: 3 warnings emitted | ||
|
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 |
---|---|---|
@@ -1,19 +1,27 @@ | ||
warning: public documentation for `DocMe` links to private item `DontDocMe` | ||
--> $DIR/private.rs:5:11 | ||
--> $DIR/private.rs:7:11 | ||
| | ||
LL | /// docs [DontDocMe] [DontDocMe::f] | ||
LL | /// docs [DontDocMe] [DontDocMe::f] [DontDocMe::x] | ||
| ^^^^^^^^^ this item is private | ||
| | ||
= note: `#[warn(rustdoc::private_intra_doc_links)]` on by default | ||
= note: this link will resolve properly if you pass `--document-private-items` | ||
|
||
warning: public documentation for `DocMe` links to private item `DontDocMe::f` | ||
--> $DIR/private.rs:5:23 | ||
--> $DIR/private.rs:7:23 | ||
| | ||
LL | /// docs [DontDocMe] [DontDocMe::f] | ||
LL | /// docs [DontDocMe] [DontDocMe::f] [DontDocMe::x] | ||
| ^^^^^^^^^^^^ this item is private | ||
| | ||
= note: this link will resolve properly if you pass `--document-private-items` | ||
|
||
warning: 2 warnings emitted | ||
warning: public documentation for `DocMe` links to private item `DontDocMe::x` | ||
--> $DIR/private.rs:7:38 | ||
| | ||
LL | /// docs [DontDocMe] [DontDocMe::f] [DontDocMe::x] | ||
| ^^^^^^^^^^^^ this item is private | ||
| | ||
= note: this link will resolve properly if you pass `--document-private-items` | ||
|
||
warning: 3 warnings emitted | ||
|
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 |
---|---|---|
@@ -1,6 +1,17 @@ | ||
#![crate_name = "private"] | ||
// compile-flags: --document-private-items | ||
/// docs [DontDocMe] | ||
|
||
// make sure to update `rustdoc-ui/intra-doc/private.rs` if you update this file | ||
|
||
/// docs [DontDocMe] [DontDocMe::f] [DontDocMe::x] | ||
// @has private/struct.DocMe.html '//*a[@href="../private/struct.DontDocMe.html"]' 'DontDocMe' | ||
// @has private/struct.DocMe.html '//*a[@href="../private/struct.DontDocMe.html#method.f"]' 'DontDocMe::f' | ||
// @has private/struct.DocMe.html '//*a[@href="../private/struct.DontDocMe.html#structfield.x"]' 'DontDocMe::x' | ||
pub struct DocMe; | ||
struct DontDocMe; | ||
struct DontDocMe { | ||
x: usize, | ||
} | ||
|
||
impl DontDocMe { | ||
fn f() {} | ||
} |
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 guess the error shows why this
resolve_primitive
might be necessary?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 bisecting this now - I think it's unlikely this is the cause, but it's possible.
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.
Oh! I figured it out -
resolve_path
gives precedence to modules over primitives, this does the reverse.The issue is that both
mod usize
and the primitive usize are in scope. I think this might actually be a bug even before - rustdoc should give an error if the base res is ambiguous, but it doesn't:For this specific test case, I think we could fix it by not giving an ambiguity error if the module has
doc(primitive)
on it?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 don't think I'm qualified to have a say in this :)
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.
cc @Manishearth - do you have an opinion here? For context, the original test case was
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.
Actually I think I'm going to wait to fix this for a follow-up PR, it's a change in behavior and shouldn't be mixed with the cleanups. Opened #83862.