Add tests
This commit is contained in:
parent
5d1adbb629
commit
2924d38dd9
4 changed files with 38 additions and 0 deletions
10
src/test/ui/type-inference/or_else-multiple-type-params.rs
Normal file
10
src/test/ui/type-inference/or_else-multiple-type-params.rs
Normal file
|
|
@ -0,0 +1,10 @@
|
|||
use std::process::{Command, Stdio};
|
||||
|
||||
fn main() {
|
||||
let process = Command::new("wc")
|
||||
.stdout(Stdio::piped())
|
||||
.spawn()
|
||||
.or_else(|err| { //~ ERROR type annotations needed
|
||||
panic!("oh no: {:?}", err);
|
||||
}).unwrap();
|
||||
}
|
||||
|
|
@ -0,0 +1,12 @@
|
|||
error[E0282]: type annotations needed
|
||||
--> $DIR/or_else-multiple-type-params.rs:7:10
|
||||
|
|
||||
LL | .or_else(|err| {
|
||||
| ^^^^^^^
|
||||
| |
|
||||
| cannot infer type for `F`
|
||||
| help: consider specifying the type arguments in the method call: `or_else::<F, O>`
|
||||
|
||||
error: aborting due to previous error
|
||||
|
||||
For more information about this error, try `rustc --explain E0282`.
|
||||
5
src/test/ui/type-inference/sort_by_key.rs
Normal file
5
src/test/ui/type-inference/sort_by_key.rs
Normal file
|
|
@ -0,0 +1,5 @@
|
|||
fn main() {
|
||||
let mut lst: [([i32; 10], bool); 10] = [([0; 10], false); 10];
|
||||
lst.sort_by_key(|&(v, _)| v.iter().sum()); //~ ERROR type annotations needed
|
||||
println!("{:?}", lst);
|
||||
}
|
||||
11
src/test/ui/type-inference/sort_by_key.stderr
Normal file
11
src/test/ui/type-inference/sort_by_key.stderr
Normal file
|
|
@ -0,0 +1,11 @@
|
|||
error[E0282]: type annotations needed
|
||||
--> $DIR/sort_by_key.rs:3:9
|
||||
|
|
||||
LL | lst.sort_by_key(|&(v, _)| v.iter().sum());
|
||||
| ^^^^^^^^^^^ --- help: consider specifying the type argument in the method call: `sum::<S>`
|
||||
| |
|
||||
| cannot infer type for `K`
|
||||
|
||||
error: aborting due to previous error
|
||||
|
||||
For more information about this error, try `rustc --explain E0282`.
|
||||
Loading…
Add table
Add a link
Reference in a new issue