From 039f70e926a859669fb046df4bd8115cad850113 Mon Sep 17 00:00:00 2001 From: CastilloDel Date: Mon, 6 Feb 2023 15:30:29 +0100 Subject: [PATCH] Add more test cases to tests/ui/issues/issue-92741.rs --- tests/ui/issues/issue-92741.rs | 10 ++++++++++ tests/ui/issues/issue-92741.stderr | 32 +++++++++++++++++++++++++++++- 2 files changed, 41 insertions(+), 1 deletion(-) diff --git a/tests/ui/issues/issue-92741.rs b/tests/ui/issues/issue-92741.rs index c42d4338fc1..4e18918c1cf 100644 --- a/tests/ui/issues/issue-92741.rs +++ b/tests/ui/issues/issue-92741.rs @@ -4,3 +4,13 @@ fn foo() -> bool { mut if true { true } else { false } } + +fn bar() -> bool { + & //~ ERROR 9:5: 10:40: mismatched types [E0308] + mut if true { true } else { false } +} + +fn baz() -> bool { + & mut //~ ERROR 14:5: 15:36: mismatched types [E0308] + if true { true } else { false } +} diff --git a/tests/ui/issues/issue-92741.stderr b/tests/ui/issues/issue-92741.stderr index 9459757d38f..7716a10cde0 100644 --- a/tests/ui/issues/issue-92741.stderr +++ b/tests/ui/issues/issue-92741.stderr @@ -14,6 +14,36 @@ LL - & LL - mut | -error: aborting due to previous error +error[E0308]: mismatched types + --> $DIR/issue-92741.rs:9:5 + | +LL | fn bar() -> bool { + | ---- expected `bool` because of return type +LL | / & +LL | | mut if true { true } else { false } + | |_______________________________________^ expected `bool`, found `&mut bool` + | +help: consider removing the borrow + | +LL - & +LL - mut if true { true } else { false } +LL + if true { true } else { false } + | + +error[E0308]: mismatched types + --> $DIR/issue-92741.rs:14:5 + | +LL | fn baz() -> bool { + | ---- expected `bool` because of return type +LL | / & mut +LL | | if true { true } else { false } + | |___________________________________^ expected `bool`, found `&mut bool` + | +help: consider removing the borrow + | +LL - & mut + | + +error: aborting due to 3 previous errors For more information about this error, try `rustc --explain E0308`.