Skip to content

Commit bd98136

Browse files
committed
---
yaml --- r: 123823 b: refs/heads/master c: 7a6208f h: refs/heads/master i: 123821: 01feee8 123819: a16d1cb 123815: 8c04b2f 123807: 26722e6 v: v3
1 parent 22114b3 commit bd98136

File tree

16 files changed

+186
-72
lines changed

16 files changed

+186
-72
lines changed

[refs]

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,5 @@
11
---
2-
refs/heads/master: aee5917556856428072cc090fb892176eaa075b3
2+
refs/heads/master: 7a6208f2cc1bbe29dc42b21d27e98894b8bacc04
33
refs/heads/snap-stage1: e33de59e47c5076a89eadeb38f4934f58a3618a6
44
refs/heads/snap-stage3: 8ddd286ea4ba4384a0dc9eae393ed515460a986e
55
refs/heads/try: 296eb104620b346d88bc4a2c2ab7693e6d3db019

trunk/src/libcollections/treemap.rs

Lines changed: 34 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -22,6 +22,7 @@ use core::iter::Peekable;
2222
use core::iter;
2323
use core::mem::{replace, swap};
2424
use core::ptr;
25+
use std::hash::{Writer, Hash};
2526

2627
use {Collection, Mutable, Set, MutableSet, MutableMap, Map};
2728
use vec::Vec;
@@ -1055,6 +1056,14 @@ impl<K: Ord, V> Extendable<(K, V)> for TreeMap<K, V> {
10551056
}
10561057
}
10571058

1059+
impl<S: Writer, K: Ord + Hash<S>, V: Hash<S>> Hash<S> for TreeMap<K, V> {
1060+
fn hash(&self, state: &mut S) {
1061+
for elt in self.iter() {
1062+
elt.hash(state);
1063+
}
1064+
}
1065+
}
1066+
10581067
impl<T: Ord> FromIterator<T> for TreeSet<T> {
10591068
fn from_iter<Iter: Iterator<T>>(iter: Iter) -> TreeSet<T> {
10601069
let mut set = TreeSet::new();
@@ -1072,6 +1081,14 @@ impl<T: Ord> Extendable<T> for TreeSet<T> {
10721081
}
10731082
}
10741083

1084+
impl<S: Writer, T: Ord + Hash<S>> Hash<S> for TreeSet<T> {
1085+
fn hash(&self, state: &mut S) {
1086+
for elt in self.iter() {
1087+
elt.hash(state);
1088+
}
1089+
}
1090+
}
1091+
10751092
#[cfg(test)]
10761093
mod test_treemap {
10771094
use std::prelude::*;
@@ -1608,6 +1625,7 @@ mod bench {
16081625
#[cfg(test)]
16091626
mod test_set {
16101627
use std::prelude::*;
1628+
use std::hash;
16111629

16121630
use {Set, MutableSet, Mutable, MutableMap};
16131631
use super::{TreeMap, TreeSet};
@@ -1748,6 +1766,22 @@ mod test_set {
17481766
assert!(m.clone() == m);
17491767
}
17501768

1769+
#[test]
1770+
fn test_hash() {
1771+
let mut x = TreeSet::new();
1772+
let mut y = TreeSet::new();
1773+
1774+
x.insert(1i);
1775+
x.insert(2);
1776+
x.insert(3);
1777+
1778+
y.insert(3i);
1779+
y.insert(2);
1780+
y.insert(1);
1781+
1782+
assert!(hash::hash(&x) == hash::hash(&y));
1783+
}
1784+
17511785
fn check(a: &[int],
17521786
b: &[int],
17531787
expected: &[int],

trunk/src/libcore/iter.rs

Lines changed: 25 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -64,14 +64,14 @@ the rest of the rust manuals.
6464
6565
*/
6666

67+
use clone::Clone;
6768
use cmp;
69+
use cmp::{PartialEq, PartialOrd, Ord};
70+
use mem;
6871
use num::{Zero, One, CheckedAdd, CheckedSub, Saturating, ToPrimitive, Int};
69-
use option::{Option, Some, None};
7072
use ops::{Add, Mul, Sub};
71-
use cmp::{PartialEq, PartialOrd, Ord};
72-
use clone::Clone;
73+
use option::{Option, Some, None};
7374
use uint;
74-
use mem;
7575

7676
/// Conversion from an `Iterator`
7777
pub trait FromIterator<A> {
@@ -2192,6 +2192,27 @@ impl<A: Clone> RandomAccessIterator<A> for Repeat<A> {
21922192
fn idx(&mut self, _: uint) -> Option<A> { Some(self.element.clone()) }
21932193
}
21942194

2195+
type IterateState<'a, T> = (|T|: 'a -> T, Option<T>, bool);
2196+
2197+
/// An iterator that repeatedly applies a given function, starting
2198+
/// from a given seed value.
2199+
pub type Iterate<'a, T> = Unfold<'a, T, IterateState<'a, T>>;
2200+
2201+
/// Creates a new iterator that produces an infinite sequence of
2202+
/// repeated applications of the given function `f`.
2203+
#[allow(visible_private_types)]
2204+
pub fn iterate<'a, T: Clone>(f: |T|: 'a -> T, seed: T) -> Iterate<'a, T> {
2205+
Unfold::new((f, Some(seed), true), |st| {
2206+
let &(ref mut f, ref mut val, ref mut first) = st;
2207+
if *first {
2208+
*first = false;
2209+
} else {
2210+
val.mutate(|x| (*f)(x));
2211+
}
2212+
val.clone()
2213+
})
2214+
}
2215+
21952216
/// Functions for lexicographical ordering of sequences.
21962217
///
21972218
/// Lexicographical ordering through `<`, `<=`, `>=`, `>` requires

trunk/src/libcoretest/iter.rs

Lines changed: 9 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -833,3 +833,12 @@ fn test_min_max_result() {
833833
let r = MinMax(1i,2);
834834
assert_eq!(r.into_option(), Some((1,2)));
835835
}
836+
837+
#[test]
838+
fn test_iterate() {
839+
let mut it = iterate(|x| x * 2, 1u);
840+
assert_eq!(it.next(), Some(1u));
841+
assert_eq!(it.next(), Some(2u));
842+
assert_eq!(it.next(), Some(4u));
843+
assert_eq!(it.next(), Some(8u));
844+
}

trunk/src/liblibc/lib.rs

Lines changed: 61 additions & 57 deletions
Original file line numberDiff line numberDiff line change
@@ -2008,6 +2008,7 @@ pub mod consts {
20082008
pub mod posix88 {
20092009
use types::os::arch::c95::c_int;
20102010
use types::common::c95::c_void;
2011+
use types::os::arch::posix88::mode_t;
20112012

20122013
pub static O_RDONLY : c_int = 0;
20132014
pub static O_WRONLY : c_int = 1;
@@ -2016,20 +2017,20 @@ pub mod consts {
20162017
pub static O_CREAT : c_int = 64;
20172018
pub static O_EXCL : c_int = 128;
20182019
pub static O_TRUNC : c_int = 512;
2019-
pub static S_IFIFO : c_int = 4096;
2020-
pub static S_IFCHR : c_int = 8192;
2021-
pub static S_IFBLK : c_int = 24576;
2022-
pub static S_IFDIR : c_int = 16384;
2023-
pub static S_IFREG : c_int = 32768;
2024-
pub static S_IFLNK : c_int = 40960;
2025-
pub static S_IFMT : c_int = 61440;
2026-
pub static S_IEXEC : c_int = 64;
2027-
pub static S_IWRITE : c_int = 128;
2028-
pub static S_IREAD : c_int = 256;
2029-
pub static S_IRWXU : c_int = 448;
2030-
pub static S_IXUSR : c_int = 64;
2031-
pub static S_IWUSR : c_int = 128;
2032-
pub static S_IRUSR : c_int = 256;
2020+
pub static S_IFIFO : mode_t = 4096;
2021+
pub static S_IFCHR : mode_t = 8192;
2022+
pub static S_IFBLK : mode_t = 24576;
2023+
pub static S_IFDIR : mode_t = 16384;
2024+
pub static S_IFREG : mode_t = 32768;
2025+
pub static S_IFLNK : mode_t = 40960;
2026+
pub static S_IFMT : mode_t = 61440;
2027+
pub static S_IEXEC : mode_t = 64;
2028+
pub static S_IWRITE : mode_t = 128;
2029+
pub static S_IREAD : mode_t = 256;
2030+
pub static S_IRWXU : mode_t = 448;
2031+
pub static S_IXUSR : mode_t = 64;
2032+
pub static S_IWUSR : mode_t = 128;
2033+
pub static S_IRUSR : mode_t = 256;
20332034
pub static F_OK : c_int = 0;
20342035
pub static R_OK : c_int = 4;
20352036
pub static W_OK : c_int = 2;
@@ -2220,6 +2221,7 @@ pub mod consts {
22202221
pub mod posix88 {
22212222
use types::os::arch::c95::c_int;
22222223
use types::common::c95::c_void;
2224+
use types::os::arch::posix88::mode_t;
22232225

22242226
pub static O_RDONLY : c_int = 0;
22252227
pub static O_WRONLY : c_int = 1;
@@ -2228,20 +2230,20 @@ pub mod consts {
22282230
pub static O_CREAT : c_int = 256;
22292231
pub static O_EXCL : c_int = 1024;
22302232
pub static O_TRUNC : c_int = 512;
2231-
pub static S_IFIFO : c_int = 4096;
2232-
pub static S_IFCHR : c_int = 8192;
2233-
pub static S_IFBLK : c_int = 24576;
2234-
pub static S_IFDIR : c_int = 16384;
2235-
pub static S_IFREG : c_int = 32768;
2236-
pub static S_IFLNK : c_int = 40960;
2237-
pub static S_IFMT : c_int = 61440;
2238-
pub static S_IEXEC : c_int = 64;
2239-
pub static S_IWRITE : c_int = 128;
2240-
pub static S_IREAD : c_int = 256;
2241-
pub static S_IRWXU : c_int = 448;
2242-
pub static S_IXUSR : c_int = 64;
2243-
pub static S_IWUSR : c_int = 128;
2244-
pub static S_IRUSR : c_int = 256;
2233+
pub static S_IFIFO : mode_t = 4096;
2234+
pub static S_IFCHR : mode_t = 8192;
2235+
pub static S_IFBLK : mode_t = 24576;
2236+
pub static S_IFDIR : mode_t = 16384;
2237+
pub static S_IFREG : mode_t = 32768;
2238+
pub static S_IFLNK : mode_t = 40960;
2239+
pub static S_IFMT : mode_t = 61440;
2240+
pub static S_IEXEC : mode_t = 64;
2241+
pub static S_IWRITE : mode_t = 128;
2242+
pub static S_IREAD : mode_t = 256;
2243+
pub static S_IRWXU : mode_t = 448;
2244+
pub static S_IXUSR : mode_t = 64;
2245+
pub static S_IWUSR : mode_t = 128;
2246+
pub static S_IRUSR : mode_t = 256;
22452247
pub static F_OK : c_int = 0;
22462248
pub static R_OK : c_int = 4;
22472249
pub static W_OK : c_int = 2;
@@ -2759,6 +2761,7 @@ pub mod consts {
27592761
pub mod posix88 {
27602762
use types::common::c95::c_void;
27612763
use types::os::arch::c95::c_int;
2764+
use types::os::arch::posix88::mode_t;
27622765

27632766
pub static O_RDONLY : c_int = 0;
27642767
pub static O_WRONLY : c_int = 1;
@@ -2767,20 +2770,20 @@ pub mod consts {
27672770
pub static O_CREAT : c_int = 512;
27682771
pub static O_EXCL : c_int = 2048;
27692772
pub static O_TRUNC : c_int = 1024;
2770-
pub static S_IFIFO : c_int = 4096;
2771-
pub static S_IFCHR : c_int = 8192;
2772-
pub static S_IFBLK : c_int = 24576;
2773-
pub static S_IFDIR : c_int = 16384;
2774-
pub static S_IFREG : c_int = 32768;
2775-
pub static S_IFLNK : c_int = 40960;
2776-
pub static S_IFMT : c_int = 61440;
2777-
pub static S_IEXEC : c_int = 64;
2778-
pub static S_IWRITE : c_int = 128;
2779-
pub static S_IREAD : c_int = 256;
2780-
pub static S_IRWXU : c_int = 448;
2781-
pub static S_IXUSR : c_int = 64;
2782-
pub static S_IWUSR : c_int = 128;
2783-
pub static S_IRUSR : c_int = 256;
2773+
pub static S_IFIFO : mode_t = 4096;
2774+
pub static S_IFCHR : mode_t = 8192;
2775+
pub static S_IFBLK : mode_t = 24576;
2776+
pub static S_IFDIR : mode_t = 16384;
2777+
pub static S_IFREG : mode_t = 32768;
2778+
pub static S_IFLNK : mode_t = 40960;
2779+
pub static S_IFMT : mode_t = 61440;
2780+
pub static S_IEXEC : mode_t = 64;
2781+
pub static S_IWRITE : mode_t = 128;
2782+
pub static S_IREAD : mode_t = 256;
2783+
pub static S_IRWXU : mode_t = 448;
2784+
pub static S_IXUSR : mode_t = 64;
2785+
pub static S_IWUSR : mode_t = 128;
2786+
pub static S_IRUSR : mode_t = 256;
27842787
pub static F_OK : c_int = 0;
27852788
pub static R_OK : c_int = 4;
27862789
pub static W_OK : c_int = 2;
@@ -3148,6 +3151,7 @@ pub mod consts {
31483151
pub mod posix88 {
31493152
use types::common::c95::c_void;
31503153
use types::os::arch::c95::c_int;
3154+
use types::os::arch::posix88::mode_t;
31513155

31523156
pub static O_RDONLY : c_int = 0;
31533157
pub static O_WRONLY : c_int = 1;
@@ -3156,20 +3160,20 @@ pub mod consts {
31563160
pub static O_CREAT : c_int = 512;
31573161
pub static O_EXCL : c_int = 2048;
31583162
pub static O_TRUNC : c_int = 1024;
3159-
pub static S_IFIFO : c_int = 4096;
3160-
pub static S_IFCHR : c_int = 8192;
3161-
pub static S_IFBLK : c_int = 24576;
3162-
pub static S_IFDIR : c_int = 16384;
3163-
pub static S_IFREG : c_int = 32768;
3164-
pub static S_IFLNK : c_int = 40960;
3165-
pub static S_IFMT : c_int = 61440;
3166-
pub static S_IEXEC : c_int = 64;
3167-
pub static S_IWRITE : c_int = 128;
3168-
pub static S_IREAD : c_int = 256;
3169-
pub static S_IRWXU : c_int = 448;
3170-
pub static S_IXUSR : c_int = 64;
3171-
pub static S_IWUSR : c_int = 128;
3172-
pub static S_IRUSR : c_int = 256;
3163+
pub static S_IFIFO : mode_t = 4096;
3164+
pub static S_IFCHR : mode_t = 8192;
3165+
pub static S_IFBLK : mode_t = 24576;
3166+
pub static S_IFDIR : mode_t = 16384;
3167+
pub static S_IFREG : mode_t = 32768;
3168+
pub static S_IFLNK : mode_t = 40960;
3169+
pub static S_IFMT : mode_t = 61440;
3170+
pub static S_IEXEC : mode_t = 64;
3171+
pub static S_IWRITE : mode_t = 128;
3172+
pub static S_IREAD : mode_t = 256;
3173+
pub static S_IRWXU : mode_t = 448;
3174+
pub static S_IXUSR : mode_t = 64;
3175+
pub static S_IWUSR : mode_t = 128;
3176+
pub static S_IRUSR : mode_t = 256;
31733177
pub static F_OK : c_int = 0;
31743178
pub static R_OK : c_int = 4;
31753179
pub static W_OK : c_int = 2;
@@ -3858,7 +3862,7 @@ pub mod funcs {
38583862
use types::os::arch::posix88::mode_t;
38593863

38603864
extern {
3861-
pub fn open(path: *const c_char, oflag: c_int, mode: c_int)
3865+
pub fn open(path: *const c_char, oflag: c_int, mode: mode_t)
38623866
-> c_int;
38633867
pub fn creat(path: *const c_char, mode: mode_t) -> c_int;
38643868
pub fn fcntl(fd: c_int, cmd: c_int, ...) -> c_int;

trunk/src/librustc/back/link.rs

Lines changed: 7 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -555,6 +555,12 @@ pub fn find_crate_name(sess: Option<&Session>,
555555
s
556556
};
557557

558+
// Look in attributes 100% of the time to make sure the attribute is marked
559+
// as used. After doing this, however, favor crate names from the command
560+
// line.
561+
let attr_crate_name = attrs.iter().find(|at| at.check_name("crate_name"))
562+
.and_then(|at| at.value_str().map(|s| (at, s)));
563+
558564
match sess {
559565
Some(sess) => {
560566
match sess.opts.crate_name {
@@ -565,9 +571,7 @@ pub fn find_crate_name(sess: Option<&Session>,
565571
None => {}
566572
}
567573

568-
let crate_name = attrs.iter().find(|at| at.check_name("crate_name"))
569-
.and_then(|at| at.value_str().map(|s| (at, s)));
570-
match crate_name {
574+
match attr_crate_name {
571575
Some((attr, s)) => return validate(s.get().to_string(), Some(attr.span)),
572576
None => {}
573577
}

trunk/src/librustc/lint/builtin.rs

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -758,6 +758,11 @@ impl LintPass for NonCamelCaseTypes {
758758
}
759759
}
760760

761+
let has_extern_repr = it.attrs.iter().fold(attr::ReprAny, |acc, attr| {
762+
attr::find_repr_attr(cx.tcx.sess.diagnostic(), attr, acc)
763+
}) == attr::ReprExtern;
764+
if has_extern_repr { return }
765+
761766
match it.node {
762767
ast::ItemTy(..) | ast::ItemStruct(..) => {
763768
check_case(cx, "type", it.ident, it.span)

trunk/src/librustdoc/html/format.rs

Lines changed: 4 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -431,7 +431,10 @@ impl fmt::Show for clean::Type {
431431
}
432432
clean::Tuple(ref typs) => {
433433
primitive_link(f, clean::PrimitiveTuple,
434-
format!("({:#})", typs).as_slice())
434+
match typs.as_slice() {
435+
[ref one] => format!("({},)", one),
436+
many => format!("({:#})", many)
437+
}.as_slice())
435438
}
436439
clean::Vector(ref t) => {
437440
primitive_link(f, clean::Slice, format!("[{}]", **t).as_slice())

trunk/src/librustuv/file.rs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -547,7 +547,7 @@ mod test {
547547
let path = &"./tmp/mk_rm_dir".to_c_str();
548548
let mode = S_IWUSR | S_IRUSR;
549549

550-
let result = FsRequest::mkdir(l(), path, mode);
550+
let result = FsRequest::mkdir(l(), path, mode as c_int);
551551
assert!(result.is_ok());
552552

553553
let result = FsRequest::rmdir(l(), path);

trunk/src/libstd/hash.rs

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -61,6 +61,8 @@
6161
* ```
6262
*/
6363

64+
#![experimental]
65+
6466
pub use core_collections::hash::{Hash, Hasher, Writer, hash, sip};
6567

6668
use default::Default;

0 commit comments

Comments
 (0)