Skip to content

Commit 043be33

Browse files
Apply suggestions from code review
Co-authored-by: Travis Cross <[email protected]>
1 parent 332e511 commit 043be33

27 files changed

+85
-67
lines changed

compiler/rustc_feature/src/builtin_attrs.rs

Lines changed: 4 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -583,7 +583,10 @@ pub static BUILTIN_ATTRIBUTES: &[BuiltinAttribute] = &[
583583
EncodeCrossCrate::Yes, min_generic_const_args, experimental!(type_const),
584584
),
585585

586-
// #[loop_match] and #[const_continue]
586+
// The `#[loop_match]` and `#[const_continue]` attributes are part of the
587+
// lang experiment for RFC 3720 tracked in:
588+
//
589+
// - https://github.com/rust-lang/rust/issues/132306
587590
gated!(
588591
const_continue, Normal, template!(Word), ErrorFollowing,
589592
EncodeCrossCrate::No, loop_match, experimental!(const_continue)

compiler/rustc_feature/src/unstable.rs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -546,7 +546,7 @@ declare_features! (
546546
/// to pass custom arguments to the linker.
547547
(unstable, link_arg_attribute, "1.76.0", Some(99427)),
548548
/// Allows fused `loop`/`match` for direct intraprocedural jumps.
549-
(incomplete, loop_match, "CURRENT_RUSTC_VERSION", Some(138777)),
549+
(incomplete, loop_match, "CURRENT_RUSTC_VERSION", Some(132306)),
550550
/// Give access to additional metadata about declarative macro meta-variables.
551551
(unstable, macro_metavar_expr, "1.61.0", Some(83527)),
552552
/// Provides a way to concatenate identifiers using metavariable expressions.

compiler/rustc_middle/src/thir.rs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -377,7 +377,7 @@ pub enum ExprKind<'tcx> {
377377
},
378378
/// A `#[loop_match] loop { state = 'blk: { match state { ... } } }` expression.
379379
LoopMatch {
380-
/// The state variable that is updated, and also the scrutinee of the match
380+
/// The state variable that is updated, and also the scrutinee of the match.
381381
state: ExprId,
382382
region_scope: region::Scope,
383383
arms: Box<[ArmId]>,

compiler/rustc_mir_build/messages.ftl

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -227,11 +227,11 @@ mir_build_loop_match_bad_statements =
227227
statements are not allowed in this position within a `#[loop_match]`
228228
229229
mir_build_loop_match_invalid_match =
230-
invalid match on `loop_match` state
231-
.note = only matches on local variables are valid
230+
invalid match on `#[loop_match]` state
231+
.note = a local variable must be the scrutinee within a `#[loop_match]`
232232
233233
mir_build_loop_match_invalid_update =
234-
invalid update of the `loop_match` state
234+
invalid update of the `#[loop_match]` state
235235
.label = the assignment must update this variable
236236
237237
mir_build_loop_match_missing_assignment =

compiler/rustc_mir_build/src/builder/expr/into.rs

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -310,7 +310,7 @@ impl<'a, 'tcx> Builder<'a, 'tcx> {
310310

311311
// The `built_tree` maps match arms to their basic block (where control flow
312312
// jumps to when a value matches the arm). This structure is stored so that a
313-
// #[const_continue] can figure out what basic block to jump to.
313+
// `#[const_continue]` can figure out what basic block to jump to.
314314
let built_tree = this.lower_match_tree(
315315
body_block,
316316
scrutinee_span,
@@ -327,7 +327,7 @@ impl<'a, 'tcx> Builder<'a, 'tcx> {
327327
// hence the `in_breakable_scope`.
328328
//
329329
// Then `in_const_continuable_scope` stores information for the lowering of
330-
// #[const_continue], and finally the match is lowered in the standard way.
330+
// `#[const_continue]`, and finally the match is lowered in the standard way.
331331
unpack!(
332332
body_block = this.in_scope(
333333
(region_scope, source_info),

compiler/rustc_mir_build/src/builder/matches/mod.rs

Lines changed: 5 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -2867,7 +2867,7 @@ impl<'a, 'tcx> Builder<'a, 'tcx> {
28672867
true
28682868
}
28692869

2870-
/// Attempt to statically pick the BasicBlock that a value would resolve to at runtime.
2870+
/// Attempt to statically pick the `BasicBlock` that a value would resolve to at runtime.
28712871
pub(crate) fn static_pattern_match(
28722872
&self,
28732873
cx: &RustcPatCtxt<'_, 'tcx>,
@@ -2926,7 +2926,8 @@ impl<'a, 'tcx> Builder<'a, 'tcx> {
29262926
// a lot of care around intrinsics. For an issue to happen here, it would require a
29272927
// macro expanding to a `simd_shuffle` call without wrapping the constant argument in a
29282928
// `const {}` block, but the user pass through arbitrary expressions.
2929-
// FIXME(oli-obk): replace the magic const generic argument of `simd_shuffle` with a
2929+
2930+
// FIXME(oli-obk): Replace the magic const generic argument of `simd_shuffle` with a
29302931
// real const generic, and get rid of this entire function.
29312932
other => span_bug!(constant.span, "{other:#?}"),
29322933
};
@@ -2977,7 +2978,7 @@ impl<'a, 'tcx> Builder<'a, 'tcx> {
29772978
},
29782979
Constructor::Wildcard => true,
29792980

2980-
// these we may eventually support
2981+
// These we may eventually support:
29812982
Constructor::Struct
29822983
| Constructor::Ref
29832984
| Constructor::Slice(_)
@@ -2989,7 +2990,7 @@ impl<'a, 'tcx> Builder<'a, 'tcx> {
29892990
| Constructor::F128Range(..)
29902991
| Constructor::Str(_) => bug!("unsupported pattern constructor {:?}", pat.ctor()),
29912992

2992-
// these should never occur here
2993+
// These should never occur here:
29932994
Constructor::Opaque(_)
29942995
| Constructor::Never
29952996
| Constructor::NonExhaustive

compiler/rustc_mir_build/src/builder/scope.rs

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -872,8 +872,8 @@ impl<'a, 'tcx> Builder<'a, 'tcx> {
872872
_ => span_bug!(state_decl.source_info.span, "unsupported #[loop_match] state"),
873873
};
874874

875-
// The PatCtxt is normally used in pattern exhaustiveness checking, but reused here
876-
// because it performs normalization and const evaluation.
875+
// The `PatCtxt` is normally used in pattern exhaustiveness checking, but reused
876+
// here because it performs normalization and const evaluation.
877877
let dropless_arena = rustc_arena::DroplessArena::default();
878878
let typeck_results = self.tcx.typeck(self.def_id);
879879
let cx = RustcPatCtxt {

compiler/rustc_mir_build/src/thir/cx/expr.rs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -873,7 +873,7 @@ impl<'tcx> ThirBuildCx<'tcx> {
873873
if is_loop_match {
874874
let dcx = self.tcx.dcx();
875875

876-
// accept either `state = expr` or `state = expr;`
876+
// Accept either `state = expr` or `state = expr;`.
877877
let loop_body_expr = match body.stmts {
878878
[] => match body.expr {
879879
Some(expr) => expr,

compiler/rustc_passes/messages.ftl

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -104,7 +104,7 @@ passes_const_continue_attr =
104104
.label = not a break expression
105105
106106
passes_const_continue_bad_label =
107-
`#[const_continue]` must break to a labeled block that participates in a `#[loop_match]`
107+
`#[const_continue]` must break to a labeled block in a `#[loop_match]`
108108
109109
passes_const_stable_not_stable =
110110
attribute `#[rustc_const_stable]` can only be applied to functions that are declared `#[stable]`

compiler/rustc_passes/src/loops.rs

Lines changed: 5 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -39,9 +39,9 @@ enum Context {
3939
AnonConst,
4040
/// E.g. `const { ... }`.
4141
ConstBlock,
42-
/// `#[loop_match] loop { state = 'label: { /* ... */ } }`
42+
/// E.g. `#[loop_match] loop { state = 'label: { /* ... */ } }`.
4343
LoopMatch {
44-
/// The label of the labeled block (so not the loop!)
44+
/// The label of the labeled block (not of the loop itself).
4545
labeled_block: Label,
4646
},
4747
}
@@ -228,7 +228,7 @@ impl<'hir> Visitor<'hir> for CheckLoopVisitor<'hir> {
228228
Err(hir::LoopIdError::UnresolvedLabel) => None,
229229
};
230230

231-
// a #[const_continue] must be to a block that participates in #[loop_match]
231+
// A `#[const_continue]` must break to a block in a `#[loop_match]`.
232232
let attrs = self.tcx.hir_attrs(e.hir_id);
233233
if attrs.iter().any(|attr| attr.has_name(sym::const_continue)) {
234234
if let Some(break_label) = break_label.label {
@@ -438,9 +438,9 @@ impl<'hir> CheckLoopVisitor<'hir> {
438438
return None;
439439
}
440440

441-
// NOTE: diagnostics are emitted during MIR construction.
441+
// NOTE: Diagnostics are emitted during MIR construction.
442442

443-
// accept either `state = expr` or `state = expr;`
443+
// Accept either `state = expr` or `state = expr;`.
444444
let loop_body_expr = match body.stmts {
445445
[] => match body.expr {
446446
Some(expr) => expr,

0 commit comments

Comments
 (0)