about summary refs log tree commit diff
diff options
context:
space:
mode:
-rw-r--r--tests/ui/doc/missing_panics_doc.rs31
-rw-r--r--tests/ui/doc/missing_panics_doc.stderr75
-rw-r--r--tests/ui/missing_panics_doc.rs32
-rw-r--r--tests/ui/missing_panics_doc.stderr74
4 files changed, 105 insertions, 107 deletions
diff --git a/tests/ui/doc/missing_panics_doc.rs b/tests/ui/doc/missing_panics_doc.rs
deleted file mode 100644
index 5cb8a9691f4..00000000000
--- a/tests/ui/doc/missing_panics_doc.rs
+++ /dev/null
@@ -1,31 +0,0 @@
-#![warn(clippy::missing_panics_doc)]
-
-pub fn option_unwrap<T>(v: &[T]) -> &T {
-    let o: Option<&T> = v.last();
-    o.unwrap()
-}
-
-pub fn option_expect<T>(v: &[T]) -> &T {
-    let o: Option<&T> = v.last();
-    o.expect("passed an empty thing")
-}
-
-pub fn result_unwrap<T>(v: &[T]) -> &T {
-    let res: Result<&T, &str> = v.last().ok_or("oh noes");
-    res.unwrap()
-}
-
-pub fn result_expect<T>(v: &[T]) -> &T {
-    let res: Result<&T, &str> = v.last().ok_or("oh noes");
-    res.expect("passed an empty thing")
-}
-
-pub fn last_unwrap(v: &[u32]) -> u32 {
-    *v.last().unwrap()
-}
-
-pub fn last_expect(v: &[u32]) -> u32 {
-    *v.last().expect("passed an empty thing")
-}
-
-fn main() {}
diff --git a/tests/ui/doc/missing_panics_doc.stderr b/tests/ui/doc/missing_panics_doc.stderr
deleted file mode 100644
index f3e613bc799..00000000000
--- a/tests/ui/doc/missing_panics_doc.stderr
+++ /dev/null
@@ -1,75 +0,0 @@
-error: docs for function which may panic missing `# Panics` section
-  --> $DIR/missing_panics_doc.rs:3:1
-   |
-LL | pub fn option_unwrap<T>(v: &[T]) -> &T {
-   | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
-   |
-note: first possible panic found here
-  --> $DIR/missing_panics_doc.rs:5:5
-   |
-LL |     o.unwrap()
-   |     ^^^^^^^^^^
-   = note: `-D clippy::missing-panics-doc` implied by `-D warnings`
-
-error: docs for function which may panic missing `# Panics` section
-  --> $DIR/missing_panics_doc.rs:8:1
-   |
-LL | pub fn option_expect<T>(v: &[T]) -> &T {
-   | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
-   |
-note: first possible panic found here
-  --> $DIR/missing_panics_doc.rs:10:5
-   |
-LL |     o.expect("passed an empty thing")
-   |     ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
-
-error: docs for function which may panic missing `# Panics` section
-  --> $DIR/missing_panics_doc.rs:13:1
-   |
-LL | pub fn result_unwrap<T>(v: &[T]) -> &T {
-   | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
-   |
-note: first possible panic found here
-  --> $DIR/missing_panics_doc.rs:15:5
-   |
-LL |     res.unwrap()
-   |     ^^^^^^^^^^^^
-
-error: docs for function which may panic missing `# Panics` section
-  --> $DIR/missing_panics_doc.rs:18:1
-   |
-LL | pub fn result_expect<T>(v: &[T]) -> &T {
-   | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
-   |
-note: first possible panic found here
-  --> $DIR/missing_panics_doc.rs:20:5
-   |
-LL |     res.expect("passed an empty thing")
-   |     ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
-
-error: docs for function which may panic missing `# Panics` section
-  --> $DIR/missing_panics_doc.rs:23:1
-   |
-LL | pub fn last_unwrap(v: &[u32]) -> u32 {
-   | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
-   |
-note: first possible panic found here
-  --> $DIR/missing_panics_doc.rs:24:6
-   |
-LL |     *v.last().unwrap()
-   |      ^^^^^^^^^^^^^^^^^
-
-error: docs for function which may panic missing `# Panics` section
-  --> $DIR/missing_panics_doc.rs:27:1
-   |
-LL | pub fn last_expect(v: &[u32]) -> u32 {
-   | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
-   |
-note: first possible panic found here
-  --> $DIR/missing_panics_doc.rs:28:6
-   |
-LL |     *v.last().expect("passed an empty thing")
-   |      ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
-
-error: aborting due to 6 previous errors
-
diff --git a/tests/ui/missing_panics_doc.rs b/tests/ui/missing_panics_doc.rs
index 10aa436d6cd..d544a0b1afb 100644
--- a/tests/ui/missing_panics_doc.rs
+++ b/tests/ui/missing_panics_doc.rs
@@ -151,3 +151,35 @@ pub fn debug_assertions() {
     debug_assert_eq!(1, 2);
     debug_assert_ne!(1, 2);
 }
+
+// all function must be triggered the lint.
+// `pub` is required, because the lint does not consider unreachable items
+pub mod issue10240 {
+    pub fn option_unwrap<T>(v: &[T]) -> &T {
+        let o: Option<&T> = v.last();
+        o.unwrap()
+    }
+
+    pub fn option_expect<T>(v: &[T]) -> &T {
+        let o: Option<&T> = v.last();
+        o.expect("passed an empty thing")
+    }
+
+    pub fn result_unwrap<T>(v: &[T]) -> &T {
+        let res: Result<&T, &str> = v.last().ok_or("oh noes");
+        res.unwrap()
+    }
+
+    pub fn result_expect<T>(v: &[T]) -> &T {
+        let res: Result<&T, &str> = v.last().ok_or("oh noes");
+        res.expect("passed an empty thing")
+    }
+
+    pub fn last_unwrap(v: &[u32]) -> u32 {
+        *v.last().unwrap()
+    }
+
+    pub fn last_expect(v: &[u32]) -> u32 {
+        *v.last().expect("passed an empty thing")
+    }
+}
diff --git a/tests/ui/missing_panics_doc.stderr b/tests/ui/missing_panics_doc.stderr
index 183c262ce0b..39d97f08373 100644
--- a/tests/ui/missing_panics_doc.stderr
+++ b/tests/ui/missing_panics_doc.stderr
@@ -83,5 +83,77 @@ note: first possible panic found here
 LL |     assert_ne!(x, 0);
    |     ^^^^^^^^^^^^^^^^
 
-error: aborting due to 7 previous errors
+error: docs for function which may panic missing `# Panics` section
+  --> $DIR/missing_panics_doc.rs:158:5
+   |
+LL |     pub fn option_unwrap<T>(v: &[T]) -> &T {
+   |     ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
+   |
+note: first possible panic found here
+  --> $DIR/missing_panics_doc.rs:160:9
+   |
+LL |         o.unwrap()
+   |         ^^^^^^^^^^
+
+error: docs for function which may panic missing `# Panics` section
+  --> $DIR/missing_panics_doc.rs:163:5
+   |
+LL |     pub fn option_expect<T>(v: &[T]) -> &T {
+   |     ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
+   |
+note: first possible panic found here
+  --> $DIR/missing_panics_doc.rs:165:9
+   |
+LL |         o.expect("passed an empty thing")
+   |         ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
+
+error: docs for function which may panic missing `# Panics` section
+  --> $DIR/missing_panics_doc.rs:168:5
+   |
+LL |     pub fn result_unwrap<T>(v: &[T]) -> &T {
+   |     ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
+   |
+note: first possible panic found here
+  --> $DIR/missing_panics_doc.rs:170:9
+   |
+LL |         res.unwrap()
+   |         ^^^^^^^^^^^^
+
+error: docs for function which may panic missing `# Panics` section
+  --> $DIR/missing_panics_doc.rs:173:5
+   |
+LL |     pub fn result_expect<T>(v: &[T]) -> &T {
+   |     ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
+   |
+note: first possible panic found here
+  --> $DIR/missing_panics_doc.rs:175:9
+   |
+LL |         res.expect("passed an empty thing")
+   |         ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
+
+error: docs for function which may panic missing `# Panics` section
+  --> $DIR/missing_panics_doc.rs:178:5
+   |
+LL |     pub fn last_unwrap(v: &[u32]) -> u32 {
+   |     ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
+   |
+note: first possible panic found here
+  --> $DIR/missing_panics_doc.rs:179:10
+   |
+LL |         *v.last().unwrap()
+   |          ^^^^^^^^^^^^^^^^^
+
+error: docs for function which may panic missing `# Panics` section
+  --> $DIR/missing_panics_doc.rs:182:5
+   |
+LL |     pub fn last_expect(v: &[u32]) -> u32 {
+   |     ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
+   |
+note: first possible panic found here
+  --> $DIR/missing_panics_doc.rs:183:10
+   |
+LL |         *v.last().expect("passed an empty thing")
+   |          ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
+
+error: aborting due to 13 previous errors