Skip to content

Commit eecb9be

Browse files
committed
---
yaml --- r: 234217 b: refs/heads/beta c: 224023d h: refs/heads/master i: 234215: e5e997c v: v3
1 parent f14c85b commit eecb9be

File tree

5 files changed

+16
-32
lines changed

5 files changed

+16
-32
lines changed

[refs]

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -23,7 +23,7 @@ refs/tags/0.9: 36870b185fc5f5486636d4515f0e22677493f225
2323
refs/tags/0.10: ac33f2b15782272ae348dbd7b14b8257b2148b5a
2424
refs/tags/0.11.0: e1247cb1d0d681be034adb4b558b5a0c0d5720f9
2525
refs/tags/0.12.0: f0c419429ef30723ceaf6b42f9b5a2aeb5d2e2d1
26-
refs/heads/beta: 9da7706dd64bbf055e3f32fe12286a521d8ac7ac
26+
refs/heads/beta: 224023dfd167afca95665ebf9f927fa1c301f950
2727
refs/tags/1.0.0-alpha: e42bd6d93a1d3433c486200587f8f9e12590a4d7
2828
refs/heads/tmp: 370fe2786109360f7c35b8ba552b83b773dd71d6
2929
refs/tags/1.0.0-alpha.2: 4c705f6bc559886632d3871b04f58aab093bfa2f

branches/beta/src/libcore/num/mod.rs

Lines changed: 15 additions & 11 deletions
Original file line numberDiff line numberDiff line change
@@ -537,21 +537,25 @@ macro_rules! int_impl {
537537
let mut base = self;
538538
let mut acc = Self::one();
539539

540-
while exp > 1 {
540+
let mut prev_base = self;
541+
let mut base_oflo = false;
542+
while exp > 0 {
541543
if (exp & 1) == 1 {
542-
acc = acc * base;
544+
if base_oflo {
545+
// ensure overflow occurs in the same manner it
546+
// would have otherwise (i.e. signal any exception
547+
// it would have otherwise).
548+
acc = acc * (prev_base * prev_base);
549+
} else {
550+
acc = acc * base;
551+
}
543552
}
553+
prev_base = base;
554+
let (new_base, new_base_oflo) = base.overflowing_mul(base);
555+
base = new_base;
556+
base_oflo = new_base_oflo;
544557
exp /= 2;
545-
base = base * base;
546-
}
547-
548-
// Deal with the final bit of the exponent separately, since
549-
// squaring the base afterwards is not necessary and may cause a
550-
// needless overflow.
551-
if exp == 1 {
552-
acc = acc * base;
553558
}
554-
555559
acc
556560
}
557561

branches/beta/src/libstd/net/tcp.rs

Lines changed: 0 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -954,7 +954,6 @@ mod tests {
954954
assert!(kind == ErrorKind::WouldBlock || kind == ErrorKind::TimedOut);
955955
});
956956
assert!(wait > Duration::from_millis(400));
957-
assert!(wait < Duration::from_millis(1600));
958957
}
959958

960959
#[test]
@@ -977,6 +976,5 @@ mod tests {
977976
assert!(kind == ErrorKind::WouldBlock || kind == ErrorKind::TimedOut);
978977
});
979978
assert!(wait > Duration::from_millis(400));
980-
assert!(wait < Duration::from_millis(1600));
981979
}
982980
}

branches/beta/src/libstd/net/udp.rs

Lines changed: 0 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -379,7 +379,6 @@ mod tests {
379379
assert!(kind == ErrorKind::WouldBlock || kind == ErrorKind::TimedOut);
380380
});
381381
assert!(wait > Duration::from_millis(400));
382-
assert!(wait < Duration::from_millis(1600));
383382
}
384383

385384
#[test]
@@ -400,6 +399,5 @@ mod tests {
400399
assert!(kind == ErrorKind::WouldBlock || kind == ErrorKind::TimedOut);
401400
});
402401
assert!(wait > Duration::from_millis(400));
403-
assert!(wait < Duration::from_millis(1600));
404402
}
405403
}

branches/beta/src/test/run-fail/overflowing-pow.rs

Lines changed: 0 additions & 16 deletions
This file was deleted.

0 commit comments

Comments
 (0)