Skip to content

Commit 8a8b6cd

Browse files
author
Cameron Zwarich
committed
---
yaml --- r: 152513 b: refs/heads/try2 c: d2d8fa2 h: refs/heads/master i: 152511: 0724393 v: v3
1 parent 24c3d0e commit 8a8b6cd

File tree

8 files changed

+47
-175
lines changed

8 files changed

+47
-175
lines changed

[refs]

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -5,7 +5,7 @@ refs/heads/snap-stage3: 78a7676898d9f80ab540c6df5d4c9ce35bb50463
55
refs/heads/try: 519addf6277dbafccbb4159db4b710c37eaa2ec5
66
refs/tags/release-0.1: 1f5c5126e96c79d22cb7862f75304136e204f105
77
refs/heads/ndm: f3868061cd7988080c30d6d5bf352a5a5fe2460b
8-
refs/heads/try2: 2c6caad1bab0660ce8b4797c10d5530964d6e8d9
8+
refs/heads/try2: d2d8fa2a0980fc6bf1a842cfff7d77ae9b95185f
99
refs/heads/dist-snap: ba4081a5a8573875fed17545846f6f6902c8ba8d
1010
refs/tags/release-0.2: c870d2dffb391e14efb05aa27898f1f6333a9596
1111
refs/tags/release-0.3: b5f0d0f648d9a6153664837026ba1be43d3e2503

branches/try2/src/libcore/num/int_macros.rs

Lines changed: 0 additions & 27 deletions
Original file line numberDiff line numberDiff line change
@@ -113,33 +113,6 @@ mod tests {
113113
assert!((0b1111001 as $T).count_zeros() == BITS as $T - 5);
114114
}
115115

116-
#[test]
117-
fn test_swap_bytes() {
118-
let n: $T = 0b0101100; assert_eq!(n.swap_bytes().swap_bytes(), n);
119-
let n: $T = 0b0100001; assert_eq!(n.swap_bytes().swap_bytes(), n);
120-
let n: $T = 0b1111001; assert_eq!(n.swap_bytes().swap_bytes(), n);
121-
122-
// Swapping these should make no difference
123-
let n: $T = 0; assert_eq!(n.swap_bytes(), n);
124-
let n: $T = -1; assert_eq!(n.swap_bytes(), n);
125-
}
126-
127-
#[test]
128-
fn test_rotate() {
129-
let n: $T = 0b0101100; assert_eq!(n.rotate_left(6).rotate_right(2).rotate_right(4), n);
130-
let n: $T = 0b0100001; assert_eq!(n.rotate_left(3).rotate_left(2).rotate_right(5), n);
131-
let n: $T = 0b1111001; assert_eq!(n.rotate_left(6).rotate_right(2).rotate_right(4), n);
132-
133-
// Rotating these should make no difference
134-
//
135-
// We test using 124 bits because to ensure that overlong bit shifts do
136-
// not cause undefined behaviour. See #10183.
137-
let n: $T = 0; assert_eq!(n.rotate_left(124), n);
138-
let n: $T = -1; assert_eq!(n.rotate_left(124), n);
139-
let n: $T = 0; assert_eq!(n.rotate_right(124), n);
140-
let n: $T = -1; assert_eq!(n.rotate_right(124), n);
141-
}
142-
143116
#[test]
144117
fn test_signed_checked_div() {
145118
assert!(10i.checked_div(&2) == Some(5));

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

Lines changed: 20 additions & 98 deletions
Original file line numberDiff line numberDiff line change
@@ -436,135 +436,57 @@ pub trait Bitwise: Bounded
436436
/// assert_eq!(n.trailing_zeros(), 3);
437437
/// ```
438438
fn trailing_zeros(&self) -> Self;
439-
440-
/// Reverses the byte order of a binary number.
441-
///
442-
/// # Example
443-
///
444-
/// ```rust
445-
/// use std::num::Bitwise;
446-
///
447-
/// let n = 0x0123456789ABCDEFu64;
448-
/// let m = 0xEFCDAB8967452301u64;
449-
/// assert_eq!(n.swap_bytes(), m);
450-
/// ```
451-
fn swap_bytes(&self) -> Self;
452-
453-
/// Shifts the bits to the left by a specified amount amount, `r`, wrapping
454-
/// the truncated bits to the end of the resulting value.
455-
///
456-
/// # Example
457-
///
458-
/// ```rust
459-
/// use std::num::Bitwise;
460-
///
461-
/// let n = 0x0123456789ABCDEFu64;
462-
/// let m = 0x3456789ABCDEF012u64;
463-
/// assert_eq!(n.rotate_left(12), m);
464-
/// ```
465-
fn rotate_left(&self, r: uint) -> Self;
466-
467-
/// Shifts the bits to the right by a specified amount amount, `r`, wrapping
468-
/// the truncated bits to the beginning of the resulting value.
469-
///
470-
/// # Example
471-
///
472-
/// ```rust
473-
/// use std::num::Bitwise;
474-
///
475-
/// let n = 0x0123456789ABCDEFu64;
476-
/// let m = 0xDEF0123456789ABCu64;
477-
/// assert_eq!(n.rotate_right(12), m);
478-
/// ```
479-
fn rotate_right(&self, r: uint) -> Self;
480439
}
481440

482-
/// Swapping a single byte does nothing. This is unsafe to be consistent with
483-
/// the other `bswap` intrinsics.
484-
#[inline]
485-
unsafe fn bswap8(x: u8) -> u8 { x }
486-
487441
macro_rules! bitwise_impl(
488-
($t:ty, $bits:expr, $co:ident, $lz:ident, $tz:ident, $bs:path) => {
442+
($t:ty, $co:path, $lz:path, $tz:path) => {
489443
impl Bitwise for $t {
490444
#[inline]
491-
fn count_ones(&self) -> $t { unsafe { intrinsics::$co(*self) } }
445+
fn count_ones(&self) -> $t { unsafe { $co(*self) } }
492446

493447
#[inline]
494-
fn leading_zeros(&self) -> $t { unsafe { intrinsics::$lz(*self) } }
448+
fn leading_zeros(&self) -> $t { unsafe { $lz(*self) } }
495449

496450
#[inline]
497-
fn trailing_zeros(&self) -> $t { unsafe { intrinsics::$tz(*self) } }
498-
499-
#[inline]
500-
fn swap_bytes(&self) -> $t { unsafe { $bs(*self) } }
501-
502-
#[inline]
503-
fn rotate_left(&self, r: uint) -> $t {
504-
// Protect against undefined behaviour for overlong bit shifts
505-
let r = r % $bits;
506-
(*self << r) | (*self >> ($bits - r))
507-
}
508-
509-
#[inline]
510-
fn rotate_right(&self, r: uint) -> $t {
511-
// Protect against undefined behaviour for overlong bit shifts
512-
let r = r % $bits;
513-
(*self >> r) | (*self << ($bits - r))
514-
}
451+
fn trailing_zeros(&self) -> $t { unsafe { $tz(*self) } }
515452
}
516453
}
517454
)
518455

519456
macro_rules! bitwise_cast_impl(
520-
($t:ty, $t_cast:ty, $bits:expr, $co:ident, $lz:ident, $tz:ident, $bs:path) => {
457+
($t:ty, $t_cast:ty, $co:path, $lz:path, $tz:path) => {
521458
impl Bitwise for $t {
522459
#[inline]
523-
fn count_ones(&self) -> $t { unsafe { intrinsics::$co(*self as $t_cast) as $t } }
524-
525-
#[inline]
526-
fn leading_zeros(&self) -> $t { unsafe { intrinsics::$lz(*self as $t_cast) as $t } }
527-
528-
#[inline]
529-
fn trailing_zeros(&self) -> $t { unsafe { intrinsics::$tz(*self as $t_cast) as $t } }
460+
fn count_ones(&self) -> $t { unsafe { $co(*self as $t_cast) as $t } }
530461

531462
#[inline]
532-
fn swap_bytes(&self) -> $t { unsafe { $bs(*self as $t_cast) as $t } }
463+
fn leading_zeros(&self) -> $t { unsafe { $lz(*self as $t_cast) as $t } }
533464

534465
#[inline]
535-
fn rotate_left(&self, r: uint) -> $t {
536-
// cast to prevent the sign bit from being corrupted
537-
(*self as $t_cast).rotate_left(r) as $t
538-
}
539-
540-
#[inline]
541-
fn rotate_right(&self, r: uint) -> $t {
542-
// cast to prevent the sign bit from being corrupted
543-
(*self as $t_cast).rotate_right(r) as $t
544-
}
466+
fn trailing_zeros(&self) -> $t { unsafe { $tz(*self as $t_cast) as $t } }
545467
}
546468
}
547469
)
548470

549471
#[cfg(target_word_size = "32")]
550-
bitwise_cast_impl!(uint, u32, 32, ctpop32, ctlz32, cttz32, intrinsics::bswap32)
472+
bitwise_cast_impl!(uint, u32, intrinsics::ctpop32, intrinsics::ctlz32, intrinsics::cttz32)
551473
#[cfg(target_word_size = "64")]
552-
bitwise_cast_impl!(uint, u64, 64, ctpop64, ctlz64, cttz64, intrinsics::bswap64)
474+
bitwise_cast_impl!(uint, u64, intrinsics::ctpop64, intrinsics::ctlz64, intrinsics::cttz64)
553475

554-
bitwise_impl!(u8, 8, ctpop8, ctlz8, cttz8, bswap8)
555-
bitwise_impl!(u16, 16, ctpop16, ctlz16, cttz16, intrinsics::bswap16)
556-
bitwise_impl!(u32, 32, ctpop32, ctlz32, cttz32, intrinsics::bswap32)
557-
bitwise_impl!(u64, 64, ctpop64, ctlz64, cttz64, intrinsics::bswap64)
476+
bitwise_impl!(u8, intrinsics::ctpop8, intrinsics::ctlz8, intrinsics::cttz8)
477+
bitwise_impl!(u16, intrinsics::ctpop16, intrinsics::ctlz16, intrinsics::cttz16)
478+
bitwise_impl!(u32, intrinsics::ctpop32, intrinsics::ctlz32, intrinsics::cttz32)
479+
bitwise_impl!(u64, intrinsics::ctpop64, intrinsics::ctlz64, intrinsics::cttz64)
558480

559481
#[cfg(target_word_size = "32")]
560-
bitwise_cast_impl!(int, u32, 32, ctpop32, ctlz32, cttz32, intrinsics::bswap32)
482+
bitwise_cast_impl!(int, u32, intrinsics::ctpop32, intrinsics::ctlz32, intrinsics::cttz32)
561483
#[cfg(target_word_size = "64")]
562-
bitwise_cast_impl!(int, u64, 64, ctpop64, ctlz64, cttz64, intrinsics::bswap64)
484+
bitwise_cast_impl!(int, u64, intrinsics::ctpop64, intrinsics::ctlz64, intrinsics::cttz64)
563485

564-
bitwise_cast_impl!(i8, u8, 8, ctpop8, ctlz8, cttz8, bswap8)
565-
bitwise_cast_impl!(i16, u16, 16, ctpop16, ctlz16, cttz16, intrinsics::bswap16)
566-
bitwise_cast_impl!(i32, u32, 32, ctpop32, ctlz32, cttz32, intrinsics::bswap32)
567-
bitwise_cast_impl!(i64, u64, 64, ctpop64, ctlz64, cttz64, intrinsics::bswap64)
486+
bitwise_cast_impl!(i8, u8, intrinsics::ctpop8, intrinsics::ctlz8, intrinsics::cttz8)
487+
bitwise_cast_impl!(i16, u16, intrinsics::ctpop16, intrinsics::ctlz16, intrinsics::cttz16)
488+
bitwise_cast_impl!(i32, u32, intrinsics::ctpop32, intrinsics::ctlz32, intrinsics::cttz32)
489+
bitwise_cast_impl!(i64, u64, intrinsics::ctpop64, intrinsics::ctlz64, intrinsics::cttz64)
568490

569491
/// Specifies the available operations common to all of Rust's core numeric primitives.
570492
/// These may not always make sense from a purely mathematical point of view, but

branches/try2/src/libcore/num/uint_macros.rs

Lines changed: 0 additions & 27 deletions
Original file line numberDiff line numberDiff line change
@@ -64,33 +64,6 @@ mod tests {
6464
assert!((0b1111001 as $T).count_zeros() == BITS as $T - 5);
6565
}
6666

67-
#[test]
68-
fn test_swap_bytes() {
69-
let n: $T = 0b0101100; assert_eq!(n.swap_bytes().swap_bytes(), n);
70-
let n: $T = 0b0100001; assert_eq!(n.swap_bytes().swap_bytes(), n);
71-
let n: $T = 0b1111001; assert_eq!(n.swap_bytes().swap_bytes(), n);
72-
73-
// Swapping these should make no difference
74-
let n: $T = 0; assert_eq!(n.swap_bytes(), n);
75-
let n: $T = MAX; assert_eq!(n.swap_bytes(), n);
76-
}
77-
78-
#[test]
79-
fn test_rotate() {
80-
let n: $T = 0b0101100; assert_eq!(n.rotate_left(6).rotate_right(2).rotate_right(4), n);
81-
let n: $T = 0b0100001; assert_eq!(n.rotate_left(3).rotate_left(2).rotate_right(5), n);
82-
let n: $T = 0b1111001; assert_eq!(n.rotate_left(6).rotate_right(2).rotate_right(4), n);
83-
84-
// Rotating these should make no difference
85-
//
86-
// We test using 124 bits because to ensure that overlong bit shifts do
87-
// not cause undefined behaviour. See #10183.
88-
let n: $T = 0; assert_eq!(n.rotate_left(124), n);
89-
let n: $T = MAX; assert_eq!(n.rotate_left(124), n);
90-
let n: $T = 0; assert_eq!(n.rotate_right(124), n);
91-
let n: $T = MAX; assert_eq!(n.rotate_right(124), n);
92-
}
93-
9467
#[test]
9568
fn test_unsigned_checked_div() {
9669
assert!(10u.checked_div(&2) == Some(5));

branches/try2/src/librustc/middle/borrowck/check_loans.rs

Lines changed: 20 additions & 13 deletions
Original file line numberDiff line numberDiff line change
@@ -874,23 +874,30 @@ impl<'a> CheckLoanCtxt<'a> {
874874
// We must check every element of a move path. See
875875
// `borrowck-move-subcomponent.rs` for a test case.
876876

877-
// check for a conflicting loan:
878877
let mut ret = MoveOk;
879-
self.each_in_scope_restriction(expr_id, move_path, |loan, _| {
880-
// Any restriction prevents moves.
881-
ret = MoveWhileBorrowed(loan.loan_path.clone(), loan.span);
882-
false
883-
});
878+
let mut loan_path = move_path;
879+
loop {
880+
// check for a conflicting loan:
881+
self.each_in_scope_restriction(expr_id, loan_path, |loan, _| {
882+
// Any restriction prevents moves.
883+
ret = MoveWhileBorrowed(loan.loan_path.clone(), loan.span);
884+
false
885+
});
884886

885-
if ret != MoveOk {
886-
return ret
887-
}
887+
if ret != MoveOk {
888+
return ret
889+
}
888890

889-
match *move_path {
890-
LpVar(_) => MoveOk,
891-
LpExtend(ref subpath, _, _) => {
892-
self.analyze_move_out_from(expr_id, &**subpath)
891+
match *loan_path {
892+
LpVar(_) => {
893+
ret = MoveOk;
894+
break;
895+
}
896+
LpExtend(ref lp_base, _, _) => {
897+
loan_path = &**lp_base;
898+
}
893899
}
894900
}
901+
ret
895902
}
896903
}

branches/try2/src/librustdoc/html/render.rs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -2001,7 +2001,7 @@ impl<'a> fmt::Show for Sidebar<'a> {
20012001
let class = if cur.name.get_ref() == item &&
20022002
short == curty { "current" } else { "" };
20032003
try!(write!(w, "<a class='{ty} {class}' href='{href}{path}'>\
2004-
{name}</a>",
2004+
{name}</a><br/>",
20052005
ty = short,
20062006
class = class,
20072007
href = if curty == "mod" {"../"} else {""},

branches/try2/src/librustdoc/html/static/main.css

Lines changed: 4 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -154,29 +154,25 @@ nav.sub {
154154

155155
.block {
156156
padding: 0 10px;
157-
margin-bottom: 14px;
157+
margin-bottom: 10px;
158158
}
159159
.block h2 {
160160
margin-top: 0;
161-
margin-bottom: 8px;
162161
text-align: center;
163162
}
164163

165164
.block a {
166-
display: block;
165+
display: inline-block;
167166
text-overflow: ellipsis;
168167
overflow: hidden;
169168
line-height: 15px;
170-
padding: 7px 5px;
169+
padding-left: 5px;
170+
padding-bottom: 6px;
171171
font-size: 14px;
172172
font-weight: 300;
173173
transition: border 500ms ease-out;
174174
}
175175

176-
.block a:hover {
177-
background: #F5F5F5;
178-
}
179-
180176
.content {
181177
padding: 15px 0;
182178
}

branches/try2/src/librustdoc/html/static/main.js

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -647,6 +647,7 @@
647647
}
648648
div.append($('<a>', {'href': '../' + crates[i] + '/index.html',
649649
'class': klass}).text(crates[i]));
650+
div.append($('<br>'));
650651
}
651652
sidebar.append(div);
652653
}

0 commit comments

Comments
 (0)