Skip to content

Commit b65550d

Browse files
committed
Auto merge of #147055 - beepster4096:subtype_is_not_a_projection, r=lcnr
Turn ProjectionElem::Subtype into CastKind::Subtype I noticed that drop elaboration can't, in general, handle `ProjectionElem::SubType`. It creates a disjoint move path that overlaps with other move paths. (`Subslice` does too, and I'm working on a different PR to make that special case less fragile.) If its skipped and treated as the same move path as its parent then `MovePath.place` has multiple possible projections. (It would probably make sense to remove all `Subtype` projections for the canonical place but it doesn't make sense to have this special case for a problem that doesn't actually occur in real MIR.) The only reason this doesn't break is that `Subtype` is always the sole projection of the local its applied to. For the same reason, it works fine as a `CastKind` so I figured that makes more sense than documenting and validating this hidden invariant. cc rust-lang/rust#112651, rust-lang/rust#133258 r? Icnr (bc you've been the main person dealing with `Subtype` it looks like)
2 parents 30f284d + 36d6327 commit b65550d

File tree

1 file changed

+2
-2
lines changed

1 file changed

+2
-2
lines changed

clippy_utils/src/qualify_min_const_fn.rs

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -141,7 +141,8 @@ fn check_rvalue<'tcx>(
141141
| CastKind::FloatToFloat
142142
| CastKind::FnPtrToPtr
143143
| CastKind::PtrToPtr
144-
| CastKind::PointerCoercion(PointerCoercion::MutToConstPointer | PointerCoercion::ArrayToPointer, _),
144+
| CastKind::PointerCoercion(PointerCoercion::MutToConstPointer | PointerCoercion::ArrayToPointer, _)
145+
| CastKind::Subtype,
145146
operand,
146147
_,
147148
) => check_operand(cx, operand, span, body, msrv),
@@ -312,7 +313,6 @@ fn check_place<'tcx>(
312313
| ProjectionElem::OpaqueCast(..)
313314
| ProjectionElem::Downcast(..)
314315
| ProjectionElem::Subslice { .. }
315-
| ProjectionElem::Subtype(_)
316316
| ProjectionElem::Index(_)
317317
| ProjectionElem::UnwrapUnsafeBinder(_) => {},
318318
}

0 commit comments

Comments
 (0)