1
Fork 0

Rollup merge of #82617 - camelid:everybody_loops-docs, r=jyn514

Document `everybody_loops`

cc `@jyn514`
This commit is contained in:
Yuki Okushi 2021-03-14 13:07:30 +09:00 committed by GitHub
commit f0ebc10410
No known key found for this signature in database
GPG key ID: 4AEE18F83AFDEB23

View file

@ -712,16 +712,24 @@ pub fn non_durable_rename(src: &Path, dst: &Path) -> std::io::Result<()> {
std::fs::rename(src, dst) std::fs::rename(src, dst)
} }
// Note: Also used by librustdoc, see PR #43348. Consider moving this struct elsewhere. /// Replaces function bodies with `loop {}` (an infinite loop). This gets rid of
// /// all semantic errors in the body while still satisfying the return type,
// FIXME: Currently the `everybody_loops` transformation is not applied to: /// except in certain cases, see below for more.
// * `const fn`, due to issue #43636 that `loop` is not supported for const evaluation. We are ///
// waiting for miri to fix that. /// This pass is known as `everybody_loops`. Very punny.
// * `impl Trait`, due to issue #43869 that functions returning impl Trait cannot be diverging. ///
// Solving this may require `!` to implement every trait, which relies on the an even more /// As of March 2021, `everybody_loops` is only used for the
// ambitious form of the closed RFC #1637. See also [#34511]. /// `-Z unpretty=everybody_loops` debugging option.
// ///
// [#34511]: https://github.com/rust-lang/rust/issues/34511#issuecomment-322340401 /// FIXME: Currently the `everybody_loops` transformation is not applied to:
/// * `const fn`; support could be added, but hasn't. Originally `const fn`
/// was skipped due to issue #43636 that `loop` was not supported for
/// const evaluation.
/// * `impl Trait`, due to issue #43869 that functions returning impl Trait cannot be diverging.
/// Solving this may require `!` to implement every trait, which relies on the an even more
/// ambitious form of the closed RFC #1637. See also [#34511].
///
/// [#34511]: https://github.com/rust-lang/rust/issues/34511#issuecomment-322340401
pub struct ReplaceBodyWithLoop<'a, 'b> { pub struct ReplaceBodyWithLoop<'a, 'b> {
within_static_or_const: bool, within_static_or_const: bool,
nested_blocks: Option<Vec<ast::Block>>, nested_blocks: Option<Vec<ast::Block>>,