Skip to content

Commit 9340348

Browse files
committed
---
yaml --- r: 131800 b: refs/heads/dist-snap c: 55cf6d7 h: refs/heads/master v: v3
1 parent 9554e09 commit 9340348

File tree

13 files changed

+151
-67
lines changed

13 files changed

+151
-67
lines changed

[refs]

+1-1
Original file line numberDiff line numberDiff line change
@@ -6,7 +6,7 @@ refs/heads/try: 457a3c991d79b971be07fce75f9d0c12848fb37c
66
refs/tags/release-0.1: 1f5c5126e96c79d22cb7862f75304136e204f105
77
refs/heads/ndm: f3868061cd7988080c30d6d5bf352a5a5fe2460b
88
refs/heads/try2: 147ecfdd8221e4a4d4e090486829a06da1e0ca3c
9-
refs/heads/dist-snap: 2cf68ba10106a73b52b3cc7893c0a0a08e8a2018
9+
refs/heads/dist-snap: 55cf6d723c40bf720d7d9f9ed3a5833caa8faf1a
1010
refs/tags/release-0.2: c870d2dffb391e14efb05aa27898f1f6333a9596
1111
refs/tags/release-0.3: b5f0d0f648d9a6153664837026ba1be43d3e2503
1212
refs/heads/try3: 9387340aab40a73e8424c48fd42f0c521a4875c0

branches/dist-snap/src/libcollections/treemap.rs

+34
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],

branches/dist-snap/src/liblibc/lib.rs

+61-57
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;

branches/dist-snap/src/librustc/back/link.rs

+7-3
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
}

branches/dist-snap/src/librustc/lint/builtin.rs

+5
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)

branches/dist-snap/src/librustdoc/html/format.rs

+4-1
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())

branches/dist-snap/src/librustuv/file.rs

+1-1
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);

branches/dist-snap/src/libstd/hash.rs

+2
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;

branches/dist-snap/src/libstd/io/fs.rs

+6-1
Original file line numberDiff line numberDiff line change
@@ -330,6 +330,11 @@ pub fn lstat(path: &Path) -> IoResult<FileStat> {
330330
}
331331

332332
fn from_rtio(s: rtio::FileStat) -> FileStat {
333+
#[cfg(windows)]
334+
type Mode = libc::c_int;
335+
#[cfg(unix)]
336+
type Mode = libc::mode_t;
337+
333338
let rtio::FileStat {
334339
size, kind, perm, created, modified,
335340
accessed, device, inode, rdev,
@@ -338,7 +343,7 @@ fn from_rtio(s: rtio::FileStat) -> FileStat {
338343

339344
FileStat {
340345
size: size,
341-
kind: match (kind as libc::c_int) & libc::S_IFMT {
346+
kind: match (kind as Mode) & libc::S_IFMT {
342347
libc::S_IFREG => io::TypeFile,
343348
libc::S_IFDIR => io::TypeDirectory,
344349
libc::S_IFIFO => io::TypeNamedPipe,

branches/dist-snap/src/libsyntax/ast.rs

+9-2
Original file line numberDiff line numberDiff line change
@@ -58,7 +58,14 @@ impl Ident {
5858

5959
impl Show for Ident {
6060
fn fmt(&self, f: &mut fmt::Formatter) -> fmt::Result {
61-
write!(f, "\"{}\"#{}", token::get_ident(*self).get(), self.ctxt)
61+
write!(f, "{}#{}", self.name, self.ctxt)
62+
}
63+
}
64+
65+
impl Show for Name {
66+
fn fmt(&self, f: &mut fmt::Formatter) -> fmt::Result {
67+
let Name(nm) = *self;
68+
write!(f, "\"{}\"({})", token::get_name(*self).get(), nm)
6269
}
6370
}
6471

@@ -106,7 +113,7 @@ pub static ILLEGAL_CTXT : SyntaxContext = 1;
106113

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

112119
impl Name {

branches/dist-snap/src/libsyntax/parse/attr.rs

+1-1
Original file line numberDiff line numberDiff line change
@@ -85,9 +85,9 @@ impl<'a> ParserAttr for Parser<'a> {
8585

8686
self.expect(&token::LBRACKET);
8787
let meta_item = self.parse_meta_item();
88+
let hi = self.span.hi;
8889
self.expect(&token::RBRACKET);
8990

90-
let hi = self.span.hi;
9191
(mk_sp(lo, hi), meta_item, style)
9292
}
9393
_ => {

branches/dist-snap/src/test/compile-fail/lint-non-camel-case-types.rs

+5
Original file line numberDiff line numberDiff line change
@@ -32,4 +32,9 @@ enum Foo5 {
3232
trait foo6 { //~ ERROR trait `foo6` should have a camel case name such as `Foo6`
3333
}
3434

35+
#[repr(C)]
36+
struct foo7 {
37+
bar: int,
38+
}
39+
3540
fn main() { }

0 commit comments

Comments
 (0)