Skip to content

Rustdoc: Allow implicit fn main() -> Result<_, _> #56260

Closed
@llogiq

Description

@llogiq

Rustdoc now allows us to use ? in our tests. Unfortunately, this requires writing the fn main() -> .. manually, which really shouldn't be needed IMHO.

So we now have to write:

/// ```rust
///# fn main() -> Result<(), ()> {
/// let foo = Ok(1usize);
/// assert!(foo? > 0);
///# }
/// ```

where it should suffice to write:

/// ```rust
/// let foo = Ok(1usize);
/// assert!(foo? > 0);
/// ```

Doing so will make the tests shorter and hopefully lead to more ? and less unwrap in tests.

Metadata

Metadata

Labels

T-rustdocRelevant to the rustdoc team, which will review and decide on the PR/issue.

Type

No type

Projects

No projects

Milestone

No milestone

Relationships

None yet

Development

No branches or pull requests

Issue actions