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

resolve, inconsistent binding mode: tweak wording #69687

Merged
merged 1 commit into from
Mar 8, 2020
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
3 changes: 1 addition & 2 deletions src/librustc_resolve/diagnostics.rs
Original file line number Diff line number Diff line change
Expand Up @@ -249,8 +249,7 @@ impl<'a> Resolver<'a> {
self.session,
span,
E0409,
"variable `{}` is bound in inconsistent \
ways within the same match arm",
"variable `{}` is bound inconsistently across alternatives separated by `|`",
variable_name
);
err.span_label(span, "bound in different ways");
Expand Down
2 changes: 1 addition & 1 deletion src/test/ui/mismatched_types/E0409.stderr
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
error[E0409]: variable `y` is bound in inconsistent ways within the same match arm
error[E0409]: variable `y` is bound inconsistently across alternatives separated by `|`
--> $DIR/E0409.rs:5:23
|
LL | (0, ref y) | (y, 0) => {}
Expand Down
16 changes: 8 additions & 8 deletions src/test/ui/or-patterns/inconsistent-modes.rs
Original file line number Diff line number Diff line change
Expand Up @@ -5,22 +5,22 @@
fn main() {
// One level:
let Ok(a) | Err(ref a): Result<&u8, u8> = Ok(&0);
//~^ ERROR variable `a` is bound in inconsistent ways
//~^ ERROR variable `a` is bound inconsistently
let Ok(ref mut a) | Err(a): Result<u8, &mut u8> = Ok(0);
//~^ ERROR variable `a` is bound in inconsistent ways
//~^ ERROR variable `a` is bound inconsistently
let Ok(ref a) | Err(ref mut a): Result<&u8, &mut u8> = Ok(&0);
//~^ ERROR variable `a` is bound in inconsistent ways
//~^ ERROR variable `a` is bound inconsistently
//~| ERROR mismatched types
let Ok((ref a, b)) | Err((ref mut a, ref b)) = Ok((0, &0));
//~^ ERROR variable `a` is bound in inconsistent ways
//~| ERROR variable `b` is bound in inconsistent ways
//~^ ERROR variable `a` is bound inconsistently
//~| ERROR variable `b` is bound inconsistently
//~| ERROR mismatched types

// Two levels:
let Ok(Ok(a) | Err(a)) | Err(ref a) = Err(0);
//~^ ERROR variable `a` is bound in inconsistent ways
//~^ ERROR variable `a` is bound inconsistently

// Three levels:
let Ok([ Ok((Ok(ref a) | Err(a),)) | Err(a) ]) | Err(a) = Err(&1);
//~^ ERROR variable `a` is bound in inconsistent ways
let Ok([Ok((Ok(ref a) | Err(a),)) | Err(a)]) | Err(a) = Err(&1);
//~^ ERROR variable `a` is bound inconsistently
}
24 changes: 12 additions & 12 deletions src/test/ui/or-patterns/inconsistent-modes.stderr
Original file line number Diff line number Diff line change
@@ -1,52 +1,52 @@
error[E0409]: variable `a` is bound in inconsistent ways within the same match arm
error[E0409]: variable `a` is bound inconsistently across alternatives separated by `|`
--> $DIR/inconsistent-modes.rs:7:25
|
LL | let Ok(a) | Err(ref a): Result<&u8, u8> = Ok(&0);
| - ^ bound in different ways
| |
| first binding

error[E0409]: variable `a` is bound in inconsistent ways within the same match arm
error[E0409]: variable `a` is bound inconsistently across alternatives separated by `|`
--> $DIR/inconsistent-modes.rs:9:29
|
LL | let Ok(ref mut a) | Err(a): Result<u8, &mut u8> = Ok(0);
| - ^ bound in different ways
| |
| first binding

error[E0409]: variable `a` is bound in inconsistent ways within the same match arm
error[E0409]: variable `a` is bound inconsistently across alternatives separated by `|`
--> $DIR/inconsistent-modes.rs:11:33
|
LL | let Ok(ref a) | Err(ref mut a): Result<&u8, &mut u8> = Ok(&0);
| - first binding ^ bound in different ways

error[E0409]: variable `a` is bound in inconsistent ways within the same match arm
error[E0409]: variable `a` is bound inconsistently across alternatives separated by `|`
--> $DIR/inconsistent-modes.rs:14:39
|
LL | let Ok((ref a, b)) | Err((ref mut a, ref b)) = Ok((0, &0));
| - first binding ^ bound in different ways

error[E0409]: variable `b` is bound in inconsistent ways within the same match arm
error[E0409]: variable `b` is bound inconsistently across alternatives separated by `|`
--> $DIR/inconsistent-modes.rs:14:46
|
LL | let Ok((ref a, b)) | Err((ref mut a, ref b)) = Ok((0, &0));
| - first binding ^ bound in different ways

error[E0409]: variable `a` is bound in inconsistent ways within the same match arm
error[E0409]: variable `a` is bound inconsistently across alternatives separated by `|`
--> $DIR/inconsistent-modes.rs:20:38
|
LL | let Ok(Ok(a) | Err(a)) | Err(ref a) = Err(0);
| - ^ bound in different ways
| |
| first binding

error[E0409]: variable `a` is bound in inconsistent ways within the same match arm
--> $DIR/inconsistent-modes.rs:24:34
error[E0409]: variable `a` is bound inconsistently across alternatives separated by `|`
--> $DIR/inconsistent-modes.rs:24:33
|
LL | let Ok([ Ok((Ok(ref a) | Err(a),)) | Err(a) ]) | Err(a) = Err(&1);
| - ^ bound in different ways
| |
| first binding
LL | let Ok([Ok((Ok(ref a) | Err(a),)) | Err(a)]) | Err(a) = Err(&1);
| - ^ bound in different ways
| |
| first binding

error[E0308]: mismatched types
--> $DIR/inconsistent-modes.rs:11:25
Expand Down
33 changes: 17 additions & 16 deletions src/test/ui/resolve/resolve-inconsistent-binding-mode.rs
Original file line number Diff line number Diff line change
@@ -1,39 +1,40 @@
enum Opts {
A(isize), B(isize), C(isize)
A(isize),
B(isize),
C(isize),
}

fn matcher1(x: Opts) {
match x {
Opts::A(ref i) | Opts::B(i) => {}
//~^ ERROR variable `i` is bound in inconsistent ways within the same match arm
//~^^ ERROR mismatched types
Opts::C(_) => {}
Opts::A(ref i) | Opts::B(i) => {}
//~^ ERROR variable `i` is bound inconsistently
//~^^ ERROR mismatched types
Opts::C(_) => {}
}
}

fn matcher2(x: Opts) {
match x {
Opts::A(ref i) | Opts::B(i) => {}
//~^ ERROR variable `i` is bound in inconsistent ways within the same match arm
//~^^ ERROR mismatched types
Opts::C(_) => {}
Opts::A(ref i) | Opts::B(i) => {}
//~^ ERROR variable `i` is bound inconsistently
//~^^ ERROR mismatched types
Opts::C(_) => {}
}
}

fn matcher4(x: Opts) {
match x {
Opts::A(ref mut i) | Opts::B(ref i) => {}
//~^ ERROR variable `i` is bound in inconsistent ways within the same match arm
//~^^ ERROR mismatched types
Opts::C(_) => {}
Opts::A(ref mut i) | Opts::B(ref i) => {}
//~^ ERROR variable `i` is bound inconsistently
//~^^ ERROR mismatched types
Opts::C(_) => {}
}
}


fn matcher5(x: Opts) {
match x {
Opts::A(ref i) | Opts::B(ref i) => {}
Opts::C(_) => {}
Opts::A(ref i) | Opts::B(ref i) => {}
Opts::C(_) => {}
}
}

Expand Down
62 changes: 31 additions & 31 deletions src/test/ui/resolve/resolve-inconsistent-binding-mode.stderr
Original file line number Diff line number Diff line change
@@ -1,58 +1,58 @@
error[E0409]: variable `i` is bound in inconsistent ways within the same match arm
--> $DIR/resolve-inconsistent-binding-mode.rs:7:32
error[E0409]: variable `i` is bound inconsistently across alternatives separated by `|`
--> $DIR/resolve-inconsistent-binding-mode.rs:9:34
|
LL | Opts::A(ref i) | Opts::B(i) => {}
| - ^ bound in different ways
| |
| first binding
LL | Opts::A(ref i) | Opts::B(i) => {}
| - ^ bound in different ways
| |
| first binding

error[E0409]: variable `i` is bound in inconsistent ways within the same match arm
--> $DIR/resolve-inconsistent-binding-mode.rs:16:32
error[E0409]: variable `i` is bound inconsistently across alternatives separated by `|`
--> $DIR/resolve-inconsistent-binding-mode.rs:18:34
|
LL | Opts::A(ref i) | Opts::B(i) => {}
| - ^ bound in different ways
| |
| first binding
LL | Opts::A(ref i) | Opts::B(i) => {}
| - ^ bound in different ways
| |
| first binding

error[E0409]: variable `i` is bound in inconsistent ways within the same match arm
--> $DIR/resolve-inconsistent-binding-mode.rs:25:40
error[E0409]: variable `i` is bound inconsistently across alternatives separated by `|`
--> $DIR/resolve-inconsistent-binding-mode.rs:27:42
|
LL | Opts::A(ref mut i) | Opts::B(ref i) => {}
| - first binding ^ bound in different ways
LL | Opts::A(ref mut i) | Opts::B(ref i) => {}
| - first binding ^ bound in different ways

error[E0308]: mismatched types
--> $DIR/resolve-inconsistent-binding-mode.rs:7:32
--> $DIR/resolve-inconsistent-binding-mode.rs:9:34
|
LL | match x {
| - this expression has type `Opts`
LL | Opts::A(ref i) | Opts::B(i) => {}
| ----- ^ expected `&isize`, found `isize`
| |
| first introduced with type `&isize` here
LL | Opts::A(ref i) | Opts::B(i) => {}
| ----- ^ expected `&isize`, found `isize`
| |
| first introduced with type `&isize` here
|
= note: in the same arm, a binding must have the same type in all alternatives

error[E0308]: mismatched types
--> $DIR/resolve-inconsistent-binding-mode.rs:16:32
--> $DIR/resolve-inconsistent-binding-mode.rs:18:34
|
LL | match x {
| - this expression has type `Opts`
LL | Opts::A(ref i) | Opts::B(i) => {}
| ----- ^ expected `&isize`, found `isize`
| |
| first introduced with type `&isize` here
LL | Opts::A(ref i) | Opts::B(i) => {}
| ----- ^ expected `&isize`, found `isize`
| |
| first introduced with type `&isize` here
|
= note: in the same arm, a binding must have the same type in all alternatives

error[E0308]: mismatched types
--> $DIR/resolve-inconsistent-binding-mode.rs:25:36
--> $DIR/resolve-inconsistent-binding-mode.rs:27:38
|
LL | match x {
| - this expression has type `Opts`
LL | Opts::A(ref mut i) | Opts::B(ref i) => {}
| --------- ^^^^^ types differ in mutability
| |
| first introduced with type `&mut isize` here
LL | Opts::A(ref mut i) | Opts::B(ref i) => {}
| --------- ^^^^^ types differ in mutability
| |
| first introduced with type `&mut isize` here
|
= note: expected type `&mut isize`
found type `&isize`
Expand Down
2 changes: 1 addition & 1 deletion src/test/ui/resolve/resolve-inconsistent-names.rs
Original file line number Diff line number Diff line change
Expand Up @@ -19,7 +19,7 @@ fn main() {
(A, B) | (ref B, c) | (c, A) => ()
//~^ ERROR variable `A` is not bound in all patterns
//~| ERROR variable `B` is not bound in all patterns
//~| ERROR variable `B` is bound in inconsistent ways
//~| ERROR variable `B` is bound inconsistently
//~| ERROR mismatched types
//~| ERROR variable `c` is not bound in all patterns
//~| HELP consider making the path in the pattern qualified: `?::A`
Expand Down
2 changes: 1 addition & 1 deletion src/test/ui/resolve/resolve-inconsistent-names.stderr
Original file line number Diff line number Diff line change
Expand Up @@ -47,7 +47,7 @@ LL | (A, B) | (ref B, c) | (c, A) => ()
| | variable not in all patterns
| pattern doesn't bind `c`

error[E0409]: variable `B` is bound in inconsistent ways within the same match arm
error[E0409]: variable `B` is bound inconsistently across alternatives separated by `|`
--> $DIR/resolve-inconsistent-names.rs:19:23
|
LL | (A, B) | (ref B, c) | (c, A) => ()
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,7 @@ pub fn main() {
let x = &Some((3, 3));
let _: &i32 = match x {
Some((x, 3)) | &Some((ref x, 5)) => x,
//~^ ERROR is bound in inconsistent ways
//~^ ERROR is bound inconsistently
_ => &5i32,
};
}
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
error[E0409]: variable `x` is bound in inconsistent ways within the same match arm
error[E0409]: variable `x` is bound inconsistently across alternatives separated by `|`
--> $DIR/issue-44912-or.rs:6:35
|
LL | Some((x, 3)) | &Some((ref x, 5)) => x,
Expand Down