summaryrefslogtreecommitdiffstats
path: root/src/test/ui/impl-trait/cross-return-site-inference.rs
diff options
context:
space:
mode:
Diffstat (limited to 'src/test/ui/impl-trait/cross-return-site-inference.rs')
-rw-r--r--src/test/ui/impl-trait/cross-return-site-inference.rs45
1 files changed, 45 insertions, 0 deletions
diff --git a/src/test/ui/impl-trait/cross-return-site-inference.rs b/src/test/ui/impl-trait/cross-return-site-inference.rs
new file mode 100644
index 000000000..d881af9ed
--- /dev/null
+++ b/src/test/ui/impl-trait/cross-return-site-inference.rs
@@ -0,0 +1,45 @@
+// edition:2021
+
+fn foo(b: bool) -> impl std::fmt::Debug {
+ if b {
+ return vec![42]
+ }
+ [].into_iter().collect()
+}
+
+fn bar(b: bool) -> impl std::fmt::Debug {
+ if b {
+ return [].into_iter().collect()
+ }
+ vec![42]
+}
+
+fn bak(b: bool) -> impl std::fmt::Debug {
+ if b {
+ return std::iter::empty().collect()
+ }
+ vec![42]
+}
+
+fn baa(b: bool) -> impl std::fmt::Debug {
+ if b {
+ return [42].into_iter().collect()
+ }
+ vec![]
+}
+
+fn muh() -> Result<(), impl std::fmt::Debug> {
+ Err("whoops")?;
+ Ok(()) //~ ERROR type annotations needed
+}
+
+fn muh2() -> Result<(), impl std::fmt::Debug> {
+ return Err(From::from("foo")); //~ ERROR type annotations needed
+ Ok(())
+}
+
+fn muh3() -> Result<(), impl std::fmt::Debug> {
+ Err(From::from("foo")) //~ ERROR type annotations needed
+}
+
+fn main() {}