From b47fe51610fbe0d8d983f3ace0682044a1a450c3 Mon Sep 17 00:00:00 2001 From: Jieyou Xu Date: Sat, 19 Apr 2025 17:29:31 +0800 Subject: [PATCH] tests: adjust `tests/ui/auto-instantiate.rs` - Reformat the test. - Document test intention. - Move test under `tests/ui/inference/`. --- tests/ui/auto-instantiate.rs | 13 ------------ tests/ui/inference/auto-instantiate.rs | 28 ++++++++++++++++++++++++++ 2 files changed, 28 insertions(+), 13 deletions(-) delete mode 100644 tests/ui/auto-instantiate.rs create mode 100644 tests/ui/inference/auto-instantiate.rs diff --git a/tests/ui/auto-instantiate.rs b/tests/ui/auto-instantiate.rs deleted file mode 100644 index 73ad5d701e18..000000000000 --- a/tests/ui/auto-instantiate.rs +++ /dev/null @@ -1,13 +0,0 @@ -//@ run-pass - -#![allow(dead_code)] -#[derive(Debug)] -struct Pair { a: T, b: U } -struct Triple { x: isize, y: isize, z: isize } - -fn f(x: T, y: U) -> Pair { 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); -} diff --git a/tests/ui/inference/auto-instantiate.rs b/tests/ui/inference/auto-instantiate.rs new file mode 100644 index 000000000000..bf43330a0b77 --- /dev/null +++ b/tests/ui/inference/auto-instantiate.rs @@ -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 . + +//@ run-pass + +#![allow(dead_code)] +#[derive(Debug)] +struct Pair { + a: T, + b: U, +} + +struct Triple { + x: isize, + y: isize, + z: isize, +} + +fn f(x: T, y: U) -> Pair { + 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); +}