|
| 1 | +error[E0277]: the trait bound `K: Hash` is not satisfied |
| 2 | + --> $DIR/bad-index-due-to-nested.rs:24:5 |
| 3 | + | |
| 4 | +LL | map[k] |
| 5 | + | ^^^ the trait `Hash` is not implemented for `K` |
| 6 | + | |
| 7 | +note: required for `HashMap<K, V>` to implement `Index<&K>` |
| 8 | + --> $DIR/bad-index-due-to-nested.rs:11:12 |
| 9 | + | |
| 10 | +LL | impl<K, V> Index<&K> for HashMap<K, V> |
| 11 | + | ^^^^^^^^^ ^^^^^^^^^^^^^ |
| 12 | +LL | where |
| 13 | +LL | K: Hash, |
| 14 | + | ---- unsatisfied trait bound introduced here |
| 15 | +help: consider restricting type parameter `K` with trait `Hash` |
| 16 | + | |
| 17 | +LL | fn index<'a, K: std::hash::Hash, V>(map: &'a HashMap<K, V>, k: K) -> &'a V { |
| 18 | + | +++++++++++++++++ |
| 19 | + |
| 20 | +error[E0277]: the trait bound `V: Copy` is not satisfied |
| 21 | + --> $DIR/bad-index-due-to-nested.rs:24:5 |
| 22 | + | |
| 23 | +LL | map[k] |
| 24 | + | ^^^ the trait `Copy` is not implemented for `V` |
| 25 | + | |
| 26 | +note: required for `HashMap<K, V>` to implement `Index<&K>` |
| 27 | + --> $DIR/bad-index-due-to-nested.rs:11:12 |
| 28 | + | |
| 29 | +LL | impl<K, V> Index<&K> for HashMap<K, V> |
| 30 | + | ^^^^^^^^^ ^^^^^^^^^^^^^ |
| 31 | +... |
| 32 | +LL | V: Copy, |
| 33 | + | ---- unsatisfied trait bound introduced here |
| 34 | +help: consider restricting type parameter `V` with trait `Copy` |
| 35 | + | |
| 36 | +LL | fn index<'a, K, V: std::marker::Copy>(map: &'a HashMap<K, V>, k: K) -> &'a V { |
| 37 | + | +++++++++++++++++++ |
| 38 | + |
| 39 | +error[E0308]: mismatched types |
| 40 | + --> $DIR/bad-index-due-to-nested.rs:24:9 |
| 41 | + | |
| 42 | +LL | fn index<'a, K, V>(map: &'a HashMap<K, V>, k: K) -> &'a V { |
| 43 | + | - found this type parameter |
| 44 | +LL | map[k] |
| 45 | + | ^ expected `&K`, found type parameter `K` |
| 46 | + | |
| 47 | + = note: expected reference `&_` |
| 48 | + found type parameter `_` |
| 49 | +help: consider borrowing here |
| 50 | + | |
| 51 | +LL | map[&k] |
| 52 | + | + |
| 53 | + |
| 54 | +error[E0277]: the trait bound `K: Hash` is not satisfied |
| 55 | + --> $DIR/bad-index-due-to-nested.rs:24:5 |
| 56 | + | |
| 57 | +LL | map[k] |
| 58 | + | ^^^^^^ the trait `Hash` is not implemented for `K` |
| 59 | + | |
| 60 | +note: required for `HashMap<K, V>` to implement `Index<&K>` |
| 61 | + --> $DIR/bad-index-due-to-nested.rs:11:12 |
| 62 | + | |
| 63 | +LL | impl<K, V> Index<&K> for HashMap<K, V> |
| 64 | + | ^^^^^^^^^ ^^^^^^^^^^^^^ |
| 65 | +LL | where |
| 66 | +LL | K: Hash, |
| 67 | + | ---- unsatisfied trait bound introduced here |
| 68 | +help: consider restricting type parameter `K` with trait `Hash` |
| 69 | + | |
| 70 | +LL | fn index<'a, K: std::hash::Hash, V>(map: &'a HashMap<K, V>, k: K) -> &'a V { |
| 71 | + | +++++++++++++++++ |
| 72 | + |
| 73 | +error: aborting due to 4 previous errors |
| 74 | + |
| 75 | +Some errors have detailed explanations: E0277, E0308. |
| 76 | +For more information about an error, try `rustc --explain E0277`. |
0 commit comments