Skip to content

Commit 402259d

Browse files
committed
Take out Op<T>/OpAssign<T> for Wrapping<T>
1 parent cd3aa31 commit 402259d

File tree

2 files changed

+6
-145
lines changed

2 files changed

+6
-145
lines changed

src/libcore/num/wrapping.rs

+1-144
Original file line numberDiff line numberDiff line change
@@ -140,6 +140,7 @@ macro_rules! sh_impl_all {
140140

141141
sh_impl_all! { u8 u16 u32 u64 usize i8 i16 i32 i64 isize }
142142

143+
// FIXME(30524): impl Op<T> for Wrapping<T>, impl OpAssign<T> for Wrapping<T>
143144
macro_rules! wrapping_impl {
144145
($($t:ty)*) => ($(
145146
#[stable(feature = "rust1", since = "1.0.0")]
@@ -152,16 +153,6 @@ macro_rules! wrapping_impl {
152153
}
153154
}
154155

155-
#[unstable(feature = "wrapping_impls", reason = "recently added", issue = "30524")]
156-
impl Add<$t> for Wrapping<$t> {
157-
type Output = Wrapping<$t>;
158-
159-
#[inline(always)]
160-
fn add(self, other: $t) -> Wrapping<$t> {
161-
self + Wrapping(other)
162-
}
163-
}
164-
165156
#[unstable(feature = "op_assign_traits", reason = "recently added", issue = "28235")]
166157
impl AddAssign for Wrapping<$t> {
167158
#[inline(always)]
@@ -170,14 +161,6 @@ macro_rules! wrapping_impl {
170161
}
171162
}
172163

173-
#[unstable(feature = "wrapping_impls", reason = "recently added", issue = "30524")]
174-
impl AddAssign<$t> for Wrapping<$t> {
175-
#[inline(always)]
176-
fn add_assign(&mut self, other: $t) {
177-
self.add_assign(Wrapping(other))
178-
}
179-
}
180-
181164
#[stable(feature = "rust1", since = "1.0.0")]
182165
impl Sub for Wrapping<$t> {
183166
type Output = Wrapping<$t>;
@@ -188,16 +171,6 @@ macro_rules! wrapping_impl {
188171
}
189172
}
190173

191-
#[unstable(feature = "wrapping_impls", reason = "recently added", issue = "30524")]
192-
impl Sub<$t> for Wrapping<$t> {
193-
type Output = Wrapping<$t>;
194-
195-
#[inline(always)]
196-
fn sub(self, other: $t) -> Wrapping<$t> {
197-
self - Wrapping(other)
198-
}
199-
}
200-
201174
#[unstable(feature = "op_assign_traits", reason = "recently added", issue = "28235")]
202175
impl SubAssign for Wrapping<$t> {
203176
#[inline(always)]
@@ -206,14 +179,6 @@ macro_rules! wrapping_impl {
206179
}
207180
}
208181

209-
#[unstable(feature = "wrapping_impls", reason = "recently added", issue = "30524")]
210-
impl SubAssign<$t> for Wrapping<$t> {
211-
#[inline(always)]
212-
fn sub_assign(&mut self, other: $t) {
213-
self.sub_assign(Wrapping(other))
214-
}
215-
}
216-
217182
#[stable(feature = "rust1", since = "1.0.0")]
218183
impl Mul for Wrapping<$t> {
219184
type Output = Wrapping<$t>;
@@ -224,16 +189,6 @@ macro_rules! wrapping_impl {
224189
}
225190
}
226191

227-
#[unstable(feature = "wrapping_impls", reason = "recently added", issue = "30524")]
228-
impl Mul<$t> for Wrapping<$t> {
229-
type Output = Wrapping<$t>;
230-
231-
#[inline(always)]
232-
fn mul(self, other: $t) -> Wrapping<$t> {
233-
self * Wrapping(other)
234-
}
235-
}
236-
237192
#[unstable(feature = "op_assign_traits", reason = "recently added", issue = "28235")]
238193
impl MulAssign for Wrapping<$t> {
239194
#[inline(always)]
@@ -242,14 +197,6 @@ macro_rules! wrapping_impl {
242197
}
243198
}
244199

245-
#[unstable(feature = "wrapping_impls", reason = "recently added", issue = "30524")]
246-
impl MulAssign<$t> for Wrapping<$t> {
247-
#[inline(always)]
248-
fn mul_assign(&mut self, other: $t) {
249-
self.mul_assign(Wrapping(other))
250-
}
251-
}
252-
253200
#[stable(feature = "wrapping_div", since = "1.3.0")]
254201
impl Div for Wrapping<$t> {
255202
type Output = Wrapping<$t>;
@@ -260,16 +207,6 @@ macro_rules! wrapping_impl {
260207
}
261208
}
262209

263-
#[unstable(feature = "wrapping_impls", reason = "recently added", issue = "30524")]
264-
impl Div<$t> for Wrapping<$t> {
265-
type Output = Wrapping<$t>;
266-
267-
#[inline(always)]
268-
fn div(self, other: $t) -> Wrapping<$t> {
269-
self / Wrapping(other)
270-
}
271-
}
272-
273210
#[unstable(feature = "op_assign_traits", reason = "recently added", issue = "28235")]
274211
impl DivAssign for Wrapping<$t> {
275212
#[inline(always)]
@@ -278,14 +215,6 @@ macro_rules! wrapping_impl {
278215
}
279216
}
280217

281-
#[unstable(feature = "wrapping_impls", reason = "recently added", issue = "30524")]
282-
impl DivAssign<$t> for Wrapping<$t> {
283-
#[inline(always)]
284-
fn div_assign(&mut self, other: $t) {
285-
self.div_assign(Wrapping(other))
286-
}
287-
}
288-
289218
#[unstable(feature = "wrapping_impls", reason = "recently added", issue = "30524")]
290219
impl Rem for Wrapping<$t> {
291220
type Output = Wrapping<$t>;
@@ -296,16 +225,6 @@ macro_rules! wrapping_impl {
296225
}
297226
}
298227

299-
#[unstable(feature = "wrapping_impls", reason = "recently added", issue = "30524")]
300-
impl Rem<$t> for Wrapping<$t> {
301-
type Output = Wrapping<$t>;
302-
303-
#[inline(always)]
304-
fn rem(self, other: $t) -> Wrapping<$t> {
305-
self % Wrapping(other)
306-
}
307-
}
308-
309228
#[unstable(feature = "op_assign_traits", reason = "recently added", issue = "28235")]
310229
impl RemAssign for Wrapping<$t> {
311230
#[inline(always)]
@@ -314,14 +233,6 @@ macro_rules! wrapping_impl {
314233
}
315234
}
316235

317-
#[unstable(feature = "wrapping_impls", reason = "recently added", issue = "30524")]
318-
impl RemAssign<$t> for Wrapping<$t> {
319-
#[inline(always)]
320-
fn rem_assign(&mut self, other: $t) {
321-
self.rem_assign(Wrapping(other))
322-
}
323-
}
324-
325236
#[stable(feature = "rust1", since = "1.0.0")]
326237
impl Not for Wrapping<$t> {
327238
type Output = Wrapping<$t>;
@@ -342,16 +253,6 @@ macro_rules! wrapping_impl {
342253
}
343254
}
344255

345-
#[unstable(feature = "wrapping_impls", reason = "recently added", issue = "30524")]
346-
impl BitXor<$t> for Wrapping<$t> {
347-
type Output = Wrapping<$t>;
348-
349-
#[inline(always)]
350-
fn bitxor(self, other: $t) -> Wrapping<$t> {
351-
self ^ Wrapping(other)
352-
}
353-
}
354-
355256
#[unstable(feature = "op_assign_traits", reason = "recently added", issue = "28235")]
356257
impl BitXorAssign for Wrapping<$t> {
357258
#[inline(always)]
@@ -360,14 +261,6 @@ macro_rules! wrapping_impl {
360261
}
361262
}
362263

363-
#[unstable(feature = "wrapping_impls", reason = "recently added", issue = "30524")]
364-
impl BitXorAssign<$t> for Wrapping<$t> {
365-
#[inline(always)]
366-
fn bitxor_assign(&mut self, other: $t) {
367-
self.bitxor_assign(Wrapping(other))
368-
}
369-
}
370-
371264
#[stable(feature = "rust1", since = "1.0.0")]
372265
impl BitOr for Wrapping<$t> {
373266
type Output = Wrapping<$t>;
@@ -378,16 +271,6 @@ macro_rules! wrapping_impl {
378271
}
379272
}
380273

381-
#[unstable(feature = "wrapping_impls", reason = "recently added", issue = "30524")]
382-
impl BitOr<$t> for Wrapping<$t> {
383-
type Output = Wrapping<$t>;
384-
385-
#[inline(always)]
386-
fn bitor(self, other: $t) -> Wrapping<$t> {
387-
self | Wrapping(other)
388-
}
389-
}
390-
391274
#[unstable(feature = "op_assign_traits", reason = "recently added", issue = "28235")]
392275
impl BitOrAssign for Wrapping<$t> {
393276
#[inline(always)]
@@ -396,14 +279,6 @@ macro_rules! wrapping_impl {
396279
}
397280
}
398281

399-
#[unstable(feature = "wrapping_impls", reason = "recently added", issue = "30524")]
400-
impl BitOrAssign<$t> for Wrapping<$t> {
401-
#[inline(always)]
402-
fn bitor_assign(&mut self, other: $t) {
403-
self.bitor_assign(Wrapping(other))
404-
}
405-
}
406-
407282
#[stable(feature = "rust1", since = "1.0.0")]
408283
impl BitAnd for Wrapping<$t> {
409284
type Output = Wrapping<$t>;
@@ -414,31 +289,13 @@ macro_rules! wrapping_impl {
414289
}
415290
}
416291

417-
#[unstable(feature = "wrapping_impls", reason = "recently added", issue = "30524")]
418-
impl BitAnd<$t> for Wrapping<$t> {
419-
type Output = Wrapping<$t>;
420-
421-
#[inline(always)]
422-
fn bitand(self, other: $t) -> Wrapping<$t> {
423-
self & Wrapping(other)
424-
}
425-
}
426-
427292
#[unstable(feature = "op_assign_traits", reason = "recently added", issue = "28235")]
428293
impl BitAndAssign for Wrapping<$t> {
429294
#[inline(always)]
430295
fn bitand_assign(&mut self, other: Wrapping<$t>) {
431296
*self = *self & other;
432297
}
433298
}
434-
435-
#[unstable(feature = "wrapping_impls", reason = "recently added", issue = "30524")]
436-
impl BitAndAssign<$t> for Wrapping<$t> {
437-
#[inline(always)]
438-
fn bitand_assign(&mut self, other: $t) {
439-
self.bitand_assign(Wrapping(other))
440-
}
441-
}
442299
)*)
443300
}
444301

src/test/run-pass/num-wrapping.rs

+5-1
Original file line numberDiff line numberDiff line change
@@ -36,7 +36,8 @@ fn test_ops() {
3636
macro_rules! op_test {
3737
($op:ident ($lhs:expr, $rhs:expr) == $ans:expr) => {
3838
assert_eq!(black_box(Wrapping($lhs).$op(Wrapping($rhs))), Wrapping($ans));
39-
assert_eq!(black_box(Wrapping($lhs).$op($rhs)), Wrapping($ans));
39+
// FIXME(30524): uncomment this test when it's implemented
40+
// assert_eq!(black_box(Wrapping($lhs).$op($rhs)), Wrapping($ans));
4041
}
4142
}
4243

@@ -141,12 +142,15 @@ fn test_op_assigns() {
141142
tmp.$op(Wrapping($rhs));
142143
assert_eq!(black_box(tmp), Wrapping($ans));
143144
}
145+
// FIXME(30524): Uncomment this test
146+
/*
144147
{
145148
let mut tmp = Wrapping($initial);
146149
tmp = black_box(tmp);
147150
tmp.$op($rhs);
148151
assert_eq!(black_box(tmp), Wrapping($ans));
149152
}
153+
*/
150154
}
151155
}
152156
op_assign_test!(add_assign(i8::MAX, 1) == i8::MIN);

0 commit comments

Comments
 (0)