Skip to content

Commit

Permalink
Add test for checking a combination of unreachable and panic.
Browse files Browse the repository at this point in the history
  • Loading branch information
daxpedda committed Feb 10, 2021
1 parent 6c73f98 commit 37f9782
Show file tree
Hide file tree
Showing 2 changed files with 42 additions and 1 deletion.
22 changes: 22 additions & 0 deletions tests/ui/doc_panics.rs
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand Down Expand Up @@ -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");
Expand Down
21 changes: 20 additions & 1 deletion tests/ui/doc_panics.stderr
Original file line number Diff line number Diff line change
Expand Up @@ -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

0 comments on commit 37f9782

Please sign in to comment.