Skip to content

Commit 6e19274

Browse files
committed
---
yaml --- r: 273683 b: refs/heads/beta c: 01c0723 h: refs/heads/master i: 273681: d7beeb2 273679: 760ea36
1 parent c237982 commit 6e19274

File tree

4 files changed

+39
-15
lines changed

4 files changed

+39
-15
lines changed

[refs]

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -23,7 +23,7 @@ refs/tags/0.9: 36870b185fc5f5486636d4515f0e22677493f225
2323
refs/tags/0.10: ac33f2b15782272ae348dbd7b14b8257b2148b5a
2424
refs/tags/0.11.0: e1247cb1d0d681be034adb4b558b5a0c0d5720f9
2525
refs/tags/0.12.0: f0c419429ef30723ceaf6b42f9b5a2aeb5d2e2d1
26-
refs/heads/beta: abb3a107e45b93ca5332ab11bfa6cc8d5a882fb4
26+
refs/heads/beta: 01c0723ef247fec4b85af203c7247b66e3817e1b
2727
refs/tags/1.0.0-alpha: e42bd6d93a1d3433c486200587f8f9e12590a4d7
2828
refs/heads/tmp: e06d2ad9fcd5027bcaac5b08fc9aa39a49d0ecd3
2929
refs/tags/1.0.0-alpha.2: 4c705f6bc559886632d3871b04f58aab093bfa2f

branches/beta/src/librustc/ty/mod.rs

Lines changed: 2 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -1202,7 +1202,6 @@ impl<'a, 'tcx> ParameterEnvironment<'a, 'tcx> {
12021202
}
12031203
}
12041204

1205-
/// Construct a parameter environment given an item, impl item, or trait item
12061205
pub fn for_item(cx: &'a TyCtxt<'tcx>, id: NodeId) -> ParameterEnvironment<'a, 'tcx> {
12071206
match cx.map.find(id) {
12081207
Some(ast_map::NodeImplItem(ref impl_item)) => {
@@ -1342,7 +1341,7 @@ impl<'a, 'tcx> ParameterEnvironment<'a, 'tcx> {
13421341
}
13431342
_ => {
13441343
cx.sess.span_bug(item.span,
1345-
"ParameterEnvironment::for_item():
1344+
"ParameterEnvironment::from_item():
13461345
can't create a parameter \
13471346
environment for this kind of item")
13481347
}
@@ -1353,7 +1352,7 @@ impl<'a, 'tcx> ParameterEnvironment<'a, 'tcx> {
13531352
ParameterEnvironment::for_item(cx, cx.map.get_parent(id))
13541353
}
13551354
_ => {
1356-
cx.sess.bug(&format!("ParameterEnvironment::for_item(): \
1355+
cx.sess.bug(&format!("ParameterEnvironment::from_item(): \
13571356
`{}` is not an item",
13581357
cx.map.node_to_string(id)))
13591358
}

branches/beta/src/libstd/sys/windows/net.rs

Lines changed: 10 additions & 11 deletions
Original file line numberDiff line numberDiff line change
@@ -61,28 +61,27 @@ fn last_error() -> io::Error {
6161
}
6262

6363
/// Checks if the signed integer is the Windows constant `SOCKET_ERROR` (-1)
64-
/// and if so, returns the last error from the Windows socket interface. This
64+
/// and if so, returns the last error from the Windows socket interface. . This
6565
/// function must be called before another call to the socket API is made.
66-
pub fn cvt<T: One + PartialEq + Neg<Output=T>>(t: T) -> io::Result<T> {
67-
if t == -T::one() {
66+
pub fn cvt<T: One + Neg<Output=T> + PartialEq>(t: T) -> io::Result<T> {
67+
let one: T = T::one();
68+
if t == -one {
6869
Err(last_error())
6970
} else {
7071
Ok(t)
7172
}
7273
}
7374

74-
/// A variant of `cvt` for `getaddrinfo` which return 0 for a success.
75+
/// Provides the functionality of `cvt` for the return values of `getaddrinfo`
76+
/// and similar, meaning that they return an error if the return value is 0.
7577
pub fn cvt_gai(err: c_int) -> io::Result<()> {
76-
if err == 0 {
77-
Ok(())
78-
} else {
79-
Err(last_error())
80-
}
78+
if err == 0 { return Ok(()) }
79+
cvt(err).map(|_| ())
8180
}
8281

83-
/// Just to provide the same interface as sys/unix/net.rs
82+
/// Provides the functionality of `cvt` for a closure.
8483
pub fn cvt_r<T, F>(mut f: F) -> io::Result<T>
85-
where T: One + PartialEq + Neg<Output=T>, F: FnMut() -> T
84+
where F: FnMut() -> T, T: One + Neg<Output=T> + PartialEq
8685
{
8786
cvt(f())
8887
}

branches/beta/src/test/run-pass/deriving-hash.rs

Lines changed: 26 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -12,6 +12,7 @@
1212
#![feature(hash_default)]
1313

1414
use std::hash::{Hash, SipHasher, Hasher};
15+
use std::mem::size_of;
1516

1617
#[derive(Hash)]
1718
struct Person {
@@ -24,12 +25,30 @@ struct Person {
2425
#[derive(Hash)] struct __H__H;
2526
#[derive(Hash)] enum Collision<__H> { __H { __H__H: __H } }
2627

28+
#[derive(Hash)]
29+
enum E { A=1, B }
30+
2731
fn hash<T: Hash>(t: &T) -> u64 {
2832
let mut s = SipHasher::new_with_keys(0, 0);
2933
t.hash(&mut s);
3034
s.finish()
3135
}
3236

37+
struct FakeHasher<'a>(&'a mut Vec<u8>);
38+
impl<'a> Hasher for FakeHasher<'a> {
39+
fn finish(&self) -> u64 {
40+
unimplemented!()
41+
}
42+
43+
fn write(&mut self, bytes: &[u8]) {
44+
self.0.extend(bytes);
45+
}
46+
}
47+
48+
fn fake_hash(v: &mut Vec<u8>, e: E) {
49+
e.hash(&mut FakeHasher(v));
50+
}
51+
3352
fn main() {
3453
let person1 = Person {
3554
id: 5,
@@ -43,4 +62,11 @@ fn main() {
4362
};
4463
assert_eq!(hash(&person1), hash(&person1));
4564
assert!(hash(&person1) != hash(&person2));
65+
66+
// test #21714
67+
let mut va = vec![];
68+
let mut vb = vec![];
69+
fake_hash(&mut va, E::A);
70+
fake_hash(&mut vb, E::B);
71+
assert!(va != vb);
4672
}

0 commit comments

Comments
 (0)