about summary refs log tree commit diff
diff options
context:
space:
mode:
authorGuillaume Gomez <guillaume1.gomez@gmail.com>2020-10-12 18:29:56 +0200
committerGuillaume Gomez <guillaume1.gomez@gmail.com>2020-11-05 10:22:08 +0100
commit6bc8965c418e90c135ee90554108bd0bdbe0a8d8 (patch)
treec9deb42a4b081adafd584f4c59cc87937542a49c
parenta54f04373382b085837f5f835569d238bf6049e1 (diff)
downloadrust-6bc8965c418e90c135ee90554108bd0bdbe0a8d8.tar.gz
rust-6bc8965c418e90c135ee90554108bd0bdbe0a8d8.zip
Add tests for automatic_links lint
-rw-r--r--src/test/rustdoc-ui/automatic-links.rs17
-rw-r--r--src/test/rustdoc-ui/automatic-links.stderr23
2 files changed, 40 insertions, 0 deletions
diff --git a/src/test/rustdoc-ui/automatic-links.rs b/src/test/rustdoc-ui/automatic-links.rs
new file mode 100644
index 00000000000..9273b854aee
--- /dev/null
+++ b/src/test/rustdoc-ui/automatic-links.rs
@@ -0,0 +1,17 @@
+#![deny(automatic_links)]
+
+/// [http://a.com](http://a.com)
+//~^ ERROR Unneeded long form for URL
+/// [http://b.com]
+//~^ ERROR Unneeded long form for URL
+///
+/// [http://b.com]: http://b.com
+///
+/// [http://c.com][http://c.com]
+pub fn a() {}
+
+/// [a](http://a.com)
+/// [b]
+///
+/// [b]: http://b.com
+pub fn everything_is_fine_here() {}
diff --git a/src/test/rustdoc-ui/automatic-links.stderr b/src/test/rustdoc-ui/automatic-links.stderr
new file mode 100644
index 00000000000..2922fedb238
--- /dev/null
+++ b/src/test/rustdoc-ui/automatic-links.stderr
@@ -0,0 +1,23 @@
+error: Unneeded long form for URL
+  --> $DIR/automatic-links.rs:3:5
+   |
+LL | /// [http://a.com](http://a.com)
+   |     ^^^^^^^^^^^^^^^^^^^^^^^^^^^^
+   |
+note: the lint level is defined here
+  --> $DIR/automatic-links.rs:1:9
+   |
+LL | #![deny(automatic_links)]
+   |         ^^^^^^^^^^^^^^^
+   = help: Try with `<http://a.com>` instead
+
+error: Unneeded long form for URL
+  --> $DIR/automatic-links.rs:5:5
+   |
+LL | /// [http://b.com]
+   |     ^^^^^^^^^^^^^^
+   |
+   = help: Try with `<http://b.com>` instead
+
+error: aborting due to 2 previous errors
+