Auto merge of #62267 - GuillaumeGomez:revert-implicit-option-return, r=Centril
Revert "implicit `Option`-returning doctests" Reverts #61279 as discussed in #61360. cc @Centril
This commit is contained in:
commit
17e62f77f9
3 changed files with 1 additions and 31 deletions
|
@ -253,19 +253,6 @@ conversion, so type inference fails because the type is not unique. Please note
|
||||||
that you must write the `(())` in one sequence without intermediate whitespace
|
that you must write the `(())` in one sequence without intermediate whitespace
|
||||||
so that rustdoc understands you want an implicit `Result`-returning function.
|
so that rustdoc understands you want an implicit `Result`-returning function.
|
||||||
|
|
||||||
As of version 1.37.0, this simplification also works with `Option`s, which can
|
|
||||||
be handy to test e.g. iterators or checked arithmetic, for example:
|
|
||||||
|
|
||||||
```ignore
|
|
||||||
/// ```
|
|
||||||
/// let _ = &[].iter().next()?;
|
|
||||||
///# Some(())
|
|
||||||
/// ```
|
|
||||||
```
|
|
||||||
|
|
||||||
Note that the result must be a `Some(())` and this has to be written in one go.
|
|
||||||
In this case disambiguating the result isn't required.
|
|
||||||
|
|
||||||
## Documenting macros
|
## Documenting macros
|
||||||
|
|
||||||
Here’s an example of documenting a macro:
|
Here’s an example of documenting a macro:
|
||||||
|
|
|
@ -528,13 +528,8 @@ pub fn make_test(s: &str,
|
||||||
prog.push_str(everything_else);
|
prog.push_str(everything_else);
|
||||||
} else {
|
} else {
|
||||||
let returns_result = everything_else.trim_end().ends_with("(())");
|
let returns_result = everything_else.trim_end().ends_with("(())");
|
||||||
let returns_option = everything_else.trim_end().ends_with("Some(())");
|
|
||||||
let (main_pre, main_post) = if returns_result {
|
let (main_pre, main_post) = if returns_result {
|
||||||
(if returns_option {
|
("fn main() { fn _inner() -> Result<(), impl core::fmt::Debug> {",
|
||||||
"fn main() { fn _inner() -> Option<()> {"
|
|
||||||
} else {
|
|
||||||
"fn main() { fn _inner() -> Result<(), impl core::fmt::Debug> {"
|
|
||||||
},
|
|
||||||
"}\n_inner().unwrap() }")
|
"}\n_inner().unwrap() }")
|
||||||
} else {
|
} else {
|
||||||
("fn main() {\n", "\n}")
|
("fn main() {\n", "\n}")
|
||||||
|
|
|
@ -21,16 +21,4 @@
|
||||||
/// Err("This is returned from `main`, leading to panic")?;
|
/// Err("This is returned from `main`, leading to panic")?;
|
||||||
/// Ok::<(), &'static str>(())
|
/// Ok::<(), &'static str>(())
|
||||||
/// ```
|
/// ```
|
||||||
///
|
|
||||||
/// This also works with `Option<()>`s now:
|
|
||||||
///
|
|
||||||
/// ```rust
|
|
||||||
/// Some(())
|
|
||||||
/// ```
|
|
||||||
///
|
|
||||||
/// ```rust,should_panic
|
|
||||||
/// let x: &[u32] = &[];
|
|
||||||
/// let _ = x.iter().next()?;
|
|
||||||
/// Some(())
|
|
||||||
/// ```
|
|
||||||
pub fn check_process_termination() {}
|
pub fn check_process_termination() {}
|
||||||
|
|
Loading…
Add table
Add a link
Reference in a new issue