diff options
| author | Esteban Küber <esteban@kuber.com.ar> | 2023-11-13 00:52:10 +0000 |
|---|---|---|
| committer | Esteban Küber <esteban@kuber.com.ar> | 2023-11-13 00:52:10 +0000 |
| commit | 69634f2077bc4f223cca7dfb63e104ac1efa0752 (patch) | |
| tree | 12bd1f8576e625e3457fe4fc31cfd609633e2a53 /tests/ui/indexing | |
| parent | d8dbf7ca0ee9c6da0fd039b1eb8cf7c7cb840f43 (diff) | |
| download | rust-69634f2077bc4f223cca7dfb63e104ac1efa0752.tar.gz rust-69634f2077bc4f223cca7dfb63e104ac1efa0752.zip | |
Always point at index span on index obligation failure
Use more targetted span for index obligation failures by rewriting the obligation cause span. CC #66023
Diffstat (limited to 'tests/ui/indexing')
| -rw-r--r-- | tests/ui/indexing/point-at-index-for-obligation-failure.rs | 7 | ||||
| -rw-r--r-- | tests/ui/indexing/point-at-index-for-obligation-failure.stderr | 13 |
2 files changed, 20 insertions, 0 deletions
diff --git a/tests/ui/indexing/point-at-index-for-obligation-failure.rs b/tests/ui/indexing/point-at-index-for-obligation-failure.rs new file mode 100644 index 00000000000..e9c429b53ce --- /dev/null +++ b/tests/ui/indexing/point-at-index-for-obligation-failure.rs @@ -0,0 +1,7 @@ +fn main() { + let a = std::collections::HashMap::<String,String>::new(); + let s = "hello"; + let _b = a[ + &s //~ ERROR E0277 + ]; +} diff --git a/tests/ui/indexing/point-at-index-for-obligation-failure.stderr b/tests/ui/indexing/point-at-index-for-obligation-failure.stderr new file mode 100644 index 00000000000..3e2fbc2ab6f --- /dev/null +++ b/tests/ui/indexing/point-at-index-for-obligation-failure.stderr @@ -0,0 +1,13 @@ +error[E0277]: the trait bound `String: Borrow<&str>` is not satisfied + --> $DIR/point-at-index-for-obligation-failure.rs:5:9 + | +LL | &s + | ^^ the trait `Borrow<&str>` is not implemented for `String` + | + = help: the trait `Borrow<str>` is implemented for `String` + = help: for that trait implementation, expected `str`, found `&str` + = note: required for `HashMap<String, String>` to implement `Index<&&str>` + +error: aborting due to previous error + +For more information about this error, try `rustc --explain E0277`. |
