mirror of
https://github.com/rust-lang/rust-analyzer
synced 2025-01-01 07:48:45 +00:00
internal: Add more doc-link tests
This commit is contained in:
parent
4a1423337f
commit
96b641e95e
1 changed files with 93 additions and 9 deletions
|
@ -299,23 +299,107 @@ fn foo() {
|
||||||
}
|
}
|
||||||
|
|
||||||
#[test]
|
#[test]
|
||||||
fn test_trait_items() {
|
fn doc_links_items_simple() {
|
||||||
|
check_doc_links(
|
||||||
|
r#"
|
||||||
|
//- /main.rs crate:main deps:krate
|
||||||
|
/// [`krate`]
|
||||||
|
//! [`Trait`]
|
||||||
|
//! [`function`]
|
||||||
|
//! [`CONST`]
|
||||||
|
//! [`STATIC`]
|
||||||
|
//! [`Struct`]
|
||||||
|
//! [`Enum`]
|
||||||
|
//! [`Union`]
|
||||||
|
//! [`Type`]
|
||||||
|
//! [`module`]
|
||||||
|
use self$0;
|
||||||
|
|
||||||
|
const CONST: () = ();
|
||||||
|
// ^^^^^ CONST
|
||||||
|
static STATIC: () = ();
|
||||||
|
// ^^^^^^ STATIC
|
||||||
|
trait Trait {
|
||||||
|
// ^^^^^ Trait
|
||||||
|
}
|
||||||
|
fn function() {}
|
||||||
|
// ^^^^^^^^ function
|
||||||
|
struct Struct;
|
||||||
|
// ^^^^^^ Struct
|
||||||
|
enum Enum {}
|
||||||
|
// ^^^^ Enum
|
||||||
|
union Union {__: ()}
|
||||||
|
// ^^^^^ Union
|
||||||
|
type Type = ();
|
||||||
|
// ^^^^ Type
|
||||||
|
mod module {}
|
||||||
|
// ^^^^^^ module
|
||||||
|
//- /krate.rs crate:krate
|
||||||
|
// empty
|
||||||
|
//^file krate
|
||||||
|
"#,
|
||||||
|
)
|
||||||
|
}
|
||||||
|
|
||||||
|
#[test]
|
||||||
|
fn doc_links_inherent_impl_items() {
|
||||||
|
check_doc_links(
|
||||||
|
r#"
|
||||||
|
// /// [`Struct::CONST`]
|
||||||
|
// /// [`Struct::function`]
|
||||||
|
/// FIXME #9694
|
||||||
|
struct Struct$0;
|
||||||
|
|
||||||
|
impl Struct {
|
||||||
|
const CONST: () = ();
|
||||||
|
fn function() {}
|
||||||
|
}
|
||||||
|
"#,
|
||||||
|
)
|
||||||
|
}
|
||||||
|
|
||||||
|
#[test]
|
||||||
|
fn doc_links_trait_impl_items() {
|
||||||
|
check_doc_links(
|
||||||
|
r#"
|
||||||
|
trait Trait {
|
||||||
|
type Type;
|
||||||
|
const CONST: usize;
|
||||||
|
fn function();
|
||||||
|
}
|
||||||
|
// /// [`Struct::Type`]
|
||||||
|
// /// [`Struct::CONST`]
|
||||||
|
// /// [`Struct::function`]
|
||||||
|
/// FIXME #9694
|
||||||
|
struct Struct$0;
|
||||||
|
|
||||||
|
impl Trait for Struct {
|
||||||
|
type Type = ();
|
||||||
|
const CONST: () = ();
|
||||||
|
fn function() {}
|
||||||
|
}
|
||||||
|
"#,
|
||||||
|
)
|
||||||
|
}
|
||||||
|
|
||||||
|
#[test]
|
||||||
|
fn doc_links_trait_items() {
|
||||||
check_doc_links(
|
check_doc_links(
|
||||||
r#"
|
r#"
|
||||||
/// [`Trait`]
|
/// [`Trait`]
|
||||||
/// [`Trait::Type`]
|
/// [`Trait::Type`]
|
||||||
/// [`Trait::CONST`]
|
/// [`Trait::CONST`]
|
||||||
/// [`Trait::func`]
|
/// [`Trait::function`]
|
||||||
trait Trait$0 {
|
trait Trait$0 {
|
||||||
// ^^^^^ Trait
|
// ^^^^^ Trait
|
||||||
type Type;
|
type Type;
|
||||||
// ^^^^ Trait::Type
|
// ^^^^ Trait::Type
|
||||||
const CONST: usize;
|
const CONST: usize;
|
||||||
// ^^^^^ Trait::CONST
|
// ^^^^^ Trait::CONST
|
||||||
fn func();
|
fn function();
|
||||||
// ^^^^ Trait::func
|
// ^^^^^^^^ Trait::function
|
||||||
}
|
}
|
||||||
"#,
|
"#,
|
||||||
)
|
)
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
Loading…
Reference in a new issue