@@ -127,6 +127,9 @@ pub enum AnalysisPhase {
127127 /// * [`StatementKind::AscribeUserType`]
128128 /// * [`StatementKind::Coverage`] with [`CoverageKind::BlockMarker`] or [`CoverageKind::SpanMarker`]
129129 /// * [`Rvalue::Ref`] with `BorrowKind::Fake`
130+ /// * [`CastKind::PointerCoercion`] with any of the following:
131+ /// * [`PointerCoercion::ArrayToPointer`]
132+ /// * [`PointerCoercion::MutToConstPointer`]
130133 ///
131134 /// Furthermore, `Deref` projections must be the first projection within any place (if they
132135 /// appear at all)
@@ -1281,8 +1284,7 @@ pub enum Rvalue<'tcx> {
12811284 ///
12821285 /// This allows for casts from/to a variety of types.
12831286 ///
1284- /// **FIXME**: Document exactly which `CastKind`s allow which types of casts. Figure out why
1285- /// `ArrayToPointer` and `MutToConstPointer` are special.
1287+ /// **FIXME**: Document exactly which `CastKind`s allow which types of casts.
12861288 Cast ( CastKind , Operand < ' tcx > , Ty < ' tcx > ) ,
12871289
12881290 /// * `Offset` has the same semantics as [`offset`](pointer::offset), except that the second
@@ -1362,6 +1364,13 @@ pub enum CastKind {
13621364 PointerWithExposedProvenance ,
13631365 /// Pointer related casts that are done by coercions. Note that reference-to-raw-ptr casts are
13641366 /// translated into `&raw mut/const *r`, i.e., they are not actually casts.
1367+ ///
1368+ /// The following are allowed in [`AnalysisPhase::Initial`] as they're needed for borrowck,
1369+ /// but after that are forbidden (including in all phases of runtime MIR):
1370+ /// * [`PointerCoercion::ArrayToPointer`]
1371+ /// * [`PointerCoercion::MutToConstPointer`]
1372+ ///
1373+ /// Both are runtime nops, so should be [`CastKind::PtrToPtr`] instead in runtime MIR.
13651374 PointerCoercion ( PointerCoercion ) ,
13661375 /// Cast into a dyn* object.
13671376 DynStar ,
0 commit comments