about summary refs log tree commit diff
path: root/tests/ui/impl-trait
diff options
context:
space:
mode:
authorMichael Goulet <michael@errs.io>2023-06-11 00:19:56 +0000
committerMichael Goulet <michael@errs.io>2023-06-11 00:19:56 +0000
commitd80440263c3eb083a91335ab14bee76bcb9988d1 (patch)
tree5d53d8120775a6cbdd4339e29911504f9b220779 /tests/ui/impl-trait
parent5dfc17f045aca52ad37a768d0f6704ea5b4fd4dd (diff)
downloadrust-d80440263c3eb083a91335ab14bee76bcb9988d1.tar.gz
rust-d80440263c3eb083a91335ab14bee76bcb9988d1.zip
Don't suggest boxing an empty if/else arm
Diffstat (limited to 'tests/ui/impl-trait')
-rw-r--r--tests/ui/impl-trait/dont-suggest-box-on-empty-else-arm.rs9
-rw-r--r--tests/ui/impl-trait/dont-suggest-box-on-empty-else-arm.stderr16
2 files changed, 25 insertions, 0 deletions
diff --git a/tests/ui/impl-trait/dont-suggest-box-on-empty-else-arm.rs b/tests/ui/impl-trait/dont-suggest-box-on-empty-else-arm.rs
new file mode 100644
index 00000000000..befd768b181
--- /dev/null
+++ b/tests/ui/impl-trait/dont-suggest-box-on-empty-else-arm.rs
@@ -0,0 +1,9 @@
+fn test() -> impl std::fmt::Debug {
+    if true {
+        "boo2"
+    } else {
+        //~^ ERROR `if` and `else` have incompatible types
+    }
+}
+
+fn main() {}
diff --git a/tests/ui/impl-trait/dont-suggest-box-on-empty-else-arm.stderr b/tests/ui/impl-trait/dont-suggest-box-on-empty-else-arm.stderr
new file mode 100644
index 00000000000..9b63911da7a
--- /dev/null
+++ b/tests/ui/impl-trait/dont-suggest-box-on-empty-else-arm.stderr
@@ -0,0 +1,16 @@
+error[E0308]: `if` and `else` have incompatible types
+  --> $DIR/dont-suggest-box-on-empty-else-arm.rs:4:12
+   |
+LL |       if true {
+   |       ------- `if` and `else` have incompatible types
+LL |           "boo2"
+   |           ------ expected because of this
+LL |       } else {
+   |  ____________^
+LL | |
+LL | |     }
+   | |_____^ expected `&str`, found `()`
+
+error: aborting due to previous error
+
+For more information about this error, try `rustc --explain E0308`.