diff options
| author | cardigan1008 <211250058@smail.nju.edu.cn> | 2024-05-16 21:10:07 +0800 |
|---|---|---|
| committer | cardigan1008 <211250058@smail.nju.edu.cn> | 2024-05-16 21:10:07 +0800 |
| commit | c811acb1f36cdeb45b46c490b7a308851347dc0d (patch) | |
| tree | ce0ef0f9f4b6fce7d271abf9b546250ed65fdc4d | |
| parent | 62318b38ef591c70d9db875e88a04aa37c565828 (diff) | |
feat: add unit test
| -rw-r--r-- | tests/ui/return/tail-expr-if-as-return.rs | 5 | ||||
| -rw-r--r-- | tests/ui/return/tail-expr-if-as-return.stderr | 12 |
2 files changed, 17 insertions, 0 deletions
diff --git a/tests/ui/return/tail-expr-if-as-return.rs b/tests/ui/return/tail-expr-if-as-return.rs new file mode 100644 index 00000000000..119ffccc6a9 --- /dev/null +++ b/tests/ui/return/tail-expr-if-as-return.rs @@ -0,0 +1,5 @@ +fn main() { + if true { + "" //~ ERROR mismatched types [E0308] + } +} diff --git a/tests/ui/return/tail-expr-if-as-return.stderr b/tests/ui/return/tail-expr-if-as-return.stderr new file mode 100644 index 00000000000..2631f1e426d --- /dev/null +++ b/tests/ui/return/tail-expr-if-as-return.stderr @@ -0,0 +1,12 @@ +error[E0308]: mismatched types + --> $DIR/tail-expr-if-as-return.rs:3:9 + | +LL | / if true { +LL | | "" + | | ^^ expected `()`, found `&str` +LL | | } + | |_____- expected this to be `()` + +error: aborting due to 1 previous error + +For more information about this error, try `rustc --explain E0308`. |
