Skip to content

Commit 5ac07a8

Browse files
bors[bot]Veykril
andauthored
Merge #11916
11916: internal: Add more doc-link tests r=Veykril a=Veykril bors r+ Co-authored-by: Lukas Wirth <[email protected]>
2 parents ec56c7e + 96b641e commit 5ac07a8

File tree

1 file changed

+94
-10
lines changed

1 file changed

+94
-10
lines changed

crates/ide/src/doc_links/tests.rs

Lines changed: 94 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -299,23 +299,107 @@ fn foo() {
299299
}
300300

301301
#[test]
302-
fn test_trait_items() {
302+
fn doc_links_items_simple() {
303+
check_doc_links(
304+
r#"
305+
//- /main.rs crate:main deps:krate
306+
/// [`krate`]
307+
//! [`Trait`]
308+
//! [`function`]
309+
//! [`CONST`]
310+
//! [`STATIC`]
311+
//! [`Struct`]
312+
//! [`Enum`]
313+
//! [`Union`]
314+
//! [`Type`]
315+
//! [`module`]
316+
use self$0;
317+
318+
const CONST: () = ();
319+
// ^^^^^ CONST
320+
static STATIC: () = ();
321+
// ^^^^^^ STATIC
322+
trait Trait {
323+
// ^^^^^ Trait
324+
}
325+
fn function() {}
326+
// ^^^^^^^^ function
327+
struct Struct;
328+
// ^^^^^^ Struct
329+
enum Enum {}
330+
// ^^^^ Enum
331+
union Union {__: ()}
332+
// ^^^^^ Union
333+
type Type = ();
334+
// ^^^^ Type
335+
mod module {}
336+
// ^^^^^^ module
337+
//- /krate.rs crate:krate
338+
// empty
339+
//^file krate
340+
"#,
341+
)
342+
}
343+
344+
#[test]
345+
fn doc_links_inherent_impl_items() {
346+
check_doc_links(
347+
r#"
348+
// /// [`Struct::CONST`]
349+
// /// [`Struct::function`]
350+
/// FIXME #9694
351+
struct Struct$0;
352+
353+
impl Struct {
354+
const CONST: () = ();
355+
fn function() {}
356+
}
357+
"#,
358+
)
359+
}
360+
361+
#[test]
362+
fn doc_links_trait_impl_items() {
363+
check_doc_links(
364+
r#"
365+
trait Trait {
366+
type Type;
367+
const CONST: usize;
368+
fn function();
369+
}
370+
// /// [`Struct::Type`]
371+
// /// [`Struct::CONST`]
372+
// /// [`Struct::function`]
373+
/// FIXME #9694
374+
struct Struct$0;
375+
376+
impl Trait for Struct {
377+
type Type = ();
378+
const CONST: () = ();
379+
fn function() {}
380+
}
381+
"#,
382+
)
383+
}
384+
385+
#[test]
386+
fn doc_links_trait_items() {
303387
check_doc_links(
304388
r#"
305389
/// [`Trait`]
306390
/// [`Trait::Type`]
307391
/// [`Trait::CONST`]
308-
/// [`Trait::func`]
392+
/// [`Trait::function`]
309393
trait Trait$0 {
310394
// ^^^^^ Trait
311-
type Type;
312-
// ^^^^ Trait::Type
313-
const CONST: usize;
314-
// ^^^^^ Trait::CONST
315-
fn func();
316-
// ^^^^ Trait::func
317-
}
318-
"#,
395+
type Type;
396+
// ^^^^ Trait::Type
397+
const CONST: usize;
398+
// ^^^^^ Trait::CONST
399+
fn function();
400+
// ^^^^^^^^ Trait::function
401+
}
402+
"#,
319403
)
320404
}
321405

0 commit comments

Comments
 (0)