/src/test/rustdoc/check-source-code-urls-to-def.rs

https://gitlab.com/rust-lang/rust · Rust · 69 lines · 33 code · 16 blank · 20 comment · 0 complexity · 63f6dbb02a0d5c40e12da8c0e61f743b MD5 · raw file

  1. // compile-flags: -Zunstable-options --generate-link-to-definition
  2. // aux-build:source_code.rs
  3. // build-aux-docs
  4. #![feature(rustdoc_internals)]
  5. #![crate_name = "foo"]
  6. extern crate source_code;
  7. // @has 'src/foo/check-source-code-urls-to-def.rs.html'
  8. // @has - '//a[@href="../../src/foo/auxiliary/source-code-bar.rs.html#1-17"]' 'bar'
  9. #[path = "auxiliary/source-code-bar.rs"]
  10. pub mod bar;
  11. // @count - '//a[@href="../../src/foo/auxiliary/source-code-bar.rs.html#5-7"]' 4
  12. use bar::Bar;
  13. // @has - '//a[@href="../../src/foo/auxiliary/source-code-bar.rs.html#13-17"]' 'self'
  14. // @has - '//a[@href="../../src/foo/auxiliary/source-code-bar.rs.html#14-16"]' 'Trait'
  15. use bar::sub::{self, Trait};
  16. pub struct Foo;
  17. impl Foo {
  18. fn hello(&self) {}
  19. }
  20. fn babar() {}
  21. // @has - '//a/@href' '/struct.String.html'
  22. // @has - '//a/@href' '/primitive.u32.html'
  23. // @has - '//a/@href' '/primitive.str.html'
  24. // @count - '//a[@href="../../src/foo/check-source-code-urls-to-def.rs.html#23"]' 5
  25. // @has - '//a[@href="../../source_code/struct.SourceCode.html"]' 'source_code::SourceCode'
  26. pub fn foo(a: u32, b: &str, c: String, d: Foo, e: bar::Bar, f: source_code::SourceCode) {
  27. let x = 12;
  28. let y: Foo = Foo;
  29. let z: Bar = bar::Bar { field: Foo };
  30. babar();
  31. // @has - '//a[@href="../../src/foo/check-source-code-urls-to-def.rs.html#26"]' 'hello'
  32. y.hello();
  33. }
  34. // @has - '//a[@href="../../src/foo/auxiliary/source-code-bar.rs.html#14-16"]' 'bar::sub::Trait'
  35. // @has - '//a[@href="../../src/foo/auxiliary/source-code-bar.rs.html#14-16"]' 'Trait'
  36. pub fn foo2<T: bar::sub::Trait, V: Trait>(t: &T, v: &V, b: bool) {}
  37. pub trait AnotherTrait {}
  38. pub trait WhyNot {}
  39. // @has - '//a[@href="../../src/foo/check-source-code-urls-to-def.rs.html#49"]' 'AnotherTrait'
  40. // @has - '//a[@href="../../src/foo/check-source-code-urls-to-def.rs.html#50"]' 'WhyNot'
  41. pub fn foo3<T, V>(t: &T, v: &V)
  42. where
  43. T: AnotherTrait,
  44. V: WhyNot
  45. {}
  46. pub trait AnotherTrait2 {}
  47. // @has - '//a[@href="../../src/foo/check-source-code-urls-to-def.rs.html#60"]' 'AnotherTrait2'
  48. pub fn foo4() {
  49. let x: Vec<AnotherTrait2> = Vec::new();
  50. }
  51. // @has - '//a[@href="../../foo/primitive.bool.html"]' 'bool'
  52. #[doc(primitive = "bool")]
  53. mod whatever {}