30
30
// #![feature(rustc_attrs)]
31
31
32
32
use std:: ops:: { Index , IndexMut } ;
33
- use std:: ops:: { AddAssign , SubAssign , MulAssign , DivAssign , RemAssign } ;
34
- use std:: ops:: { BitAndAssign , BitOrAssign , BitXorAssign , ShlAssign , ShrAssign } ;
35
33
36
34
// This is case outlined by Niko that we want to ensure we reject
37
35
// (at least initially).
@@ -186,56 +184,6 @@ fn coerce_index_op() {
186
184
//[nll]~^^ ERROR cannot borrow `i` as immutable because it is also borrowed as mutable [E0502]
187
185
}
188
186
189
- struct A ( i32 ) ;
190
-
191
- macro_rules! trivial_binop {
192
- ( $Trait: ident, $m: ident) => {
193
- impl $Trait<i32 > for A { fn $m( & mut self , rhs: i32 ) { self . 0 = rhs; } }
194
- }
195
- }
196
-
197
- trivial_binop ! ( AddAssign , add_assign) ;
198
- trivial_binop ! ( SubAssign , sub_assign) ;
199
- trivial_binop ! ( MulAssign , mul_assign) ;
200
- trivial_binop ! ( DivAssign , div_assign) ;
201
- trivial_binop ! ( RemAssign , rem_assign) ;
202
- trivial_binop ! ( BitAndAssign , bitand_assign) ;
203
- trivial_binop ! ( BitOrAssign , bitor_assign) ;
204
- trivial_binop ! ( BitXorAssign , bitxor_assign) ;
205
- trivial_binop ! ( ShlAssign , shl_assign) ;
206
- trivial_binop ! ( ShrAssign , shr_assign) ;
207
-
208
- fn overloaded_binops ( ) {
209
- let mut a = A ( 10 ) ;
210
- a += a. 0 ;
211
- //[lxl]~^ ERROR cannot use `a.0` because it was mutably borrowed
212
- //[nll]~^^ ERROR cannot use `a.0` because it was mutably borrowed
213
- a -= a. 0 ;
214
- //[lxl]~^ ERROR cannot use `a.0` because it was mutably borrowed
215
- //[nll]~^^ ERROR cannot use `a.0` because it was mutably borrowed
216
- a *= a. 0 ;
217
- //[lxl]~^ ERROR cannot use `a.0` because it was mutably borrowed
218
- //[nll]~^^ ERROR cannot use `a.0` because it was mutably borrowed
219
- a /= a. 0 ;
220
- //[lxl]~^ ERROR cannot use `a.0` because it was mutably borrowed
221
- //[nll]~^^ ERROR cannot use `a.0` because it was mutably borrowed
222
- a &= a. 0 ;
223
- //[lxl]~^ ERROR cannot use `a.0` because it was mutably borrowed
224
- //[nll]~^^ ERROR cannot use `a.0` because it was mutably borrowed
225
- a |= a. 0 ;
226
- //[lxl]~^ ERROR cannot use `a.0` because it was mutably borrowed
227
- //[nll]~^^ ERROR cannot use `a.0` because it was mutably borrowed
228
- a ^= a. 0 ;
229
- //[lxl]~^ ERROR cannot use `a.0` because it was mutably borrowed
230
- //[nll]~^^ ERROR cannot use `a.0` because it was mutably borrowed
231
- a <<= a. 0 ;
232
- //[lxl]~^ ERROR cannot use `a.0` because it was mutably borrowed
233
- //[nll]~^^ ERROR cannot use `a.0` because it was mutably borrowed
234
- a >>= a. 0 ;
235
- //[lxl]~^ ERROR cannot use `a.0` because it was mutably borrowed
236
- //[nll]~^^ ERROR cannot use `a.0` because it was mutably borrowed
237
- }
238
-
239
187
fn main ( ) {
240
188
241
189
// As a reminder, this is the basic case we want to ensure we handle.
@@ -256,5 +204,4 @@ fn main() {
256
204
257
205
coerce_unsized ( ) ;
258
206
coerce_index_op ( ) ;
259
- overloaded_binops ( ) ;
260
207
}
0 commit comments