1- //! This pass checks the HIR bodies in a const context (e.g., `const`, `static`, `const fn`) for
2- //! structured control flow (e.g. `if`, `while`), which is forbidden in a const context.
1+ //! This pass checks HIR bodies that may be evaluated at compile-time (e.g., `const`, `static`,
2+ //! `const fn`) for structured control flow (e.g. `if`, `while`), which is forbidden in a const
3+ //! context.
34//!
45//! By the time the MIR const-checker runs, these high-level constructs have been lowered to
56//! control-flow primitives (e.g., `Goto`, `SwitchInt`), making it tough to properly attribute
@@ -98,7 +99,7 @@ impl<'tcx> CheckConstVisitor<'tcx> {
9899 span_err ! ( self . sess, span, E0744 , "`{}` is not allowed in a `{}`" , bad_op, const_kind) ;
99100 }
100101
101- /// Saves the parent `const_kind` before visiting a nested `Body ` and restores it afterwards.
102+ /// Saves the parent `const_kind` before calling `f ` and restores it afterwards.
102103 fn recurse_into ( & mut self , kind : Option < ConstKind > , f : impl FnOnce ( & mut Self ) ) {
103104 let parent_kind = self . const_kind ;
104105 self . const_kind = kind;
@@ -124,7 +125,7 @@ impl<'tcx> Visitor<'tcx> for CheckConstVisitor<'tcx> {
124125
125126 fn visit_expr ( & mut self , e : & ' tcx hir:: Expr ) {
126127 match & e. kind {
127- // Skip these checks if the current item is not const.
128+ // Skip the following checks if we are not currently in a const context .
128129 _ if self . const_kind . is_none ( ) => { }
129130
130131 hir:: ExprKind :: Loop ( _, _, source) => {
0 commit comments