Skip to content

Commit ff4352e

Browse files
Add regression tests for #108653
1 parent d3846aa commit ff4352e

8 files changed

+252
-0
lines changed
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,17 @@
1+
// This is ensuring that the UI output for associated items is as expected.
2+
3+
#![deny(rustdoc::broken_intra_doc_links)]
4+
5+
/// [`Trait::IDENT`]
6+
//~^ ERROR
7+
pub trait Trait {
8+
type IDENT;
9+
const IDENT: usize;
10+
}
11+
12+
/// [`Trait2::IDENT`]
13+
//~^ ERROR
14+
pub trait Trait2 {
15+
type IDENT;
16+
fn IDENT() {}
17+
}
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,37 @@
1+
error: `Trait::IDENT` is both an associated type and an associated constant
2+
--> $DIR/issue-108653-associated-items-2.rs:5:7
3+
|
4+
LL | /// [`Trait::IDENT`]
5+
| ^^^^^^^^^^^^ ambiguous link
6+
|
7+
note: the lint level is defined here
8+
--> $DIR/issue-108653-associated-items-2.rs:3:9
9+
|
10+
LL | #![deny(rustdoc::broken_intra_doc_links)]
11+
| ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
12+
help: to link to the associated type, prefix with `type@`
13+
|
14+
LL | /// [`type@Trait::IDENT`]
15+
| +++++
16+
help: to link to the associated constant, prefix with `const@`
17+
|
18+
LL | /// [`const@Trait::IDENT`]
19+
| ++++++
20+
21+
error: `Trait2::IDENT` is both an associated type and an associated function
22+
--> $DIR/issue-108653-associated-items-2.rs:12:7
23+
|
24+
LL | /// [`Trait2::IDENT`]
25+
| ^^^^^^^^^^^^^ ambiguous link
26+
|
27+
help: to link to the associated type, prefix with `type@`
28+
|
29+
LL | /// [`type@Trait2::IDENT`]
30+
| +++++
31+
help: to link to the associated function, add parentheses
32+
|
33+
LL | /// [`Trait2::IDENT()`]
34+
| ++
35+
36+
error: aborting due to 2 previous errors
37+
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,16 @@
1+
// This is ensuring that the UI output for associated items works when it's being documented
2+
// from another item.
3+
4+
#![deny(rustdoc::broken_intra_doc_links)]
5+
#![allow(nonstandard_style)]
6+
7+
pub trait Trait {
8+
type Trait;
9+
const Trait: usize;
10+
}
11+
12+
/// [`Trait`]
13+
//~^ ERROR
14+
/// [`Trait::Trait`]
15+
//~^ ERROR
16+
pub const Trait: usize = 0;
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,37 @@
1+
error: `Trait` is both a trait and a constant
2+
--> $DIR/issue-108653-associated-items-3.rs:12:7
3+
|
4+
LL | /// [`Trait`]
5+
| ^^^^^ ambiguous link
6+
|
7+
note: the lint level is defined here
8+
--> $DIR/issue-108653-associated-items-3.rs:4:9
9+
|
10+
LL | #![deny(rustdoc::broken_intra_doc_links)]
11+
| ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
12+
help: to link to the trait, prefix with `trait@`
13+
|
14+
LL | /// [`trait@Trait`]
15+
| ++++++
16+
help: to link to the constant, prefix with `const@`
17+
|
18+
LL | /// [`const@Trait`]
19+
| ++++++
20+
21+
error: `Trait::Trait` is both an associated type and an associated constant
22+
--> $DIR/issue-108653-associated-items-3.rs:14:7
23+
|
24+
LL | /// [`Trait::Trait`]
25+
| ^^^^^^^^^^^^ ambiguous link
26+
|
27+
help: to link to the associated type, prefix with `type@`
28+
|
29+
LL | /// [`type@Trait::Trait`]
30+
| +++++
31+
help: to link to the associated constant, prefix with `const@`
32+
|
33+
LL | /// [`const@Trait::Trait`]
34+
| ++++++
35+
36+
error: aborting due to 2 previous errors
37+
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,21 @@
1+
// This is ensuring that the UI output for associated items works when it's being documented
2+
// from another item.
3+
4+
#![deny(rustdoc::broken_intra_doc_links)]
5+
#![allow(nonstandard_style)]
6+
7+
pub trait Trait {
8+
type Trait;
9+
}
10+
11+
/// [`Struct::Trait`]
12+
//~^ ERROR
13+
pub struct Struct;
14+
15+
impl Trait for Struct {
16+
type Trait = Struct;
17+
}
18+
19+
impl Struct {
20+
pub const Trait: usize = 0;
21+
}
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,22 @@
1+
error: `Struct::Trait` is both an associated constant and an associated type
2+
--> $DIR/issue-108653-associated-items-4.rs:11:7
3+
|
4+
LL | /// [`Struct::Trait`]
5+
| ^^^^^^^^^^^^^ ambiguous link
6+
|
7+
note: the lint level is defined here
8+
--> $DIR/issue-108653-associated-items-4.rs:4:9
9+
|
10+
LL | #![deny(rustdoc::broken_intra_doc_links)]
11+
| ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
12+
help: to link to the associated constant, prefix with `const@`
13+
|
14+
LL | /// [`const@Struct::Trait`]
15+
| ++++++
16+
help: to link to the associated type, prefix with `type@`
17+
|
18+
LL | /// [`type@Struct::Trait`]
19+
| +++++
20+
21+
error: aborting due to previous error
22+
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,35 @@
1+
// This is ensuring that the UI output for associated items is as expected.
2+
3+
#![deny(rustdoc::broken_intra_doc_links)]
4+
5+
pub enum Enum {
6+
IDENT,
7+
}
8+
9+
/// [`Self::IDENT`]
10+
//~^ ERROR
11+
pub trait Trait {
12+
type IDENT;
13+
fn IDENT();
14+
}
15+
16+
/// [`Self::IDENT`]
17+
//~^ ERROR
18+
impl Trait for Enum {
19+
type IDENT = usize;
20+
fn IDENT() {}
21+
}
22+
23+
/// [`Self::IDENT2`]
24+
//~^ ERROR
25+
pub trait Trait2 {
26+
type IDENT2;
27+
const IDENT2: usize;
28+
}
29+
30+
/// [`Self::IDENT2`]
31+
//~^ ERROR
32+
impl Trait2 for Enum {
33+
type IDENT2 = usize;
34+
const IDENT2: usize = 0;
35+
}
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,67 @@
1+
error: `Self::IDENT` is both an associated type and an associated function
2+
--> $DIR/issue-108653-associated-items.rs:9:7
3+
|
4+
LL | /// [`Self::IDENT`]
5+
| ^^^^^^^^^^^ ambiguous link
6+
|
7+
note: the lint level is defined here
8+
--> $DIR/issue-108653-associated-items.rs:3:9
9+
|
10+
LL | #![deny(rustdoc::broken_intra_doc_links)]
11+
| ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
12+
help: to link to the associated type, prefix with `type@`
13+
|
14+
LL | /// [`type@Self::IDENT`]
15+
| +++++
16+
help: to link to the associated function, add parentheses
17+
|
18+
LL | /// [`Self::IDENT()`]
19+
| ++
20+
21+
error: `Self::IDENT2` is both an associated type and an associated constant
22+
--> $DIR/issue-108653-associated-items.rs:23:7
23+
|
24+
LL | /// [`Self::IDENT2`]
25+
| ^^^^^^^^^^^^ ambiguous link
26+
|
27+
help: to link to the associated type, prefix with `type@`
28+
|
29+
LL | /// [`type@Self::IDENT2`]
30+
| +++++
31+
help: to link to the associated constant, prefix with `const@`
32+
|
33+
LL | /// [`const@Self::IDENT2`]
34+
| ++++++
35+
36+
error: `Self::IDENT2` is both an associated type and an associated constant
37+
--> $DIR/issue-108653-associated-items.rs:30:7
38+
|
39+
LL | /// [`Self::IDENT2`]
40+
| ^^^^^^^^^^^^ ambiguous link
41+
|
42+
help: to link to the associated type, prefix with `type@`
43+
|
44+
LL | /// [`type@Self::IDENT2`]
45+
| +++++
46+
help: to link to the associated constant, prefix with `const@`
47+
|
48+
LL | /// [`const@Self::IDENT2`]
49+
| ++++++
50+
51+
error: `Self::IDENT` is both an associated type and an associated function
52+
--> $DIR/issue-108653-associated-items.rs:16:7
53+
|
54+
LL | /// [`Self::IDENT`]
55+
| ^^^^^^^^^^^ ambiguous link
56+
|
57+
help: to link to the associated type, prefix with `type@`
58+
|
59+
LL | /// [`type@Self::IDENT`]
60+
| +++++
61+
help: to link to the associated function, add parentheses
62+
|
63+
LL | /// [`Self::IDENT()`]
64+
| ++
65+
66+
error: aborting due to 4 previous errors
67+

0 commit comments

Comments
 (0)