mirror of
https://github.com/rust-lang/rust.git
synced 2024-12-11 16:15:03 +00:00
Add test for checking a combination of unreachable and panic.
This commit is contained in:
parent
6c73f989e2
commit
37f978299e
@ -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
|
/// This is documented
|
||||||
///
|
///
|
||||||
/// # Panics
|
/// # Panics
|
||||||
@ -69,6 +78,19 @@ pub fn todo_documented() {
|
|||||||
todo!()
|
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
|
/// This is okay because it is private
|
||||||
fn unwrap_private() {
|
fn unwrap_private() {
|
||||||
let result = Err("Hi");
|
let result = Err("Hi");
|
||||||
|
@ -63,5 +63,24 @@ LL | panic!()
|
|||||||
| ^^^^^^^^
|
| ^^^^^^^^
|
||||||
= note: this error originates in a macro (in Nightly builds, run with -Z macro-backtrace for more info)
|
= 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
|
||||||
|
|
||||||
|
Loading…
Reference in New Issue
Block a user