-
Notifications
You must be signed in to change notification settings - Fork 13k
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Auto merge of #57381 - estebank:if-else-308, r=nikomatsakis
Tweak output of type mismatch between "then" and `else` `if` arms ``` error[E0308]: if and else have incompatible types --> $DIR/if-else-type-mismatch.rs:5:9 | LL | let _ = if true { | _____________- LL | | 42i32 | | ----- expected because of this LL | | } else { LL | | 42u32 | | ^^^^^ expected i32, found u32 LL | | }; | |_____- if and else have incompatible types | = note: expected type `i32` found type `u32` error[E0308]: if and else have incompatible types --> file.rs:2:38 | LL | let _ = if false { 3u8; } else { 3u8 }; | ---- ^^^ expected (), found u8 | | | | | help: consider removing this semicolon | expected because of this | = note: expected type `()` found type `u8` error[E0308]: if and else have incompatible types --> file.rs:3:37 | LL | let _ = if false { 3u8 } else { 3u8; }; | --- ^^^- | | | | | | | help: consider removing this semicolon | | expected u8, found () | expected because of this | = note: expected type `u8` found type `()` error[E0308]: if and else have incompatible types --> file.rs:4:37 | LL | let _ = if false { 3i8 } else { 3u8 }; | --- ^^^ expected i8, found u8 | | | expected because of this | = note: expected type `i8` found type `u8` ``` Fix #57348.
- Loading branch information
Showing
10 changed files
with
331 additions
and
28 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,46 @@ | ||
fn main() { | ||
let _ = if true { | ||
1i32 | ||
} else { | ||
2u32 | ||
}; | ||
//~^^ ERROR if and else have incompatible types | ||
let _ = if true { 42i32 } else { 42u32 }; | ||
//~^ ERROR if and else have incompatible types | ||
let _ = if true { | ||
3u32; | ||
} else { | ||
4u32 | ||
}; | ||
//~^^ ERROR if and else have incompatible types | ||
let _ = if true { | ||
5u32 | ||
} else { | ||
6u32; | ||
}; | ||
//~^^ ERROR if and else have incompatible types | ||
let _ = if true { | ||
7i32; | ||
} else { | ||
8u32 | ||
}; | ||
//~^^ ERROR if and else have incompatible types | ||
let _ = if true { | ||
9i32 | ||
} else { | ||
10u32; | ||
}; | ||
//~^^ ERROR if and else have incompatible types | ||
let _ = if true { | ||
|
||
} else { | ||
11u32 | ||
}; | ||
//~^^ ERROR if and else have incompatible types | ||
let _ = if true { | ||
12i32 | ||
} else { | ||
|
||
}; | ||
//~^^^ ERROR if and else have incompatible types | ||
} |
Oops, something went wrong.