about summary refs log tree commit diff
diff options
context:
space:
mode:
authorAliƩnore Bouttefeux <alienore.bouttefeux@gmail.com>2021-04-05 09:16:48 +0200
committerAliƩnore Bouttefeux <alienore.bouttefeux@gmail.com>2021-04-05 09:16:48 +0200
commit8e5dd4b2e9baa107dc3cf8abf44a4208fdf0f489 (patch)
tree79644a1edaf36fb7f3e42a58b0c812ad0f5530fe
parent2f81e4e34f96ee674072cbd1ffe55b68da5cc425 (diff)
downloadrust-8e5dd4b2e9baa107dc3cf8abf44a4208fdf0f489.tar.gz
rust-8e5dd4b2e9baa107dc3cf8abf44a4208fdf0f489.zip
add test for missing_panic_doc on assert_eq/assert_ne
-rw-r--r--tests/ui/missing_panics_doc.rs32
-rw-r--r--tests/ui/missing_panics_doc.stderr34
2 files changed, 65 insertions, 1 deletions
diff --git a/tests/ui/missing_panics_doc.rs b/tests/ui/missing_panics_doc.rs
index 3fe35c75799..2e1379a58a6 100644
--- a/tests/ui/missing_panics_doc.rs
+++ b/tests/ui/missing_panics_doc.rs
@@ -33,6 +33,18 @@ pub fn unreachable_and_panic() {
     if true { unreachable!() } else { panic!() }
 }
 
+/// This needs to be documented
+pub fn assert_eq() {
+    let x = 0;
+    assert_eq!(x, 0);
+}
+
+/// This needs to be documented
+pub fn assert_ne() {
+    let x = 0;
+    assert_ne!(x, 0);
+}
+
 /// This is documented
 ///
 /// # Panics
@@ -83,6 +95,26 @@ pub fn unreachable_amd_panic_documented() {
     if true { unreachable!() } else { panic!() }
 }
 
+/// This is documented
+///
+/// # Panics
+///
+/// Panics if `x` is not 0.
+pub fn assert_eq_documented() {
+    let x = 0;
+    assert_eq!(x, 0);
+}
+
+/// This is documented
+///
+/// # Panics
+///
+/// Panics if `x` is 0.
+pub fn assert_ne_documented() {
+    let x = 0;
+    assert_ne!(x, 0);
+}
+
 /// This is okay because it is private
 fn unwrap_private() {
     let result = Err("Hi");
diff --git a/tests/ui/missing_panics_doc.stderr b/tests/ui/missing_panics_doc.stderr
index 37da6bfd92d..ba96a6a12b5 100644
--- a/tests/ui/missing_panics_doc.stderr
+++ b/tests/ui/missing_panics_doc.stderr
@@ -78,5 +78,37 @@ LL |     if true { unreachable!() } else { panic!() }
    |                                       ^^^^^^^^
    = note: this error originates in a macro (in Nightly builds, run with -Z macro-backtrace for more info)
 
-error: aborting due to 5 previous errors
+error: docs for function which may panic missing `# Panics` section
+  --> $DIR/missing_panics_doc.rs:37:1
+   |
+LL | / pub fn assert_eq() {
+LL | |     let x = 0;
+LL | |     assert_eq!(x, 0);
+LL | | }
+   | |_^
+   |
+note: first possible panic found here
+  --> $DIR/missing_panics_doc.rs:39:5
+   |
+LL |     assert_eq!(x, 0);
+   |     ^^^^^^^^^^^^^^^^^
+   = note: this error originates in a macro (in Nightly builds, run with -Z macro-backtrace for more info)
+
+error: docs for function which may panic missing `# Panics` section
+  --> $DIR/missing_panics_doc.rs:43:1
+   |
+LL | / pub fn assert_ne() {
+LL | |     let x = 0;
+LL | |     assert_ne!(x, 0);
+LL | | }
+   | |_^
+   |
+note: first possible panic found here
+  --> $DIR/missing_panics_doc.rs:45:5
+   |
+LL |     assert_ne!(x, 0);
+   |     ^^^^^^^^^^^^^^^^^
+   = note: this error originates in a macro (in Nightly builds, run with -Z macro-backtrace for more info)
+
+error: aborting due to 7 previous errors