From 5706be1854db74d0aafcc4658423884689f139e9 Mon Sep 17 00:00:00 2001 From: Nilstrieb <48135649+Nilstrieb@users.noreply.github.com> Date: Thu, 3 Aug 2023 21:43:17 +0200 Subject: 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. --- tests/ui/indexing/index_message.stderr | 9 +++++++++ 1 file changed, 9 insertions(+) create mode 100644 tests/ui/indexing/index_message.stderr (limited to 'tests/ui/indexing/index_message.stderr') diff --git a/tests/ui/indexing/index_message.stderr b/tests/ui/indexing/index_message.stderr new file mode 100644 index 00000000000..80f2bd52314 --- /dev/null +++ b/tests/ui/indexing/index_message.stderr @@ -0,0 +1,9 @@ +error[E0608]: cannot index into a value of type `({integer},)` + --> $DIR/index_message.rs:3:14 + | +LL | let _ = z[0]; + | ^^^ help: to access tuple elements, use: `.0` + +error: aborting due to previous error + +For more information about this error, try `rustc --explain E0608`. -- cgit 1.4.1-3-g733a5