diff options
| author | Michael Goulet <michael@errs.io> | 2022-08-03 03:30:17 +0000 |
|---|---|---|
| committer | Michael Goulet <michael@errs.io> | 2022-09-12 03:24:04 +0000 |
| commit | 3b573c9b986a98064b6c155c7029f8ce253ed69c (patch) | |
| tree | e7fa632aa33181490328fb774234ea2592b3a812 /src/test/ui/function-pointer/unsized-ret.rs | |
| parent | 98e1f041b6e33598a18edb928ec9db93a850c6cb (diff) | |
| download | rust-3b573c9b986a98064b6c155c7029f8ce253ed69c.tar.gz rust-3b573c9b986a98064b6c155c7029f8ce253ed69c.zip | |
fn pointers don't implement Fn/FnMut/FnOnce traits if its return type is unsized
Diffstat (limited to 'src/test/ui/function-pointer/unsized-ret.rs')
| -rw-r--r-- | src/test/ui/function-pointer/unsized-ret.rs | 14 |
1 files changed, 14 insertions, 0 deletions
diff --git a/src/test/ui/function-pointer/unsized-ret.rs b/src/test/ui/function-pointer/unsized-ret.rs new file mode 100644 index 00000000000..60af5769d6d --- /dev/null +++ b/src/test/ui/function-pointer/unsized-ret.rs @@ -0,0 +1,14 @@ +#![feature(fn_traits)] +#![feature(unboxed_closures)] + +fn foo<F: Fn<T>, T>(f: Option<F>, t: T) { + let y = (f.unwrap()).call(t); +} + +fn main() { + foo::<fn() -> str, _>(None, ()); + //~^ ERROR the size for values of type `str` cannot be known at compilation time + + foo::<for<'a> fn(&'a ()) -> (dyn std::fmt::Display + 'a), _>(None, (&(),)); + //~^ ERROR the size for values of type `(dyn std::fmt::Display + 'a)` cannot be known at compilation time +} |
