diff options
Diffstat (limited to 'tests/ui/typeck/bad-index-due-to-nested.stderr')
-rw-r--r-- | tests/ui/typeck/bad-index-due-to-nested.stderr | 36 |
1 files changed, 22 insertions, 14 deletions
diff --git a/tests/ui/typeck/bad-index-due-to-nested.stderr b/tests/ui/typeck/bad-index-due-to-nested.stderr index e03b06b336e..f9cdb280e27 100644 --- a/tests/ui/typeck/bad-index-due-to-nested.stderr +++ b/tests/ui/typeck/bad-index-due-to-nested.stderr @@ -4,11 +4,14 @@ error[E0277]: the trait bound `K: Hash` is not satisfied LL | map[k] | ^^^ the trait `Hash` is not implemented for `K` | -note: required by a bound in `<HashMap<K, V> as Index<&K>>` - --> $DIR/bad-index-due-to-nested.rs:9:8 +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, - | ^^^^ required by this bound in `<HashMap<K, V> as Index<&K>>` + | ---- 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 { @@ -20,11 +23,14 @@ error[E0277]: the trait bound `V: Copy` is not satisfied LL | map[k] | ^^^ the trait `Copy` is not implemented for `V` | -note: required by a bound in `<HashMap<K, V> as Index<&K>>` - --> $DIR/bad-index-due-to-nested.rs:10:8 +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, - | ^^^^ required by this bound in `<HashMap<K, V> as Index<&K>>` + | ---- 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 { @@ -36,13 +42,14 @@ error[E0308]: mismatched types 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` - | help: consider borrowing here: `&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 @@ -50,13 +57,14 @@ error[E0308]: mismatched types 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` - | help: consider borrowing here: `&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 |