You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
When encountering code like the following, where a match arm pattern is not the expected type, point at the match expression to provide more context
fn main() {
let a: usize = 3;
let b: usize = 3;
let temp: usize = match a + b {
Ok(num) => num,
Err(_) => 0,
};
}
error[E0308]: mismatched types
--> src/main.rs:5:9
|
4 | let temp: usize = match a + b {
| ----- this `match` expression is of type `usize`
5 | Ok(num) => num,
| ^^^^^^^ expected usize, found enum `std::result::Result`
|
= note: expected type `usize`
found type `std::result::Result<_, _>`
error[E0308]: mismatched types
--> src/main.rs:6:9
|
4 | let temp: usize = match a + b {
| ----- this `match` expression is of type `usize`
5 | Ok(num) => num,
6 | Err(_) => 0,
| ^^^^^^ expected usize, found enum `std::result::Result`
|
= note: expected type `usize`
found type `std::result::Result<_, _>`
The text was updated successfully, but these errors were encountered:
estebank
changed the title
Point at match expression on type error in match arm pattern
Point at match discrimant on type error in match arm pattern
Jan 6, 2019
estebank
changed the title
Point at match discrimant on type error in match arm pattern
Point at match discriminant on type error in match arm pattern
Jan 6, 2019
Centril
added a commit
to Centril/rust
that referenced
this issue
Jan 13, 2019
Point at match discriminant on type error in match arm pattern
```
error[E0308]: mismatched types
--> src/main.rs:5:9
|
4 | let temp: usize = match a + b {
| ----- this expression has type `usize`
5 | Ok(num) => num,
| ^^^^^^^ expected usize, found enum `std::result::Result`
|
= note: expected type `usize`
found type `std::result::Result<_, _>`
```
Fixrust-lang#57279.
From https://www.reddit.com/r/rust/comments/abjzi7/expected_usize_found_enum_stdresultresult/
When encountering code like the following, where a match arm pattern is not the expected type, point at the match expression to provide more context
The text was updated successfully, but these errors were encountered: