Skip to content

Commit ddfb581

Browse files
committed
Move src/test/rustdoc intra-doc link tests into a subdirectory
They were starting to get unwieldy.
1 parent e37f25a commit ddfb581

Some content is hidden

Large Commits have some content hidden by default. Use the searchbox below for content that may be hidden.

64 files changed

+254
-258
lines changed

src/test/rustdoc/intra-doc-link-mod-ambiguity.rs

-18
This file was deleted.

src/test/rustdoc/intra-links-anchors.rs renamed to src/test/rustdoc/intra-doc/anchors.rs

+2-2
Original file line numberDiff line numberDiff line change
@@ -3,8 +3,8 @@
33
/// # Anchor!
44
pub struct Something;
55

6-
// @has intra_links_anchors/struct.SomeOtherType.html
7-
// @has - '//a/@href' '../intra_links_anchors/struct.Something.html#Anchor!'
6+
// @has anchors/struct.SomeOtherType.html
7+
// @has - '//a/@href' '../anchors/struct.Something.html#Anchor!'
88

99
/// I want...
1010
///
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,27 @@
1+
// ignore-tidy-linelength
2+
#![deny(intra_doc_link_resolution_failure)]
3+
#![feature(associated_type_defaults)]
4+
5+
pub trait TraitWithDefault {
6+
type T = usize;
7+
fn f() -> Self::T {
8+
0
9+
}
10+
}
11+
12+
/// Link to [UsesDefaults::T] and [UsesDefaults::f]
13+
// @has 'associated_defaults/struct.UsesDefaults.html' '//a[@href="../associated_defaults/struct.UsesDefaults.html#associatedtype.T"]' 'UsesDefaults::T'
14+
// @has 'associated_defaults/struct.UsesDefaults.html' '//a[@href="../associated_defaults/struct.UsesDefaults.html#method.f"]' 'UsesDefaults::f'
15+
pub struct UsesDefaults;
16+
impl TraitWithDefault for UsesDefaults {}
17+
18+
/// Link to [OverridesDefaults::T] and [OverridesDefaults::f]
19+
// @has 'associated_defaults/struct.OverridesDefaults.html' '//a[@href="../associated_defaults/struct.OverridesDefaults.html#associatedtype.T"]' 'OverridesDefaults::T'
20+
// @has 'associated_defaults/struct.OverridesDefaults.html' '//a[@href="../associated_defaults/struct.OverridesDefaults.html#method.f"]' 'OverridesDefaults::f'
21+
pub struct OverridesDefaults;
22+
impl TraitWithDefault for OverridesDefaults {
23+
type T = bool;
24+
fn f() -> bool {
25+
true
26+
}
27+
}
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,61 @@
1+
// ignore-tidy-linelength
2+
#![deny(intra_doc_link_resolution_failure)]
3+
4+
/// [`std::collections::BTreeMap::into_iter`]
5+
/// [`String::from`] is ambiguous as to which `From` impl
6+
/// [Vec::into_iter()] uses a disambiguator
7+
// @has 'associated_items/fn.foo.html' '//a[@href="https://doc.rust-lang.org/nightly/alloc/collections/btree/map/struct.BTreeMap.html#method.into_iter"]' 'std::collections::BTreeMap::into_iter'
8+
// @has 'associated_items/fn.foo.html' '//a[@href="https://doc.rust-lang.org/nightly/alloc/string/struct.String.html#method.from"]' 'String::from'
9+
// @has 'associated_items/fn.foo.html' '//a[@href="https://doc.rust-lang.org/nightly/alloc/vec/struct.Vec.html#method.into_iter"]' 'Vec::into_iter'
10+
pub fn foo() {}
11+
12+
/// Link to [MyStruct], [link from struct][MyStruct::method], [MyStruct::clone], [MyStruct::Input]
13+
// @has 'associated_items/struct.MyStruct.html' '//a[@href="../associated_items/struct.MyStruct.html"]' 'MyStruct'
14+
// @has 'associated_items/struct.MyStruct.html' '//a[@href="../associated_items/struct.MyStruct.html#method.method"]' 'link from struct'
15+
// @has 'associated_items/struct.MyStruct.html' '//a[@href="../associated_items/struct.MyStruct.html#method.clone"]' 'MyStruct::clone'
16+
// @has 'associated_items/struct.MyStruct.html' '//a[@href="../associated_items/struct.MyStruct.html#associatedtype.Input"]' 'MyStruct::Input'
17+
pub struct MyStruct { foo: () }
18+
19+
impl Clone for MyStruct {
20+
fn clone(&self) -> Self {
21+
MyStruct
22+
}
23+
}
24+
25+
pub trait T {
26+
type Input;
27+
fn method(i: Self::Input);
28+
}
29+
30+
impl T for MyStruct {
31+
type Input = usize;
32+
33+
/// [link from method][MyStruct::method] on method
34+
// @has 'associated_items/struct.MyStruct.html' '//a[@href="../associated_items/struct.MyStruct.html#method.method"]' 'link from method'
35+
fn method(i: usize) {
36+
}
37+
}
38+
39+
/// Ambiguity between which trait to use
40+
pub trait T1 {
41+
fn ambiguous_method();
42+
}
43+
44+
pub trait T2 {
45+
fn ambiguous_method();
46+
}
47+
48+
/// Link to [S::ambiguous_method]
49+
// FIXME: there is no way to disambiguate these.
50+
// Since we have `#[deny(intra_doc_failure)]`, we still know it was one or the other.
51+
pub struct S;
52+
53+
impl T1 for S {
54+
fn ambiguous_method() {}
55+
}
56+
57+
impl T2 for S {
58+
fn ambiguous_method() {}
59+
}
60+
61+
fn main() {}

src/test/rustdoc/auxiliary/intra-link-proc-macro-macro.rs renamed to src/test/rustdoc/intra-doc/auxiliary/proc-macro-macro.rs

-1
Original file line numberDiff line numberDiff line change
@@ -3,7 +3,6 @@
33
// compile-flags: --crate-type proc-macro
44

55
#![crate_type="proc-macro"]
6-
#![crate_name="intra_link_proc_macro_macro"]
76

87
extern crate proc_macro;
98

src/test/rustdoc/intra-links.rs renamed to src/test/rustdoc/intra-doc/basic.rs

+23-23
Original file line numberDiff line numberDiff line change
@@ -1,21 +1,21 @@
1-
// @has intra_links/index.html
2-
// @has - '//a/@href' '../intra_links/struct.ThisType.html'
3-
// @has - '//a/@href' '../intra_links/struct.ThisType.html#method.this_method'
4-
// @has - '//a/@href' '../intra_links/enum.ThisEnum.html'
5-
// @has - '//a/@href' '../intra_links/enum.ThisEnum.html#variant.ThisVariant'
6-
// @has - '//a/@href' '../intra_links/trait.ThisTrait.html'
7-
// @has - '//a/@href' '../intra_links/trait.ThisTrait.html#tymethod.this_associated_method'
8-
// @has - '//a/@href' '../intra_links/trait.ThisTrait.html#associatedtype.ThisAssociatedType'
9-
// @has - '//a/@href' '../intra_links/trait.ThisTrait.html#associatedconstant.THIS_ASSOCIATED_CONST'
10-
// @has - '//a/@href' '../intra_links/trait.ThisTrait.html'
11-
// @has - '//a/@href' '../intra_links/type.ThisAlias.html'
12-
// @has - '//a/@href' '../intra_links/union.ThisUnion.html'
13-
// @has - '//a/@href' '../intra_links/fn.this_function.html'
14-
// @has - '//a/@href' '../intra_links/constant.THIS_CONST.html'
15-
// @has - '//a/@href' '../intra_links/static.THIS_STATIC.html'
16-
// @has - '//a/@href' '../intra_links/macro.this_macro.html'
17-
// @has - '//a/@href' '../intra_links/trait.SoAmbiguous.html'
18-
// @has - '//a/@href' '../intra_links/fn.SoAmbiguous.html'
1+
// @has basic/index.html
2+
// @has - '//a/@href' '../basic/struct.ThisType.html'
3+
// @has - '//a/@href' '../basic/struct.ThisType.html#method.this_method'
4+
// @has - '//a/@href' '../basic/enum.ThisEnum.html'
5+
// @has - '//a/@href' '../basic/enum.ThisEnum.html#variant.ThisVariant'
6+
// @has - '//a/@href' '../basic/trait.ThisTrait.html'
7+
// @has - '//a/@href' '../basic/trait.ThisTrait.html#tymethod.this_associated_method'
8+
// @has - '//a/@href' '../basic/trait.ThisTrait.html#associatedtype.ThisAssociatedType'
9+
// @has - '//a/@href' '../basic/trait.ThisTrait.html#associatedconstant.THIS_ASSOCIATED_CONST'
10+
// @has - '//a/@href' '../basic/trait.ThisTrait.html'
11+
// @has - '//a/@href' '../basic/type.ThisAlias.html'
12+
// @has - '//a/@href' '../basic/union.ThisUnion.html'
13+
// @has - '//a/@href' '../basic/fn.this_function.html'
14+
// @has - '//a/@href' '../basic/constant.THIS_CONST.html'
15+
// @has - '//a/@href' '../basic/static.THIS_STATIC.html'
16+
// @has - '//a/@href' '../basic/macro.this_macro.html'
17+
// @has - '//a/@href' '../basic/trait.SoAmbiguous.html'
18+
// @has - '//a/@href' '../basic/fn.SoAmbiguous.html'
1919
//! In this crate we would like to link to:
2020
//!
2121
//! * [`ThisType`](ThisType)
@@ -46,7 +46,7 @@ macro_rules! this_macro {
4646
() => {};
4747
}
4848

49-
// @has intra_links/struct.ThisType.html '//a/@href' '../intra_links/macro.this_macro.html'
49+
// @has basic/struct.ThisType.html '//a/@href' '../basic/macro.this_macro.html'
5050
/// another link to [`this_macro!()`]
5151
pub struct ThisType;
5252

@@ -72,10 +72,10 @@ pub trait SoAmbiguous {}
7272
pub fn SoAmbiguous() {}
7373

7474

75-
// @has intra_links/struct.SomeOtherType.html '//a/@href' '../intra_links/struct.ThisType.html'
76-
// @has - '//a/@href' '../intra_links/struct.ThisType.html#method.this_method'
77-
// @has - '//a/@href' '../intra_links/enum.ThisEnum.html'
78-
// @has - '//a/@href' '../intra_links/enum.ThisEnum.html#variant.ThisVariant'
75+
// @has basic/struct.SomeOtherType.html '//a/@href' '../basic/struct.ThisType.html'
76+
// @has - '//a/@href' '../basic/struct.ThisType.html#method.this_method'
77+
// @has - '//a/@href' '../basic/enum.ThisEnum.html'
78+
// @has - '//a/@href' '../basic/enum.ThisEnum.html#variant.ThisVariant'
7979
/// Shortcut links for:
8080
/// * [`ThisType`]
8181
/// * [`ThisType::this_method`]
Original file line numberDiff line numberDiff line change
@@ -1,3 +1,3 @@
1-
// @has intra_link_builtin_macros/index.html
1+
// @has builtin_macros/index.html
22
// @has - '//a/@href' 'https://doc.rust-lang.org/nightly/core/macro.cfg.html'
33
//! [cfg]
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,51 @@
1+
// ignore-tidy-linelength
2+
#![deny(intra_doc_link_resolution_failure)]
3+
// first try backticks
4+
/// Trait: [`trait@Name`], fn: [`fn@Name`], [`Name`][`macro@Name`]
5+
// @has disambiguators_removed/struct.AtDisambiguator.html
6+
// @has - '//a[@href="../disambiguators_removed/trait.Name.html"][code]' "Name"
7+
// @has - '//a[@href="../disambiguators_removed/fn.Name.html"][code]' "Name"
8+
// @has - '//a[@href="../disambiguators_removed/macro.Name.html"][code]' "Name"
9+
pub struct AtDisambiguator;
10+
11+
/// fn: [`Name()`], macro: [`Name!`]
12+
// @has disambiguators_removed/struct.SymbolDisambiguator.html
13+
// @has - '//a[@href="../disambiguators_removed/fn.Name.html"][code]' "Name()"
14+
// @has - '//a[@href="../disambiguators_removed/macro.Name.html"][code]' "Name!"
15+
pub struct SymbolDisambiguator;
16+
17+
// Now make sure that backticks aren't added if they weren't already there
18+
/// [fn@Name]
19+
// @has disambiguators_removed/trait.Name.html
20+
// @has - '//a[@href="../disambiguators_removed/fn.Name.html"]' "Name"
21+
// @!has - '//a[@href="../disambiguators_removed/fn.Name.html"][code]' "Name"
22+
23+
// FIXME: this will turn !() into ! alone
24+
/// [Name!()]
25+
// @has - '//a[@href="../disambiguators_removed/macro.Name.html"]' "Name!"
26+
pub trait Name {}
27+
28+
#[allow(non_snake_case)]
29+
30+
// Try collapsed reference links
31+
/// [macro@Name][]
32+
// @has disambiguators_removed/fn.Name.html
33+
// @has - '//a[@href="../disambiguators_removed/macro.Name.html"]' "Name"
34+
35+
// Try links that have the same text as a generated URL
36+
/// Weird URL aligned [../disambiguators_removed/macro.Name.html][trait@Name]
37+
// @has - '//a[@href="../disambiguators_removed/trait.Name.html"]' "../disambiguators_removed/macro.Name.html"
38+
pub fn Name() {}
39+
40+
#[macro_export]
41+
// Rustdoc doesn't currently handle links that have weird interspersing of inline code blocks.
42+
/// [fn@Na`m`e]
43+
// @has disambiguators_removed/macro.Name.html
44+
// @has - '//a[@href="../disambiguators_removed/fn.Name.html"]' "fn@Name"
45+
46+
// It also doesn't handle any case where the code block isn't the whole link text:
47+
/// [trait@`Name`]
48+
// @has - '//a[@href="../disambiguators_removed/trait.Name.html"]' "trait@Name"
49+
macro_rules! Name {
50+
() => ()
51+
}
+17
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,17 @@
1+
#![feature(extern_types)]
2+
3+
extern {
4+
pub type ExternType;
5+
}
6+
7+
impl ExternType {
8+
pub fn f(&self) {
9+
10+
}
11+
}
12+
13+
// @has 'extern_type/foreigntype.ExternType.html'
14+
// @has 'extern_type/fn.links_to_extern_type.html' \
15+
// 'href="../extern_type/foreigntype.ExternType.html#method.f"'
16+
/// See also [ExternType::f]
17+
pub fn links_to_extern_type() {}
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,16 @@
1+
#![deny(broken_intra_doc_links)]
2+
3+
4+
pub fn foo() {
5+
6+
}
7+
8+
pub mod foo {}
9+
// @has mod_ambiguity/struct.A.html '//a/@href' '../mod_ambiguity/foo/index.html'
10+
/// Module is [`module@foo`]
11+
pub struct A;
12+
13+
14+
// @has mod_ambiguity/struct.B.html '//a/@href' '../mod_ambiguity/fn.foo.html'
15+
/// Function is [`fn@foo`]
16+
pub struct B;
+5
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,5 @@
1+
// ignore-tidy-linelength
2+
#![deny(broken_intra_doc_links)]
3+
4+
//! [i32::MAX]
5+
// @has prim_assoc/index.html '//a[@href="https://doc.rust-lang.org/nightly/std/primitive.i32.html#associatedconstant.MAX"]' "i32::MAX"

src/test/rustdoc/intra-link-prim-methods-external-core.rs renamed to src/test/rustdoc/intra-doc/prim-methods-external-core.rs

+1-1
Original file line numberDiff line numberDiff line change
@@ -9,7 +9,7 @@
99
#![no_core]
1010
#![crate_type = "rlib"]
1111

12-
// @has intra_link_prim_methods_external_core/index.html
12+
// @has prim_methods_external_core/index.html
1313
// @has - '//*[@id="main"]//a[@href="https://doc.rust-lang.org/nightly/std/primitive.char.html"]' 'char'
1414
// @has - '//*[@id="main"]//a[@href="https://doc.rust-lang.org/nightly/std/primitive.char.html#method.len_utf8"]' 'char::len_utf8'
1515

src/test/rustdoc/intra-link-prim-methods-local.rs renamed to src/test/rustdoc/intra-doc/prim-methods-local.rs

+1-1
Original file line numberDiff line numberDiff line change
@@ -5,7 +5,7 @@
55

66
// ignore-tidy-linelength
77

8-
// @has intra_link_prim_methods_local/index.html
8+
// @has prim_methods_local/index.html
99
// @has - '//*[@id="main"]//a[@href="https://doc.rust-lang.org/nightly/std/primitive.char.html"]' 'char'
1010
// @has - '//*[@id="main"]//a[@href="https://doc.rust-lang.org/nightly/std/primitive.char.html#method.len_utf8"]' 'char::len_utf8'
1111

src/test/rustdoc/intra-link-prim-methods.rs renamed to src/test/rustdoc/intra-doc/prim-methods.rs

+1-1
Original file line numberDiff line numberDiff line change
@@ -2,7 +2,7 @@
22

33
// ignore-tidy-linelength
44

5-
// @has intra_link_prim_methods/index.html
5+
// @has prim_methods/index.html
66
// @has - '//*[@id="main"]//a[@href="https://doc.rust-lang.org/nightly/std/primitive.char.html"]' 'char'
77
// @has - '//*[@id="main"]//a[@href="https://doc.rust-lang.org/nightly/std/primitive.char.html#method.len_utf8"]' 'char::len_utf8'
88

Original file line numberDiff line numberDiff line change
@@ -0,0 +1,17 @@
1+
// ignore-tidy-linelength
2+
#![deny(broken_intra_doc_links)]
3+
4+
pub mod char {
5+
/// [char]
6+
// @has prim_precedence/char/struct.Inner.html '//a/@href' 'https://doc.rust-lang.org/nightly/std/primitive.char.html'
7+
pub struct Inner;
8+
}
9+
10+
/// See [prim@char]
11+
// @has prim_precedence/struct.MyString.html '//a/@href' 'https://doc.rust-lang.org/nightly/std/primitive.char.html'
12+
pub struct MyString;
13+
14+
/// See also [crate::char] and [mod@char]
15+
// @has prim_precedence/struct.MyString2.html '//*[@href="../prim_precedence/char/index.html"]' 'crate::char'
16+
// @has - '//*[@href="../prim_precedence/char/index.html"]' 'mod@char'
17+
pub struct MyString2;

src/test/rustdoc/intra-link-primitive-non-default-impl.rs renamed to src/test/rustdoc/intra-doc/primitive-non-default-impl.rs

+3-3
Original file line numberDiff line numberDiff line change
@@ -2,7 +2,7 @@
22

33
// ignore-tidy-linelength
44

5-
// @has intra_link_primitive_non_default_impl/fn.str_methods.html
5+
// @has primitive_non_default_impl/fn.str_methods.html
66
/// [`str::trim`]
77
// @has - '//*[@href="https://doc.rust-lang.org/nightly/std/primitive.str.html#method.trim"]' 'str::trim'
88
/// [`str::to_lowercase`]
@@ -13,7 +13,7 @@
1313
// @has - '//*[@href="https://doc.rust-lang.org/nightly/std/primitive.str.html#method.replace"]' 'str::replace'
1414
pub fn str_methods() {}
1515

16-
// @has intra_link_primitive_non_default_impl/fn.f32_methods.html
16+
// @has primitive_non_default_impl/fn.f32_methods.html
1717
/// [f32::powi]
1818
// @has - '//*[@href="https://doc.rust-lang.org/nightly/std/primitive.f32.html#method.powi"]' 'f32::powi'
1919
/// [f32::sqrt]
@@ -22,7 +22,7 @@ pub fn str_methods() {}
2222
// @has - '//*[@href="https://doc.rust-lang.org/nightly/std/primitive.f32.html#method.mul_add"]' 'f32::mul_add'
2323
pub fn f32_methods() {}
2424

25-
// @has intra_link_primitive_non_default_impl/fn.f64_methods.html
25+
// @has primitive_non_default_impl/fn.f64_methods.html
2626
/// [`f64::powi`]
2727
// @has - '//*[@href="https://doc.rust-lang.org/nightly/std/primitive.f64.html#method.powi"]' 'f64::powi'
2828
/// [`f64::sqrt`]
+27
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,27 @@
1+
// aux-build:proc-macro-macro.rs
2+
// build-aux-docs
3+
#![deny(broken_intra_doc_links)]
4+
5+
extern crate proc_macro_macro;
6+
7+
8+
pub use proc_macro_macro::{DeriveA, attr_a};
9+
use proc_macro_macro::{DeriveB, attr_b};
10+
11+
// @has proc_macro/struct.Foo.html
12+
// @has - '//a/@href' '../proc_macro/derive.DeriveA.html'
13+
// @has - '//a/@href' '../proc_macro/attr.attr_a.html'
14+
// @has - '//a/@href' '../proc_macro/trait.DeriveTrait.html'
15+
// @has - '//a/@href' '../proc_macro_macro/derive.DeriveB.html'
16+
// @has - '//a/@href' '../proc_macro_macro/attr.attr_b.html'
17+
/// Link to [DeriveA], [attr_a], [DeriveB], [attr_b], [DeriveTrait]
18+
pub struct Foo;
19+
20+
// @has proc_macro/struct.Bar.html
21+
// @has - '//a/@href' '../proc_macro/derive.DeriveA.html'
22+
// @has - '//a/@href' '../proc_macro/attr.attr_a.html'
23+
/// Link to [deriveA](derive@DeriveA) [attr](macro@attr_a)
24+
pub struct Bar;
25+
26+
// this should not cause ambiguity errors
27+
pub trait DeriveTrait {}

src/test/rustdoc/intra-link-trait-item.rs renamed to src/test/rustdoc/intra-doc/trait-item.rs

+1-1
Original file line numberDiff line numberDiff line change
@@ -3,7 +3,7 @@
33

44
/// Link to [S::assoc_fn()]
55
/// Link to [Default::default()]
6-
// @has intra_link_trait_item/struct.S.html '//*[@href="../intra_link_trait_item/struct.S.html#method.assoc_fn"]' 'S::assoc_fn()'
6+
// @has trait_item/struct.S.html '//*[@href="../trait_item/struct.S.html#method.assoc_fn"]' 'S::assoc_fn()'
77
// @has - '//*[@href="https://doc.rust-lang.org/nightly/core/default/trait.Default.html#tymethod.default"]' 'Default::default()'
88
pub struct S;
99

0 commit comments

Comments
 (0)