diff options
| author | Dylan MacKenzie <ecstaticmorse@gmail.com> | 2019-11-07 10:02:01 -0800 |
|---|---|---|
| committer | Dylan MacKenzie <ecstaticmorse@gmail.com> | 2019-11-13 10:44:14 -0800 |
| commit | eff83e5f49f42e174424da2dd517c1bc5821aa13 (patch) | |
| tree | ddbf60bd5f8b1c57e01774043102d0354aa21c14 | |
| parent | 281e898ecfb07ab1347a2c7d745542028d4376a8 (diff) | |
| download | rust-eff83e5f49f42e174424da2dd517c1bc5821aa13.tar.gz rust-eff83e5f49f42e174424da2dd517c1bc5821aa13.zip | |
Small fixes to comments
| -rw-r--r-- | src/librustc_passes/check_const.rs | 9 |
1 files changed, 5 insertions, 4 deletions
diff --git a/src/librustc_passes/check_const.rs b/src/librustc_passes/check_const.rs index 70e4a19e96f..ff0de4a73b7 100644 --- a/src/librustc_passes/check_const.rs +++ b/src/librustc_passes/check_const.rs @@ -1,5 +1,6 @@ -//! This pass checks the HIR bodies in a const context (e.g., `const`, `static`, `const fn`) for -//! structured control flow (e.g. `if`, `while`), which is forbidden in a const context. +//! This pass checks HIR bodies that may be evaluated at compile-time (e.g., `const`, `static`, +//! `const fn`) for structured control flow (e.g. `if`, `while`), which is forbidden in a const +//! context. //! //! By the time the MIR const-checker runs, these high-level constructs have been lowered to //! control-flow primitives (e.g., `Goto`, `SwitchInt`), making it tough to properly attribute @@ -98,7 +99,7 @@ impl<'tcx> CheckConstVisitor<'tcx> { span_err!(self.sess, span, E0744, "`{}` is not allowed in a `{}`", bad_op, const_kind); } - /// Saves the parent `const_kind` before visiting a nested `Body` and restores it afterwards. + /// Saves the parent `const_kind` before calling `f` and restores it afterwards. fn recurse_into(&mut self, kind: Option<ConstKind>, f: impl FnOnce(&mut Self)) { let parent_kind = self.const_kind; self.const_kind = kind; @@ -124,7 +125,7 @@ impl<'tcx> Visitor<'tcx> for CheckConstVisitor<'tcx> { fn visit_expr(&mut self, e: &'tcx hir::Expr) { match &e.kind { - // Skip these checks if the current item is not const. + // Skip the following checks if we are not currently in a const context. _ if self.const_kind.is_none() => {} hir::ExprKind::Loop(_, _, source) => { |
