Skip to content

Commit ff30b8c

Browse files
authored
Rollup merge of #110583 - Ezrashaw:tweak-make-mut-spans, r=estebank
tweak "make mut" spans when assigning to locals Work towards fixing #106857 This PR just cleans up a lot of spans which is helpful before properly fixing the issues. Best reviewed commit-by-commit. r? `@estebank`
2 parents 2ecc722 + 3e64e98 commit ff30b8c

33 files changed

+338
-323
lines changed

compiler/rustc_borrowck/src/diagnostics/mutability_errors.rs

Lines changed: 264 additions & 245 deletions
Large diffs are not rendered by default.

tests/ui/array-slice-vec/slice-mut-2.stderr

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -7,7 +7,7 @@ LL | let _ = &mut x[2..4];
77
help: consider changing this to be a mutable reference
88
|
99
LL | let x: &[isize] = &mut [1, 2, 3, 4, 5];
10-
| ~~~~~~~~~~~~~~~~~~~~
10+
| +++
1111

1212
error: aborting due to previous error
1313

tests/ui/borrowck/borrow-raw-address-of-deref-mutability.stderr

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -7,7 +7,7 @@ LL | let q = &raw mut *x;
77
help: consider changing this to be a mutable reference
88
|
99
LL | let x = &mut 0;
10-
| ~~~~~~
10+
| +++
1111

1212
error[E0596]: cannot borrow `*x` as mutable, as it is behind a `*const` pointer
1313
--> $DIR/borrow-raw-address-of-deref-mutability.rs:14:13
@@ -18,7 +18,7 @@ LL | let q = &raw mut *x;
1818
help: consider changing this to be a mutable pointer
1919
|
2020
LL | let x = &mut 0 as *const i32;
21-
| ~~~~~~
21+
| +++
2222

2323
error: aborting due to 2 previous errors
2424

tests/ui/borrowck/borrowck-access-permissions.stderr

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -35,7 +35,7 @@ LL | let _y1 = &mut *ref_x;
3535
help: consider changing this to be a mutable reference
3636
|
3737
LL | let ref_x = &mut x;
38-
| ~~~~~~
38+
| +++
3939

4040
error[E0596]: cannot borrow `*ptr_x` as mutable, as it is behind a `*const` pointer
4141
--> $DIR/borrowck-access-permissions.rs:39:23
@@ -46,7 +46,7 @@ LL | let _y1 = &mut *ptr_x;
4646
help: consider changing this to be a mutable pointer
4747
|
4848
LL | let ptr_x : *const _ = &mut x;
49-
| ~~~~~~
49+
| +++
5050

5151
error[E0596]: cannot borrow `*foo_ref.f` as mutable, as it is behind a `&` reference
5252
--> $DIR/borrowck-access-permissions.rs:48:18
@@ -57,7 +57,7 @@ LL | let _y = &mut *foo_ref.f;
5757
help: consider changing this to be a mutable reference
5858
|
5959
LL | let foo_ref = &mut foo;
60-
| ~~~~~~~~
60+
| +++
6161

6262
error: aborting due to 6 previous errors
6363

tests/ui/borrowck/borrowck-assign-to-andmut-in-aliasable-loc.stderr

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -6,8 +6,8 @@ LL | *s.pointer += 1;
66
|
77
help: consider changing this to be a mutable reference
88
|
9-
LL | fn a(s: &mut S<'_>) {
10-
| ~~~~~~~~~~
9+
LL | fn a(s: &mut S) {
10+
| +++
1111

1212
error[E0594]: cannot assign to `*s.pointer`, which is behind a `&` reference
1313
--> $DIR/borrowck-assign-to-andmut-in-aliasable-loc.rs:17:5
@@ -17,8 +17,8 @@ LL | *s.pointer += 1;
1717
|
1818
help: consider changing this to be a mutable reference
1919
|
20-
LL | fn c(s: &mut &mut S<'_>) {
21-
| ~~~~~~~~~~~~~~~
20+
LL | fn c(s: &mut &mut S) {
21+
| +++
2222

2323
error: aborting due to 2 previous errors
2424

tests/ui/borrowck/borrowck-borrow-mut-base-ptr-in-aliasable-loc.stderr

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -27,8 +27,8 @@ LL | let x: &mut isize = &mut **t0;
2727
|
2828
help: consider changing this to be a mutable reference
2929
|
30-
LL | fn foo4(t0: &mut &mut isize) {
31-
| ~~~~~~~~~~~~~~~
30+
LL | fn foo4(t0: &mut &mut isize) {
31+
| +++
3232

3333
error: aborting due to 3 previous errors
3434

tests/ui/borrowck/borrowck-issue-14498.stderr

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -7,7 +7,7 @@ LL | ***p = 2;
77
help: consider changing this to be a mutable reference
88
|
99
LL | let p = &mut y;
10-
| ~~~~~~
10+
| +++
1111

1212
error[E0506]: cannot assign to `**y` because it is borrowed
1313
--> $DIR/borrowck-issue-14498.rs:25:5

tests/ui/borrowck/borrowck-reborrow-from-mut.stderr

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -111,7 +111,7 @@ LL | let _bar1 = &mut foo.bar1;
111111
help: consider changing this to be a mutable reference
112112
|
113113
LL | fn borrow_mut_from_imm(foo: &mut Foo) {
114-
| ~~~~~~~~
114+
| +++
115115

116116
error: aborting due to 11 previous errors
117117

tests/ui/borrowck/issue-85765.stderr

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -18,7 +18,7 @@ LL | *r = 0;
1818
help: consider changing this to be a mutable reference
1919
|
2020
LL | let r = &mut mutvar;
21-
| ~~~~~~~~~~~
21+
| +++
2222

2323
error[E0594]: cannot assign to `*x`, which is behind a `&` reference
2424
--> $DIR/issue-85765.rs:19:5

tests/ui/borrowck/mutability-errors.stderr

Lines changed: 12 additions & 12 deletions
Original file line numberDiff line numberDiff line change
@@ -7,7 +7,7 @@ LL | *x = (1,);
77
help: consider changing this to be a mutable reference
88
|
99
LL | fn named_ref(x: &mut (i32,)) {
10-
| ~~~~~~~~~~~
10+
| +++
1111

1212
error[E0594]: cannot assign to `x.0`, which is behind a `&` reference
1313
--> $DIR/mutability-errors.rs:10:5
@@ -18,7 +18,7 @@ LL | x.0 = 1;
1818
help: consider changing this to be a mutable reference
1919
|
2020
LL | fn named_ref(x: &mut (i32,)) {
21-
| ~~~~~~~~~~~
21+
| +++
2222

2323
error[E0596]: cannot borrow `*x` as mutable, as it is behind a `&` reference
2424
--> $DIR/mutability-errors.rs:11:5
@@ -29,7 +29,7 @@ LL | &mut *x;
2929
help: consider changing this to be a mutable reference
3030
|
3131
LL | fn named_ref(x: &mut (i32,)) {
32-
| ~~~~~~~~~~~
32+
| +++
3333

3434
error[E0596]: cannot borrow `x.0` as mutable, as it is behind a `&` reference
3535
--> $DIR/mutability-errors.rs:12:5
@@ -40,7 +40,7 @@ LL | &mut x.0;
4040
help: consider changing this to be a mutable reference
4141
|
4242
LL | fn named_ref(x: &mut (i32,)) {
43-
| ~~~~~~~~~~~
43+
| +++
4444

4545
error[E0594]: cannot assign to data in a `&` reference
4646
--> $DIR/mutability-errors.rs:16:5
@@ -74,8 +74,8 @@ LL | *x = (1,);
7474
|
7575
help: consider changing this to be a mutable pointer
7676
|
77-
LL | unsafe fn named_ptr(x: *mut (i32,)) {
78-
| ~~~~~~~~~~~
77+
LL | unsafe fn named_ptr(x: *mut const (i32,)) {
78+
| +++
7979

8080
error[E0594]: cannot assign to `x.0`, which is behind a `*const` pointer
8181
--> $DIR/mutability-errors.rs:24:5
@@ -85,8 +85,8 @@ LL | (*x).0 = 1;
8585
|
8686
help: consider changing this to be a mutable pointer
8787
|
88-
LL | unsafe fn named_ptr(x: *mut (i32,)) {
89-
| ~~~~~~~~~~~
88+
LL | unsafe fn named_ptr(x: *mut const (i32,)) {
89+
| +++
9090

9191
error[E0596]: cannot borrow `*x` as mutable, as it is behind a `*const` pointer
9292
--> $DIR/mutability-errors.rs:25:5
@@ -96,8 +96,8 @@ LL | &mut *x;
9696
|
9797
help: consider changing this to be a mutable pointer
9898
|
99-
LL | unsafe fn named_ptr(x: *mut (i32,)) {
100-
| ~~~~~~~~~~~
99+
LL | unsafe fn named_ptr(x: *mut const (i32,)) {
100+
| +++
101101

102102
error[E0596]: cannot borrow `x.0` as mutable, as it is behind a `*const` pointer
103103
--> $DIR/mutability-errors.rs:26:5
@@ -107,8 +107,8 @@ LL | &mut (*x).0;
107107
|
108108
help: consider changing this to be a mutable pointer
109109
|
110-
LL | unsafe fn named_ptr(x: *mut (i32,)) {
111-
| ~~~~~~~~~~~
110+
LL | unsafe fn named_ptr(x: *mut const (i32,)) {
111+
| +++
112112

113113
error[E0594]: cannot assign to data in a `*const` pointer
114114
--> $DIR/mutability-errors.rs:30:5

0 commit comments

Comments
 (0)