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).
@@ -182,56 +180,6 @@ fn coerce_index_op() {
182
180
//[nll]~^^ ERROR cannot borrow `i` as immutable because it is also borrowed as mutable [E0502]
183
181
}
184
182
185
- struct A ( i32 ) ;
186
-
187
- macro_rules! trivial_binop {
188
- ( $Trait: ident, $m: ident) => {
189
- impl $Trait<i32 > for A { fn $m( & mut self , rhs: i32 ) { self . 0 = rhs; } }
190
- }
191
- }
192
-
193
- trivial_binop ! ( AddAssign , add_assign) ;
194
- trivial_binop ! ( SubAssign , sub_assign) ;
195
- trivial_binop ! ( MulAssign , mul_assign) ;
196
- trivial_binop ! ( DivAssign , div_assign) ;
197
- trivial_binop ! ( RemAssign , rem_assign) ;
198
- trivial_binop ! ( BitAndAssign , bitand_assign) ;
199
- trivial_binop ! ( BitOrAssign , bitor_assign) ;
200
- trivial_binop ! ( BitXorAssign , bitxor_assign) ;
201
- trivial_binop ! ( ShlAssign , shl_assign) ;
202
- trivial_binop ! ( ShrAssign , shr_assign) ;
203
-
204
- fn overloaded_binops ( ) {
205
- let mut a = A ( 10 ) ;
206
- a += a. 0 ;
207
- //[lxl]~^ ERROR cannot use `a.0` because it was mutably borrowed
208
- //[nll]~^^ ERROR cannot use `a.0` because it was mutably borrowed
209
- a -= a. 0 ;
210
- //[lxl]~^ ERROR cannot use `a.0` because it was mutably borrowed
211
- //[nll]~^^ ERROR cannot use `a.0` because it was mutably borrowed
212
- a *= a. 0 ;
213
- //[lxl]~^ ERROR cannot use `a.0` because it was mutably borrowed
214
- //[nll]~^^ ERROR cannot use `a.0` because it was mutably borrowed
215
- a /= a. 0 ;
216
- //[lxl]~^ ERROR cannot use `a.0` because it was mutably borrowed
217
- //[nll]~^^ ERROR cannot use `a.0` because it was mutably borrowed
218
- a &= a. 0 ;
219
- //[lxl]~^ ERROR cannot use `a.0` because it was mutably borrowed
220
- //[nll]~^^ ERROR cannot use `a.0` because it was mutably borrowed
221
- a |= a. 0 ;
222
- //[lxl]~^ ERROR cannot use `a.0` because it was mutably borrowed
223
- //[nll]~^^ ERROR cannot use `a.0` because it was mutably borrowed
224
- a ^= a. 0 ;
225
- //[lxl]~^ ERROR cannot use `a.0` because it was mutably borrowed
226
- //[nll]~^^ ERROR cannot use `a.0` because it was mutably borrowed
227
- a <<= a. 0 ;
228
- //[lxl]~^ ERROR cannot use `a.0` because it was mutably borrowed
229
- //[nll]~^^ ERROR cannot use `a.0` because it was mutably borrowed
230
- a >>= a. 0 ;
231
- //[lxl]~^ ERROR cannot use `a.0` because it was mutably borrowed
232
- //[nll]~^^ ERROR cannot use `a.0` because it was mutably borrowed
233
- }
234
-
235
183
fn main ( ) {
236
184
237
185
// As a reminder, this is the basic case we want to ensure we handle.
@@ -252,5 +200,4 @@ fn main() {
252
200
253
201
coerce_unsized ( ) ;
254
202
coerce_index_op ( ) ;
255
- overloaded_binops ( ) ;
256
203
}
0 commit comments