Skip to content

Commit

Permalink
---
Browse files Browse the repository at this point in the history
yaml
---
r: 131800
b: refs/heads/dist-snap
c: 55cf6d7
h: refs/heads/master
v: v3
  • Loading branch information
bors committed Jul 13, 2014
1 parent 9554e09 commit 9340348
Show file tree
Hide file tree
Showing 13 changed files with 151 additions and 67 deletions.
2 changes: 1 addition & 1 deletion [refs]
Original file line number Diff line number Diff line change
Expand Up @@ -6,7 +6,7 @@ refs/heads/try: 457a3c991d79b971be07fce75f9d0c12848fb37c
refs/tags/release-0.1: 1f5c5126e96c79d22cb7862f75304136e204f105
refs/heads/ndm: f3868061cd7988080c30d6d5bf352a5a5fe2460b
refs/heads/try2: 147ecfdd8221e4a4d4e090486829a06da1e0ca3c
refs/heads/dist-snap: 2cf68ba10106a73b52b3cc7893c0a0a08e8a2018
refs/heads/dist-snap: 55cf6d723c40bf720d7d9f9ed3a5833caa8faf1a
refs/tags/release-0.2: c870d2dffb391e14efb05aa27898f1f6333a9596
refs/tags/release-0.3: b5f0d0f648d9a6153664837026ba1be43d3e2503
refs/heads/try3: 9387340aab40a73e8424c48fd42f0c521a4875c0
Expand Down
34 changes: 34 additions & 0 deletions branches/dist-snap/src/libcollections/treemap.rs
Original file line number Diff line number Diff line change
Expand Up @@ -22,6 +22,7 @@ use core::iter::Peekable;
use core::iter;
use core::mem::{replace, swap};
use core::ptr;
use std::hash::{Writer, Hash};

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

impl<S: Writer, K: Ord + Hash<S>, V: Hash<S>> Hash<S> for TreeMap<K, V> {
fn hash(&self, state: &mut S) {
for elt in self.iter() {
elt.hash(state);
}
}
}

impl<T: Ord> FromIterator<T> for TreeSet<T> {
fn from_iter<Iter: Iterator<T>>(iter: Iter) -> TreeSet<T> {
let mut set = TreeSet::new();
Expand All @@ -1072,6 +1081,14 @@ impl<T: Ord> Extendable<T> for TreeSet<T> {
}
}

impl<S: Writer, T: Ord + Hash<S>> Hash<S> for TreeSet<T> {
fn hash(&self, state: &mut S) {
for elt in self.iter() {
elt.hash(state);
}
}
}

#[cfg(test)]
mod test_treemap {
use std::prelude::*;
Expand Down Expand Up @@ -1608,6 +1625,7 @@ mod bench {
#[cfg(test)]
mod test_set {
use std::prelude::*;
use std::hash;

use {Set, MutableSet, Mutable, MutableMap};
use super::{TreeMap, TreeSet};
Expand Down Expand Up @@ -1748,6 +1766,22 @@ mod test_set {
assert!(m.clone() == m);
}

#[test]
fn test_hash() {
let mut x = TreeSet::new();
let mut y = TreeSet::new();

x.insert(1i);
x.insert(2);
x.insert(3);

y.insert(3i);
y.insert(2);
y.insert(1);

assert!(hash::hash(&x) == hash::hash(&y));
}

fn check(a: &[int],
b: &[int],
expected: &[int],
Expand Down
118 changes: 61 additions & 57 deletions branches/dist-snap/src/liblibc/lib.rs
Original file line number Diff line number Diff line change
Expand Up @@ -2008,6 +2008,7 @@ pub mod consts {
pub mod posix88 {
use types::os::arch::c95::c_int;
use types::common::c95::c_void;
use types::os::arch::posix88::mode_t;

pub static O_RDONLY : c_int = 0;
pub static O_WRONLY : c_int = 1;
Expand All @@ -2016,20 +2017,20 @@ pub mod consts {
pub static O_CREAT : c_int = 64;
pub static O_EXCL : c_int = 128;
pub static O_TRUNC : c_int = 512;
pub static S_IFIFO : c_int = 4096;
pub static S_IFCHR : c_int = 8192;
pub static S_IFBLK : c_int = 24576;
pub static S_IFDIR : c_int = 16384;
pub static S_IFREG : c_int = 32768;
pub static S_IFLNK : c_int = 40960;
pub static S_IFMT : c_int = 61440;
pub static S_IEXEC : c_int = 64;
pub static S_IWRITE : c_int = 128;
pub static S_IREAD : c_int = 256;
pub static S_IRWXU : c_int = 448;
pub static S_IXUSR : c_int = 64;
pub static S_IWUSR : c_int = 128;
pub static S_IRUSR : c_int = 256;
pub static S_IFIFO : mode_t = 4096;
pub static S_IFCHR : mode_t = 8192;
pub static S_IFBLK : mode_t = 24576;
pub static S_IFDIR : mode_t = 16384;
pub static S_IFREG : mode_t = 32768;
pub static S_IFLNK : mode_t = 40960;
pub static S_IFMT : mode_t = 61440;
pub static S_IEXEC : mode_t = 64;
pub static S_IWRITE : mode_t = 128;
pub static S_IREAD : mode_t = 256;
pub static S_IRWXU : mode_t = 448;
pub static S_IXUSR : mode_t = 64;
pub static S_IWUSR : mode_t = 128;
pub static S_IRUSR : mode_t = 256;
pub static F_OK : c_int = 0;
pub static R_OK : c_int = 4;
pub static W_OK : c_int = 2;
Expand Down Expand Up @@ -2220,6 +2221,7 @@ pub mod consts {
pub mod posix88 {
use types::os::arch::c95::c_int;
use types::common::c95::c_void;
use types::os::arch::posix88::mode_t;

pub static O_RDONLY : c_int = 0;
pub static O_WRONLY : c_int = 1;
Expand All @@ -2228,20 +2230,20 @@ pub mod consts {
pub static O_CREAT : c_int = 256;
pub static O_EXCL : c_int = 1024;
pub static O_TRUNC : c_int = 512;
pub static S_IFIFO : c_int = 4096;
pub static S_IFCHR : c_int = 8192;
pub static S_IFBLK : c_int = 24576;
pub static S_IFDIR : c_int = 16384;
pub static S_IFREG : c_int = 32768;
pub static S_IFLNK : c_int = 40960;
pub static S_IFMT : c_int = 61440;
pub static S_IEXEC : c_int = 64;
pub static S_IWRITE : c_int = 128;
pub static S_IREAD : c_int = 256;
pub static S_IRWXU : c_int = 448;
pub static S_IXUSR : c_int = 64;
pub static S_IWUSR : c_int = 128;
pub static S_IRUSR : c_int = 256;
pub static S_IFIFO : mode_t = 4096;
pub static S_IFCHR : mode_t = 8192;
pub static S_IFBLK : mode_t = 24576;
pub static S_IFDIR : mode_t = 16384;
pub static S_IFREG : mode_t = 32768;
pub static S_IFLNK : mode_t = 40960;
pub static S_IFMT : mode_t = 61440;
pub static S_IEXEC : mode_t = 64;
pub static S_IWRITE : mode_t = 128;
pub static S_IREAD : mode_t = 256;
pub static S_IRWXU : mode_t = 448;
pub static S_IXUSR : mode_t = 64;
pub static S_IWUSR : mode_t = 128;
pub static S_IRUSR : mode_t = 256;
pub static F_OK : c_int = 0;
pub static R_OK : c_int = 4;
pub static W_OK : c_int = 2;
Expand Down Expand Up @@ -2759,6 +2761,7 @@ pub mod consts {
pub mod posix88 {
use types::common::c95::c_void;
use types::os::arch::c95::c_int;
use types::os::arch::posix88::mode_t;

pub static O_RDONLY : c_int = 0;
pub static O_WRONLY : c_int = 1;
Expand All @@ -2767,20 +2770,20 @@ pub mod consts {
pub static O_CREAT : c_int = 512;
pub static O_EXCL : c_int = 2048;
pub static O_TRUNC : c_int = 1024;
pub static S_IFIFO : c_int = 4096;
pub static S_IFCHR : c_int = 8192;
pub static S_IFBLK : c_int = 24576;
pub static S_IFDIR : c_int = 16384;
pub static S_IFREG : c_int = 32768;
pub static S_IFLNK : c_int = 40960;
pub static S_IFMT : c_int = 61440;
pub static S_IEXEC : c_int = 64;
pub static S_IWRITE : c_int = 128;
pub static S_IREAD : c_int = 256;
pub static S_IRWXU : c_int = 448;
pub static S_IXUSR : c_int = 64;
pub static S_IWUSR : c_int = 128;
pub static S_IRUSR : c_int = 256;
pub static S_IFIFO : mode_t = 4096;
pub static S_IFCHR : mode_t = 8192;
pub static S_IFBLK : mode_t = 24576;
pub static S_IFDIR : mode_t = 16384;
pub static S_IFREG : mode_t = 32768;
pub static S_IFLNK : mode_t = 40960;
pub static S_IFMT : mode_t = 61440;
pub static S_IEXEC : mode_t = 64;
pub static S_IWRITE : mode_t = 128;
pub static S_IREAD : mode_t = 256;
pub static S_IRWXU : mode_t = 448;
pub static S_IXUSR : mode_t = 64;
pub static S_IWUSR : mode_t = 128;
pub static S_IRUSR : mode_t = 256;
pub static F_OK : c_int = 0;
pub static R_OK : c_int = 4;
pub static W_OK : c_int = 2;
Expand Down Expand Up @@ -3148,6 +3151,7 @@ pub mod consts {
pub mod posix88 {
use types::common::c95::c_void;
use types::os::arch::c95::c_int;
use types::os::arch::posix88::mode_t;

pub static O_RDONLY : c_int = 0;
pub static O_WRONLY : c_int = 1;
Expand All @@ -3156,20 +3160,20 @@ pub mod consts {
pub static O_CREAT : c_int = 512;
pub static O_EXCL : c_int = 2048;
pub static O_TRUNC : c_int = 1024;
pub static S_IFIFO : c_int = 4096;
pub static S_IFCHR : c_int = 8192;
pub static S_IFBLK : c_int = 24576;
pub static S_IFDIR : c_int = 16384;
pub static S_IFREG : c_int = 32768;
pub static S_IFLNK : c_int = 40960;
pub static S_IFMT : c_int = 61440;
pub static S_IEXEC : c_int = 64;
pub static S_IWRITE : c_int = 128;
pub static S_IREAD : c_int = 256;
pub static S_IRWXU : c_int = 448;
pub static S_IXUSR : c_int = 64;
pub static S_IWUSR : c_int = 128;
pub static S_IRUSR : c_int = 256;
pub static S_IFIFO : mode_t = 4096;
pub static S_IFCHR : mode_t = 8192;
pub static S_IFBLK : mode_t = 24576;
pub static S_IFDIR : mode_t = 16384;
pub static S_IFREG : mode_t = 32768;
pub static S_IFLNK : mode_t = 40960;
pub static S_IFMT : mode_t = 61440;
pub static S_IEXEC : mode_t = 64;
pub static S_IWRITE : mode_t = 128;
pub static S_IREAD : mode_t = 256;
pub static S_IRWXU : mode_t = 448;
pub static S_IXUSR : mode_t = 64;
pub static S_IWUSR : mode_t = 128;
pub static S_IRUSR : mode_t = 256;
pub static F_OK : c_int = 0;
pub static R_OK : c_int = 4;
pub static W_OK : c_int = 2;
Expand Down Expand Up @@ -3858,7 +3862,7 @@ pub mod funcs {
use types::os::arch::posix88::mode_t;

extern {
pub fn open(path: *const c_char, oflag: c_int, mode: c_int)
pub fn open(path: *const c_char, oflag: c_int, mode: mode_t)
-> c_int;
pub fn creat(path: *const c_char, mode: mode_t) -> c_int;
pub fn fcntl(fd: c_int, cmd: c_int, ...) -> c_int;
Expand Down
10 changes: 7 additions & 3 deletions branches/dist-snap/src/librustc/back/link.rs
Original file line number Diff line number Diff line change
Expand Up @@ -555,6 +555,12 @@ pub fn find_crate_name(sess: Option<&Session>,
s
};

// Look in attributes 100% of the time to make sure the attribute is marked
// as used. After doing this, however, favor crate names from the command
// line.
let attr_crate_name = attrs.iter().find(|at| at.check_name("crate_name"))
.and_then(|at| at.value_str().map(|s| (at, s)));

match sess {
Some(sess) => {
match sess.opts.crate_name {
Expand All @@ -565,9 +571,7 @@ pub fn find_crate_name(sess: Option<&Session>,
None => {}
}

let crate_name = attrs.iter().find(|at| at.check_name("crate_name"))
.and_then(|at| at.value_str().map(|s| (at, s)));
match crate_name {
match attr_crate_name {
Some((attr, s)) => return validate(s.get().to_string(), Some(attr.span)),
None => {}
}
Expand Down
5 changes: 5 additions & 0 deletions branches/dist-snap/src/librustc/lint/builtin.rs
Original file line number Diff line number Diff line change
Expand Up @@ -758,6 +758,11 @@ impl LintPass for NonCamelCaseTypes {
}
}

let has_extern_repr = it.attrs.iter().fold(attr::ReprAny, |acc, attr| {
attr::find_repr_attr(cx.tcx.sess.diagnostic(), attr, acc)
}) == attr::ReprExtern;
if has_extern_repr { return }

match it.node {
ast::ItemTy(..) | ast::ItemStruct(..) => {
check_case(cx, "type", it.ident, it.span)
Expand Down
5 changes: 4 additions & 1 deletion branches/dist-snap/src/librustdoc/html/format.rs
Original file line number Diff line number Diff line change
Expand Up @@ -431,7 +431,10 @@ impl fmt::Show for clean::Type {
}
clean::Tuple(ref typs) => {
primitive_link(f, clean::PrimitiveTuple,
format!("({:#})", typs).as_slice())
match typs.as_slice() {
[ref one] => format!("({},)", one),
many => format!("({:#})", many)
}.as_slice())
}
clean::Vector(ref t) => {
primitive_link(f, clean::Slice, format!("[{}]", **t).as_slice())
Expand Down
2 changes: 1 addition & 1 deletion branches/dist-snap/src/librustuv/file.rs
Original file line number Diff line number Diff line change
Expand Up @@ -547,7 +547,7 @@ mod test {
let path = &"./tmp/mk_rm_dir".to_c_str();
let mode = S_IWUSR | S_IRUSR;

let result = FsRequest::mkdir(l(), path, mode);
let result = FsRequest::mkdir(l(), path, mode as c_int);
assert!(result.is_ok());

let result = FsRequest::rmdir(l(), path);
Expand Down
2 changes: 2 additions & 0 deletions branches/dist-snap/src/libstd/hash.rs
Original file line number Diff line number Diff line change
Expand Up @@ -61,6 +61,8 @@
* ```
*/

#![experimental]

pub use core_collections::hash::{Hash, Hasher, Writer, hash, sip};

use default::Default;
Expand Down
7 changes: 6 additions & 1 deletion branches/dist-snap/src/libstd/io/fs.rs
Original file line number Diff line number Diff line change
Expand Up @@ -330,6 +330,11 @@ pub fn lstat(path: &Path) -> IoResult<FileStat> {
}

fn from_rtio(s: rtio::FileStat) -> FileStat {
#[cfg(windows)]
type Mode = libc::c_int;
#[cfg(unix)]
type Mode = libc::mode_t;

let rtio::FileStat {
size, kind, perm, created, modified,
accessed, device, inode, rdev,
Expand All @@ -338,7 +343,7 @@ fn from_rtio(s: rtio::FileStat) -> FileStat {

FileStat {
size: size,
kind: match (kind as libc::c_int) & libc::S_IFMT {
kind: match (kind as Mode) & libc::S_IFMT {
libc::S_IFREG => io::TypeFile,
libc::S_IFDIR => io::TypeDirectory,
libc::S_IFIFO => io::TypeNamedPipe,
Expand Down
11 changes: 9 additions & 2 deletions branches/dist-snap/src/libsyntax/ast.rs
Original file line number Diff line number Diff line change
Expand Up @@ -58,7 +58,14 @@ impl Ident {

impl Show for Ident {
fn fmt(&self, f: &mut fmt::Formatter) -> fmt::Result {
write!(f, "\"{}\"#{}", token::get_ident(*self).get(), self.ctxt)
write!(f, "{}#{}", self.name, self.ctxt)
}
}

impl Show for Name {
fn fmt(&self, f: &mut fmt::Formatter) -> fmt::Result {
let Name(nm) = *self;
write!(f, "\"{}\"({})", token::get_name(*self).get(), nm)
}
}

Expand Down Expand Up @@ -106,7 +113,7 @@ pub static ILLEGAL_CTXT : SyntaxContext = 1;

/// A name is a part of an identifier, representing a string or gensym. It's
/// the result of interning.
#[deriving(Eq, Ord, PartialEq, PartialOrd, Hash, Encodable, Decodable, Clone, Show)]
#[deriving(Eq, Ord, PartialEq, PartialOrd, Hash, Encodable, Decodable, Clone)]
pub struct Name(pub u32);

impl Name {
Expand Down
2 changes: 1 addition & 1 deletion branches/dist-snap/src/libsyntax/parse/attr.rs
Original file line number Diff line number Diff line change
Expand Up @@ -85,9 +85,9 @@ impl<'a> ParserAttr for Parser<'a> {

self.expect(&token::LBRACKET);
let meta_item = self.parse_meta_item();
let hi = self.span.hi;
self.expect(&token::RBRACKET);

let hi = self.span.hi;
(mk_sp(lo, hi), meta_item, style)
}
_ => {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -32,4 +32,9 @@ enum Foo5 {
trait foo6 { //~ ERROR trait `foo6` should have a camel case name such as `Foo6`
}

#[repr(C)]
struct foo7 {
bar: int,
}

fn main() { }
Loading

0 comments on commit 9340348

Please sign in to comment.