-
Notifications
You must be signed in to change notification settings - Fork 12.8k
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Auto merge of #74098 - GuillaumeGomez:doc-alias-checks, r=ollie27
Doc alias checks: ensure only items appearing in search index can use it Following the discussion in #73721, I added checks to ensure that only items appearing in the search are allowed to have doc alias. r? @ollie27
- Loading branch information
Showing
10 changed files
with
174 additions
and
9 deletions.
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; | ||
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 | ||
|