rust/tests/ui/mut
Esteban Küber 71b0755a98 Provide more context when mutably borrowing an imutable borrow
Point at statics and consts being mutable borrowed or written to:

```
error[E0594]: cannot assign to immutable static item `NUM`
  --> $DIR/E0594.rs:4:5
   |
LL | static NUM: i32 = 18;
   | --------------- this `static` cannot be written to
...
LL |     NUM = 20;
   |     ^^^^^^^^ cannot assign
```

Point at the expression that couldn't be mutably borrowed from a pattern:

```
error[E0596]: cannot borrow data in a `&` reference as mutable
  --> $DIR/mut-pattern-of-immutable-borrow.rs:19:14
   |
LL |     match &arg.field {
   |           ---------- this cannot be borrowed as mutable
LL |         Some(ref mut s) => s.push('a'),
   |              ^^^^^^^^^ cannot borrow as mutable
```
2025-11-09 22:14:48 +00:00
..
mut-cant-alias.rs Move /src/test to /tests 2023-01-11 09:32:08 +00:00
mut-cant-alias.stderr Show number in error message even for one error 2023-11-24 19:15:52 +01:00
mut-cross-borrowing.rs Move /src/test to /tests 2023-01-11 09:32:08 +00:00
mut-cross-borrowing.stderr Show number in error message even for one error 2023-11-24 19:15:52 +01:00
mut-pattern-internal-mutability.rs Move /src/test to /tests 2023-01-11 09:32:08 +00:00
mut-pattern-internal-mutability.stderr Better span for "make binding mutable" suggestion 2024-07-04 02:02:21 +00:00
mut-pattern-mismatched.rs compiletest: Make diagnostic kind mandatory on line annotations 2025-04-30 10:44:24 +03:00
mut-pattern-mismatched.stderr compiletest: Make diagnostic kind mandatory on line annotations 2025-04-30 10:44:24 +03:00
mut-ref.rs Feature gate 2024-03-27 11:20:28 -04:00
mut-suggestion.rs Move /src/test to /tests 2023-01-11 09:32:08 +00:00
mut-suggestion.stderr Do not set up wrong span for adjustments 2023-07-10 20:09:26 +00:00
mutable-class-fields-2.rs Move /src/test to /tests 2023-01-11 09:32:08 +00:00
mutable-class-fields-2.stderr Provide more context when mutably borrowing an imutable borrow 2025-11-09 22:14:48 +00:00
mutable-class-fields.rs Move /src/test to /tests 2023-01-11 09:32:08 +00:00
mutable-class-fields.stderr Show number in error message even for one error 2023-11-24 19:15:52 +01:00
mutable-enum-indirect.rs Move /src/test to /tests 2023-01-11 09:32:08 +00:00
mutable-enum-indirect.stderr On E0277, point at type that doesn't implement bound 2025-08-22 17:55:15 +00:00
no-mut-lint-for-desugared-mut.rs [AUTO-GENERATED] Migrate ui tests from // to //@ directives 2024-02-16 20:02:50 +00:00