From da8c57ba6c782dd3c86d61f47ce18f9402ed4541 Mon Sep 17 00:00:00 2001 From: Obei Sideg Date: Sun, 10 Sep 2023 21:45:25 +0300 Subject: [PATCH] Add ui tests for functions --- crates/formality-check/src/fns.rs | 4 +--- tests/ui/fn/lifetime.stderr | 1 + "tests/ui/fn/lifetime.\360\237\224\254" | 7 +++++++ "tests/ui/fn/ok.\360\237\224\254" | 20 ++++++++++++++++++++ 4 files changed, 29 insertions(+), 3 deletions(-) create mode 100644 tests/ui/fn/lifetime.stderr create mode 100644 "tests/ui/fn/lifetime.\360\237\224\254" create mode 100644 "tests/ui/fn/ok.\360\237\224\254" diff --git a/crates/formality-check/src/fns.rs b/crates/formality-check/src/fns.rs index b9858ce5..15f2357a 100644 --- a/crates/formality-check/src/fns.rs +++ b/crates/formality-check/src/fns.rs @@ -3,9 +3,7 @@ use formality_rust::{ grammar::{Fn, FnBoundData}, prove::ToWcs, }; -use formality_types::{ - grammar::{Fallible, Wcs}, -}; +use formality_types::grammar::{Fallible, Wcs}; use crate::Check; diff --git a/tests/ui/fn/lifetime.stderr b/tests/ui/fn/lifetime.stderr new file mode 100644 index 00000000..325d1878 --- /dev/null +++ b/tests/ui/fn/lifetime.stderr @@ -0,0 +1 @@ +Error: failed to prove {@ wf((rigid &(shared) !lt_1 !ty_2))} given {}, got {} diff --git "a/tests/ui/fn/lifetime.\360\237\224\254" "b/tests/ui/fn/lifetime.\360\237\224\254" new file mode 100644 index 00000000..e1f33550 --- /dev/null +++ "b/tests/ui/fn/lifetime.\360\237\224\254" @@ -0,0 +1,7 @@ +// Test lifetimes on function +[ + crate Foo { + // fn one_lt_arg<'a, T>(_: &'a T) -> () {} + fn one_lt_arg(&a T) -> () where [] { trusted } + } +] diff --git "a/tests/ui/fn/ok.\360\237\224\254" "b/tests/ui/fn/ok.\360\237\224\254" new file mode 100644 index 00000000..cfa61a7e --- /dev/null +++ "b/tests/ui/fn/ok.\360\237\224\254" @@ -0,0 +1,20 @@ +// Test functions, function's arguments, and function's returns +//@check-pass +[ + crate Foo { + // fn simple_fn() {} + fn simple_fn<>() -> () where [] { trusted } + + // fn one_arg(_: T) {} + fn one_arg(T) -> () where [] { trusted } + + // fn one_ret(_: T) {} + fn one_ret() -> T where [] { trusted } + + // fn arg_ret(_: T) -> U {} + fn arg_ret(T) -> U where [] { trusted } + + // fn multi_arg_ret(_: T, _: Y) -> (U, I) {} + fn multi_arg_ret(T, Y) -> (U, I) where [] { trusted } + } +]