diff options
| author | kennytm <kennytm@gmail.com> | 2019-02-20 01:13:12 +0800 |
|---|---|---|
| committer | GitHub <noreply@github.com> | 2019-02-20 01:13:12 +0800 |
| commit | 5a06eab1f5b56735928a2d16728d9cdbfb44cac2 (patch) | |
| tree | a1613c4b5f8ef3d0990fba0fcd2c651e7e3c70d3 /src/test/rustdoc | |
| parent | 4d66b7b76df04c29422ae3385920abb5cb947cff (diff) | |
| parent | dad211ef9fdcef5328813a1907d323303f09fc6c (diff) | |
| download | rust-5a06eab1f5b56735928a2d16728d9cdbfb44cac2.tar.gz rust-5a06eab1f5b56735928a2d16728d9cdbfb44cac2.zip | |
Rollup merge of #56470 - llogiq:process-termination-doctest, r=GuillaumeGomez
Modify doctest's auto-`fn main()` to allow `Result`s This lets the default `fn main()` ~~return `impl Termination`~~ unwrap Results, which allows the use of `?` in most tests without adding it manually. This fixes #56260 ~~Blocked on `std::process::Termination` stabilization.~~ Using `Termination` would have been cleaner, but this should work OK.
Diffstat (limited to 'src/test/rustdoc')
| -rw-r--r-- | src/test/rustdoc/process-termination.rs | 24 |
1 files changed, 24 insertions, 0 deletions
diff --git a/src/test/rustdoc/process-termination.rs b/src/test/rustdoc/process-termination.rs new file mode 100644 index 00000000000..32258792b6e --- /dev/null +++ b/src/test/rustdoc/process-termination.rs @@ -0,0 +1,24 @@ +// compile-flags:--test + +/// A check of using various process termination strategies +/// +/// # Examples +/// +/// ```rust +/// assert!(true); // this returns `()`, all is well +/// ``` +/// +/// You can also simply return `Ok(())`, but you'll need to disambiguate the +/// type using turbofish, because we cannot infer the type: +/// +/// ```rust +/// Ok::<(), &'static str>(()) +/// ``` +/// +/// You can err with anything that implements `Debug`: +/// +/// ```rust,should_panic +/// Err("This is returned from `main`, leading to panic")?; +/// Ok::<(), &'static str>(()) +/// ``` +pub fn check_process_termination() {} |
