Skip to content

Commit 3d626a3

Browse files
committed
---
yaml --- r: 56742 b: refs/heads/try c: 3136fba h: refs/heads/master v: v3
1 parent 17fc15e commit 3d626a3

File tree

23 files changed

+139
-227
lines changed

23 files changed

+139
-227
lines changed

[refs]

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -2,7 +2,7 @@
22
refs/heads/master: c081ffbd1e845687202a975ea2e698b623e5722f
33
refs/heads/snap-stage1: e33de59e47c5076a89eadeb38f4934f58a3618a6
44
refs/heads/snap-stage3: 79a2b2eafc3c766cecec8a5f76317693bae9ed17
5-
refs/heads/try: 1968130885985dcf10ca19157d2e90c11566ae5c
5+
refs/heads/try: 3136fba5aeca9184c944829596b93e45886fecf2
66
refs/tags/release-0.1: 1f5c5126e96c79d22cb7862f75304136e204f105
77
refs/heads/ndm: f3868061cd7988080c30d6d5bf352a5a5fe2460b
88
refs/heads/try2: 147ecfdd8221e4a4d4e090486829a06da1e0ca3c

branches/try/doc/tutorial.md

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -2320,7 +2320,7 @@ impl Shape for CircleStruct {
23202320
Notice that methods of `Circle` can call methods on `Shape`, as our
23212321
`radius` implementation calls the `area` method.
23222322
This is a silly way to compute the radius of a circle
2323-
(since we could just return the `radius` field), but you get the idea.
2323+
(since we could just return the `circle` field), but you get the idea.
23242324

23252325
In type-parameterized functions,
23262326
methods of the supertrait may be called on values of subtrait-bound type parameters.

branches/try/man/rustc.1

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -170,5 +170,5 @@ See \fBAUTHORS.txt\fR in the rust source distribution. Graydon Hoare
170170
<\fI[email protected]\fR> is the project leader.
171171

172172
.SH "COPYRIGHT"
173-
This work is dual-licensed under Apache 2.0 and MIT terms. See \fBCOPYRIGHT\fR
174-
file in the rust source distribution.
173+
This work is licensed under MIT-like terms. See \fBLICENSE.txt\fR
174+
in the rust source distribution.

branches/try/mk/dist.mk

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -18,7 +18,6 @@ PKG_FILES := \
1818
$(S)COPYRIGHT \
1919
$(S)LICENSE-APACHE \
2020
$(S)LICENSE-MIT \
21-
$(S)AUTHORS.txt \
2221
$(S)README.md \
2322
$(S)configure $(S)Makefile.in \
2423
$(S)man \

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

Lines changed: 2 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -110,11 +110,8 @@ syn match rustFloat display "\<[0-9][0-9_]*\.[0-9_]\+\%([eE][+-]\=[0-9
110110
syn match rustLifetime display "\'\%([^[:cntrl:][:space:][:punct:][:digit:]]\|_\)\%([^[:cntrl:][:punct:][:space:]]\|_\)*"
111111
syn match rustCharacter "'\([^'\\]\|\\\(['nrt\\\"]\|x\x\{2}\|u\x\{4}\|U\x\{8}\)\)'"
112112

113-
syn region rustCommentDoc start="/\*\*" end="\*/"
114-
syn region rustCommentDoc start="///" skip="\\$" end="$" keepend
115-
syn match rustComment "/\*\*/"
116-
syn region rustComment start="/\*\([^\*]\|$\)" end="\*/" contains=rustTodo
117-
syn region rustComment start="//\([^/]\|$\)" skip="\\$" end="$" contains=rustTodo keepend
113+
syn region rustComment start="/\*" end="\*/" contains=rustComment,rustTodo
114+
syn region rustComment start="//" skip="\\$" end="$" contains=rustTodo keepend
118115

119116
syn keyword rustTodo contained TODO FIXME XXX NB
120117

@@ -137,7 +134,6 @@ hi def link rustConditional Conditional
137134
hi def link rustIdentifier Identifier
138135
hi def link rustModPath Include
139136
hi def link rustFuncName Function
140-
hi def link rustCommentDoc SpecialComment
141137
hi def link rustComment Comment
142138
hi def link rustMacro Macro
143139
hi def link rustType Type

branches/try/src/libcore/clone.rs

Lines changed: 11 additions & 19 deletions
Original file line numberDiff line numberDiff line change
@@ -14,7 +14,7 @@ In Rust, some simple types are "implicitly copyable" and when you
1414
assign them or pass them as arguments, the receiver will get a copy,
1515
leaving the original value in place. These types do not require
1616
allocation to copy and do not have finalizers (i.e. they do not
17-
contain owned boxes or implement `Drop`), so the compiler considers
17+
contain owned pointers or implement `Drop`), so the compiler considers
1818
them cheap and safe to copy and automatically implements the `Copy`
1919
trait for them. For other types copies must be made explicitly,
2020
by convention implementing the `Clone` trait and calling the
@@ -23,38 +23,32 @@ by convention implementing the `Clone` trait and calling the
2323
*/
2424

2525
pub trait Clone {
26-
/// Return a deep copy of the owned object tree. Managed boxes are cloned with a shallow copy.
2726
fn clone(&self) -> Self;
2827
}
2928

3029
impl Clone for () {
31-
/// Return a copy of the value.
3230
#[inline(always)]
3331
fn clone(&self) -> () { () }
3432
}
3533

3634
impl<T:Clone> Clone for ~T {
37-
/// Return a deep copy of the owned box.
3835
#[inline(always)]
3936
fn clone(&self) -> ~T { ~(**self).clone() }
4037
}
4138

42-
impl<T> Clone for @T {
43-
/// Return a shallow copy of the managed box.
39+
impl<T:Clone> Clone for @T {
4440
#[inline(always)]
45-
fn clone(&self) -> @T { *self }
41+
fn clone(&self) -> @T { @(**self).clone() }
4642
}
4743

48-
impl<T> Clone for @mut T {
49-
/// Return a shallow copy of the managed box.
44+
impl<T:Clone> Clone for @mut T {
5045
#[inline(always)]
51-
fn clone(&self) -> @mut T { *self }
46+
fn clone(&self) -> @mut T { @mut (**self).clone() }
5247
}
5348

5449
macro_rules! clone_impl(
5550
($t:ty) => {
5651
impl Clone for $t {
57-
/// Return a copy of the value.
5852
#[inline(always)]
5953
fn clone(&self) -> $t { *self }
6054
}
@@ -82,23 +76,21 @@ clone_impl!(char)
8276

8377
#[test]
8478
fn test_owned_clone() {
85-
let a: ~int = ~5i;
86-
let b: ~int = a.clone();
79+
let a : ~int = ~5i;
80+
let b : ~int = a.clone();
8781
assert!(a == b);
8882
}
8983

9084
#[test]
9185
fn test_managed_clone() {
92-
let a: @int = @5i;
93-
let b: @int = a.clone();
86+
let a : @int = @5i;
87+
let b : @int = a.clone();
9488
assert!(a == b);
9589
}
9690

9791
#[test]
9892
fn test_managed_mut_clone() {
99-
let a: @mut int = @mut 5i;
100-
let b: @mut int = a.clone();
101-
assert!(a == b);
102-
*b = 10;
93+
let a : @int = @5i;
94+
let b : @int = a.clone();
10395
assert!(a == b);
10496
}

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

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -507,7 +507,7 @@ impl num::ToStrRadix for f32 {
507507
#[inline(always)]
508508
pub fn from_str(num: &str) -> Option<f32> {
509509
strconv::from_str_common(num, 10u, true, true, true,
510-
strconv::ExpDec, false, false)
510+
strconv::ExpDec, false)
511511
}
512512

513513
/**
@@ -540,7 +540,7 @@ pub fn from_str(num: &str) -> Option<f32> {
540540
#[inline(always)]
541541
pub fn from_str_hex(num: &str) -> Option<f32> {
542542
strconv::from_str_common(num, 16u, true, true, true,
543-
strconv::ExpBin, false, false)
543+
strconv::ExpBin, false)
544544
}
545545

546546
/**
@@ -565,7 +565,7 @@ pub fn from_str_hex(num: &str) -> Option<f32> {
565565
#[inline(always)]
566566
pub fn from_str_radix(num: &str, rdx: uint) -> Option<f32> {
567567
strconv::from_str_common(num, rdx, true, true, false,
568-
strconv::ExpNone, false, false)
568+
strconv::ExpNone, false)
569569
}
570570

571571
impl from_str::FromStr for f32 {

branches/try/src/libcore/num/f64.rs

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -529,7 +529,7 @@ impl num::ToStrRadix for f64 {
529529
#[inline(always)]
530530
pub fn from_str(num: &str) -> Option<f64> {
531531
strconv::from_str_common(num, 10u, true, true, true,
532-
strconv::ExpDec, false, false)
532+
strconv::ExpDec, false)
533533
}
534534

535535
/**
@@ -562,7 +562,7 @@ pub fn from_str(num: &str) -> Option<f64> {
562562
#[inline(always)]
563563
pub fn from_str_hex(num: &str) -> Option<f64> {
564564
strconv::from_str_common(num, 16u, true, true, true,
565-
strconv::ExpBin, false, false)
565+
strconv::ExpBin, false)
566566
}
567567

568568
/**
@@ -587,7 +587,7 @@ pub fn from_str_hex(num: &str) -> Option<f64> {
587587
#[inline(always)]
588588
pub fn from_str_radix(num: &str, rdx: uint) -> Option<f64> {
589589
strconv::from_str_common(num, rdx, true, true, false,
590-
strconv::ExpNone, false, false)
590+
strconv::ExpNone, false)
591591
}
592592

593593
impl from_str::FromStr for f64 {

branches/try/src/libcore/num/float.rs

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -242,7 +242,7 @@ impl num::ToStrRadix for float {
242242
#[inline(always)]
243243
pub fn from_str(num: &str) -> Option<float> {
244244
strconv::from_str_common(num, 10u, true, true, true,
245-
strconv::ExpDec, false, false)
245+
strconv::ExpDec, false)
246246
}
247247
248248
/**
@@ -275,7 +275,7 @@ pub fn from_str(num: &str) -> Option<float> {
275275
#[inline(always)]
276276
pub fn from_str_hex(num: &str) -> Option<float> {
277277
strconv::from_str_common(num, 16u, true, true, true,
278-
strconv::ExpBin, false, false)
278+
strconv::ExpBin, false)
279279
}
280280
281281
/**
@@ -300,7 +300,7 @@ pub fn from_str_hex(num: &str) -> Option<float> {
300300
#[inline(always)]
301301
pub fn from_str_radix(num: &str, radix: uint) -> Option<float> {
302302
strconv::from_str_common(num, radix, true, true, false,
303-
strconv::ExpNone, false, false)
303+
strconv::ExpNone, false)
304304
}
305305
306306
impl from_str::FromStr for float {

branches/try/src/libcore/num/int-template.rs

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -202,21 +202,21 @@ impl ops::Neg<T> for T {
202202
#[inline(always)]
203203
pub fn from_str(s: &str) -> Option<T> {
204204
strconv::from_str_common(s, 10u, true, false, false,
205-
strconv::ExpNone, false, false)
205+
strconv::ExpNone, false)
206206
}
207207
208208
/// Parse a string as a number in the given base.
209209
#[inline(always)]
210210
pub fn from_str_radix(s: &str, radix: uint) -> Option<T> {
211211
strconv::from_str_common(s, radix, true, false, false,
212-
strconv::ExpNone, false, false)
212+
strconv::ExpNone, false)
213213
}
214214
215215
/// Parse a byte slice as a number in the given base.
216216
#[inline(always)]
217217
pub fn parse_bytes(buf: &[u8], radix: uint) -> Option<T> {
218218
strconv::from_str_bytes_common(buf, radix, true, false, false,
219-
strconv::ExpNone, false, false)
219+
strconv::ExpNone, false)
220220
}
221221
222222
impl FromStr for T {

branches/try/src/libcore/num/strconv.rs

Lines changed: 13 additions & 52 deletions
Original file line numberDiff line numberDiff line change
@@ -429,8 +429,6 @@ priv static DIGIT_E_RADIX: uint = ('e' as uint) - ('a' as uint) + 11u;
429429
* `FFp128`. The exponent string itself is always base 10.
430430
* Can conflict with `radix`, see Failure.
431431
* - `empty_zero` - Whether to accept a empty `buf` as a 0 or not.
432-
* - `ignore_underscores` - Whether all underscores within the string should
433-
* be ignored.
434432
*
435433
* # Return value
436434
* Returns `Some(n)` if `buf` parses to a number n without overflowing, and
@@ -445,13 +443,16 @@ priv static DIGIT_E_RADIX: uint = ('e' as uint) - ('a' as uint) + 11u;
445443
* between digit and exponent sign `'p'`.
446444
* - Fails if `radix` > 18 and `special == true` due to conflict
447445
* between digit and lowest first character in `inf` and `NaN`, the `'i'`.
446+
*
447+
* # Possible improvements
448+
* - Could accept option to allow ignoring underscores, allowing for numbers
449+
* formated like `FF_AE_FF_FF`.
448450
*/
449-
pub fn from_str_bytes_common<T:NumCast+Zero+One+Eq+Ord+Copy+Div<T,T>+
451+
pub fn from_str_bytes_common<T:NumCast+Zero+One+Ord+Copy+Div<T,T>+
450452
Mul<T,T>+Sub<T,T>+Neg<T>+Add<T,T>+
451453
NumStrConv>(
452454
buf: &[u8], radix: uint, negative: bool, fractional: bool,
453-
special: bool, exponent: ExponentFormat, empty_zero: bool,
454-
ignore_underscores: bool
455+
special: bool, exponent: ExponentFormat, empty_zero: bool
455456
) -> Option<T> {
456457
match exponent {
457458
ExpDec if radix >= DIGIT_E_RADIX // decimal exponent 'e'
@@ -530,16 +531,12 @@ pub fn from_str_bytes_common<T:NumCast+Zero+One+Eq+Ord+Copy+Div<T,T>+
530531
accum -= cast(digit as int);
531532
}
532533

533-
// Detect overflow by comparing to last value, except
534-
// if we've not seen any non-zero digits.
535-
if last_accum != _0 {
536-
if accum_positive && accum <= last_accum { return None; }
537-
if !accum_positive && accum >= last_accum { return None; }
538-
}
534+
// Detect overflow by comparing to last value
535+
if accum_positive && accum < last_accum { return None; }
536+
if !accum_positive && accum > last_accum { return None; }
539537
last_accum = accum;
540538
}
541539
None => match c {
542-
'_' if ignore_underscores => {}
543540
'e' | 'E' | 'p' | 'P' => {
544541
exp_found = true;
545542
break; // start of exponent
@@ -583,7 +580,6 @@ pub fn from_str_bytes_common<T:NumCast+Zero+One+Eq+Ord+Copy+Div<T,T>+
583580
last_accum = accum;
584581
}
585582
None => match c {
586-
'_' if ignore_underscores => {}
587583
'e' | 'E' | 'p' | 'P' => {
588584
exp_found = true;
589585
break; // start of exponent
@@ -611,7 +607,6 @@ pub fn from_str_bytes_common<T:NumCast+Zero+One+Eq+Ord+Copy+Div<T,T>+
611607
if exp_found {
612608
let c = buf[i] as char;
613609
let base = match (c, exponent) {
614-
// c is never _ so don't need to handle specially
615610
('e', ExpDec) | ('E', ExpDec) => 10u,
616611
('p', ExpBin) | ('P', ExpBin) => 2u,
617612
_ => return None // char doesn't fit given exponent format
@@ -620,8 +615,7 @@ pub fn from_str_bytes_common<T:NumCast+Zero+One+Eq+Ord+Copy+Div<T,T>+
620615
// parse remaining bytes as decimal integer,
621616
// skipping the exponent char
622617
let exp: Option<int> = from_str_bytes_common(
623-
buf.slice(i+1, len), 10, true, false, false, ExpNone, false,
624-
ignore_underscores);
618+
buf.slice(i+1, len), 10, true, false, false, ExpNone, false);
625619

626620
match exp {
627621
Some(exp_pow) => {
@@ -643,44 +637,11 @@ pub fn from_str_bytes_common<T:NumCast+Zero+One+Eq+Ord+Copy+Div<T,T>+
643637
* `from_str_bytes_common()`, for details see there.
644638
*/
645639
#[inline(always)]
646-
pub fn from_str_common<T:NumCast+Zero+One+Eq+Ord+Copy+Div<T,T>+Mul<T,T>+
640+
pub fn from_str_common<T:NumCast+Zero+One+Ord+Copy+Div<T,T>+Mul<T,T>+
647641
Sub<T,T>+Neg<T>+Add<T,T>+NumStrConv>(
648642
buf: &str, radix: uint, negative: bool, fractional: bool,
649-
special: bool, exponent: ExponentFormat, empty_zero: bool,
650-
ignore_underscores: bool
643+
special: bool, exponent: ExponentFormat, empty_zero: bool
651644
) -> Option<T> {
652645
from_str_bytes_common(str::to_bytes(buf), radix, negative,
653-
fractional, special, exponent, empty_zero,
654-
ignore_underscores)
655-
}
656-
657-
#[cfg(test)]
658-
mod test {
659-
use super::*;
660-
use option::*;
661-
662-
#[test]
663-
fn from_str_ignore_underscores() {
664-
let s : Option<u8> = from_str_common("__1__", 2, false, false, false,
665-
ExpNone, false, true);
666-
assert_eq!(s, Some(1u8));
667-
668-
let n : Option<u8> = from_str_common("__1__", 2, false, false, false,
669-
ExpNone, false, false);
670-
assert_eq!(n, None);
671-
672-
let f : Option<f32> = from_str_common("_1_._1_e_1_", 10, false, true, false,
673-
ExpDec, false, true);
674-
assert_eq!(f, Some(1.1e1f32));
675-
}
676-
677-
#[test]
678-
fn from_str_issue5770() {
679-
// try to parse 0b1_1111_1111 = 511 as a u8. Caused problems
680-
// since 255*2+1 == 255 (mod 256) so the overflow wasn't
681-
// detected.
682-
let n : Option<u8> = from_str_common("111111111", 2, false, false, false,
683-
ExpNone, false, false);
684-
assert_eq!(n, None);
685-
}
646+
fractional, special, exponent, empty_zero)
686647
}

branches/try/src/libcore/num/uint-template.rs

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -168,21 +168,21 @@ impl ops::Neg<T> for T {
168168
#[inline(always)]
169169
pub fn from_str(s: &str) -> Option<T> {
170170
strconv::from_str_common(s, 10u, false, false, false,
171-
strconv::ExpNone, false, false)
171+
strconv::ExpNone, false)
172172
}
173173
174174
/// Parse a string as a number in the given base.
175175
#[inline(always)]
176176
pub fn from_str_radix(s: &str, radix: uint) -> Option<T> {
177177
strconv::from_str_common(s, radix, false, false, false,
178-
strconv::ExpNone, false, false)
178+
strconv::ExpNone, false)
179179
}
180180
181181
/// Parse a byte slice as a number in the given base.
182182
#[inline(always)]
183183
pub fn parse_bytes(buf: &[u8], radix: uint) -> Option<T> {
184184
strconv::from_str_bytes_common(buf, radix, false, false, false,
185-
strconv::ExpNone, false, false)
185+
strconv::ExpNone, false)
186186
}
187187
188188
impl FromStr for T {

0 commit comments

Comments
 (0)