Skip to content

Commit 1e7afa5

Browse files
committed
---
yaml --- r: 140012 b: refs/heads/try2 c: 276293a h: refs/heads/master v: v3
1 parent dad9e54 commit 1e7afa5

Some content is hidden

Large Commits have some content hidden by default. Use the searchbox below for content that may be hidden.

109 files changed

+577
-1159
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: aba93c6b60a91fc4b6b60408e51b23dbee5f44c9
8+
refs/heads/try2: 276293af7c0fb901c8344e88562ce635f26f47a9
99
refs/heads/dist-snap: ba4081a5a8573875fed17545846f6f6902c8ba8d
1010
refs/tags/release-0.2: c870d2dffb391e14efb05aa27898f1f6333a9596
1111
refs/tags/release-0.3: b5f0d0f648d9a6153664837026ba1be43d3e2503

branches/try2/doc/rust.md

Lines changed: 8 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -1467,10 +1467,10 @@ A complete list of the built-in language items follows:
14671467
: Elements can be subtracted.
14681468
`mul`
14691469
: Elements can be multiplied.
1470-
`quot`
1471-
: Elements have a quotient operation.
1472-
`rem`
1473-
: Elements have a remainder operation.
1470+
`div`
1471+
: Elements can be divided.
1472+
`mod`
1473+
: Elements have a modulo operation.
14741474
`neg`
14751475
: Elements can be negated arithmetically.
14761476
`not`
@@ -1856,11 +1856,11 @@ The default meaning of the operators on standard types is given here.
18561856
: Multiplication.
18571857
Calls the `mul` method on the `core::ops::Mul` trait.
18581858
`/`
1859-
: Quotient.
1860-
Calls the `quot` method on the `core::ops::Quot` trait.
1859+
: Division.
1860+
Calls the `div` method on the `core::ops::Div` trait.
18611861
`%`
1862-
: Remainder.
1863-
Calls the `rem` method on the `core::ops::Rem` trait.
1862+
: Modulo (a.k.a. "remainder").
1863+
Calls the `modulo` method on the `core::ops::Modulo` trait.
18641864

18651865
#### Bitwise operators
18661866

branches/try2/doc/tutorial.md

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -362,7 +362,7 @@ The nil type, written `()`, has a single value, also written `()`.
362362
## Operators
363363

364364
Rust's set of operators contains very few surprises. Arithmetic is done with
365-
`*`, `/`, `%`, `+`, and `-` (multiply, quotient, remainder, add, and subtract). `-` is
365+
`*`, `/`, `%`, `+`, and `-` (multiply, divide, take remainder, add, and subtract). `-` is
366366
also a unary prefix operator that negates numbers. As in C, the bitwise operators
367367
`>>`, `<<`, `&`, `|`, and `^` are also supported.
368368

branches/try2/src/etc/kate/rust.xml

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -57,8 +57,8 @@
5757
<item> Add </item>
5858
<item> Sub </item>
5959
<item> Mul </item>
60-
<item> Quot </item>
61-
<item> Rem </item>
60+
<item> Div </item>
61+
<item> Modulo </item>
6262
<item> Neg </item>
6363
<item> BitAnd </item>
6464
<item> BitOr </item>

branches/try2/src/etc/vim/syntax/rust.vim

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -46,7 +46,7 @@ syn keyword rustType off_t dev_t ino_t pid_t mode_t ssize_t
4646

4747
syn keyword rustTrait Const Copy Send Owned " inherent traits
4848
syn keyword rustTrait Eq Ord Num Ptr
49-
syn keyword rustTrait Drop Add Sub Mul Quot Rem Neg BitAnd BitOr
49+
syn keyword rustTrait Drop Add Sub Mul Div Modulo Neg BitAnd BitOr
5050
syn keyword rustTrait BitXor Shl Shr Index
5151

5252
syn keyword rustSelf self

branches/try2/src/libcore/at_vec.rs

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -41,7 +41,7 @@ pub mod rustrt {
4141
pub fn capacity<T>(v: @[T]) -> uint {
4242
unsafe {
4343
let repr: **raw::VecRepr =
44-
::cast::transmute(addr_of(&v));
44+
::cast::reinterpret_cast(&addr_of(&v));
4545
(**repr).unboxed.alloc / sys::size_of::<T>()
4646
}
4747
}
@@ -208,7 +208,7 @@ pub mod raw {
208208
*/
209209
#[inline(always)]
210210
pub unsafe fn set_len<T>(v: @[T], new_len: uint) {
211-
let repr: **mut VecRepr = ::cast::transmute(addr_of(&v));
211+
let repr: **mut VecRepr = ::cast::reinterpret_cast(&addr_of(&v));
212212
(**repr).unboxed.fill = new_len * sys::size_of::<T>();
213213
}
214214

@@ -226,7 +226,7 @@ pub mod raw {
226226

227227
#[inline(always)] // really pretty please
228228
pub unsafe fn push_fast<T>(v: &mut @[T], initval: T) {
229-
let repr: **mut VecRepr = ::cast::transmute(v);
229+
let repr: **mut VecRepr = ::cast::reinterpret_cast(&v);
230230
let fill = (**repr).unboxed.fill;
231231
(**repr).unboxed.fill += sys::size_of::<T>();
232232
let p = addr_of(&((**repr).unboxed.data));
@@ -322,4 +322,4 @@ mod test {
322322
assert!(from_slice([@"abc", @"123"]) == @[@"abc", @"123"]);
323323
assert!(from_slice([@[42]]) == @[@[42]]);
324324
}
325-
}
325+
}

branches/try2/src/libcore/cell.rs

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -20,7 +20,7 @@ Similar to a mutable option type, but friendlier.
2020
*/
2121

2222
pub struct Cell<T> {
23-
priv value: Option<T>
23+
value: Option<T>
2424
}
2525

2626
impl<T:cmp::Eq> cmp::Eq for Cell<T> {
@@ -121,7 +121,7 @@ fn test_with_ref() {
121121
#[test]
122122
fn test_with_mut_ref() {
123123
let good = ~[1, 2, 3];
124-
let v = ~[1, 2];
124+
let mut v = ~[1, 2];
125125
let c = Cell(v);
126126
do c.with_mut_ref() |v| { v.push(3); }
127127
let v = c.take();

branches/try2/src/libcore/char.rs

Lines changed: 16 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,4 @@
1-
// Copyright 2012 The Rust Project Developers. See the COPYRIGHT
1+
// Copyright 2012-2013 The Rust Project Developers. See the COPYRIGHT
22
// file at the top-level directory of this distribution and at
33
// http://rust-lang.org/COPYRIGHT.
44
//
@@ -234,6 +234,21 @@ pub fn escape_default(c: char) -> ~str {
234234
}
235235
}
236236

237+
/// Returns the amount of bytes this character would need if encoded in utf8
238+
pub fn len_utf8_bytes(c: char) -> uint {
239+
static max_one_b: uint = 128u;
240+
static max_two_b: uint = 2048u;
241+
static max_three_b: uint = 65536u;
242+
static max_four_b: uint = 2097152u;
243+
244+
let code = c as uint;
245+
if code < max_one_b { 1u }
246+
else if code < max_two_b { 2u }
247+
else if code < max_three_b { 3u }
248+
else if code < max_four_b { 4u }
249+
else { fail!(~"invalid character!") }
250+
}
251+
237252
/**
238253
* Compare two chars
239254
*
@@ -334,7 +349,6 @@ fn test_escape_default() {
334349
assert_eq!(escape_default('\U0001d4b6'), ~"\\U0001d4b6");
335350
}
336351
337-
338352
#[test]
339353
fn test_escape_unicode() {
340354
assert_eq!(escape_unicode('\x00'), ~"\\x00");

branches/try2/src/libcore/core.rc

Lines changed: 0 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -75,12 +75,7 @@ they contained the following prologue:
7575

7676
pub use kinds::{Const, Copy, Owned, Durable};
7777
pub use ops::{Drop};
78-
#[cfg(stage0)]
7978
pub use ops::{Add, Sub, Mul, Div, Modulo, Neg, Not};
80-
#[cfg(stage1)]
81-
#[cfg(stage2)]
82-
#[cfg(stage3)]
83-
pub use ops::{Add, Sub, Mul, Quot, Rem, Neg, Not};
8479
pub use ops::{BitAnd, BitOr, BitXor};
8580
pub use ops::{Shl, Shr, Index};
8681

branches/try2/src/libcore/flate.rs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -67,7 +67,7 @@ pub fn deflate_bytes(bytes: &const [u8]) -> ~[u8] {
6767
pub fn inflate_bytes(bytes: &const [u8]) -> ~[u8] {
6868
do vec::as_const_buf(bytes) |b, len| {
6969
unsafe {
70-
let outsz : size_t = 0;
70+
let mut outsz : size_t = 0;
7171
let res =
7272
rustrt::tinfl_decompress_mem_to_heap(b as *c_void,
7373
len as size_t,

branches/try2/src/libcore/gc.rs

Lines changed: 9 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -73,19 +73,18 @@ pub mod rustrt {
7373
pub unsafe fn rust_gc_metadata() -> *Word;
7474

7575
pub unsafe fn rust_get_stack_segment() -> *StackSegment;
76-
pub unsafe fn rust_get_c_stack() -> *StackSegment;
7776
}
7877
}
7978

8079
unsafe fn bump<T, U>(ptr: *T, count: uint) -> *U {
81-
return cast::transmute(ptr::offset(ptr, count));
80+
return cast::reinterpret_cast(&ptr::offset(ptr, count));
8281
}
8382

8483
unsafe fn align_to_pointer<T>(ptr: *T) -> *T {
8584
let align = sys::min_align_of::<*T>();
86-
let ptr: uint = cast::transmute(ptr);
85+
let ptr: uint = cast::reinterpret_cast(&ptr);
8786
let ptr = (ptr + (align - 1)) & -align;
88-
return cast::transmute(ptr);
87+
return cast::reinterpret_cast(&ptr);
8988
}
9089

9190
unsafe fn get_safe_point_count() -> uint {
@@ -130,8 +129,8 @@ type Visitor<'self> = &'self fn(root: **Word, tydesc: *Word) -> bool;
130129
// Walks the list of roots for the given safe point, and calls visitor
131130
// on each root.
132131
unsafe fn walk_safe_point(fp: *Word, sp: SafePoint, visitor: Visitor) {
133-
let fp_bytes: *u8 = cast::transmute(fp);
134-
let sp_meta: *u32 = cast::transmute(sp.sp_meta);
132+
let fp_bytes: *u8 = cast::reinterpret_cast(&fp);
133+
let sp_meta: *u32 = cast::reinterpret_cast(&sp.sp_meta);
135134

136135
let num_stack_roots = *sp_meta as uint;
137136
let num_reg_roots = *ptr::offset(sp_meta, 1) as uint;
@@ -172,9 +171,9 @@ unsafe fn walk_safe_point(fp: *Word, sp: SafePoint, visitor: Visitor) {
172171

173172
// Is fp contained in segment?
174173
unsafe fn is_frame_in_segment(fp: *Word, segment: *StackSegment) -> bool {
175-
let begin: Word = cast::transmute(segment);
176-
let end: Word = cast::transmute((*segment).end);
177-
let frame: Word = cast::transmute(fp);
174+
let begin: Word = cast::reinterpret_cast(&segment);
175+
let end: Word = cast::reinterpret_cast(&(*segment).end);
176+
let frame: Word = cast::reinterpret_cast(&fp);
178177

179178
return begin <= frame && frame <= end;
180179
}
@@ -340,7 +339,7 @@ pub fn cleanup_stack_for_failure() {
340339
// own stack roots on the stack anyway.
341340
let sentinel_box = ~0;
342341
let sentinel: **Word = if expect_sentinel() {
343-
cast::transmute(ptr::addr_of(&sentinel_box))
342+
cast::reinterpret_cast(&ptr::addr_of(&sentinel_box))
344343
} else {
345344
ptr::null()
346345
};

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

Lines changed: 18 additions & 31 deletions
Original file line numberDiff line numberDiff line change
@@ -16,13 +16,8 @@ use option::Option;
1616
use from_str;
1717
use to_str;
1818

19-
#[cfg(notest)] use cmp::{Eq, Ord};
20-
#[cfg(stage0,notest)]
21-
use ops::{Add, Sub, Mul, Div, Modulo, Neg};
22-
#[cfg(stage1,notest)]
23-
#[cfg(stage2,notest)]
24-
#[cfg(stage3,notest)]
25-
use ops::{Add, Sub, Mul, Quot, Rem, Neg};
19+
#[cfg(notest)] use cmp;
20+
#[cfg(notest)] use ops;
2621

2722
pub use cmath::c_float_targ_consts::*;
2823

@@ -136,7 +131,7 @@ pub fn sub(x: f32, y: f32) -> f32 { return x - y; }
136131
pub fn mul(x: f32, y: f32) -> f32 { return x * y; }
137132

138133
#[inline(always)]
139-
pub fn quot(x: f32, y: f32) -> f32 { return x / y; }
134+
pub fn div(x: f32, y: f32) -> f32 { return x / y; }
140135

141136
#[inline(always)]
142137
pub fn rem(x: f32, y: f32) -> f32 { return x % y; }
@@ -270,15 +265,15 @@ pub fn logarithm(n: f32, b: f32) -> f32 {
270265
}
271266

272267
#[cfg(notest)]
273-
impl Eq for f32 {
268+
impl cmp::Eq for f32 {
274269
#[inline(always)]
275270
fn eq(&self, other: &f32) -> bool { (*self) == (*other) }
276271
#[inline(always)]
277272
fn ne(&self, other: &f32) -> bool { (*self) != (*other) }
278273
}
279274

280275
#[cfg(notest)]
281-
impl Ord for f32 {
276+
impl cmp::Ord for f32 {
282277
#[inline(always)]
283278
fn lt(&self, other: &f32) -> bool { (*self) < (*other) }
284279
#[inline(always)]
@@ -300,41 +295,33 @@ impl num::One for f32 {
300295
}
301296

302297
#[cfg(notest)]
303-
impl Add<f32,f32> for f32 {
298+
impl ops::Add<f32,f32> for f32 {
299+
#[inline(always)]
304300
fn add(&self, other: &f32) -> f32 { *self + *other }
305301
}
306302
#[cfg(notest)]
307-
impl Sub<f32,f32> for f32 {
303+
impl ops::Sub<f32,f32> for f32 {
304+
#[inline(always)]
308305
fn sub(&self, other: &f32) -> f32 { *self - *other }
309306
}
310307
#[cfg(notest)]
311-
impl Mul<f32,f32> for f32 {
308+
impl ops::Mul<f32,f32> for f32 {
309+
#[inline(always)]
312310
fn mul(&self, other: &f32) -> f32 { *self * *other }
313311
}
314-
#[cfg(stage0,notest)]
315-
impl Div<f32,f32> for f32 {
312+
#[cfg(notest)]
313+
impl ops::Div<f32,f32> for f32 {
314+
#[inline(always)]
316315
fn div(&self, other: &f32) -> f32 { *self / *other }
317316
}
318-
#[cfg(stage1,notest)]
319-
#[cfg(stage2,notest)]
320-
#[cfg(stage3,notest)]
321-
impl Quot<f32,f32> for f32 {
317+
#[cfg(notest)]
318+
impl ops::Modulo<f32,f32> for f32 {
322319
#[inline(always)]
323-
fn quot(&self, other: &f32) -> f32 { *self / *other }
324-
}
325-
#[cfg(stage0,notest)]
326-
impl Modulo<f32,f32> for f32 {
327320
fn modulo(&self, other: &f32) -> f32 { *self % *other }
328321
}
329-
#[cfg(stage1,notest)]
330-
#[cfg(stage2,notest)]
331-
#[cfg(stage3,notest)]
332-
impl Rem<f32,f32> for f32 {
333-
#[inline(always)]
334-
fn rem(&self, other: &f32) -> f32 { *self % *other }
335-
}
336322
#[cfg(notest)]
337-
impl Neg<f32> for f32 {
323+
impl ops::Neg<f32> for f32 {
324+
#[inline(always)]
338325
fn neg(&self) -> f32 { -*self }
339326
}
340327

0 commit comments

Comments
 (0)