about summary refs log tree commit diff
path: root/src/libsyntax
diff options
context:
space:
mode:
authorbors <bors@rust-lang.org>2014-10-31 17:11:43 +0000
committerbors <bors@rust-lang.org>2014-10-31 17:11:43 +0000
commit5e834243b6837a2386d623e1d546a3d25057b8f5 (patch)
treeeae18a8506858edd48394dc84ae7f69bf7832b36 /src/libsyntax
parent7e662316d1c2618c87eb0328aa6b2bccd7eaa8d4 (diff)
parent1384a43db3a8b1551bfc3c6feb37e2174d4c2ba0 (diff)
downloadrust-5e834243b6837a2386d623e1d546a3d25057b8f5.tar.gz
rust-5e834243b6837a2386d623e1d546a3d25057b8f5.zip
auto merge of #18440 : japaric/rust/hash, r=alexcrichton
- The signature of the `*_equiv` methods of `HashMap` and similar structures have changed, and now require one less level of indirection. Change your code from:

``` rust
hashmap.find_equiv(&"Hello");
hashmap.find_equiv(&&[0u8, 1, 2]);
```

to:

``` rust
hashmap.find_equiv("Hello");
hashmap.find_equiv(&[0u8, 1, 2]);
```

- The generic parameter `T` of the `Hasher::hash<T>` method have become `Sized?`. Downstream code must add `Sized?` to that method in their implementations. For example:

``` rust
impl Hasher<FnvState> for FnvHasher {
    fn hash<T: Hash<FnvState>>(&self, t: &T) -> u64 { /* .. */ }
}
```

must be changed to:

``` rust
impl Hasher<FnvState> for FnvHasher {
    fn hash<Sized? T: Hash<FnvState>>(&self, t: &T) -> u64 { /* .. */ }
    //      ^^^^^^
}
```

[breaking-change]

---

After review I'll squash the commits and update the commit message with the above paragraph.

r? @aturon 
cc #16918
Diffstat (limited to 'src/libsyntax')
-rw-r--r--src/libsyntax/diagnostics/registry.rs2
-rw-r--r--src/libsyntax/ext/format.rs6
-rw-r--r--src/libsyntax/util/interner.rs6
3 files changed, 7 insertions, 7 deletions
diff --git a/src/libsyntax/diagnostics/registry.rs b/src/libsyntax/diagnostics/registry.rs
index 7bc191df55a..71d82a41f38 100644
--- a/src/libsyntax/diagnostics/registry.rs
+++ b/src/libsyntax/diagnostics/registry.rs
@@ -20,6 +20,6 @@ impl Registry {
     }
 
     pub fn find_description(&self, code: &str) -> Option<&'static str> {
-        self.descriptions.find_equiv(&code).map(|desc| *desc)
+        self.descriptions.find_equiv(code).map(|desc| *desc)
     }
 }
diff --git a/src/libsyntax/ext/format.rs b/src/libsyntax/ext/format.rs
index fa9a844233a..53d091db095 100644
--- a/src/libsyntax/ext/format.rs
+++ b/src/libsyntax/ext/format.rs
@@ -140,7 +140,7 @@ fn parse_args(ecx: &mut ExtCtxt, sp: Span, allow_method: bool,
             let name = interned_name.get();
             p.expect(&token::Eq);
             let e = p.parse_expr();
-            match names.find_equiv(&name) {
+            match names.find_equiv(name) {
                 None => {}
                 Some(prev) => {
                     ecx.span_err(e.span,
@@ -362,7 +362,7 @@ impl<'a, 'b> Context<'a, 'b> {
                 self.ecx.expr_path(path)
             }
             parse::CountIsName(n) => {
-                let i = match self.name_positions.find_equiv(&n) {
+                let i = match self.name_positions.find_equiv(n) {
                     Some(&i) => i,
                     None => 0, // error already emitted elsewhere
                 };
@@ -406,7 +406,7 @@ impl<'a, 'b> Context<'a, 'b> {
                     // Named arguments are converted to positional arguments at
                     // the end of the list of arguments
                     parse::ArgumentNamed(n) => {
-                        let i = match self.name_positions.find_equiv(&n) {
+                        let i = match self.name_positions.find_equiv(n) {
                             Some(&i) => i,
                             None => 0, // error already emitted elsewhere
                         };
diff --git a/src/libsyntax/util/interner.rs b/src/libsyntax/util/interner.rs
index ed2455d0a30..105118ff76a 100644
--- a/src/libsyntax/util/interner.rs
+++ b/src/libsyntax/util/interner.rs
@@ -75,7 +75,7 @@ impl<T: Eq + Hash + Clone + 'static> Interner<T> {
         (*vect).len()
     }
 
-    pub fn find_equiv<Q:Hash + Equiv<T>>(&self, val: &Q) -> Option<Name> {
+    pub fn find_equiv<Sized? Q: Hash + Equiv<T>>(&self, val: &Q) -> Option<Name> {
         let map = self.map.borrow();
         match (*map).find_equiv(val) {
             Some(v) => Some(*v),
@@ -149,7 +149,7 @@ impl StrInterner {
 
     pub fn intern(&self, val: &str) -> Name {
         let mut map = self.map.borrow_mut();
-        match map.find_equiv(&val) {
+        match map.find_equiv(val) {
             Some(&idx) => return idx,
             None => (),
         }
@@ -195,7 +195,7 @@ impl StrInterner {
         self.vect.borrow().len()
     }
 
-    pub fn find_equiv<Q:Hash + Equiv<RcStr>>(&self, val: &Q) -> Option<Name> {
+    pub fn find_equiv<Sized? Q:Hash + Equiv<RcStr>>(&self, val: &Q) -> Option<Name> {
         match (*self.map.borrow()).find_equiv(val) {
             Some(v) => Some(*v),
             None => None,