rust/src/test/ui/array-slice-vec
bors 4aa7879b55 Auto merge of #89110 - Aaron1011:adjustment-span, r=estebank
Use larger span for adjustment THIR expressions

Currently, we use a relatively 'small' span for THIR
expressions generated by an 'adjustment' (e.g. an autoderef,
autoborrow, unsizing). As a result, if a borrow generated
by an adustment ends up causing a borrowcheck error, for example:

```rust
let mut my_var = String::new();
let my_ref = &my_var
my_var.push('a');
my_ref;
```

then the span for the mutable borrow may end up referring
to only the base expression (e.g. `my_var`), rather than
the method call which triggered the mutable borrow
(e.g. `my_var.push('a')`)

Due to a quirk of the MIR borrowck implementation,
this doesn't always get exposed in migration mode,
but it does in many cases.

This commit makes THIR building consistently use 'larger'
spans for adjustment expressions. These spans are recoded
when we first create the adjustment during typecheck. For
example, an autoref adjustment triggered by a method call
will record the span of the entire method call.

The intent of this change it make it clearer to users
when it's the specific way in which a variable is
used (for example, in a method call) that produdes
a borrowcheck error. For example, an error message
claiming that a 'mutable borrow occurs here' might
be confusing if it just points at a usage of a variable
(e.g. `my_var`), when no `&mut` is in sight. Pointing
at the entire expression should help to emphasize
that the method call itself is responsible for
the mutable borrow.

In several cases, this makes the `#![feature(nll)]` diagnostic
output match up exactly with the default (migration mode) output.
As a result, several `.nll.stderr` files end up getting removed
entirely.
2021-09-30 01:40:30 +00:00
..
array-break-length.rs Move array-slice-vec-related tests 2020-12-31 08:01:58 +09:00
array-break-length.stderr Move array-slice-vec-related tests 2020-12-31 08:01:58 +09:00
array-not-vector.rs Move array-slice-vec-related tests 2020-12-31 08:01:58 +09:00
array-not-vector.stderr Move array-slice-vec-related tests 2020-12-31 08:01:58 +09:00
array_const_index-0.rs make const_err a future incompat lint 2021-02-03 15:45:43 +01:00
array_const_index-0.stderr make const_err a future incompat lint 2021-02-03 15:45:43 +01:00
array_const_index-1.rs make const_err a future incompat lint 2021-02-03 15:45:43 +01:00
array_const_index-1.stderr make const_err a future incompat lint 2021-02-03 15:45:43 +01:00
array_const_index-2.rs Move array-slice-vec-related tests 2020-12-31 08:01:58 +09:00
bounds-check-no-overflow.rs Update tests to remove old numeric constants 2020-11-29 00:55:55 -05:00
box-of-array-of-drop-1.rs Migrate standard library away from compare_and_swap 2020-12-22 12:19:46 +01:00
box-of-array-of-drop-2.rs Migrate standard library away from compare_and_swap 2020-12-22 12:19:46 +01:00
cast-in-array-size.rs
check-static-mut-slices.rs
check-static-slice.rs
copy-out-of-array-1.rs Remove compile-fail test suite 2020-12-29 23:39:56 +03:00
destructure-array-1.rs
dst-raw-slice.rs Skip tests on emscripten 2020-05-08 00:39:02 +09:00
empty-mutable-vec.rs
estr-slice.rs
evec-slice.rs
fixed_length_copy.rs
huge-largest-array.rs
infer_array_len.rs add test for array len inference 2020-03-30 19:13:47 +02:00
infer_array_len.stderr add test for array len inference 2020-03-30 19:13:47 +02:00
issue-15730.rs Move some tests to more reasonable directories - 2 2021-01-16 19:46:54 -03:00
issue-18425.rs Move some tests to more reasonable directories 2021-01-31 19:46:46 -03:00
issue-69103-extra-binding-subslice.rs fix extra subslice lowering 2020-02-13 12:24:53 +01:00
issue-69103-extra-binding-subslice.stderr fix extra subslice lowering 2020-02-13 12:24:53 +01:00
ivec-pass-by-value.rs
match_arr_unknown_len.rs feature(const_generics) -> feature(const_param_types) 2021-08-30 11:00:21 +02:00
match_arr_unknown_len.stderr feature(const_generics) -> feature(const_param_types) 2021-08-30 11:00:21 +02:00
mutability-inherits-through-fixed-length-vec.rs
mutable-alias-vec.rs
nested-vec-1.rs
nested-vec-2.rs
nested-vec-3.rs Migrate standard library away from compare_and_swap 2020-12-22 12:19:46 +01:00
new-style-fixed-length-vec.rs
rcvr-borrowed-to-slice.rs
repeat_empty_ok.rs Remove const_in_array_rep_expr 2021-01-30 23:20:24 +00:00
repeat_empty_ok.stderr Remove const_in_array_rep_expr 2021-01-30 23:20:24 +00:00
repeated-vector-syntax.rs
show-boxed-slice.rs
slice-2.rs Move array-slice-vec-related tests 2020-12-31 08:01:58 +09:00
slice-2.stderr Move array-slice-vec-related tests 2020-12-31 08:01:58 +09:00
slice-mut-2.rs Move array-slice-vec-related tests 2020-12-31 08:01:58 +09:00
slice-mut-2.stderr Move array-slice-vec-related tests 2020-12-31 08:01:58 +09:00
slice-mut.rs Move array-slice-vec-related tests 2020-12-31 08:01:58 +09:00
slice-mut.stderr Move array-slice-vec-related tests 2020-12-31 08:01:58 +09:00
slice-of-zero-size-elements.rs
slice-panic-1.rs Lint for unused borrows as part of UNUSED_MUST_USE 2021-06-18 15:09:40 +08:00
slice-panic-2.rs Lint for unused borrows as part of UNUSED_MUST_USE 2021-06-18 15:09:40 +08:00
slice-pat-type-mismatches.rs pretty: trim paths of unique symbols 2020-09-02 22:26:37 +03:00
slice-pat-type-mismatches.stderr pretty: trim paths of unique symbols 2020-09-02 22:26:37 +03:00
slice-to-vec-comparison.rs Move array-slice-vec-related tests 2020-12-31 08:01:58 +09:00
slice-to-vec-comparison.stderr Move array-slice-vec-related tests 2020-12-31 08:01:58 +09:00
slice.rs Lint for unused borrows as part of UNUSED_MUST_USE 2021-06-18 15:09:40 +08:00
slice_binary_search.rs Ignore automatically derived impls of Clone and Debug in dead code analysis 2021-09-09 19:49:07 +02:00
subslice-only-once-semantic-restriction.rs slice_patterns: organize some tests 2020-01-18 19:33:47 +01:00
subslice-only-once-semantic-restriction.stderr slice_patterns: organize some tests 2020-01-18 19:33:47 +01:00
subslice-patterns-const-eval-match.rs remove const_fn feature gate from const tests 2021-04-29 09:27:45 +02:00
subslice-patterns-const-eval.rs slice_patterns: remove gates in tests 2020-01-18 19:33:47 +01:00
variance-vec-covariant.rs
vec-dst.rs Remove box syntax from most places in src/test outside of the issues dir 2021-09-26 04:07:44 +02:00
vec-fixed-length.rs update tests 2020-03-31 19:01:49 +02:00
vec-late-init.rs
vec-macro-no-std.rs
vec-macro-rvalue-scope.rs
vec-macro-with-brackets.rs
vec-macro-with-comma-only.rs Move array-slice-vec-related tests 2020-12-31 08:01:58 +09:00
vec-macro-with-comma-only.stderr Move array-slice-vec-related tests 2020-12-31 08:01:58 +09:00
vec-macro-with-trailing-comma.rs
vec-matching-autoslice.rs
vec-matching-fixed.rs slice_patterns: remove gates in tests 2020-01-18 19:33:47 +01:00
vec-matching-fold.rs slice_patterns: remove gates in tests 2020-01-18 19:33:47 +01:00
vec-matching-legal-tail-element-borrow.rs slice_patterns: remove gates in tests 2020-01-18 19:33:47 +01:00
vec-matching.rs slice_patterns: remove gates in tests 2020-01-18 19:33:47 +01:00
vec-mut-iter-borrow.rs Move array-slice-vec-related tests 2020-12-31 08:01:58 +09:00
vec-mut-iter-borrow.stderr Use larger span for adjustments on method calls 2021-09-25 10:00:41 -05:00
vec-overrun.rs Move array-slice-vec-related tests 2020-12-31 08:01:58 +09:00
vec-repeat-with-cast.rs
vec-res-add.rs Move array-slice-vec-related tests 2020-12-31 08:01:58 +09:00
vec-res-add.stderr Move array-slice-vec-related tests 2020-12-31 08:01:58 +09:00
vec-tail-matching.rs slice_patterns: remove gates in tests 2020-01-18 19:33:47 +01:00
vector-cast-weirdness.rs Allow casting mut array ref to mut ptr 2021-02-10 15:44:41 +03:00
vector-cast-weirdness.stderr Allow casting mut array ref to mut ptr 2021-02-10 15:44:41 +03:00
vector-no-ann-2.rs Remove box syntax from most places in src/test outside of the issues dir 2021-09-26 04:07:44 +02:00
vector-no-ann.rs Move array-slice-vec-related tests 2020-12-31 08:01:58 +09:00
vector-no-ann.stderr Move array-slice-vec-related tests 2020-12-31 08:01:58 +09:00