-
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
Doc alias checks: ensure only items appearing in search index can use it #74098
Merged
Merged
Changes from all commits
Commits
Show all changes
7 commits
Select commit
Hold shift + click to select a range
213dc41
Add checks for doc alias on which item it's used
GuillaumeGomez 23a2ba6
Add more tests for doc alias
GuillaumeGomez b04fda8
Add doc(alias) attribute checks for associated consts and associated …
GuillaumeGomez 9d252ba
Remove invalid #[doc(alias)] from doc-alias search-index test
GuillaumeGomez 51db2a6
Put back attributes check pass in rustdoc
GuillaumeGomez 3b6e4a8
Move #[doc(alias)] attribute checks in rustc
GuillaumeGomez fc6fb3f
Allow #[doc(alias)] on impl const items
GuillaumeGomez 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
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,23 @@ | ||
#![feature(doc_alias)] | ||
|
||
pub struct Bar; | ||
pub trait Foo { | ||
type X; | ||
fn foo() -> Self::X; | ||
} | ||
|
||
#[doc(alias = "foo")] //~ ERROR | ||
extern {} | ||
|
||
#[doc(alias = "bar")] //~ ERROR | ||
impl Bar { | ||
#[doc(alias = "const")] | ||
pub const A: u32 = 0; | ||
} | ||
|
||
#[doc(alias = "foobar")] //~ ERROR | ||
impl Foo for Bar { | ||
#[doc(alias = "assoc")] //~ ERROR | ||
type X = i32; | ||
GuillaumeGomez marked this conversation as resolved.
Show resolved
Hide resolved
|
||
fn foo() -> Self::X { 0 } | ||
} |
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,26 @@ | ||
error: `#[doc(alias = "...")]` isn't allowed on extern block | ||
--> $DIR/check-doc-alias-attr-location.rs:9:7 | ||
| | ||
LL | #[doc(alias = "foo")] | ||
| ^^^^^^^^^^^^^ | ||
|
||
error: `#[doc(alias = "...")]` isn't allowed on implementation block | ||
--> $DIR/check-doc-alias-attr-location.rs:12:7 | ||
| | ||
LL | #[doc(alias = "bar")] | ||
| ^^^^^^^^^^^^^ | ||
|
||
error: `#[doc(alias = "...")]` isn't allowed on implementation block | ||
--> $DIR/check-doc-alias-attr-location.rs:18:7 | ||
| | ||
LL | #[doc(alias = "foobar")] | ||
| ^^^^^^^^^^^^^^^^ | ||
|
||
error: `#[doc(alias = "...")]` isn't allowed on type alias in implementation block | ||
--> $DIR/check-doc-alias-attr-location.rs:20:11 | ||
| | ||
LL | #[doc(alias = "assoc")] | ||
| ^^^^^^^^^^^^^^^ | ||
|
||
error: aborting due to 4 previous errors | ||
|
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,10 @@ | ||
#![crate_type = "lib"] | ||
#![feature(doc_alias)] | ||
|
||
#[doc(alias = "foo")] // ok! | ||
pub struct Bar; | ||
|
||
#[doc(alias)] //~ ERROR | ||
#[doc(alias = 0)] //~ ERROR | ||
#[doc(alias("bar"))] //~ ERROR | ||
pub struct Foo; |
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,20 @@ | ||
error: doc alias attribute expects a string: #[doc(alias = "0")] | ||
--> $DIR/check-doc-alias-attr.rs:7:7 | ||
| | ||
LL | #[doc(alias)] | ||
| ^^^^^ | ||
|
||
error: doc alias attribute expects a string: #[doc(alias = "0")] | ||
--> $DIR/check-doc-alias-attr.rs:8:7 | ||
| | ||
LL | #[doc(alias = 0)] | ||
| ^^^^^^^^^ | ||
|
||
error: doc alias attribute expects a string: #[doc(alias = "0")] | ||
--> $DIR/check-doc-alias-attr.rs:9:7 | ||
| | ||
LL | #[doc(alias("bar"))] | ||
| ^^^^^^^^^^^^ | ||
|
||
error: aborting due to 3 previous errors | ||
|
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,24 @@ | ||
#![crate_type="lib"] | ||
#![feature(doc_alias)] | ||
|
||
pub struct Bar; | ||
pub trait Foo { | ||
type X; | ||
fn foo() -> Self::X; | ||
} | ||
|
||
#[doc(alias = "foo")] //~ ERROR | ||
extern {} | ||
|
||
#[doc(alias = "bar")] //~ ERROR | ||
impl Bar { | ||
#[doc(alias = "const")] | ||
const A: u32 = 0; | ||
} | ||
|
||
#[doc(alias = "foobar")] //~ ERROR | ||
impl Foo for Bar { | ||
#[doc(alias = "assoc")] //~ ERROR | ||
type X = i32; | ||
fn foo() -> Self::X { 0 } | ||
} |
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,26 @@ | ||
error: `#[doc(alias = "...")]` isn't allowed on extern block | ||
--> $DIR/check-doc-alias-attr-location.rs:10:7 | ||
| | ||
LL | #[doc(alias = "foo")] | ||
| ^^^^^^^^^^^^^ | ||
|
||
error: `#[doc(alias = "...")]` isn't allowed on implementation block | ||
--> $DIR/check-doc-alias-attr-location.rs:13:7 | ||
| | ||
LL | #[doc(alias = "bar")] | ||
| ^^^^^^^^^^^^^ | ||
|
||
error: `#[doc(alias = "...")]` isn't allowed on implementation block | ||
--> $DIR/check-doc-alias-attr-location.rs:19:7 | ||
| | ||
LL | #[doc(alias = "foobar")] | ||
| ^^^^^^^^^^^^^^^^ | ||
|
||
error: `#[doc(alias = "...")]` isn't allowed on type alias in implementation block | ||
--> $DIR/check-doc-alias-attr-location.rs:21:11 | ||
| | ||
LL | #[doc(alias = "assoc")] | ||
| ^^^^^^^^^^^^^^^ | ||
|
||
error: aborting due to 4 previous errors | ||
|
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.
ImplTraitItem
should be removed from here as well now it's been removed fromdoc-alias.rs
.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.
That's why the search for it is returning nothing below. The goal was to check that nothing was returned.
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.
ImplTraitItem
doesn't appear anywhere in the source file anymore so of course it's not going to produce any search results. This isn't a particularly useful test.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.
But that's the point of the test: it's supposed to not return anything, so we ensure that it doesn't.