Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Compiler error messages: reduce assertiveness of message E0384 #84172

Merged
merged 2 commits into from
Apr 16, 2021
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Original file line number Diff line number Diff line change
Expand Up @@ -1681,7 +1681,7 @@ impl<'cx, 'tcx> MirBorrowckCtxt<'cx, 'tcx> {
if decl.can_be_made_mutable() {
err.span_suggestion(
decl.source_info.span,
"make this binding mutable",
"consider making this binding mutable",
format!("mut {}", name),
Applicability::MachineApplicable,
);
Expand Down
2 changes: 1 addition & 1 deletion src/test/ui/assign-imm-local-twice.rs
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
fn test() {
let v: isize;
//~^ HELP make this binding mutable
//~^ HELP consider making this binding mutable
//~| SUGGESTION mut v
v = 1; //~ NOTE first assignment
println!("v={}", v);
Expand Down
2 changes: 1 addition & 1 deletion src/test/ui/assign-imm-local-twice.stderr
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,7 @@ error[E0384]: cannot assign twice to immutable variable `v`
--> $DIR/assign-imm-local-twice.rs:7:5
|
LL | let v: isize;
| - help: make this binding mutable: `mut v`
| - help: consider making this binding mutable: `mut v`
...
LL | v = 1;
| ----- first assignment to `v`
Expand Down
2 changes: 1 addition & 1 deletion src/test/ui/async-await/issue-61452.stderr
Original file line number Diff line number Diff line change
Expand Up @@ -13,7 +13,7 @@ LL | pub async fn g(x: usize) {
| -
| |
| first assignment to `x`
| help: make this binding mutable: `mut x`
| help: consider making this binding mutable: `mut x`
LL | x += 1;
| ^^^^^^ cannot assign twice to immutable variable

Expand Down
4 changes: 2 additions & 2 deletions src/test/ui/borrowck/borrowck-asm.stderr
Original file line number Diff line number Diff line change
Expand Up @@ -29,7 +29,7 @@ LL | let x = 3;
| -
| |
| first assignment to `x`
| help: make this binding mutable: `mut x`
| help: consider making this binding mutable: `mut x`
LL | unsafe {
LL | llvm_asm!("nop" : "=r"(x));
| ^ cannot assign twice to immutable variable
Expand All @@ -41,7 +41,7 @@ LL | let x = 3;
| -
| |
| first assignment to `x`
| help: make this binding mutable: `mut x`
| help: consider making this binding mutable: `mut x`
LL | unsafe {
LL | llvm_asm!("nop" : "+r"(x));
| ^ cannot assign twice to immutable variable
Expand Down
10 changes: 5 additions & 5 deletions src/test/ui/borrowck/borrowck-match-binding-is-assignment.stderr
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,7 @@ LL | x => {
| -
| |
| first assignment to `x`
| help: make this binding mutable: `mut x`
| help: consider making this binding mutable: `mut x`
LL | x += 1;
| ^^^^^^ cannot assign twice to immutable variable

Expand All @@ -16,7 +16,7 @@ LL | E::Foo(x) => {
| -
| |
| first assignment to `x`
| help: make this binding mutable: `mut x`
| help: consider making this binding mutable: `mut x`
LL | x += 1;
| ^^^^^^ cannot assign twice to immutable variable

Expand All @@ -27,7 +27,7 @@ LL | S { bar: x } => {
| -
| |
| first assignment to `x`
| help: make this binding mutable: `mut x`
| help: consider making this binding mutable: `mut x`
LL | x += 1;
| ^^^^^^ cannot assign twice to immutable variable

Expand All @@ -38,7 +38,7 @@ LL | (x,) => {
| -
| |
| first assignment to `x`
| help: make this binding mutable: `mut x`
| help: consider making this binding mutable: `mut x`
LL | x += 1;
| ^^^^^^ cannot assign twice to immutable variable

Expand All @@ -49,7 +49,7 @@ LL | [x,_,_] => {
| -
| |
| first assignment to `x`
| help: make this binding mutable: `mut x`
| help: consider making this binding mutable: `mut x`
LL | x += 1;
| ^^^^^^ cannot assign twice to immutable variable

Expand Down
2 changes: 1 addition & 1 deletion src/test/ui/borrowck/immutable-arg.stderr
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,7 @@ error[E0384]: cannot assign to immutable argument `_x`
--> $DIR/immutable-arg.rs:2:5
|
LL | fn foo(_x: u32) {
| -- help: make this binding mutable: `mut _x`
| -- help: consider making this binding mutable: `mut _x`
LL | _x = 4;
| ^^^^^^ cannot assign to immutable argument

Expand Down
6 changes: 3 additions & 3 deletions src/test/ui/borrowck/issue-45199.rs
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
fn test_drop_replace() {
let b: Box<isize>;
//~^ HELP make this binding mutable
//~^ HELP consider making this binding mutable
//~| SUGGESTION mut b
b = Box::new(1); //~ NOTE first assignment
b = Box::new(2); //~ ERROR cannot assign twice to immutable variable `b`
Expand All @@ -9,13 +9,13 @@ fn test_drop_replace() {

fn test_call() {
let b = Box::new(1); //~ NOTE first assignment
//~| HELP make this binding mutable
//~| HELP consider making this binding mutable
//~| SUGGESTION mut b
b = Box::new(2); //~ ERROR cannot assign twice to immutable variable `b`
//~| NOTE cannot assign twice to immutable
}

fn test_args(b: Box<i32>) { //~ HELP make this binding mutable
fn test_args(b: Box<i32>) { //~ HELP consider making this binding mutable
//~| SUGGESTION mut b
b = Box::new(2); //~ ERROR cannot assign to immutable argument `b`
//~| NOTE cannot assign to immutable argument
Expand Down
6 changes: 3 additions & 3 deletions src/test/ui/borrowck/issue-45199.stderr
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,7 @@ error[E0384]: cannot assign twice to immutable variable `b`
--> $DIR/issue-45199.rs:6:5
|
LL | let b: Box<isize>;
| - help: make this binding mutable: `mut b`
| - help: consider making this binding mutable: `mut b`
...
LL | b = Box::new(1);
| - first assignment to `b`
Expand All @@ -16,7 +16,7 @@ LL | let b = Box::new(1);
| -
| |
| first assignment to `b`
| help: make this binding mutable: `mut b`
| help: consider making this binding mutable: `mut b`
...
LL | b = Box::new(2);
| ^ cannot assign twice to immutable variable
Expand All @@ -25,7 +25,7 @@ error[E0384]: cannot assign to immutable argument `b`
--> $DIR/issue-45199.rs:20:5
|
LL | fn test_args(b: Box<i32>) {
| - help: make this binding mutable: `mut b`
| - help: consider making this binding mutable: `mut b`
LL |
LL | b = Box::new(2);
| ^ cannot assign to immutable argument
Expand Down
2 changes: 1 addition & 1 deletion src/test/ui/command-line-diagnostics.stderr
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,7 @@ LL | let x = 42;
| -
| |
| first assignment to `x`
| help: make this binding mutable: `mut x`
| help: consider making this binding mutable: `mut x`
LL | x = 43;
| ^^^^^^ cannot assign twice to immutable variable

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -12,7 +12,7 @@ error[E0384]: cannot assign to immutable argument `y`
--> $DIR/ex3-both-anon-regions-one-is-struct-2.rs:4:5
|
LL | fn foo(mut x: Ref, y: &u32) {
| - help: make this binding mutable: `mut y`
| - help: consider making this binding mutable: `mut y`
LL | y = x.b;
| ^^^^^^^ cannot assign to immutable argument

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,7 @@ error[E0384]: cannot assign twice to immutable variable `x`
--> $DIR/liveness-assign-imm-local-notes.rs:10:9
|
LL | let x;
| - help: make this binding mutable: `mut x`
| - help: consider making this binding mutable: `mut x`
...
LL | x = 2;
| ----- first assignment to `x`
Expand All @@ -13,7 +13,7 @@ error[E0384]: cannot assign twice to immutable variable `x`
--> $DIR/liveness-assign-imm-local-notes.rs:21:13
|
LL | let x;
| - help: make this binding mutable: `mut x`
| - help: consider making this binding mutable: `mut x`
...
LL | x = 2;
| ----- first assignment to `x`
Expand All @@ -24,7 +24,7 @@ error[E0384]: cannot assign twice to immutable variable `x`
--> $DIR/liveness-assign-imm-local-notes.rs:30:13
|
LL | let x;
| - help: make this binding mutable: `mut x`
| - help: consider making this binding mutable: `mut x`
...
LL | x = 1;
| ^^^^^ cannot assign twice to immutable variable
Expand All @@ -33,7 +33,7 @@ error[E0384]: cannot assign twice to immutable variable `x`
--> $DIR/liveness-assign-imm-local-notes.rs:32:13
|
LL | let x;
| - help: make this binding mutable: `mut x`
| - help: consider making this binding mutable: `mut x`
...
LL | x = 1;
| ----- first assignment to `x`
Expand Down
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
fn test() {
let v: isize;
//~^ HELP make this binding mutable
//~^ HELP consider making this binding mutable
//~| SUGGESTION mut v
loop {
v = 1; //~ ERROR cannot assign twice to immutable variable `v`
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,7 @@ error[E0384]: cannot assign twice to immutable variable `v`
--> $DIR/liveness-assign-imm-local-in-loop.rs:6:9
|
LL | let v: isize;
| - help: make this binding mutable: `mut v`
| - help: consider making this binding mutable: `mut v`
...
LL | v = 1;
| ^^^^^ cannot assign twice to immutable variable
Expand Down
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
fn test() {
let v: isize;
//~^ HELP make this binding mutable
//~^ HELP consider making this binding mutable
//~| SUGGESTION mut v
v = 2; //~ NOTE first assignment
v += 1; //~ ERROR cannot assign twice to immutable variable `v`
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,7 @@ error[E0384]: cannot assign twice to immutable variable `v`
--> $DIR/liveness-assign-imm-local-in-op-eq.rs:6:5
|
LL | let v: isize;
| - help: make this binding mutable: `mut v`
| - help: consider making this binding mutable: `mut v`
...
LL | v = 2;
| ----- first assignment to `v`
Expand Down
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
fn test() {
let b = Box::new(1); //~ NOTE first assignment
//~| HELP make this binding mutable
//~| HELP consider making this binding mutable
//~| SUGGESTION mut b
drop(b);
b = Box::new(2); //~ ERROR cannot assign twice to immutable variable `b`
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,7 @@ LL | let b = Box::new(1);
| -
| |
| first assignment to `b`
| help: make this binding mutable: `mut b`
| help: consider making this binding mutable: `mut b`
...
LL | b = Box::new(2);
| ^ cannot assign twice to immutable variable
Expand Down
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
fn test() {
let v: isize = 1; //~ NOTE first assignment
//~| HELP make this binding mutable
//~| HELP consider making this binding mutable
//~| SUGGESTION mut v
v.clone();
v = 2; //~ ERROR cannot assign twice to immutable variable `v`
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,7 @@ LL | let v: isize = 1;
| -
| |
| first assignment to `v`
| help: make this binding mutable: `mut v`
| help: consider making this binding mutable: `mut v`
...
LL | v = 2;
| ^^^^^ cannot assign twice to immutable variable
Expand Down
2 changes: 1 addition & 1 deletion src/test/ui/llvm-asm/llvm-asm-out-assign-imm.stderr
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,7 @@ error[E0384]: cannot assign twice to immutable variable `x`
--> $DIR/llvm-asm-out-assign-imm.rs:25:39
|
LL | let x: isize;
| - help: make this binding mutable: `mut x`
| - help: consider making this binding mutable: `mut x`
LL | x = 1;
| ----- first assignment to `x`
...
Expand Down
2 changes: 1 addition & 1 deletion src/test/ui/mut/mut-pattern-internal-mutability.stderr
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,7 @@ LL | let &mut x = foo;
| -
| |
| first assignment to `x`
| help: make this binding mutable: `mut x`
| help: consider making this binding mutable: `mut x`
LL | x += 1;
| ^^^^^^ cannot assign twice to immutable variable

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -16,7 +16,7 @@ LL | let [ref _x0_hold, _x1, ref xs_hold @ ..] = arr;
| ---
| |
| first assignment to `_x1`
| help: make this binding mutable: `mut _x1`
| help: consider making this binding mutable: `mut _x1`
LL | _x1 = U;
| ^^^^^^^ cannot assign twice to immutable variable

Expand Down Expand Up @@ -74,7 +74,7 @@ LL | let (ref _x0, _x1, ref _x2, ..) = tup;
| ---
| |
| first assignment to `_x1`
| help: make this binding mutable: `mut _x1`
| help: consider making this binding mutable: `mut _x1`
LL | _x1 = U;
| ^^^^^^^ cannot assign twice to immutable variable

Expand Down