@@ -110,15 +110,16 @@ impl<'tcx> Visitor<'tcx> for DeduceReadOnly {
110110
111111 if let TerminatorKind :: Call { ref args, .. } = terminator. kind {
112112 for arg in args {
113- if let Operand :: Move ( _) = * arg {
114- // ArgumentChecker panics if a direct move of an argument from a caller to a
115- // callee was detected.
116- //
117- // If, in the future, MIR optimizations cause arguments to be moved directly
118- // from callers to callees, change the panic to instead add the argument in
119- // question to `mutating_uses`.
120- ArgumentChecker :: new ( self . mutable_args . domain_size ( ) )
121- . visit_operand ( arg, location)
113+ if let Operand :: Move ( place) = * arg {
114+ let local = place. local ;
115+ if place. is_indirect ( )
116+ || local == RETURN_PLACE
117+ || local. index ( ) > self . mutable_args . domain_size ( )
118+ {
119+ continue ;
120+ }
121+
122+ self . mutable_args . insert ( local. index ( ) - 1 ) ;
122123 }
123124 }
124125 } ;
@@ -127,35 +128,6 @@ impl<'tcx> Visitor<'tcx> for DeduceReadOnly {
127128 }
128129}
129130
130- /// A visitor that simply panics if a direct move of an argument from a caller to a callee was
131- /// detected.
132- struct ArgumentChecker {
133- /// The number of arguments to the calling function.
134- arg_count : usize ,
135- }
136-
137- impl ArgumentChecker {
138- /// Creates a new ArgumentChecker.
139- fn new ( arg_count : usize ) -> Self {
140- Self { arg_count }
141- }
142- }
143-
144- impl < ' tcx > Visitor < ' tcx > for ArgumentChecker {
145- fn visit_local ( & mut self , local : Local , context : PlaceContext , _: Location ) {
146- // Check to make sure that, if this local is an argument, we didn't move directly from it.
147- if matches ! ( context, PlaceContext :: NonMutatingUse ( NonMutatingUseContext :: Move ) )
148- && local != RETURN_PLACE
149- && local. index ( ) <= self . arg_count
150- {
151- // If, in the future, MIR optimizations cause arguments to be moved directly from
152- // callers to callees, change this panic to instead add the argument in question to
153- // `mutating_uses`.
154- panic ! ( "Detected a direct move from a caller's argument to a callee's argument!" )
155- }
156- }
157- }
158-
159131/// Returns true if values of a given type will never be passed indirectly, regardless of ABI.
160132fn type_will_always_be_passed_directly < ' tcx > ( ty : Ty < ' tcx > ) -> bool {
161133 matches ! (
0 commit comments