]> git.lizzy.rs Git - rust.git/commitdiff
Add test for source code pages URLs
authorGuillaume Gomez <guillaume1.gomez@gmail.com>
Tue, 13 Apr 2021 20:03:29 +0000 (22:03 +0200)
committerGuillaume Gomez <guillaume.gomez@huawei.com>
Thu, 5 Aug 2021 21:08:28 +0000 (23:08 +0200)
src/test/rustdoc/auxiliary/source-code-bar.rs [new file with mode: 0644]
src/test/rustdoc/check-source-code-urls-to-def.rs [new file with mode: 0644]

diff --git a/src/test/rustdoc/auxiliary/source-code-bar.rs b/src/test/rustdoc/auxiliary/source-code-bar.rs
new file mode 100644 (file)
index 0000000..8700d68
--- /dev/null
@@ -0,0 +1,17 @@
+//! just some other file. :)
+
+use crate::Foo;
+
+pub struct Bar {
+    field: Foo,
+}
+
+pub struct Bar2 {
+    field: crate::Foo,
+}
+
+pub mod sub {
+    pub trait Trait {
+        fn tadam() {}
+    }
+}
diff --git a/src/test/rustdoc/check-source-code-urls-to-def.rs b/src/test/rustdoc/check-source-code-urls-to-def.rs
new file mode 100644 (file)
index 0000000..32973ba
--- /dev/null
@@ -0,0 +1,38 @@
+// compile-flags: -Zunstable-options --generate-link-to-definition
+
+#![crate_name = "foo"]
+
+#[path = "auxiliary/source-code-bar.rs"]
+pub mod bar;
+
+// @has 'src/foo/check-source-code-urls-to-def.rs.html'
+
+// @count - '//a[@href="../../src/foo/auxiliary/source-code-bar.rs.html#5-7"]' 4
+use bar::Bar;
+// @has - '//a[@href="../../src/foo/auxiliary/source-code-bar.rs.html#13-17"]' 'self'
+// @has - '//a[@href="../../src/foo/auxiliary/source-code-bar.rs.html#14-16"]' 'Trait'
+use bar::sub::{self, Trait};
+
+pub struct Foo;
+
+impl Foo {
+    fn hello(&self) {}
+}
+
+fn babar() {}
+
+// @has - '//a[@href="https://doc.rust-lang.org/nightly/alloc/string/struct.String.html"]' 'String'
+// @count - '//a[@href="../../src/foo/check-source-code-urls-to-def.rs.html#16"]' 5
+pub fn foo(a: u32, b: &str, c: String, d: Foo, e: bar::Bar) {
+    let x = 12;
+    let y: Foo = Foo;
+    let z: Bar = bar::Bar { field: Foo };
+    babar();
+    // @has - '//a[@href="../../src/foo/check-source-code-urls-to-def.rs.html#19"]' 'hello'
+    y.hello();
+}
+
+// @has - '//a[@href="../../src/foo/auxiliary/source-code-bar.rs.html#14-16"]' 'bar::sub::Trait'
+// @has - '//a[@href="../../src/foo/auxiliary/source-code-bar.rs.html#14-16"]' 'Trait'
+pub fn foo2<T: bar::sub::Trait, V: Trait>(t: &T, v: &V) {
+}