summaryrefslogtreecommitdiffstats
path: root/src/test/ui/impl-trait/point-to-type-err-cause-on-impl-trait-return.rs
diff options
context:
space:
mode:
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() {}