 extension String.Index {
   @_alwaysEmitIntoClient // Swift 5.7
   @inline(__always)
-  internal var _isCharacterAligned: Bool { return 0 != _rawBits & 0x2 }
+  internal var _isCharacterAligned: Bool {
+    0 != _rawBits & Self.__characterAlignmentBit
+  }
 
   /// Return the same index with both the scalar- and `Character`-aligned bits
   /// set.

  @inline(__always)
  internal var _canBeUTF16: Bool {
    // The only way an index cannot be UTF-16 is it has only the UTF-8 flag set.
    _rawBits & 0xC != 0x04
  }

  /// Returns the same index with the UTF-8 bit set.
  @_alwaysEmitIntoClient // Swift 5.7
  @inline(__always)
  internal var _knownUTF8: Self { Self(_rawBits | 0x4) }

  /// Returns the same index with the UTF-16 bit set.
  @_alwaysEmitIntoClient // Swift 5.7
  @inline(__always)
  internal var _knownUTF16: Self { Self(_rawBits | 0x8) }

  /// Returns the same index with both UTF-8 & UTF-16 bits set.
  @_alwaysEmitIntoClient // Swift 5.7
  @inline(__always)
  internal var _encodingIndependent: Self { Self(_rawBits | 0xC) }

  /// Returns true if the UTF-8 flag is set.
  ///
  /// This is for debugging purposes only. Do not use this property to determine
  /// whether an index is compatible with UTF-8 storage; instead, use
  /// `_canBeUTF8`.
  @_alwaysEmitIntoClient // Swift 5.7
  @inline(__always)
  internal var __isUTF8: Bool { _rawBits & 0x4 != 0 }

  /// Returns true if the UTF-16 flag is set.
  ///
  /// This is for debugging purposes only. Do not use this property to determine
  /// whether an index is compatible with UTF-16 storage; instead, use
  /// `_canBeUTF16`.
  @_alwaysEmitIntoClient // Swift 5.7
  @inline(__always)
  internal var __isUTF16: Bool { _rawBits & 0x8 != 0 }

  @_alwaysEmitIntoClient // Swift 5.7
  internal func _copyEncoding(from index: Self) -> Self {
    Self((_rawBits & ~0xC) | (index._rawBits & 0xC))
  }
}


extension String.Index {
  @_alwaysEmitIntoClient // Swift 5.1
  @inline(__always)
  internal var _isScalarAligned: Bool {
    0 != _rawBits & Self.__scalarAlignmentBit
  }

  @_alwaysEmitIntoClient // Swift 5.1
  @inline(__always)
  internal var _scalarAligned: String.Index {
    var idx = self
    idx._rawBits |= Self.__scalarAlignmentBit
    idx._invariantCheck()
    return idx
  }
