@@ -374,7 +374,7 @@ impl<'tcx> Validator<'_, 'tcx> {
374
374
375
375
// In theory, any zero-sized value could be borrowed
376
376
// mutably without consequences. However, only &mut []
377
- // is allowed right now, and only in functions .
377
+ // is allowed right now.
378
378
if let ty:: Array ( _, len) = ty. kind ( ) {
379
379
match len. try_eval_usize ( self . tcx , self . param_env ) {
380
380
Some ( 0 ) => { }
@@ -524,7 +524,7 @@ impl<'tcx> Validator<'_, 'tcx> {
524
524
if let Some ( did) = c. check_static_ptr ( self . tcx ) {
525
525
// Evaluating a promoted may not read statics except if it got
526
526
// promoted from a static (this is a CTFE check). So we
527
- // can only promoted static accesses inside statics.
527
+ // can only promote static accesses inside statics.
528
528
if let Some ( hir:: ConstContext :: Static ( ..) ) = self . const_kind {
529
529
// The `is_empty` predicate is introduced to exclude the case
530
530
// where the projection operations are [ .field, * ].
@@ -586,9 +586,10 @@ impl<'tcx> Validator<'_, 'tcx> {
586
586
if let Some ( def_id) = c. check_static_ptr ( self . tcx ) {
587
587
// Only allow statics (not consts) to refer to other statics.
588
588
// FIXME(eddyb) does this matter at all for promotion?
589
- // FIXME(RalfJung) it makes little sense to not promote this in `fn/`const fn`,
590
- // and in `const` this cannot occur anyway. The concern is that we might promote
591
- // even `let x = &STATIC` which would be useless.
589
+ // FIXME(RalfJung) it makes little sense to not promote this in `fn`/`const fn`,
590
+ // and in `const` this cannot occur anyway. The only concern is that we might
591
+ // promote even `let x = &STATIC` which would be useless, but this applies to
592
+ // promotion inside statics as well.
592
593
let is_static = matches ! ( self . const_kind, Some ( hir:: ConstContext :: Static ( _) ) ) ;
593
594
if !is_static {
594
595
return Err ( Unpromotable ) ;
@@ -681,7 +682,7 @@ impl<'tcx> Validator<'_, 'tcx> {
681
682
682
683
// In theory, any zero-sized value could be borrowed
683
684
// mutably without consequences. However, only &mut []
684
- // is allowed right now, and only in functions .
685
+ // is allowed right now.
685
686
if let ty:: Array ( _, len) = ty. kind ( ) {
686
687
match len. try_eval_usize ( self . tcx , self . param_env ) {
687
688
Some ( 0 ) => { }
0 commit comments