/src/test/rustdoc/intra-doc/self.rs

https://gitlab.com/rust-lang/rust · Rust · 116 lines · 39 code · 27 blank · 50 comment · 1 complexity · acef69c3fe902c694f0c3dc93c7f7e44 MD5 · raw file

  1. #![crate_name = "foo"]
  2. // @has foo/index.html '//a/@href' 'struct.Foo.html#method.new'
  3. // @has foo/struct.Foo.html '//a/@href' 'struct.Foo.html#method.new'
  4. /// Use [`new`] to create a new instance.
  5. ///
  6. /// [`new`]: Self::new
  7. pub struct Foo;
  8. impl Foo {
  9. pub fn new() -> Self {
  10. unimplemented!()
  11. }
  12. }
  13. // @has foo/index.html '//a/@href' 'struct.Bar.html#method.new2'
  14. // @has foo/struct.Bar.html '//a/@href' 'struct.Bar.html#method.new2'
  15. /// Use [`new2`] to create a new instance.
  16. ///
  17. /// [`new2`]: Self::new2
  18. pub struct Bar;
  19. impl Bar {
  20. pub fn new2() -> Self {
  21. unimplemented!()
  22. }
  23. }
  24. pub struct MyStruct {
  25. // @has foo/struct.MyStruct.html '//a/@href' 'struct.MyStruct.html#structfield.struct_field'
  26. /// [`struct_field`]
  27. ///
  28. /// [`struct_field`]: Self::struct_field
  29. pub struct_field: u8,
  30. }
  31. pub enum MyEnum {
  32. // @has foo/enum.MyEnum.html '//a/@href' 'enum.MyEnum.html#variant.EnumVariant'
  33. /// [`EnumVariant`]
  34. ///
  35. /// [`EnumVariant`]: Self::EnumVariant
  36. EnumVariant,
  37. }
  38. pub union MyUnion {
  39. // @has foo/union.MyUnion.html '//a/@href' 'union.MyUnion.html#structfield.union_field'
  40. /// [`union_field`]
  41. ///
  42. /// [`union_field`]: Self::union_field
  43. pub union_field: f32,
  44. }
  45. pub trait MyTrait {
  46. // @has foo/trait.MyTrait.html '//a/@href' 'trait.MyTrait.html#associatedtype.AssoType'
  47. /// [`AssoType`]
  48. ///
  49. /// [`AssoType`]: Self::AssoType
  50. type AssoType;
  51. // @has foo/trait.MyTrait.html '//a/@href' 'trait.MyTrait.html#associatedconstant.ASSO_CONST'
  52. /// [`ASSO_CONST`]
  53. ///
  54. /// [`ASSO_CONST`]: Self::ASSO_CONST
  55. const ASSO_CONST: i32 = 1;
  56. // @has foo/trait.MyTrait.html '//a/@href' 'trait.MyTrait.html#method.asso_fn'
  57. /// [`asso_fn`]
  58. ///
  59. /// [`asso_fn`]: Self::asso_fn
  60. fn asso_fn() {}
  61. }
  62. impl MyStruct {
  63. // @has foo/struct.MyStruct.html '//a/@href' 'struct.MyStruct.html#method.for_impl'
  64. /// [`for_impl`]
  65. ///
  66. /// [`for_impl`]: Self::for_impl
  67. pub fn for_impl() {
  68. unimplemented!()
  69. }
  70. }
  71. impl MyTrait for MyStruct {
  72. // @has foo/struct.MyStruct.html '//a/@href' 'struct.MyStruct.html#associatedtype.AssoType'
  73. /// [`AssoType`]
  74. ///
  75. /// [`AssoType`]: Self::AssoType
  76. type AssoType = u32;
  77. // @has foo/struct.MyStruct.html '//a/@href' 'struct.MyStruct.html#associatedconstant.ASSO_CONST'
  78. /// [`ASSO_CONST`]
  79. ///
  80. /// [`ASSO_CONST`]: Self::ASSO_CONST
  81. const ASSO_CONST: i32 = 10;
  82. // @has foo/struct.MyStruct.html '//a/@href' 'struct.MyStruct.html#method.asso_fn'
  83. /// [`asso_fn`]
  84. ///
  85. /// [`asso_fn`]: Self::asso_fn
  86. fn asso_fn() {
  87. unimplemented!()
  88. }
  89. }