diff options
| author | daxpedda <daxpedda@gmail.com> | 2021-02-10 20:55:31 +0100 |
|---|---|---|
| committer | daxpedda <daxpedda@gmail.com> | 2021-02-10 20:55:31 +0100 |
| commit | 37f978299e514c977e747d0212fa72c2b1a86d11 (patch) | |
| tree | 7ac214cf2649b73d14656c1e39e0d65a69337524 | |
| parent | 6c73f989e2682b0fde6759428df27e6f8aacd656 (diff) | |
| download | rust-37f978299e514c977e747d0212fa72c2b1a86d11.tar.gz rust-37f978299e514c977e747d0212fa72c2b1a86d11.zip | |
Add test for checking a combination of unreachable and panic.
| -rw-r--r-- | tests/ui/doc_panics.rs | 22 | ||||
| -rw-r--r-- | tests/ui/doc_panics.stderr | 21 |
2 files changed, 42 insertions, 1 deletions
diff --git a/tests/ui/doc_panics.rs b/tests/ui/doc_panics.rs index a3b9cbb5114..3008c2d5b85 100644 --- a/tests/ui/doc_panics.rs +++ b/tests/ui/doc_panics.rs @@ -28,6 +28,15 @@ pub fn inner_body(opt: Option<u32>) { }); } +/// This needs to be documented +pub fn unreachable_and_panic() { + if true { + unreachable!() + } else { + panic!() + } +} + /// This is documented /// /// # Panics @@ -69,6 +78,19 @@ pub fn todo_documented() { todo!() } +/// This is documented +/// +/// # Panics +/// +/// We still need to do this part +pub fn unreachable_amd_panic_documented() { + if true { + unreachable!() + } else { + panic!() + } +} + /// This is okay because it is private fn unwrap_private() { let result = Err("Hi"); diff --git a/tests/ui/doc_panics.stderr b/tests/ui/doc_panics.stderr index c0c4e9e4fa7..287148690d2 100644 --- a/tests/ui/doc_panics.stderr +++ b/tests/ui/doc_panics.stderr @@ -63,5 +63,24 @@ LL | panic!() | ^^^^^^^^ = note: this error originates in a macro (in Nightly builds, run with -Z macro-backtrace for more info) -error: aborting due to 4 previous errors +error: docs for function which may panic missing `# Panics` section + --> $DIR/doc_panics.rs:32:1 + | +LL | / pub fn unreachable_and_panic() { +LL | | if true { +LL | | unreachable!() +LL | | } else { +LL | | panic!() +LL | | } +LL | | } + | |_^ + | +note: first possible panic found here + --> $DIR/doc_panics.rs:36:9 + | +LL | 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 |
