tests: adjust tests/ui/auto-instantiate.rs
- Reformat the test. - Document test intention. - Move test under `tests/ui/inference/`.
This commit is contained in:
parent
40b73322b9
commit
b47fe51610
2 changed files with 28 additions and 13 deletions
|
@ -1,13 +0,0 @@
|
|||
//@ run-pass
|
||||
|
||||
#![allow(dead_code)]
|
||||
#[derive(Debug)]
|
||||
struct Pair<T, U> { a: T, b: U }
|
||||
struct Triple { x: isize, y: isize, z: isize }
|
||||
|
||||
fn f<T,U>(x: T, y: U) -> Pair<T, U> { return Pair {a: x, b: y}; }
|
||||
|
||||
pub fn main() {
|
||||
println!("{}", f(Triple {x: 3, y: 4, z: 5}, 4).a.x);
|
||||
println!("{}", f(5, 6).a);
|
||||
}
|
28
tests/ui/inference/auto-instantiate.rs
Normal file
28
tests/ui/inference/auto-instantiate.rs
Normal file
|
@ -0,0 +1,28 @@
|
|||
//! Check that type parameters in generic function arg position and in "nested" return type position
|
||||
//! can be inferred on an invocation of the generic function.
|
||||
//!
|
||||
//! See <https://github.com/rust-lang/rust/issues/45>.
|
||||
|
||||
//@ run-pass
|
||||
|
||||
#![allow(dead_code)]
|
||||
#[derive(Debug)]
|
||||
struct Pair<T, U> {
|
||||
a: T,
|
||||
b: U,
|
||||
}
|
||||
|
||||
struct Triple {
|
||||
x: isize,
|
||||
y: isize,
|
||||
z: isize,
|
||||
}
|
||||
|
||||
fn f<T, U>(x: T, y: U) -> Pair<T, U> {
|
||||
return Pair { a: x, b: y };
|
||||
}
|
||||
|
||||
pub fn main() {
|
||||
println!("{}", f(Triple {x: 3, y: 4, z: 5}, 4).a.x);
|
||||
println!("{}", f(5, 6).a);
|
||||
}
|
Loading…
Add table
Add a link
Reference in a new issue