summaryrefslogtreecommitdiff
path: root/tests/ui/typeck/bad-index-due-to-nested.stderr
blob: f9cdb280e276a320071154514c5fa89f6d2a9ac0 (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
error[E0277]: the trait bound `K: Hash` is not satisfied
  --> $DIR/bad-index-due-to-nested.rs:20: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:7: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`
   |
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:20: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:7: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`
   |
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:20:9
   |
LL | fn index<'a, K, V>(map: &'a HashMap<K, V>, k: K) -> &'a V {
   |              - this type parameter
LL |     map[k]
   |         ^ expected `&K`, found type parameter `K`
   |
   = note:   expected reference `&K`
           found type parameter `K`
help: consider borrowing here
   |
LL |     map[&k]
   |         +

error[E0308]: mismatched types
  --> $DIR/bad-index-due-to-nested.rs:20:5
   |
LL | fn index<'a, K, V>(map: &'a HashMap<K, V>, k: K) -> &'a V {
   |                 - this type parameter               ----- expected `&'a V` because of return type
LL |     map[k]
   |     ^^^^^^ expected `&V`, found type parameter `V`
   |
   = note:   expected reference `&'a V`
           found type parameter `V`
help: consider borrowing here
   |
LL |     &map[k]
   |     +

error: aborting due to 4 previous errors

Some errors have detailed explanations: E0277, E0308.
For more information about an error, try `rustc --explain E0277`.