summaryrefslogtreecommitdiffstats
path: root/src/test/ui/impl-trait/point-to-type-err-cause-on-impl-trait-return.rs
diff options
context:
space:
mode:
authorDaniel Baumann <daniel.baumann@progress-linux.org>2024-04-17 12:02:58 +0000
committerDaniel Baumann <daniel.baumann@progress-linux.org>2024-04-17 12:02:58 +0000
commit698f8c2f01ea549d77d7dc3338a12e04c11057b9 (patch)
tree173a775858bd501c378080a10dca74132f05bc50 /src/test/ui/impl-trait/point-to-type-err-cause-on-impl-trait-return.rs
parentInitial commit. (diff)
downloadrustc-698f8c2f01ea549d77d7dc3338a12e04c11057b9.tar.xz
rustc-698f8c2f01ea549d77d7dc3338a12e04c11057b9.zip
Adding upstream version 1.64.0+dfsg1.upstream/1.64.0+dfsg1
Signed-off-by: Daniel Baumann <daniel.baumann@progress-linux.org>
Diffstat (limited to 'src/test/ui/impl-trait/point-to-type-err-cause-on-impl-trait-return.rs')
-rw-r--r--src/test/ui/impl-trait/point-to-type-err-cause-on-impl-trait-return.rs101
1 files changed, 101 insertions, 0 deletions
diff --git a/src/test/ui/impl-trait/point-to-type-err-cause-on-impl-trait-return.rs b/src/test/ui/impl-trait/point-to-type-err-cause-on-impl-trait-return.rs
new file mode 100644
index 000000000..fa7664a83
--- /dev/null
+++ b/src/test/ui/impl-trait/point-to-type-err-cause-on-impl-trait-return.rs
@@ -0,0 +1,101 @@
+fn foo() -> impl std::fmt::Display {
+ if false {
+ return 0i32;
+ }
+ 1u32 //~ ERROR mismatched types
+}
+
+fn bar() -> impl std::fmt::Display {
+ if false {
+ return 0i32;
+ } else {
+ return 1u32; //~ ERROR mismatched types
+ }
+}
+
+fn baz() -> impl std::fmt::Display {
+ if false {
+ return 0i32;
+ } else {
+ 1u32 //~ ERROR mismatched types
+ }
+}
+
+fn qux() -> impl std::fmt::Display {
+ if false {
+ 0i32
+ } else {
+ 1u32 //~ ERROR `if` and `else` have incompatible types
+ }
+}
+
+fn bat() -> impl std::fmt::Display {
+ match 13 {
+ 0 => return 0i32,
+ _ => 1u32, //~ ERROR mismatched types
+ }
+}
+
+fn can() -> impl std::fmt::Display {
+ match 13 { //~ ERROR mismatched types
+ 0 => return 0i32,
+ 1 => 1u32,
+ _ => 2u32,
+ }
+}
+
+fn cat() -> impl std::fmt::Display {
+ match 13 {
+ 0 => {
+ return 0i32;
+ }
+ _ => {
+ 1u32 //~ ERROR mismatched types
+ }
+ }
+}
+
+fn dog() -> impl std::fmt::Display {
+ match 13 {
+ 0 => 0i32,
+ 1 => 1u32, //~ ERROR `match` arms have incompatible types
+ _ => 2u32,
+ }
+}
+
+fn hat() -> dyn std::fmt::Display { //~ ERROR return type cannot have an unboxed trait object
+ match 13 {
+ 0 => {
+ return 0i32;
+ }
+ _ => {
+ 1u32
+ }
+ }
+}
+
+fn pug() -> dyn std::fmt::Display { //~ ERROR return type cannot have an unboxed trait object
+ match 13 {
+ 0 => 0i32,
+ 1 => 1u32, //~ ERROR `match` arms have incompatible types
+ _ => 2u32,
+ }
+}
+
+fn man() -> dyn std::fmt::Display { //~ ERROR return type cannot have an unboxed trait object
+ if false {
+ 0i32
+ } else {
+ 1u32 //~ ERROR `if` and `else` have incompatible types
+ }
+}
+
+fn apt() -> impl std::fmt::Display {
+ if let Some(42) = Some(42) {
+ 0i32
+ } else {
+ 1u32 //~ ERROR `if` and `else` have incompatible types
+ }
+}
+
+fn main() {}