about summary refs log tree commit diff
path: root/tests/ui/indexing/index-bot.rs
diff options
context:
space:
mode:
authorNilstrieb <48135649+Nilstrieb@users.noreply.github.com>2023-08-03 21:43:17 +0200
committerNilstrieb <48135649+Nilstrieb@users.noreply.github.com>2023-08-04 13:17:39 +0200
commit5706be1854db74d0aafcc4658423884689f139e9 (patch)
tree5e4a3543de6a955d72ece8459d3e3353a05cc906 /tests/ui/indexing/index-bot.rs
parentfcf3006e0133365ecd26894689c086387edcbecb (diff)
downloadrust-5706be1854db74d0aafcc4658423884689f139e9.tar.gz
rust-5706be1854db74d0aafcc4658423884689f139e9.zip
Improve spans for indexing expressions
Indexing is similar to method calls in having an arbitrary
left-hand-side and then something on the right, which is the main part
of the expression. Method calls already have a span for that right part,
but indexing does not. This means that long method chains that use
indexing have really bad spans, especially when the indexing panics and
that span in coverted into a panic location.

This does the same thing as method calls for the AST and HIR, storing an
extra span which is then put into the `fn_span` field in THIR.
Diffstat (limited to 'tests/ui/indexing/index-bot.rs')
-rw-r--r--tests/ui/indexing/index-bot.rs3
1 files changed, 3 insertions, 0 deletions
diff --git a/tests/ui/indexing/index-bot.rs b/tests/ui/indexing/index-bot.rs
new file mode 100644
index 00000000000..e69c4019f61
--- /dev/null
+++ b/tests/ui/indexing/index-bot.rs
@@ -0,0 +1,3 @@
+fn main() {
+    (return)[0]; //~ ERROR cannot index into a value of type `!`
+}