Skip to content

Commit 531f685

Browse files
committed
---
yaml --- r: 153049 b: refs/heads/try2 c: 94a56a3 h: refs/heads/master i: 153047: 3d079ab v: v3
1 parent a018657 commit 531f685

File tree

14 files changed

+771
-1089
lines changed

14 files changed

+771
-1089
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: eda75bcf42ad99e3e4c99585d39705fccac606ee
8+
refs/heads/try2: 94a56a375803abf1826ed31756b6ac12df23de7c
99
refs/heads/dist-snap: ba4081a5a8573875fed17545846f6f6902c8ba8d
1010
refs/tags/release-0.2: c870d2dffb391e14efb05aa27898f1f6333a9596
1111
refs/tags/release-0.3: b5f0d0f648d9a6153664837026ba1be43d3e2503

branches/try2/src/doc/rust.md

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -2155,6 +2155,8 @@ These are functions:
21552155

21562156
* `str_eq`
21572157
: Compare two strings (`&str`) for equality.
2158+
* `uniq_str_eq`
2159+
: Compare two owned strings (`String`) for equality.
21582160
* `strdup_uniq`
21592161
: Return a new unique string
21602162
containing a copy of the contents of a unique string.

branches/try2/src/doc/rustdoc.md

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -51,7 +51,7 @@ Calculates the factorial of a number.
5151
5252
Given the input integer `n`, this function will calculate `n!` and return it.
5353
"]
54-
pub fn factorial(n: int) -> int { if n < 2 {1} else {n * factorial(n - 1)} }
54+
pub fn factorial(n: int) -> int { if n < 2 {1} else {n * factorial(n)} }
5555
# fn main() {}
5656
~~~
5757

branches/try2/src/etc/install.sh

Lines changed: 2 additions & 67 deletions
Original file line numberDiff line numberDiff line change
@@ -35,13 +35,6 @@ need_ok() {
3535
fi
3636
}
3737

38-
need_cmd() {
39-
if command -v $1 >/dev/null 2>&1
40-
then msg "found $1"
41-
else err "need $1"
42-
fi
43-
}
44-
4538
putvar() {
4639
local T
4740
eval T=\$$1
@@ -205,15 +198,6 @@ absolutify() {
205198
ABSOLUTIFIED="${FILE_PATH}"
206199
}
207200

208-
msg "looking for install programs"
209-
need_cmd mkdir
210-
need_cmd printf
211-
need_cmd cut
212-
need_cmd grep
213-
need_cmd uname
214-
need_cmd tr
215-
need_cmd sed
216-
217201
CFG_SRC_DIR="$(cd $(dirname $0) && pwd)/"
218202
CFG_SELF="$0"
219203
CFG_ARGS="$@"
@@ -232,65 +216,16 @@ else
232216
step_msg "processing $CFG_SELF args"
233217
fi
234218

235-
# Check for mingw or cygwin in order to special case $CFG_LIBDIR_RELATIVE.
236-
# This logic is duplicated from configure in order to get the correct libdir
237-
# for Windows installs.
238-
CFG_OSTYPE=$(uname -s)
239-
240-
case $CFG_OSTYPE in
241-
242-
MINGW32*)
243-
CFG_OSTYPE=pc-mingw32
244-
;;
245-
246-
MINGW64*)
247-
# msys2, MSYSTEM=MINGW64
248-
CFG_OSTYPE=w64-mingw32
249-
;;
250-
251-
# Thad's Cygwin identifers below
252-
253-
# Vista 32 bit
254-
CYGWIN_NT-6.0)
255-
CFG_OSTYPE=pc-mingw32
256-
;;
257-
258-
# Vista 64 bit
259-
CYGWIN_NT-6.0-WOW64)
260-
CFG_OSTYPE=w64-mingw32
261-
;;
262-
263-
# Win 7 32 bit
264-
CYGWIN_NT-6.1)
265-
CFG_OSTYPE=pc-mingw32
266-
;;
267-
268-
# Win 7 64 bit
269-
CYGWIN_NT-6.1-WOW64)
270-
CFG_OSTYPE=w64-mingw32
271-
;;
272-
esac
273-
274219
OPTIONS=""
275220
BOOL_OPTIONS=""
276221
VAL_OPTIONS=""
277222

278-
# On windows we just store the libraries in the bin directory because
279-
# there's no rpath. This is where the build system itself puts libraries;
280-
# --libdir is used to configure the installation directory.
281-
# FIXME: Thise needs to parameterized over target triples. Do it in platform.mk
282-
CFG_LIBDIR_RELATIVE=lib
283-
if [ "$CFG_OSTYPE" = "pc-mingw32" ] || [ "$CFG_OSTYPE" = "w64-mingw32" ]
284-
then
285-
CFG_LIBDIR_RELATIVE=bin
286-
fi
287-
288223
flag uninstall "only uninstall from the installation prefix"
289224
opt verify 1 "verify that the installed binaries run correctly"
290225
valopt prefix "/usr/local" "set installation prefix"
291226
# NB This isn't quite the same definition as in `configure`.
292227
# just using 'lib' instead of CFG_LIBDIR_RELATIVE
293-
valopt libdir "${CFG_PREFIX}/${CFG_LIBDIR_RELATIVE}" "install libraries"
228+
valopt libdir "${CFG_PREFIX}/lib" "install libraries"
294229
valopt mandir "${CFG_PREFIX}/share/man" "install man pages in PATH"
295230

296231
if [ $HELP -eq 1 ]
@@ -449,7 +384,7 @@ while read p; do
449384
need_ok "failed to update manifest"
450385

451386
# The manifest lists all files to install
452-
done < "${CFG_SRC_DIR}/${CFG_LIBDIR_RELATIVE}/rustlib/manifest.in"
387+
done < "${CFG_SRC_DIR}/lib/rustlib/manifest.in"
453388

454389
# Sanity check: can we run the installed binaries?
455390
if [ -z "${CFG_DISABLE_VERIFY}" ]

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

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -586,14 +586,14 @@ macro_rules! int_impl {
586586
fn rotate_left(self, n: uint) -> $T {
587587
// Protect against undefined behaviour for over-long bit shifts
588588
let n = n % $BITS;
589-
(self << n) | (self >> (($BITS - n) % $BITS))
589+
(self << n) | (self >> ($BITS - n))
590590
}
591591

592592
#[inline]
593593
fn rotate_right(self, n: uint) -> $T {
594594
// Protect against undefined behaviour for over-long bit shifts
595595
let n = n % $BITS;
596-
(self >> n) | (self << (($BITS - n) % $BITS))
596+
(self >> n) | (self << ($BITS - n))
597597
}
598598

599599
#[inline]

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

Lines changed: 0 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -114,15 +114,6 @@ mod tests {
114114
assert_eq!(_1.rotate_left(124), _1);
115115
assert_eq!(_0.rotate_right(124), _0);
116116
assert_eq!(_1.rotate_right(124), _1);
117-
118-
// Rotating by 0 should have no effect
119-
assert_eq!(A.rotate_left(0), A);
120-
assert_eq!(B.rotate_left(0), B);
121-
assert_eq!(C.rotate_left(0), C);
122-
// Rotating by a multiple of word size should also have no effect
123-
assert_eq!(A.rotate_left(64), A);
124-
assert_eq!(B.rotate_left(64), B);
125-
assert_eq!(C.rotate_left(64), C);
126117
}
127118

128119
#[test]

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

Lines changed: 0 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -74,15 +74,6 @@ mod tests {
7474
assert_eq!(_1.rotate_left(124), _1);
7575
assert_eq!(_0.rotate_right(124), _0);
7676
assert_eq!(_1.rotate_right(124), _1);
77-
78-
// Rotating by 0 should have no effect
79-
assert_eq!(A.rotate_left(0), A);
80-
assert_eq!(B.rotate_left(0), B);
81-
assert_eq!(C.rotate_left(0), C);
82-
// Rotating by a multiple of word size should also have no effect
83-
assert_eq!(A.rotate_left(64), A);
84-
assert_eq!(B.rotate_left(64), B);
85-
assert_eq!(C.rotate_left(64), C);
8677
}
8778

8879
#[test]

branches/try2/src/libnum/rational.rs

Lines changed: 17 additions & 28 deletions
Original file line numberDiff line numberDiff line change
@@ -274,17 +274,12 @@ impl<T: Clone + Integer + PartialOrd>
274274
Num for Ratio<T> {}
275275

276276
/* String conversions */
277-
impl<T: fmt::Show + Eq + One> fmt::Show for Ratio<T> {
278-
/// Renders as `numer/denom`. If denom=1, renders as numer.
277+
impl<T: fmt::Show> fmt::Show for Ratio<T> {
278+
/// Renders as `numer/denom`.
279279
fn fmt(&self, f: &mut fmt::Formatter) -> fmt::Result {
280-
if self.denom == One::one() {
281-
write!(f, "{}", self.numer)
282-
} else {
283-
write!(f, "{}/{}", self.numer, self.denom)
284-
}
280+
write!(f, "{}/{}", self.numer, self.denom)
285281
}
286282
}
287-
288283
impl<T: ToStrRadix> ToStrRadix for Ratio<T> {
289284
/// Renders as `numer/denom` where the numbers are in base `radix`.
290285
fn to_str_radix(&self, radix: uint) -> String {
@@ -296,20 +291,21 @@ impl<T: ToStrRadix> ToStrRadix for Ratio<T> {
296291

297292
impl<T: FromStr + Clone + Integer + PartialOrd>
298293
FromStr for Ratio<T> {
299-
/// Parses `numer/denom` or just `numer`
294+
/// Parses `numer/denom`.
300295
fn from_str(s: &str) -> Option<Ratio<T>> {
301-
let mut split = s.splitn('/', 1);
302-
303-
let num = split.next().and_then(|n| FromStr::from_str(n));
304-
let den = split.next().or(Some("1")).and_then(|d| FromStr::from_str(d));
305-
306-
match (num, den) {
307-
(Some(n), Some(d)) => Some(Ratio::new(n, d)),
308-
_ => None
296+
let split: Vec<&str> = s.splitn('/', 1).collect();
297+
if split.len() < 2 {
298+
return None
309299
}
300+
let a_option: Option<T> = FromStr::from_str(*split.get(0));
301+
a_option.and_then(|a| {
302+
let b_option: Option<T> = FromStr::from_str(*split.get(1));
303+
b_option.and_then(|b| {
304+
Some(Ratio::new(a.clone(), b.clone()))
305+
})
306+
})
310307
}
311308
}
312-
313309
impl<T: FromStrRadix + Clone + Integer + PartialOrd>
314310
FromStrRadix for Ratio<T> {
315311
/// Parses `numer/denom` where the numbers are in base `radix`.
@@ -433,13 +429,6 @@ mod test {
433429
assert!(!_neg1_2.is_integer());
434430
}
435431

436-
#[test]
437-
fn test_show() {
438-
assert_eq!(format!("{}", _2), "2".to_string());
439-
assert_eq!(format!("{}", _1_2), "1/2".to_string());
440-
assert_eq!(format!("{}", _0), "0".to_string());
441-
assert_eq!(format!("{}", Ratio::from_integer(-2i)), "-2".to_string());
442-
}
443432

444433
mod arith {
445434
use super::{_0, _1, _2, _1_2, _3_2, _neg1_2, to_big};
@@ -573,11 +562,11 @@ mod test {
573562
assert_eq!(FromStr::from_str(s.as_slice()), Some(r));
574563
assert_eq!(r.to_str(), s);
575564
}
576-
test(_1, "1".to_string());
577-
test(_0, "0".to_string());
565+
test(_1, "1/1".to_string());
566+
test(_0, "0/1".to_string());
578567
test(_1_2, "1/2".to_string());
579568
test(_3_2, "3/2".to_string());
580-
test(_2, "2".to_string());
569+
test(_2, "2/1".to_string());
581570
test(_neg1_2, "-1/2".to_string());
582571
}
583572
#[test]

branches/try2/src/librustc/middle/check_match.rs

Lines changed: 10 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -74,12 +74,12 @@ impl fmt::Show for Matrix {
7474
}
7575
}
7676

77-
pub struct MatchCheckCtxt<'a> {
78-
pub tcx: &'a ty::ctxt
77+
struct MatchCheckCtxt<'a> {
78+
tcx: &'a ty::ctxt
7979
}
8080

8181
#[deriving(Clone, PartialEq)]
82-
pub enum Constructor {
82+
enum Constructor {
8383
/// The constructor of all patterns that don't vary by constructor,
8484
/// e.g. struct patterns and fixed-length arrays.
8585
Single,
@@ -492,9 +492,9 @@ fn is_useful_specialized(cx: &MatchCheckCtxt, &Matrix(ref m): &Matrix, v: &[Gc<P
492492
ctor: Constructor, lty: ty::t, witness: WitnessPreference) -> Usefulness {
493493
let arity = constructor_arity(cx, &ctor, lty);
494494
let matrix = Matrix(m.iter().filter_map(|r| {
495-
specialize(cx, r.as_slice(), &ctor, 0u, arity)
495+
specialize(cx, r.as_slice(), &ctor, arity)
496496
}).collect());
497-
match specialize(cx, v, &ctor, 0u, arity) {
497+
match specialize(cx, v, &ctor, arity) {
498498
Some(v) => is_useful(cx, &matrix, v.as_slice(), witness),
499499
None => NotUseful
500500
}
@@ -580,7 +580,7 @@ fn is_wild(cx: &MatchCheckCtxt, p: Gc<Pat>) -> bool {
580580
///
581581
/// For instance, a tuple pattern (_, 42u, Some([])) has the arity of 3.
582582
/// A struct pattern's arity is the number of fields it contains, etc.
583-
pub fn constructor_arity(cx: &MatchCheckCtxt, ctor: &Constructor, ty: ty::t) -> uint {
583+
fn constructor_arity(cx: &MatchCheckCtxt, ctor: &Constructor, ty: ty::t) -> uint {
584584
match ty::get(ty).sty {
585585
ty::ty_tup(ref fs) => fs.len(),
586586
ty::ty_box(_) | ty::ty_uniq(_) => 1u,
@@ -628,11 +628,11 @@ fn range_covered_by_constructor(ctor: &Constructor,
628628
/// different patterns.
629629
/// Structure patterns with a partial wild pattern (Foo { a: 42, .. }) have their missing
630630
/// fields filled with wild patterns.
631-
pub fn specialize(cx: &MatchCheckCtxt, r: &[Gc<Pat>],
632-
constructor: &Constructor, col: uint, arity: uint) -> Option<Vec<Gc<Pat>>> {
631+
fn specialize(cx: &MatchCheckCtxt, r: &[Gc<Pat>],
632+
constructor: &Constructor, arity: uint) -> Option<Vec<Gc<Pat>>> {
633633
let &Pat {
634634
id: pat_id, node: ref node, span: pat_span
635-
} = &(*raw_pat(r[col]));
635+
} = &(*raw_pat(r[0]));
636636
let head: Option<Vec<Gc<Pat>>> = match node {
637637
&PatWild =>
638638
Some(Vec::from_elem(arity, wild())),
@@ -776,7 +776,7 @@ pub fn specialize(cx: &MatchCheckCtxt, r: &[Gc<Pat>],
776776
None
777777
}
778778
};
779-
head.map(|head| head.append(r.slice_to(col)).append(r.slice_from(col + 1)))
779+
head.map(|head| head.append(r.tail()))
780780
}
781781

782782
fn default(cx: &MatchCheckCtxt, r: &[Gc<Pat>]) -> Option<Vec<Gc<Pat>>> {

branches/try2/src/librustc/middle/lang_items.rs

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -248,6 +248,7 @@ lets_do_this! {
248248
OrdTraitLangItem, "ord", ord_trait;
249249

250250
StrEqFnLangItem, "str_eq", str_eq_fn;
251+
UniqStrEqFnLangItem, "uniq_str_eq", uniq_str_eq_fn;
251252

252253
// A number of failure-related lang items. The `fail_` item corresponds to
253254
// divide-by-zero and various failure cases with `match`. The

0 commit comments

Comments
 (0)