Support doc links that resolve to fields

This commit is contained in:
Ryo Yoshida 2023-08-07 00:59:35 +09:00
parent 70fa270637
commit 0c433c23b1
No known key found for this signature in database
GPG key ID: E25698A930586171
5 changed files with 219 additions and 68 deletions

View file

@ -517,6 +517,62 @@ fn function();
)
}
#[test]
fn doc_links_field() {
check_doc_links(
r#"
/// [`S::f`]
/// [`S2::f`]
/// [`T::0`]
/// [`U::a`]
/// [`E::A::f`]
/// [`E::B::0`]
struct S$0 {
f: i32,
//^ S::f
//^ S2::f
}
type S2 = S;
struct T(i32);
//^^^ T::0
union U {
a: i32,
//^ U::a
}
enum E {
A { f: i32 },
//^ E::A::f
B(i32),
//^^^ E::B::0
}
"#,
);
}
#[test]
fn doc_links_field_via_self() {
check_doc_links(
r#"
/// [`Self::f`]
struct S$0 {
f: i32,
//^ Self::f
}
"#,
);
}
#[test]
fn doc_links_tuple_field_via_self() {
check_doc_links(
r#"
/// [`Self::0`]
struct S$0(i32);
//^^^ Self::0
"#,
);
}
#[test]
fn rewrite_html_root_url() {
check_rewrite(