Skip to content

Commit f5494e1

Browse files
rustdoc: Add test for correct LinkReplacer link matching
1 parent ec16250 commit f5494e1

File tree

1 file changed

+35
-0
lines changed

1 file changed

+35
-0
lines changed
Lines changed: 35 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,35 @@
1+
#![deny(rustdoc::broken_intra_doc_links)]
2+
3+
pub struct S;
4+
pub mod char {}
5+
6+
// Ensure this doesn't ICE due to trying to slice off non-existent backticks from "S"
7+
8+
/// See [S] and [`S`]
9+
pub struct MyStruct1;
10+
11+
// Ensure that link texts are replaced correctly even if there are multiple links with the same target but different text
12+
13+
/// See also [crate::char] and [mod@char] and [prim@char]
14+
// @has prim_precedence/struct.MyStruct2.html '//*[@href="char/index.html"]' 'crate::char'
15+
// @has - '//*[@href="char/index.html"]' 'char'
16+
// @has - '//*[@href="{{channel}}/std/primitive.char.html"]' 'char'
17+
pub struct MyStruct2;
18+
19+
/// See also [mod@char] and [prim@char] and [crate::char]
20+
// @has prim_precedence/struct.MyStruct3.html '//*[@href="char/index.html"]' 'crate::char'
21+
// @has - '//*[@href="char/index.html"]' 'char'
22+
// @has - '//*[@href="{{channel}}/std/primitive.char.html"]' 'char'
23+
pub struct MyStruct3;
24+
25+
// Ensure that links are correct even if there are multiple links with the same text but different targets
26+
27+
/// See also [char][mod@char] and [char][prim@char]
28+
// @has prim_precedence/struct.MyStruct4.html '//*[@href="char/index.html"]' 'char'
29+
// @has - '//*[@href="{{channel}}/std/primitive.char.html"]' 'char'
30+
pub struct MyStruct4;
31+
32+
/// See also [char][prim@char] and [char][crate::char]
33+
// @has prim_precedence/struct.MyStruct5.html '//*[@href="char/index.html"]' 'char'
34+
// @has - '//*[@href="{{channel}}/std/primitive.char.html"]' 'char'
35+
pub struct MyStruct5;

0 commit comments

Comments
 (0)