Skip to content
Open
Show file tree
Hide file tree
Changes from 1 commit
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Next Next commit
Add test suggest-compatible-variants-macro-issue-142359.rs
Signed-off-by: xizheyin <[email protected]>
  • Loading branch information
xizheyin committed Jul 20, 2025
commit d61b8bda9373d8b46759c94949c943ab17b468c6
Original file line number Diff line number Diff line change
@@ -0,0 +1,11 @@
// Make sure we don't suggest compatible variants inside macro. (issue #142359)
use std::ops::ControlFlow;

fn main(){
let x: Result<i32, i32> = Err(1);

let v= match x {
Err(r) => ControlFlow::Break(r),
Ok(r) => { println!("A")} //~ ERROR `match` arms have incompatible types [E0308]
};
}
Original file line number Diff line number Diff line change
@@ -0,0 +1,19 @@
error[E0308]: `match` arms have incompatible types
--> $DIR/suggest-compatible-variants-macro-issue-142359.rs:9:20
|
LL | let v= match x {
| ____________-
LL | | Err(r) => ControlFlow::Break(r),
| | --------------------- this is found to be of type `ControlFlow<i32, _>`
LL | | Ok(r) => { println!("A")}
| | ^^^^^^^^^^^^^ expected `ControlFlow<i32, _>`, found `()`
LL | | };
| |_____- `match` arms have incompatible types
|
= note: expected enum `ControlFlow<i32, _>`
found unit type `()`
= note: this error originates in the macro `println` (in Nightly builds, run with -Z macro-backtrace for more info)

error: aborting due to 1 previous error

For more information about this error, try `rustc --explain E0308`.