blob: a0b275b7852badac2822b1e41a7401824d6f1e38 [file] [log] [blame]
error[E0277]: the trait bound `K: Hash` is not satisfied
--> $DIR/bad-index-due-to-nested.rs:24:5
|
LL | map[k]
| ^^^ the trait `Hash` is not implemented for `K`
|
note: required for `HashMap<K, V>` to implement `Index<&K>`
--> $DIR/bad-index-due-to-nested.rs:11:12
|
LL | impl<K, V> Index<&K> for HashMap<K, V>
| ^^^^^^^^^ ^^^^^^^^^^^^^
LL | where
LL | K: Hash,
| ---- unsatisfied trait bound introduced here
help: consider restricting type parameter `K` with trait `Hash`
|
LL | fn index<'a, K: std::hash::Hash, V>(map: &'a HashMap<K, V>, k: K) -> &'a V {
| +++++++++++++++++
error[E0277]: the trait bound `V: Copy` is not satisfied
--> $DIR/bad-index-due-to-nested.rs:24:5
|
LL | map[k]
| ^^^ the trait `Copy` is not implemented for `V`
|
note: required for `HashMap<K, V>` to implement `Index<&K>`
--> $DIR/bad-index-due-to-nested.rs:11:12
|
LL | impl<K, V> Index<&K> for HashMap<K, V>
| ^^^^^^^^^ ^^^^^^^^^^^^^
...
LL | V: Copy,
| ---- unsatisfied trait bound introduced here
help: consider restricting type parameter `V` with trait `Copy`
|
LL | fn index<'a, K, V: std::marker::Copy>(map: &'a HashMap<K, V>, k: K) -> &'a V {
| +++++++++++++++++++
error[E0308]: mismatched types
--> $DIR/bad-index-due-to-nested.rs:24:9
|
LL | fn index<'a, K, V>(map: &'a HashMap<K, V>, k: K) -> &'a V {
| - found this type parameter
LL | map[k]
| ^ expected `&K`, found type parameter `K`
|
= note: expected reference `&_`
found type parameter `_`
help: consider borrowing here
|
LL | map[&k]
| +
error[E0277]: the trait bound `K: Hash` is not satisfied
--> $DIR/bad-index-due-to-nested.rs:24:5
|
LL | map[k]
| ^^^^^^ the trait `Hash` is not implemented for `K`
|
note: required for `HashMap<K, V>` to implement `Index<&K>`
--> $DIR/bad-index-due-to-nested.rs:11:12
|
LL | impl<K, V> Index<&K> for HashMap<K, V>
| ^^^^^^^^^ ^^^^^^^^^^^^^
LL | where
LL | K: Hash,
| ---- unsatisfied trait bound introduced here
help: consider restricting type parameter `K` with trait `Hash`
|
LL | fn index<'a, K: std::hash::Hash, V>(map: &'a HashMap<K, V>, k: K) -> &'a V {
| +++++++++++++++++
error: aborting due to 4 previous errors
Some errors have detailed explanations: E0277, E0308.
For more information about an error, try `rustc --explain E0277`.