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
This commit is contained in:
bors 2020-08-19 13:10:16 +00:00
commit e7f6ed14d5
10 changed files with 174 additions and 9 deletions

View file

@ -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 }
}

View file

@ -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