Skip to content

Commit

Permalink
Update tests with the new error messages
Browse files Browse the repository at this point in the history
  • Loading branch information
Jakub Bukaj committed Oct 24, 2014
1 parent 4380e96 commit 1484f9c
Show file tree
Hide file tree
Showing 15 changed files with 56 additions and 29 deletions.
12 changes: 6 additions & 6 deletions src/test/compile-fail/destructure-trait-ref.rs
Expand Up @@ -30,12 +30,12 @@ fn main() {
let &&x = &&(&1i as &T);

// n == m
let &x = &1i as &T; //~ ERROR cannot be dereferenced
let &&x = &(&1i as &T); //~ ERROR cannot be dereferenced
let box x = box 1i as Box<T>; //~ ERROR cannot be dereferenced
let &x = &1i as &T; //~ ERROR type `&T` cannot be dereferenced
let &&x = &(&1i as &T); //~ ERROR type `&T` cannot be dereferenced
let box x = box 1i as Box<T>; //~ ERROR type `Box<T>` cannot be dereferenced

// n > m
let &&x = &1i as &T; //~ ERROR found an `&`-pointer pattern
let &&&x = &(&1i as &T); //~ ERROR found an `&`-pointer pattern
let box box x = box 1i as Box<T>; //~ ERROR found a box pattern
let &&x = &1i as &T; //~ ERROR found &-ptr
let &&&x = &(&1i as &T); //~ ERROR found &-ptr
let box box x = box 1i as Box<T>; //~ ERROR found box
}
3 changes: 2 additions & 1 deletion src/test/compile-fail/issue-13482.rs
Expand Up @@ -12,7 +12,8 @@ fn main() {
let x = [1,2];
let y = match x {
[] => None,
//~^ ERROR expected `[<generic integer #0>, ..2]`, found a fixed array pattern of size 0
//~^ ERROR mismatched types: expected `[<generic integer #0>, ..2]`, found `[<generic #7>, ..0]`
// (expected array, found array)
[a,_] => Some(a)
};
}
3 changes: 2 additions & 1 deletion src/test/compile-fail/issue-13624.rs
Expand Up @@ -29,7 +29,8 @@ mod b {
let enum_struct_variant = ::a::get_enum_struct_variant();
match enum_struct_variant {
a::EnumStructVariant { x, y, z } => {
//~^ ERROR error: mismatched types: expected `()`, found a structure pattern
//~^ ERROR mismatched types: expected `()`, found `a::Enum`
// (expected (), found enum a::Enum)
}
}
}
Expand Down
4 changes: 2 additions & 2 deletions src/test/compile-fail/issue-14541.rs
Expand Up @@ -13,8 +13,8 @@ struct vec3 { y: f32, z: f32 }

fn make(v: vec2) {
let vec3 { y: _, z: _ } = v;
//~^ ERROR `vec3` does not name the structure `vec2`
//~^^ ERROR struct `vec2` does not have a field named `z`
//~^ ERROR mismatched types: expected `vec2`, found `vec3`
// (expected struct vec2, found struct vec3)
}

fn main() { }
22 changes: 17 additions & 5 deletions src/test/compile-fail/issue-15260.rs
Expand Up @@ -9,11 +9,23 @@
// except according to those terms.

struct Foo {
a: uint,
a: uint,
}

fn main(){
let Foo {a: _, a: _} = Foo {a: 29};
//~^ ERROR field `a` bound twice in pattern
}
fn main() {
let Foo {
a: _, //~ NOTE field `a` previously bound here
a: _ //~ ERROR field `a` bound multiple times in the pattern
} = Foo { a: 29 };

let Foo {
a, //~ NOTE field `a` previously bound here
a: _ //~ ERROR field `a` bound multiple times in the pattern
} = Foo { a: 29 };

let Foo {
a, //~ NOTE field `a` previously bound here
a: _, //~ ERROR field `a` bound multiple times in the pattern
a: x //~ ERROR field `a` bound multiple times in the pattern
} = Foo { a: 29 };
}
4 changes: 3 additions & 1 deletion src/test/compile-fail/issue-15896.rs
Expand Up @@ -18,7 +18,9 @@ fn main() {
let e = B(REB(()), Tau { t: 3 });
let u = match e {
B(
Tau{t: x}, //~ ERROR `Tau` does not name a variant
Tau{t: x},
//~^ ERROR mismatched types: expected `main::R`, found `main::Tau`
// (expected enum main::R, found struct main::Tau)
_) => x,
};
}
3 changes: 2 additions & 1 deletion src/test/compile-fail/issue-16338.rs
Expand Up @@ -12,6 +12,7 @@ use std::raw::Slice;

fn main() {
let Slice { data: data, len: len } = "foo";
//~^ ERROR mismatched types: expected `&str`, found a structure pattern
//~^ ERROR mismatched types: expected `&str`, found `core::raw::Slice<<generic #3>>`
// (expected &-ptr, found struct core::raw::Slice)
}

3 changes: 2 additions & 1 deletion src/test/compile-fail/issue-16401.rs
Expand Up @@ -13,7 +13,8 @@ use std::raw::Slice;
fn main() {
match () {
Slice { data: data, len: len } => (),
//~^ ERROR mismatched types: expected `()`, found a structure pattern
//~^ ERROR mismatched types: expected `()`, found `core::raw::Slice<<generic #3>>`
// (expected (), found struct core::raw::Slice)
_ => unreachable!()
}
}
2 changes: 1 addition & 1 deletion src/test/compile-fail/issue-17405.rs
Expand Up @@ -14,6 +14,6 @@ enum Foo {

fn main() {
match Bar(1i) {
Foo { i } => () //~ ERROR `Foo` does not name a variant
Foo { i } => () //~ ERROR `Foo` does not name a struct or a struct variant
}
}
2 changes: 1 addition & 1 deletion src/test/compile-fail/issue-17800.rs
Expand Up @@ -15,7 +15,7 @@ enum MyOption<T> {

fn main() {
match MySome(42i) {
MySome { x: 42i } => (), //~ ERROR `MySome` does not name a struct variant
MySome { x: 42i } => (), //~ ERROR `MySome` does not name a struct or a struct variant
_ => (),
}
}
13 changes: 9 additions & 4 deletions src/test/compile-fail/issue-5100.rs
Expand Up @@ -12,24 +12,29 @@ enum A { B, C }

fn main() {
match (true, false) {
B => (), //~ ERROR expected `(bool,bool)`, found an enum or structure pattern
B => (),
//~^ ERROR mismatched types: expected `(bool,bool)`, found `A`
// (expected tuple, found enum A)
_ => ()
}

match (true, false) {
(true, false, false) => ()
//~^ ERROR mismatched types: expected `(bool,bool)`, found tuple
//~^ ERROR mismatched types: expected `(bool,bool)`,
// found `(<generic #7>,<generic #8>,<generic #9>)`
// (expected a tuple with 2 elements, found one with 3 elements)
}

match (true, false) {
box (true, false) => ()
//~^ ERROR mismatched types: expected `(bool,bool)`, found a box pattern
//~^ ERROR mismatched types: expected `(bool,bool)`, found `Box<<generic #11>>`
// (expected tuple, found box)
}

match (true, false) {
&(true, false) => ()
//~^ ERROR mismatched types: expected `(bool,bool)`, found an `&`-pointer pattern
//~^ ERROR mismatched types: expected `(bool,bool)`, found `&<generic #15>`
// (expected tuple, found &-ptr)
}


Expand Down
5 changes: 3 additions & 2 deletions src/test/compile-fail/issue-7092.rs
Expand Up @@ -13,8 +13,9 @@ enum Whatever {

fn foo(x: Whatever) {
match x {
Some(field) => field.access(),
//~^ ERROR: mismatched types: expected `Whatever`, found
Some(field) =>
//~^ ERROR: mismatched types: expected `Whatever`, found `core::option::Option<<generic #3>>`
field.access(), //~ ERROR the type of this value must be known in this context
}
}

Expand Down
3 changes: 2 additions & 1 deletion src/test/compile-fail/match-vec-mismatch-2.rs
Expand Up @@ -10,6 +10,7 @@

fn main() {
match () {
[()] => { } //~ ERROR mismatched types: expected `()`, found an array pattern
[()] => { }
//~^ ERROR mismatched types: expected `()`, found `&[<generic #1>]` (expected (), found &-ptr)
}
}
3 changes: 2 additions & 1 deletion src/test/compile-fail/pattern-error-continue.rs
Expand Up @@ -29,7 +29,8 @@ fn main() {
_ => ()
}
match 'c' {
S { .. } => (), //~ ERROR mismatched types: expected `char`, found a structure pattern
S { .. } => (),
//~^ ERROR mismatched types: expected `char`, found `S` (expected char, found struct S)

_ => ()
}
Expand Down
3 changes: 2 additions & 1 deletion src/test/compile-fail/suppressed-error.rs
Expand Up @@ -9,6 +9,7 @@
// except according to those terms.

fn main() {
let (x, y) = (); //~ ERROR expected `()`, found tuple (types differ)
let (x, y) = ();
//~^ ERROR types: expected `()`, found `(<generic #3>,<generic #4>)` (expected (), found tuple)
return x;
}

5 comments on commit 1484f9c

@bors
Copy link
Contributor

@bors bors commented on 1484f9c Oct 25, 2014

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

@bors
Copy link
Contributor

@bors bors commented on 1484f9c Oct 25, 2014

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

merging jakub-/rust/match-typeck = 1484f9c into auto

@bors
Copy link
Contributor

@bors bors commented on 1484f9c Oct 25, 2014

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

jakub-/rust/match-typeck = 1484f9c merged ok, testing candidate = a34b8de

@bors
Copy link
Contributor

@bors bors commented on 1484f9c Oct 25, 2014

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

@bors
Copy link
Contributor

@bors bors commented on 1484f9c Oct 25, 2014

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

fast-forwarding master to auto = a34b8de

Please sign in to comment.