about summary refs log tree commit diff
path: root/tests/ui/inference
diff options
context:
space:
mode:
authorJieyou Xu <jieyouxu@outlook.com>2025-04-19 17:29:31 +0800
committerJieyou Xu <jieyouxu@outlook.com>2025-04-19 18:42:24 +0800
commitb47fe51610fbe0d8d983f3ace0682044a1a450c3 (patch)
tree47ff86fc94f048d4075a9eddeb1b8fef91ae8c23 /tests/ui/inference
parent40b73322b93bf1627a7cb58aec5a7fe019af1f66 (diff)
downloadrust-b47fe51610fbe0d8d983f3ace0682044a1a450c3.tar.gz
rust-b47fe51610fbe0d8d983f3ace0682044a1a450c3.zip
tests: adjust `tests/ui/auto-instantiate.rs`
- Reformat the test.
- Document test intention.
- Move test under `tests/ui/inference/`.
Diffstat (limited to 'tests/ui/inference')
-rw-r--r--tests/ui/inference/auto-instantiate.rs28
1 files changed, 28 insertions, 0 deletions
diff --git a/tests/ui/inference/auto-instantiate.rs b/tests/ui/inference/auto-instantiate.rs
new file mode 100644
index 00000000000..bf43330a0b7
--- /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 <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);
+}