summaryrefslogtreecommitdiffstats
path: root/src/test/ui/type/type-check
diff options
context:
space:
mode:
Diffstat (limited to 'src/test/ui/type/type-check')
-rw-r--r--src/test/ui/type/type-check/assignment-expected-bool.rs34
-rw-r--r--src/test/ui/type/type-check/assignment-expected-bool.stderr141
-rw-r--r--src/test/ui/type/type-check/assignment-in-if.rs43
-rw-r--r--src/test/ui/type/type-check/assignment-in-if.stderr69
-rw-r--r--src/test/ui/type/type-check/cannot_infer_local_or_array.rs3
-rw-r--r--src/test/ui/type/type-check/cannot_infer_local_or_array.stderr14
-rw-r--r--src/test/ui/type/type-check/cannot_infer_local_or_vec.rs4
-rw-r--r--src/test/ui/type/type-check/cannot_infer_local_or_vec.stderr14
-rw-r--r--src/test/ui/type/type-check/cannot_infer_local_or_vec_in_tuples.rs4
-rw-r--r--src/test/ui/type/type-check/cannot_infer_local_or_vec_in_tuples.stderr14
-rw-r--r--src/test/ui/type/type-check/issue-22897.rs5
-rw-r--r--src/test/ui/type/type-check/issue-22897.stderr9
-rw-r--r--src/test/ui/type/type-check/issue-40294.rs13
-rw-r--r--src/test/ui/type/type-check/issue-40294.stderr11
-rw-r--r--src/test/ui/type/type-check/issue-41314.rs10
-rw-r--r--src/test/ui/type/type-check/issue-41314.stderr14
-rw-r--r--src/test/ui/type/type-check/issue-67273-assignment-match-prior-arm-bool-expected-unit.rs27
-rw-r--r--src/test/ui/type/type-check/issue-67273-assignment-match-prior-arm-bool-expected-unit.stderr22
-rw-r--r--src/test/ui/type/type-check/issue-88577-check-fn-with-more-than-65535-arguments.rs12
-rw-r--r--src/test/ui/type/type-check/issue-88577-check-fn-with-more-than-65535-arguments.stderr13
-rw-r--r--src/test/ui/type/type-check/missing_trait_impl.rs16
-rw-r--r--src/test/ui/type/type-check/missing_trait_impl.stderr58
-rw-r--r--src/test/ui/type/type-check/unknown_type_for_closure.rs17
-rw-r--r--src/test/ui/type/type-check/unknown_type_for_closure.stderr37
24 files changed, 604 insertions, 0 deletions
diff --git a/src/test/ui/type/type-check/assignment-expected-bool.rs b/src/test/ui/type/type-check/assignment-expected-bool.rs
new file mode 100644
index 000000000..191939bdb
--- /dev/null
+++ b/src/test/ui/type/type-check/assignment-expected-bool.rs
@@ -0,0 +1,34 @@
+// The purpose of this text is to ensure that we get good
+// diagnostics when a `bool` is expected but that due to
+// an assignment expression `x = y` the type is `()`.
+
+fn main() {
+ let _: bool = 0 = 0; //~ ERROR mismatched types [E0308]
+
+ let _: bool = match 0 {
+ 0 => 0 = 0, //~ ERROR mismatched types [E0308]
+ _ => 0 = 0, //~ ERROR mismatched types [E0308]
+ };
+
+ let _: bool = match true {
+ true => 0 = 0, //~ ERROR mismatched types [E0308]
+ _ => (),
+ };
+
+ if 0 = 0 {} //~ ERROR mismatched types [E0308]
+
+ let _: bool = if { 0 = 0 } { //~ ERROR mismatched types [E0308]
+ 0 = 0 //~ ERROR mismatched types [E0308]
+ } else {
+ 0 = 0 //~ ERROR mismatched types [E0308]
+ };
+
+ let _ = (0 = 0) //~ ERROR mismatched types [E0308]
+ && { 0 = 0 } //~ ERROR mismatched types [E0308]
+ || (0 = 0); //~ ERROR mismatched types [E0308]
+
+ // A test to check that not expecting `bool` behaves well:
+ let _: usize = 0 = 0;
+ //~^ ERROR mismatched types [E0308]
+ //~| ERROR invalid left-hand side of assignment [E0070]
+}
diff --git a/src/test/ui/type/type-check/assignment-expected-bool.stderr b/src/test/ui/type/type-check/assignment-expected-bool.stderr
new file mode 100644
index 000000000..e2b821f7b
--- /dev/null
+++ b/src/test/ui/type/type-check/assignment-expected-bool.stderr
@@ -0,0 +1,141 @@
+error[E0308]: mismatched types
+ --> $DIR/assignment-expected-bool.rs:6:19
+ |
+LL | let _: bool = 0 = 0;
+ | ^^^^^ expected `bool`, found `()`
+ |
+help: you might have meant to compare for equality
+ |
+LL | let _: bool = 0 == 0;
+ | ~~
+
+error[E0308]: mismatched types
+ --> $DIR/assignment-expected-bool.rs:9:14
+ |
+LL | 0 => 0 = 0,
+ | ^^^^^ expected `bool`, found `()`
+ |
+help: you might have meant to compare for equality
+ |
+LL | 0 => 0 == 0,
+ | ~~
+
+error[E0308]: mismatched types
+ --> $DIR/assignment-expected-bool.rs:10:14
+ |
+LL | _ => 0 = 0,
+ | ^^^^^ expected `bool`, found `()`
+ |
+help: you might have meant to compare for equality
+ |
+LL | _ => 0 == 0,
+ | ~~
+
+error[E0308]: mismatched types
+ --> $DIR/assignment-expected-bool.rs:14:17
+ |
+LL | true => 0 = 0,
+ | ^^^^^ expected `bool`, found `()`
+ |
+help: you might have meant to compare for equality
+ |
+LL | true => 0 == 0,
+ | ~~
+
+error[E0308]: mismatched types
+ --> $DIR/assignment-expected-bool.rs:18:8
+ |
+LL | if 0 = 0 {}
+ | ^^^^^ expected `bool`, found `()`
+ |
+help: you might have meant to compare for equality
+ |
+LL | if 0 == 0 {}
+ | ~~
+
+error[E0308]: mismatched types
+ --> $DIR/assignment-expected-bool.rs:20:24
+ |
+LL | let _: bool = if { 0 = 0 } {
+ | ^^^^^ expected `bool`, found `()`
+ |
+help: you might have meant to compare for equality
+ |
+LL | let _: bool = if { 0 == 0 } {
+ | ~~
+
+error[E0308]: mismatched types
+ --> $DIR/assignment-expected-bool.rs:21:9
+ |
+LL | 0 = 0
+ | ^^^^^ expected `bool`, found `()`
+ |
+help: you might have meant to compare for equality
+ |
+LL | 0 == 0
+ | ~~
+
+error[E0308]: mismatched types
+ --> $DIR/assignment-expected-bool.rs:23:9
+ |
+LL | 0 = 0
+ | ^^^^^ expected `bool`, found `()`
+ |
+help: you might have meant to compare for equality
+ |
+LL | 0 == 0
+ | ~~
+
+error[E0308]: mismatched types
+ --> $DIR/assignment-expected-bool.rs:26:13
+ |
+LL | let _ = (0 = 0)
+ | ^^^^^^^ expected `bool`, found `()`
+ |
+help: you might have meant to compare for equality
+ |
+LL | let _ = (0 == 0)
+ | ~~
+
+error[E0308]: mismatched types
+ --> $DIR/assignment-expected-bool.rs:27:14
+ |
+LL | && { 0 = 0 }
+ | ^^^^^ expected `bool`, found `()`
+ |
+help: you might have meant to compare for equality
+ |
+LL | && { 0 == 0 }
+ | ~~
+
+error[E0308]: mismatched types
+ --> $DIR/assignment-expected-bool.rs:28:12
+ |
+LL | || (0 = 0);
+ | ^^^^^^^ expected `bool`, found `()`
+ |
+help: you might have meant to compare for equality
+ |
+LL | || (0 == 0);
+ | ~~
+
+error[E0070]: invalid left-hand side of assignment
+ --> $DIR/assignment-expected-bool.rs:31:22
+ |
+LL | let _: usize = 0 = 0;
+ | - ^
+ | |
+ | cannot assign to this expression
+
+error[E0308]: mismatched types
+ --> $DIR/assignment-expected-bool.rs:31:20
+ |
+LL | let _: usize = 0 = 0;
+ | ----- ^^^^^ expected `usize`, found `()`
+ | |
+ | expected due to this
+
+error: aborting due to 13 previous errors
+
+Some errors have detailed explanations: E0070, E0308.
+For more information about an error, try `rustc --explain E0070`.
diff --git a/src/test/ui/type/type-check/assignment-in-if.rs b/src/test/ui/type/type-check/assignment-in-if.rs
new file mode 100644
index 000000000..8da7b32b4
--- /dev/null
+++ b/src/test/ui/type/type-check/assignment-in-if.rs
@@ -0,0 +1,43 @@
+// Test that the parser does not attempt to parse struct literals
+// within assignments in if expressions.
+
+#![allow(unused_parens)]
+
+struct Foo {
+ foo: usize
+}
+
+fn main() {
+ let x = 1;
+ let y: Foo;
+
+ // `x { ... }` should not be interpreted as a struct literal here
+ if x = x {
+ //~^ ERROR mismatched types
+ println!("{}", x);
+ }
+ // Explicit parentheses on the left should match behavior of above
+ if (x = x) {
+ //~^ ERROR mismatched types
+ println!("{}", x);
+ }
+ // The struct literal interpretation is fine with explicit parentheses on the right
+ if y = (Foo { foo: x }) {
+ //~^ ERROR mismatched types
+ println!("{}", x);
+ }
+ // "invalid left-hand side of assignment" error is suppresed
+ if 3 = x {
+ //~^ ERROR mismatched types
+ println!("{}", x);
+ }
+ if (
+ if true {
+ x = 4 //~ ERROR mismatched types
+ } else {
+ x = 5 //~ ERROR mismatched types
+ }
+ ) {
+ println!("{}", x);
+ }
+}
diff --git a/src/test/ui/type/type-check/assignment-in-if.stderr b/src/test/ui/type/type-check/assignment-in-if.stderr
new file mode 100644
index 000000000..f4ef44e24
--- /dev/null
+++ b/src/test/ui/type/type-check/assignment-in-if.stderr
@@ -0,0 +1,69 @@
+error[E0308]: mismatched types
+ --> $DIR/assignment-in-if.rs:15:8
+ |
+LL | if x = x {
+ | ^^^^^ expected `bool`, found `()`
+ |
+help: you might have meant to compare for equality
+ |
+LL | if x == x {
+ | ~~
+
+error[E0308]: mismatched types
+ --> $DIR/assignment-in-if.rs:20:8
+ |
+LL | if (x = x) {
+ | ^^^^^^^ expected `bool`, found `()`
+ |
+help: you might have meant to compare for equality
+ |
+LL | if (x == x) {
+ | ~~
+
+error[E0308]: mismatched types
+ --> $DIR/assignment-in-if.rs:25:8
+ |
+LL | if y = (Foo { foo: x }) {
+ | ^^^^^^^^^^^^^^^^^^^^ expected `bool`, found `()`
+ |
+help: you might have meant to compare for equality
+ |
+LL | if y == (Foo { foo: x }) {
+ | ~~
+
+error[E0308]: mismatched types
+ --> $DIR/assignment-in-if.rs:30:8
+ |
+LL | if 3 = x {
+ | ^^^^^ expected `bool`, found `()`
+ |
+help: you might have meant to compare for equality
+ |
+LL | if 3 == x {
+ | ~~
+
+error[E0308]: mismatched types
+ --> $DIR/assignment-in-if.rs:36:13
+ |
+LL | x = 4
+ | ^^^^^ expected `bool`, found `()`
+ |
+help: you might have meant to compare for equality
+ |
+LL | x == 4
+ | ~~
+
+error[E0308]: mismatched types
+ --> $DIR/assignment-in-if.rs:38:13
+ |
+LL | x = 5
+ | ^^^^^ expected `bool`, found `()`
+ |
+help: you might have meant to compare for equality
+ |
+LL | x == 5
+ | ~~
+
+error: aborting due to 6 previous errors
+
+For more information about this error, try `rustc --explain E0308`.
diff --git a/src/test/ui/type/type-check/cannot_infer_local_or_array.rs b/src/test/ui/type/type-check/cannot_infer_local_or_array.rs
new file mode 100644
index 000000000..af7552523
--- /dev/null
+++ b/src/test/ui/type/type-check/cannot_infer_local_or_array.rs
@@ -0,0 +1,3 @@
+fn main() {
+ let x = []; //~ ERROR type annotations needed
+}
diff --git a/src/test/ui/type/type-check/cannot_infer_local_or_array.stderr b/src/test/ui/type/type-check/cannot_infer_local_or_array.stderr
new file mode 100644
index 000000000..e823bad26
--- /dev/null
+++ b/src/test/ui/type/type-check/cannot_infer_local_or_array.stderr
@@ -0,0 +1,14 @@
+error[E0282]: type annotations needed for `[_; 0]`
+ --> $DIR/cannot_infer_local_or_array.rs:2:9
+ |
+LL | let x = [];
+ | ^ -- type must be known at this point
+ |
+help: consider giving `x` an explicit type, where the placeholders `_` are specified
+ |
+LL | let x: [_; 0] = [];
+ | ++++++++
+
+error: aborting due to previous error
+
+For more information about this error, try `rustc --explain E0282`.
diff --git a/src/test/ui/type/type-check/cannot_infer_local_or_vec.rs b/src/test/ui/type/type-check/cannot_infer_local_or_vec.rs
new file mode 100644
index 000000000..e72ddabf3
--- /dev/null
+++ b/src/test/ui/type/type-check/cannot_infer_local_or_vec.rs
@@ -0,0 +1,4 @@
+fn main() {
+ let x = vec![];
+ //~^ ERROR type annotations needed
+}
diff --git a/src/test/ui/type/type-check/cannot_infer_local_or_vec.stderr b/src/test/ui/type/type-check/cannot_infer_local_or_vec.stderr
new file mode 100644
index 000000000..b63d2a3b6
--- /dev/null
+++ b/src/test/ui/type/type-check/cannot_infer_local_or_vec.stderr
@@ -0,0 +1,14 @@
+error[E0282]: type annotations needed for `Vec<T>`
+ --> $DIR/cannot_infer_local_or_vec.rs:2:9
+ |
+LL | let x = vec![];
+ | ^
+ |
+help: consider giving `x` an explicit type, where the type for type parameter `T` is specified
+ |
+LL | let x: Vec<T> = vec![];
+ | ++++++++
+
+error: aborting due to previous error
+
+For more information about this error, try `rustc --explain E0282`.
diff --git a/src/test/ui/type/type-check/cannot_infer_local_or_vec_in_tuples.rs b/src/test/ui/type/type-check/cannot_infer_local_or_vec_in_tuples.rs
new file mode 100644
index 000000000..d21456439
--- /dev/null
+++ b/src/test/ui/type/type-check/cannot_infer_local_or_vec_in_tuples.rs
@@ -0,0 +1,4 @@
+fn main() {
+ let (x, ) = (vec![], );
+ //~^ ERROR type annotations needed
+}
diff --git a/src/test/ui/type/type-check/cannot_infer_local_or_vec_in_tuples.stderr b/src/test/ui/type/type-check/cannot_infer_local_or_vec_in_tuples.stderr
new file mode 100644
index 000000000..be60cda68
--- /dev/null
+++ b/src/test/ui/type/type-check/cannot_infer_local_or_vec_in_tuples.stderr
@@ -0,0 +1,14 @@
+error[E0282]: type annotations needed for `(Vec<T>,)`
+ --> $DIR/cannot_infer_local_or_vec_in_tuples.rs:2:9
+ |
+LL | let (x, ) = (vec![], );
+ | ^^^^^
+ |
+help: consider giving this pattern a type, where the type for type parameter `T` is specified
+ |
+LL | let (x, ): (Vec<T>,) = (vec![], );
+ | +++++++++++
+
+error: aborting due to previous error
+
+For more information about this error, try `rustc --explain E0282`.
diff --git a/src/test/ui/type/type-check/issue-22897.rs b/src/test/ui/type/type-check/issue-22897.rs
new file mode 100644
index 000000000..8171a0ef1
--- /dev/null
+++ b/src/test/ui/type/type-check/issue-22897.rs
@@ -0,0 +1,5 @@
+fn main() { }
+
+fn unconstrained_type() {
+ []; //~ ERROR type annotations needed
+}
diff --git a/src/test/ui/type/type-check/issue-22897.stderr b/src/test/ui/type/type-check/issue-22897.stderr
new file mode 100644
index 000000000..fae7b7926
--- /dev/null
+++ b/src/test/ui/type/type-check/issue-22897.stderr
@@ -0,0 +1,9 @@
+error[E0282]: type annotations needed
+ --> $DIR/issue-22897.rs:4:5
+ |
+LL | [];
+ | ^^ cannot infer type for array `[_; 0]`
+
+error: aborting due to previous error
+
+For more information about this error, try `rustc --explain E0282`.
diff --git a/src/test/ui/type/type-check/issue-40294.rs b/src/test/ui/type/type-check/issue-40294.rs
new file mode 100644
index 000000000..5493a4e5f
--- /dev/null
+++ b/src/test/ui/type/type-check/issue-40294.rs
@@ -0,0 +1,13 @@
+trait Foo: Sized {
+ fn foo(self);
+}
+
+fn foo<'a,'b,T>(x: &'a T, y: &'b T)
+ where &'a T : Foo, //~ ERROR type annotations needed
+ &'b T : Foo
+{
+ x.foo();
+ y.foo();
+}
+
+fn main() { }
diff --git a/src/test/ui/type/type-check/issue-40294.stderr b/src/test/ui/type/type-check/issue-40294.stderr
new file mode 100644
index 000000000..75feb5698
--- /dev/null
+++ b/src/test/ui/type/type-check/issue-40294.stderr
@@ -0,0 +1,11 @@
+error[E0283]: type annotations needed: cannot satisfy `&'a T: Foo`
+ --> $DIR/issue-40294.rs:6:19
+ |
+LL | where &'a T : Foo,
+ | ^^^
+ |
+ = note: cannot satisfy `&'a T: Foo`
+
+error: aborting due to previous error
+
+For more information about this error, try `rustc --explain E0283`.
diff --git a/src/test/ui/type/type-check/issue-41314.rs b/src/test/ui/type/type-check/issue-41314.rs
new file mode 100644
index 000000000..cbd39f5f9
--- /dev/null
+++ b/src/test/ui/type/type-check/issue-41314.rs
@@ -0,0 +1,10 @@
+enum X {
+ Y(u32)
+}
+
+fn main() {
+ match X::Y(0) {
+ X::Y { number } => {}
+ //~^ ERROR tuple variant `X::Y` written as struct variant
+ }
+}
diff --git a/src/test/ui/type/type-check/issue-41314.stderr b/src/test/ui/type/type-check/issue-41314.stderr
new file mode 100644
index 000000000..4a9bf6106
--- /dev/null
+++ b/src/test/ui/type/type-check/issue-41314.stderr
@@ -0,0 +1,14 @@
+error[E0769]: tuple variant `X::Y` written as struct variant
+ --> $DIR/issue-41314.rs:7:9
+ |
+LL | X::Y { number } => {}
+ | ^^^^^^^^^^^^^^^
+ |
+help: use the tuple variant pattern syntax instead
+ |
+LL | X::Y(number) => {}
+ | ~~~~~~~~
+
+error: aborting due to previous error
+
+For more information about this error, try `rustc --explain E0769`.
diff --git a/src/test/ui/type/type-check/issue-67273-assignment-match-prior-arm-bool-expected-unit.rs b/src/test/ui/type/type-check/issue-67273-assignment-match-prior-arm-bool-expected-unit.rs
new file mode 100644
index 000000000..c39ab9544
--- /dev/null
+++ b/src/test/ui/type/type-check/issue-67273-assignment-match-prior-arm-bool-expected-unit.rs
@@ -0,0 +1,27 @@
+fn main() {
+ let mut i: i64;
+ // Expected type is an inference variable `?T`
+ // because the `match` is used as a statement.
+ // This is the "initial" type of the `coercion`.
+ match i {
+ // Add `bool` to the overall `coercion`.
+ 0 => true,
+
+ // Necessary to cause the ICE:
+ 1 => true,
+
+ // Suppose that we had `let _: bool = match i { ... }`.
+ // In that case, as the expected type would be `bool`,
+ // we would suggest `i == 1` as a fix.
+ //
+ // However, no type error happens when checking `i = 1` because `expected == ?T`,
+ // which will unify with `typeof(i = 1) == ()`.
+ //
+ // However, in #67273, we would delay the unification of this arm with the above
+ // because we used the hitherto accumulated coercion as opposed to the "initial" type.
+ 2 => i = 1,
+ //~^ ERROR `match` arms have incompatible types
+
+ _ => (),
+ }
+}
diff --git a/src/test/ui/type/type-check/issue-67273-assignment-match-prior-arm-bool-expected-unit.stderr b/src/test/ui/type/type-check/issue-67273-assignment-match-prior-arm-bool-expected-unit.stderr
new file mode 100644
index 000000000..a431fe89c
--- /dev/null
+++ b/src/test/ui/type/type-check/issue-67273-assignment-match-prior-arm-bool-expected-unit.stderr
@@ -0,0 +1,22 @@
+error[E0308]: `match` arms have incompatible types
+ --> $DIR/issue-67273-assignment-match-prior-arm-bool-expected-unit.rs:22:14
+ |
+LL | / match i {
+LL | | // Add `bool` to the overall `coercion`.
+LL | | 0 => true,
+ | | ---- this is found to be of type `bool`
+LL | |
+LL | | // Necessary to cause the ICE:
+LL | | 1 => true,
+ | | ---- this is found to be of type `bool`
+... |
+LL | | 2 => i = 1,
+ | | ^^^^^ expected `bool`, found `()`
+... |
+LL | | _ => (),
+LL | | }
+ | |_____- `match` arms have incompatible types
+
+error: aborting due to previous error
+
+For more information about this error, try `rustc --explain E0308`.
diff --git a/src/test/ui/type/type-check/issue-88577-check-fn-with-more-than-65535-arguments.rs b/src/test/ui/type/type-check/issue-88577-check-fn-with-more-than-65535-arguments.rs
new file mode 100644
index 000000000..e50cc5865
--- /dev/null
+++ b/src/test/ui/type/type-check/issue-88577-check-fn-with-more-than-65535-arguments.rs
@@ -0,0 +1,12 @@
+macro_rules! many_args {
+ ([$($t:tt)*]#$($h:tt)*) => {
+ many_args!{[$($t)*$($t)*]$($h)*}
+ };
+ ([$($t:tt)*]) => {
+ fn _f($($t: ()),*) {} //~ ERROR function can not have more than 65535 arguments
+ }
+}
+
+many_args!{[_]########## ######}
+
+fn main() {}
diff --git a/src/test/ui/type/type-check/issue-88577-check-fn-with-more-than-65535-arguments.stderr b/src/test/ui/type/type-check/issue-88577-check-fn-with-more-than-65535-arguments.stderr
new file mode 100644
index 000000000..615fd2ccb
--- /dev/null
+++ b/src/test/ui/type/type-check/issue-88577-check-fn-with-more-than-65535-arguments.stderr
@@ -0,0 +1,13 @@
+error: function can not have more than 65535 arguments
+ --> $DIR/issue-88577-check-fn-with-more-than-65535-arguments.rs:6:24
+ |
+LL | fn _f($($t: ()),*) {}
+ | ________________________^
+LL | | }
+LL | | }
+LL | |
+LL | | many_args!{[_]########## ######}
+ | |____________^
+
+error: aborting due to previous error
+
diff --git a/src/test/ui/type/type-check/missing_trait_impl.rs b/src/test/ui/type/type-check/missing_trait_impl.rs
new file mode 100644
index 000000000..0e3e703a2
--- /dev/null
+++ b/src/test/ui/type/type-check/missing_trait_impl.rs
@@ -0,0 +1,16 @@
+fn main() {
+}
+
+fn foo<T>(x: T, y: T) {
+ let z = x + y; //~ ERROR cannot add `T` to `T`
+}
+
+fn bar<T>(x: T) {
+ x += x; //~ ERROR binary assignment operation `+=` cannot be applied to type `T`
+}
+
+fn baz<T>(x: T) {
+ let y = -x; //~ ERROR cannot apply unary operator `-` to type `T`
+ let y = !x; //~ ERROR cannot apply unary operator `!` to type `T`
+ let y = *x; //~ ERROR type `T` cannot be dereferenced
+}
diff --git a/src/test/ui/type/type-check/missing_trait_impl.stderr b/src/test/ui/type/type-check/missing_trait_impl.stderr
new file mode 100644
index 000000000..2b58cd418
--- /dev/null
+++ b/src/test/ui/type/type-check/missing_trait_impl.stderr
@@ -0,0 +1,58 @@
+error[E0369]: cannot add `T` to `T`
+ --> $DIR/missing_trait_impl.rs:5:15
+ |
+LL | let z = x + y;
+ | - ^ - T
+ | |
+ | T
+ |
+help: consider restricting type parameter `T`
+ |
+LL | fn foo<T: std::ops::Add>(x: T, y: T) {
+ | +++++++++++++++
+
+error[E0368]: binary assignment operation `+=` cannot be applied to type `T`
+ --> $DIR/missing_trait_impl.rs:9:5
+ |
+LL | x += x;
+ | -^^^^^
+ | |
+ | cannot use `+=` on type `T`
+ |
+help: consider restricting type parameter `T`
+ |
+LL | fn bar<T: std::ops::AddAssign>(x: T) {
+ | +++++++++++++++++++++
+
+error[E0600]: cannot apply unary operator `-` to type `T`
+ --> $DIR/missing_trait_impl.rs:13:13
+ |
+LL | let y = -x;
+ | ^^ cannot apply unary operator `-`
+ |
+help: consider restricting type parameter `T`
+ |
+LL | fn baz<T: std::ops::Neg>(x: T) {
+ | +++++++++++++++
+
+error[E0600]: cannot apply unary operator `!` to type `T`
+ --> $DIR/missing_trait_impl.rs:14:13
+ |
+LL | let y = !x;
+ | ^^ cannot apply unary operator `!`
+ |
+help: consider restricting type parameter `T`
+ |
+LL | fn baz<T: std::ops::Not>(x: T) {
+ | +++++++++++++++
+
+error[E0614]: type `T` cannot be dereferenced
+ --> $DIR/missing_trait_impl.rs:15:13
+ |
+LL | let y = *x;
+ | ^^
+
+error: aborting due to 5 previous errors
+
+Some errors have detailed explanations: E0368, E0369, E0600, E0614.
+For more information about an error, try `rustc --explain E0368`.
diff --git a/src/test/ui/type/type-check/unknown_type_for_closure.rs b/src/test/ui/type/type-check/unknown_type_for_closure.rs
new file mode 100644
index 000000000..167687c18
--- /dev/null
+++ b/src/test/ui/type/type-check/unknown_type_for_closure.rs
@@ -0,0 +1,17 @@
+fn infer_in_arg() {
+ let x = |b: Vec<_>| {}; //~ ERROR E0282
+}
+
+fn empty_pattern() {
+ let x = |_| {}; //~ ERROR type annotations needed
+}
+
+fn infer_ty() {
+ let x = |k: _| {}; //~ ERROR type annotations needed
+}
+
+fn ambig_return() {
+ let x = || -> Vec<_> { Vec::new() }; //~ ERROR type annotations needed
+}
+
+fn main() {}
diff --git a/src/test/ui/type/type-check/unknown_type_for_closure.stderr b/src/test/ui/type/type-check/unknown_type_for_closure.stderr
new file mode 100644
index 000000000..9ae97f390
--- /dev/null
+++ b/src/test/ui/type/type-check/unknown_type_for_closure.stderr
@@ -0,0 +1,37 @@
+error[E0282]: type annotations needed
+ --> $DIR/unknown_type_for_closure.rs:2:13
+ |
+LL | let x = |b: Vec<_>| {};
+ | ^^^^^^^^^^^^^^ cannot infer type for struct `Vec<_>`
+
+error[E0282]: type annotations needed
+ --> $DIR/unknown_type_for_closure.rs:6:14
+ |
+LL | let x = |_| {};
+ | ^
+ |
+help: consider giving this closure parameter an explicit type
+ |
+LL | let x = |_: _| {};
+ | +++
+
+error[E0282]: type annotations needed
+ --> $DIR/unknown_type_for_closure.rs:10:14
+ |
+LL | let x = |k: _| {};
+ | ^ cannot infer type
+
+error[E0282]: type annotations needed
+ --> $DIR/unknown_type_for_closure.rs:14:28
+ |
+LL | let x = || -> Vec<_> { Vec::new() };
+ | ^^^^^^^^ cannot infer type of the type parameter `T` declared on the struct `Vec`
+ |
+help: consider specifying the generic argument
+ |
+LL | let x = || -> Vec<_> { Vec::<T>::new() };
+ | +++++
+
+error: aborting due to 4 previous errors
+
+For more information about this error, try `rustc --explain E0282`.