@@ -463,7 +463,7 @@ mod tests {
463
463
use super :: * ;
464
464
465
465
#[ test]
466
- fn test_doc_url_crate ( ) {
466
+ fn external_docs_doc_url_crate ( ) {
467
467
check_external_docs (
468
468
r#"
469
469
//- /main.rs crate:main deps:test
@@ -476,7 +476,7 @@ pub struct Foo;
476
476
}
477
477
478
478
#[ test]
479
- fn test_doc_url_struct ( ) {
479
+ fn external_docs_doc_url_struct ( ) {
480
480
check_external_docs (
481
481
r#"
482
482
pub struct Fo$0o;
@@ -486,7 +486,19 @@ pub struct Fo$0o;
486
486
}
487
487
488
488
#[ test]
489
- fn test_doc_url_fn ( ) {
489
+ fn external_docs_doc_url_struct_field ( ) {
490
+ check_external_docs (
491
+ r#"
492
+ pub struct Foo {
493
+ field$0: ()
494
+ }
495
+ "# ,
496
+ expect ! [ [ r##"https://docs.rs/test/*/test/struct.Foo.html#structfield.field"## ] ] ,
497
+ ) ;
498
+ }
499
+
500
+ #[ test]
501
+ fn external_docs_doc_url_fn ( ) {
490
502
check_external_docs (
491
503
r#"
492
504
pub fn fo$0o() {}
@@ -496,73 +508,119 @@ pub fn fo$0o() {}
496
508
}
497
509
498
510
#[ test]
499
- fn test_doc_url_inherent_method ( ) {
511
+ fn external_docs_doc_url_impl_assoc ( ) {
500
512
check_external_docs (
501
513
r#"
502
514
pub struct Foo;
503
515
impl Foo {
504
- pub fn met$0hod () {}
516
+ pub fn method$0 () {}
505
517
}
506
518
"# ,
507
519
expect ! [ [ r##"https://docs.rs/test/*/test/struct.Foo.html#method.method"## ] ] ,
508
520
) ;
521
+ check_external_docs (
522
+ r#"
523
+ pub struct Foo;
524
+ impl Foo {
525
+ const CONST$0: () = ();
526
+ }
527
+ "# ,
528
+ expect ! [ [ r##"https://docs.rs/test/*/test/struct.Foo.html#associatedconstant.CONST"## ] ] ,
529
+ ) ;
509
530
}
510
531
511
532
#[ test]
512
- fn test_doc_url_impl_trait_method ( ) {
533
+ fn external_docs_doc_url_impl_trait_assoc ( ) {
513
534
check_external_docs (
514
535
r#"
515
536
pub struct Foo;
516
537
pub trait Trait {
517
- fn met hod();
538
+ fn method() {}
518
539
}
519
540
impl Trait for Foo {
520
- pub fn met$0hod () {}
541
+ pub fn method$0 () {}
521
542
}
522
543
"# ,
523
544
expect ! [ [ r##"https://docs.rs/test/*/test/struct.Foo.html#method.method"## ] ] ,
524
545
) ;
546
+ check_external_docs (
547
+ r#"
548
+ pub struct Foo;
549
+ pub trait Trait {
550
+ const CONST: () = ();
551
+ }
552
+ impl Trait for Foo {
553
+ const CONST$0: () = ();
554
+ }
555
+ "# ,
556
+ expect ! [ [ r##"https://docs.rs/test/*/test/struct.Foo.html#associatedconstant.CONST"## ] ] ,
557
+ ) ;
558
+ check_external_docs (
559
+ r#"
560
+ pub struct Foo;
561
+ pub trait Trait {
562
+ type Type;
563
+ }
564
+ impl Trait for Foo {
565
+ type Type$0 = ();
566
+ }
567
+ "# ,
568
+ expect ! [ [ r##"https://docs.rs/test/*/test/struct.Foo.html#associatedtype.Type"## ] ] ,
569
+ ) ;
525
570
}
526
571
527
572
#[ test]
528
- fn test_doc_url_trait_required_method ( ) {
573
+ fn external_docs_doc_url_trait_assoc ( ) {
529
574
check_external_docs (
530
575
r#"
531
576
pub trait Foo {
532
- fn met$0hod ();
577
+ fn method$0 ();
533
578
}
534
579
"# ,
535
580
expect ! [ [ r##"https://docs.rs/test/*/test/trait.Foo.html#tymethod.method"## ] ] ,
536
581
) ;
582
+ check_external_docs (
583
+ r#"
584
+ pub trait Foo {
585
+ const CONST$0: ();
586
+ }
587
+ "# ,
588
+ expect ! [ [ r##"https://docs.rs/test/*/test/trait.Foo.html#associatedconstant.CONST"## ] ] ,
589
+ ) ;
590
+ check_external_docs (
591
+ r#"
592
+ pub trait Foo {
593
+ type Type$0;
594
+ }
595
+ "# ,
596
+ expect ! [ [ r##"https://docs.rs/test/*/test/trait.Foo.html#associatedtype.Type"## ] ] ,
597
+ ) ;
537
598
}
538
599
539
600
#[ test]
540
- fn test_doc_url_field ( ) {
601
+ fn external_docs_trait ( ) {
541
602
check_external_docs (
542
603
r#"
543
- pub struct Foo {
544
- pub fie$0ld: ()
545
- }
546
-
604
+ trait Trait$0 {}
547
605
"# ,
548
- expect ! [ [ r## "https://docs.rs/test/*/test/struct.Foo .html#structfield.field"# # ] ] ,
549
- ) ;
606
+ expect ! [ [ r#"https://docs.rs/test/*/test/trait.Trait .html" # ] ] ,
607
+ )
550
608
}
551
609
552
610
#[ test]
553
- fn test_module ( ) {
611
+ fn external_docs_module ( ) {
554
612
check_external_docs (
555
613
r#"
556
614
pub mod foo {
557
615
pub mod ba$0r {}
558
616
}
559
- "#,
617
+ "# ,
560
618
expect ! [ [ r#"https://docs.rs/test/*/test/foo/bar/index.html"# ] ] ,
561
619
)
562
620
}
563
621
564
622
#[ test]
565
- fn test_reexport_order ( ) {
623
+ fn external_docs_reexport_order ( ) {
566
624
check_external_docs (
567
625
r#"
568
626
pub mod wrapper {
@@ -603,7 +661,7 @@ trait Trait$0 {
603
661
}
604
662
605
663
#[ test]
606
- fn test_rewrite_html_root_url ( ) {
664
+ fn rewrite_html_root_url ( ) {
607
665
check_rewrite (
608
666
r#"
609
667
#![doc(arbitrary_attribute = "test", html_root_url = "https:/example.com", arbitrary_attribute2)]
@@ -619,7 +677,7 @@ pub struct B$0ar
619
677
}
620
678
621
679
#[ test]
622
- fn test_rewrite_on_field ( ) {
680
+ fn rewrite_on_field ( ) {
623
681
// FIXME: Should be
624
682
// [Foo](https://docs.rs/test/*/test/struct.Foo.html)
625
683
check_rewrite (
@@ -634,7 +692,7 @@ pub struct Foo {
634
692
}
635
693
636
694
#[ test]
637
- fn test_rewrite_struct ( ) {
695
+ fn rewrite_struct ( ) {
638
696
check_rewrite (
639
697
r#"
640
698
/// [Foo]
@@ -674,22 +732,6 @@ pub struct $0Foo;
674
732
) ;
675
733
}
676
734
677
- #[ test]
678
- fn test_rewrite ( ) {
679
- check_rewrite (
680
- r#"
681
- pub trait Foo {
682
- fn buzz() -> usize;
683
- }
684
- /// [Foo][buzz]
685
- ///
686
- /// [buzz]: Foo::buzz
687
- pub struct Bar$0;
688
- "# ,
689
- expect ! [ [ r###"[Foo](https://docs.rs/test/*/test/trait.Foo.html#tymethod.buzz)"### ] ] ,
690
- )
691
- }
692
-
693
735
fn check_external_docs ( ra_fixture : & str , expect : Expect ) {
694
736
let ( analysis, position) = fixture:: position ( ra_fixture) ;
695
737
let url = analysis. external_docs ( position) . unwrap ( ) . expect ( "could not find url for symbol" ) ;
0 commit comments