about summary refs log tree commit diff
path: root/tests/ui/error-codes
diff options
context:
space:
mode:
authorbors <bors@rust-lang.org>2023-07-12 12:11:09 +0000
committerbors <bors@rust-lang.org>2023-07-12 12:11:09 +0000
commitda1d099f91ea387a2814a6244dd875a2048b486f (patch)
treede7d014f0abf2b8f6e4e55621156c58495c1d946 /tests/ui/error-codes
parent136dab66142115d9de16b4cfe2d8395d71a8ab6d (diff)
parenta74db1abb3cda6f28088f816b2781a120ddc56be (diff)
downloadrust-da1d099f91ea387a2814a6244dd875a2048b486f.tar.gz
rust-da1d099f91ea387a2814a6244dd875a2048b486f.zip
Auto merge of #112945 - compiler-errors:tighten-span-of-adjustment-error, r=oli-obk
(re-)tighten sourceinfo span of adjustments in MIR

Diagnostics rely on the spans of MIR statements being (approximately) correct in order to give suggestions relative to that span (i.e. `shrink_to_hi` and `shrink_to_lo`).

I discovered that we're *intentionally* lowering THIR exprs with their parent expr's span if they come from adjustments that are due to a parent expression. While I understand why that may be desirable to demonstrate the relationship of an adjustment and the expression that requires it, it leads to

1. very verbose borrowck output
2. incorrect spans for suggestions

Some diagnostics get around that by giving suggestions relative to other spans we've collected during MIR lowering, such as the span of the method's identifier (e.g. `name` in `.name()`), but this doesn't work too well when things come from desugaring.

I assume it also has lead to numerous tweaks and complications to diagnostics code down the road, which this PR doesn't necessarily aim to fix but may open the gates to fixing later... The last three commits are simplifications due to the fact that we can assume that the move span actually points to what is being moved (and a test).

This regressed in #89110, which was debated somewhat in #90286. cc `@Aaron1011` who originally made this change.

r? diagnostics

Fixes #113547
Fixes #111016
Diffstat (limited to 'tests/ui/error-codes')
-rw-r--r--tests/ui/error-codes/E0161.base.stderr2
-rw-r--r--tests/ui/error-codes/E0499.stderr2
-rw-r--r--tests/ui/error-codes/E0502.stderr2
-rw-r--r--tests/ui/error-codes/E0503.stderr2
-rw-r--r--tests/ui/error-codes/E0505.stderr2
-rw-r--r--tests/ui/error-codes/E0507.stderr5
6 files changed, 7 insertions, 8 deletions
diff --git a/tests/ui/error-codes/E0161.base.stderr b/tests/ui/error-codes/E0161.base.stderr
index 15d98b657a2..ae82e6702e6 100644
--- a/tests/ui/error-codes/E0161.base.stderr
+++ b/tests/ui/error-codes/E0161.base.stderr
@@ -2,7 +2,7 @@ error[E0161]: cannot move a value of type `dyn Bar`
   --> $DIR/E0161.rs:16:5
    |
 LL |     x.f();
-   |     ^^^^^ the size of `dyn Bar` cannot be statically determined
+   |     ^ the size of `dyn Bar` cannot be statically determined
 
 error: aborting due to previous error
 
diff --git a/tests/ui/error-codes/E0499.stderr b/tests/ui/error-codes/E0499.stderr
index af5a1e18633..d56baf72272 100644
--- a/tests/ui/error-codes/E0499.stderr
+++ b/tests/ui/error-codes/E0499.stderr
@@ -7,7 +7,7 @@ LL |     let mut a = &mut i;
    |                 ^^^^^^ second mutable borrow occurs here
 LL |     a.use_mut();
 LL |     x.use_mut();
-   |     ----------- first borrow later used here
+   |     - first borrow later used here
 
 error: aborting due to previous error
 
diff --git a/tests/ui/error-codes/E0502.stderr b/tests/ui/error-codes/E0502.stderr
index 94cc89754db..cade6d71852 100644
--- a/tests/ui/error-codes/E0502.stderr
+++ b/tests/ui/error-codes/E0502.stderr
@@ -6,7 +6,7 @@ LL |     let ref y = a;
 LL |     bar(a);
    |     ^^^^^^ mutable borrow occurs here
 LL |     y.use_ref();
-   |     ----------- immutable borrow later used here
+   |     - immutable borrow later used here
 
 error: aborting due to previous error
 
diff --git a/tests/ui/error-codes/E0503.stderr b/tests/ui/error-codes/E0503.stderr
index 2f02e3b1a61..275abb23f53 100644
--- a/tests/ui/error-codes/E0503.stderr
+++ b/tests/ui/error-codes/E0503.stderr
@@ -6,7 +6,7 @@ LL |     let _borrow = &mut value;
 LL |     let _sum = value + 1;
    |                ^^^^^ use of borrowed `value`
 LL |     _borrow.use_mut();
-   |     ----------------- borrow later used here
+   |     ------- borrow later used here
 
 error: aborting due to previous error
 
diff --git a/tests/ui/error-codes/E0505.stderr b/tests/ui/error-codes/E0505.stderr
index 2ecb4a75c43..1a85e031705 100644
--- a/tests/ui/error-codes/E0505.stderr
+++ b/tests/ui/error-codes/E0505.stderr
@@ -9,7 +9,7 @@ LL |         let _ref_to_val: &Value = &x;
 LL |         eat(x);
    |             ^ move out of `x` occurs here
 LL |         _ref_to_val.use_ref();
-   |         --------------------- borrow later used here
+   |         ----------- borrow later used here
 
 error: aborting due to previous error
 
diff --git a/tests/ui/error-codes/E0507.stderr b/tests/ui/error-codes/E0507.stderr
index 03630f38987..08993951622 100644
--- a/tests/ui/error-codes/E0507.stderr
+++ b/tests/ui/error-codes/E0507.stderr
@@ -2,9 +2,8 @@ error[E0507]: cannot move out of dereference of `Ref<'_, TheDarkKnight>`
   --> $DIR/E0507.rs:12:5
    |
 LL |     x.borrow().nothing_is_true();
-   |     ^^^^^^^^^^^-----------------
-   |     |          |
-   |     |          value moved due to this method call
+   |     ^^^^^^^^^^ ----------------- value moved due to this method call
+   |     |
    |     move occurs because value has type `TheDarkKnight`, which does not implement the `Copy` trait
    |
 note: `TheDarkKnight::nothing_is_true` takes ownership of the receiver `self`, which moves value