summaryrefslogtreecommitdiffstats
path: root/tests/ui/inference/issue-86094-suggest-add-return-to-coerce-ret-ty.rs
diff options
context:
space:
mode:
authorDaniel Baumann <daniel.baumann@progress-linux.org>2024-06-07 05:48:48 +0000
committerDaniel Baumann <daniel.baumann@progress-linux.org>2024-06-07 05:48:48 +0000
commitef24de24a82fe681581cc130f342363c47c0969a (patch)
tree0d494f7e1a38b95c92426f58fe6eaa877303a86c /tests/ui/inference/issue-86094-suggest-add-return-to-coerce-ret-ty.rs
parentReleasing progress-linux version 1.74.1+dfsg1-1~progress7.99u1. (diff)
downloadrustc-ef24de24a82fe681581cc130f342363c47c0969a.tar.xz
rustc-ef24de24a82fe681581cc130f342363c47c0969a.zip
Merging upstream version 1.75.0+dfsg1.
Signed-off-by: Daniel Baumann <daniel.baumann@progress-linux.org>
Diffstat (limited to 'tests/ui/inference/issue-86094-suggest-add-return-to-coerce-ret-ty.rs')
-rw-r--r--tests/ui/inference/issue-86094-suggest-add-return-to-coerce-ret-ty.rs61
1 files changed, 61 insertions, 0 deletions
diff --git a/tests/ui/inference/issue-86094-suggest-add-return-to-coerce-ret-ty.rs b/tests/ui/inference/issue-86094-suggest-add-return-to-coerce-ret-ty.rs
new file mode 100644
index 000000000..4544c898a
--- /dev/null
+++ b/tests/ui/inference/issue-86094-suggest-add-return-to-coerce-ret-ty.rs
@@ -0,0 +1,61 @@
+struct MyError;
+
+fn foo(x: bool) -> Result<(), MyError> {
+ if x {
+ Err(MyError);
+ //~^ ERROR type annotations needed
+ }
+
+ Ok(())
+}
+
+fn bar(x: bool) -> Result<(), MyError> {
+ if x {
+ Ok(());
+ //~^ ERROR type annotations needed
+ }
+
+ Ok(())
+}
+
+fn baz(x: bool) -> Result<(), MyError> {
+ //~^ ERROR mismatched types
+ if x {
+ 1;
+ }
+
+ Err(MyError);
+}
+
+fn error() -> Result<(), MyError> {
+ Err(MyError)
+}
+
+fn bak(x: bool) -> Result<(), MyError> {
+ if x {
+ //~^ ERROR mismatched types
+ error();
+ } else {
+ //~^ ERROR mismatched types
+ error();
+ }
+}
+
+fn bad(x: bool) -> Result<(), MyError> {
+ Err(MyError); //~ ERROR type annotations needed
+ Ok(())
+}
+
+fn with_closure<F, A, B>(_: F) -> i32
+where
+ F: FnOnce(A, B),
+{
+ 0
+}
+
+fn a() -> i32 {
+ with_closure(|x: u32, y| {}); //~ ERROR type annotations needed
+ 0
+}
+
+fn main() {}