Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Tweak output of type mismatch between "then" and
else
if
arms
- Loading branch information
Showing
10 changed files
with
238 additions
and
13 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,34 @@ | ||
fn main() { | ||
let _ = if true { | ||
42i32 | ||
} else { | ||
42u32 | ||
}; | ||
//~^^ ERROR if and else have incompatible types | ||
let _ = if true { 42i32 } else { 42u32 }; | ||
//~^ ERROR if and else have incompatible types | ||
let _ = if true { | ||
42i32; | ||
} else { | ||
42u32 | ||
}; | ||
//~^^ ERROR if and else have incompatible types | ||
let _ = if true { | ||
42i32 | ||
} else { | ||
42u32; | ||
}; | ||
//~^^ ERROR if and else have incompatible types | ||
let _ = if true { | ||
|
||
} else { | ||
42u32 | ||
}; | ||
//~^^ ERROR if and else have incompatible types | ||
let _ = if true { | ||
42i32 | ||
} else { | ||
|
||
}; | ||
//~^^^ ERROR if and else have incompatible types | ||
} |
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,92 @@ | ||
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 | ||
--> $DIR/if-else-type-mismatch.rs:8:38 | ||
| | ||
LL | let _ = if true { 42i32 } else { 42u32 }; | ||
| ----- ^^^^^ expected i32, found u32 | ||
| | | ||
| expected because of this | ||
| | ||
= note: expected type `i32` | ||
found type `u32` | ||
|
||
error[E0308]: if and else have incompatible types | ||
--> $DIR/if-else-type-mismatch.rs:13:9 | ||
| | ||
LL | let _ = if true { | ||
| _____________- | ||
LL | | 42i32; | ||
| | ------ expected because of this | ||
LL | | } else { | ||
LL | | 42u32 | ||
| | ^^^^^ expected (), found u32 | ||
LL | | }; | ||
| |_____- if and else have incompatible types | ||
| | ||
= note: expected type `()` | ||
found type `u32` | ||
|
||
error[E0308]: if and else have incompatible types | ||
--> $DIR/if-else-type-mismatch.rs:19:9 | ||
| | ||
LL | let _ = if true { | ||
| _____________- | ||
LL | | 42i32 | ||
| | ----- expected because of this | ||
LL | | } else { | ||
LL | | 42u32; | ||
| | ^^^^^^ expected i32, found () | ||
LL | | }; | ||
| |_____- if and else have incompatible types | ||
| | ||
= note: expected type `i32` | ||
found type `()` | ||
|
||
error[E0308]: if and else have incompatible types | ||
--> $DIR/if-else-type-mismatch.rs:25:9 | ||
| | ||
LL | let _ = if true { | ||
| _____________________- | ||
LL | | | ||
LL | | } else { | ||
| |_____- expected because of this | ||
LL | 42u32 | ||
| ^^^^^ expected (), found u32 | ||
| | ||
= note: expected type `()` | ||
found type `u32` | ||
|
||
error[E0308]: if and else have incompatible types | ||
--> $DIR/if-else-type-mismatch.rs:30:12 | ||
| | ||
LL | let _ = if true { | ||
| ------- if and else have incompatible types | ||
LL | 42i32 | ||
| ----- expected because of this | ||
LL | } else { | ||
| ____________^ | ||
LL | | | ||
LL | | }; | ||
| |_____^ expected i32, found () | ||
| | ||
= note: expected type `i32` | ||
found type `()` | ||
|
||
error: aborting due to 6 previous errors | ||
|
||
For more information about this error, try `rustc --explain E0308`. |
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
8 changes: 5 additions & 3 deletions
8
src/test/ui/regions/region-invariant-static-error-reporting.stderr
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