rust/src/test/ui/mut
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
..
mut-cant-alias.rs Remove licenses 2018-12-25 21:08:33 -07:00
mut-cant-alias.stderr Use larger span for adjustments on method calls 2021-09-25 10:00:41 -05:00
mut-cross-borrowing.rs Remove box syntax from most places in src/test outside of the issues dir 2021-09-26 04:07:44 +02:00
mut-cross-borrowing.stderr pretty: trim paths of unique symbols 2020-09-02 22:26:37 +03:00
mut-pattern-internal-mutability.rs update tests for migrate mode by default 2019-04-22 08:40:08 +01:00
mut-pattern-internal-mutability.stderr Compiler error messages: reduce assertiveness of message E0384 2021-04-12 23:29:09 +01:00
mut-pattern-mismatched.rs Specific labels when referring to "expected" and "found" types 2019-11-18 11:02:22 -08:00
mut-pattern-mismatched.stderr check_pat_ref: use pattern_cause 2020-02-25 05:53:21 +01:00
mut-ref.rs tests: Do not use -Z parse-only, continue compilation to test recovery 2019-01-06 22:20:46 +03:00
mut-ref.stderr Update tests 2019-03-11 23:10:26 +03:00
mut-suggestion.rs update tests for migrate mode by default 2019-04-22 08:40:08 +01:00
mut-suggestion.stderr Use larger span for adjustments on method calls 2021-09-25 10:00:41 -05:00
mutable-class-fields-2.rs Remove licenses 2018-12-25 21:08:33 -07:00
mutable-class-fields-2.stderr Improve error reporting for modifications behind & references 2021-07-02 18:29:49 +02:00
mutable-class-fields.rs update tests for migrate mode by default 2019-04-22 08:40:08 +01:00
mutable-class-fields.stderr Update ui tests 2019-11-18 19:00:10 +01:00
mutable-enum-indirect.rs introduce negative_impls feature gate and document 2020-03-26 06:52:55 -04:00
mutable-enum-indirect.stderr Use note to point at bound introducing requirement 2021-08-16 17:47:22 +00:00
no-mut-lint-for-desugared-mut.rs Only warn about unused mut in user-written code 2018-10-03 14:14:11 +01:00