@@ -775,6 +775,10 @@ impl<'tcx> Visitor<'tcx> for CanConstProp {
775
775
// Projections are fine, because `&mut foo.x` will be caught by
776
776
// `MutatingUseContext::Borrow` elsewhere.
777
777
MutatingUse ( MutatingUseContext :: Projection )
778
+ // These are just stores, where the storing is not propagatable, but there may be later
779
+ // mutations of the same local via `Store`
780
+ | MutatingUse ( MutatingUseContext :: Call )
781
+ // Actual store that can possibly even propagate a value
778
782
| MutatingUse ( MutatingUseContext :: Store ) => {
779
783
if !self . found_assignment . insert ( local) {
780
784
match & mut self . can_const_prop [ local] {
@@ -799,7 +803,21 @@ impl<'tcx> Visitor<'tcx> for CanConstProp {
799
803
| NonMutatingUse ( NonMutatingUseContext :: Inspect )
800
804
| NonMutatingUse ( NonMutatingUseContext :: Projection )
801
805
| NonUse ( _) => { }
802
- _ => {
806
+
807
+ // These could be propagated with a smarter analysis or just some careful thinking about
808
+ // whether they'd be fine right now.
809
+ MutatingUse ( MutatingUseContext :: AsmOutput )
810
+ | MutatingUse ( MutatingUseContext :: Yield )
811
+ | MutatingUse ( MutatingUseContext :: Drop )
812
+ | MutatingUse ( MutatingUseContext :: Retag )
813
+ // These can't ever be propagated under any scheme, as we can't reason about indirect
814
+ // mutation.
815
+ | NonMutatingUse ( NonMutatingUseContext :: SharedBorrow )
816
+ | NonMutatingUse ( NonMutatingUseContext :: ShallowBorrow )
817
+ | NonMutatingUse ( NonMutatingUseContext :: UniqueBorrow )
818
+ | NonMutatingUse ( NonMutatingUseContext :: AddressOf )
819
+ | MutatingUse ( MutatingUseContext :: Borrow )
820
+ | MutatingUse ( MutatingUseContext :: AddressOf ) => {
803
821
trace ! ( "local {:?} can't be propagaged because it's used: {:?}" , local, context) ;
804
822
self . can_const_prop [ local] = ConstPropMode :: NoPropagation ;
805
823
}
0 commit comments