forked from rust-lang/rust
-
Notifications
You must be signed in to change notification settings - Fork 1
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Rollup merge of rust-lang#57723 - estebank:fix, r=davidtwco
Point at cause for expectation in return type type error Various improvements and fixes for type errors in return expressions. Fix rust-lang#57664.
- Loading branch information
Showing
13 changed files
with
201 additions
and
19 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
2 changes: 2 additions & 0 deletions
2
src/test/ui/fully-qualified-type/fully-qualified-type-name2.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
2 changes: 2 additions & 0 deletions
2
src/test/ui/fully-qualified-type/fully-qualified-type-name4.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
17 changes: 17 additions & 0 deletions
17
src/test/ui/point-to-type-err-cause-on-impl-trait-return-2.rs
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,17 @@ | ||
fn unrelated() -> Result<(), std::string::ParseError> { // #57664 | ||
let x = 0; | ||
|
||
match x { | ||
1 => { | ||
let property_value_as_string = "a".parse()?; | ||
} | ||
2 => { | ||
let value: &bool = unsafe { &42 }; | ||
//~^ ERROR mismatched types | ||
} | ||
}; | ||
|
||
Ok(()) | ||
} | ||
|
||
fn main() {} |
12 changes: 12 additions & 0 deletions
12
src/test/ui/point-to-type-err-cause-on-impl-trait-return-2.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
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,12 @@ | ||
error[E0308]: mismatched types | ||
--> $DIR/point-to-type-err-cause-on-impl-trait-return-2.rs:9:41 | ||
| | ||
LL | let value: &bool = unsafe { &42 }; | ||
| ^^^ expected bool, found integer | ||
| | ||
= note: expected type `&bool` | ||
found type `&{integer}` | ||
|
||
error: aborting due to previous error | ||
|
||
For more information about this error, try `rustc --explain E0308`. |
36 changes: 36 additions & 0 deletions
36
src/test/ui/point-to-type-err-cause-on-impl-trait-return.rs
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,36 @@ | ||
fn foo() -> impl std::fmt::Display { | ||
if false { | ||
return 0i32; | ||
} | ||
1u32 | ||
//~^ ERROR mismatched types | ||
} | ||
|
||
fn bar() -> impl std::fmt::Display { | ||
if false { | ||
return 0i32; | ||
} else { | ||
return 1u32; | ||
//~^ ERROR mismatched types | ||
} | ||
} | ||
|
||
fn baz() -> impl std::fmt::Display { | ||
if false { | ||
//~^ ERROR mismatched types | ||
return 0i32; | ||
} else { | ||
1u32 | ||
} | ||
} | ||
|
||
fn qux() -> impl std::fmt::Display { | ||
if false { | ||
0i32 | ||
} else { | ||
1u32 | ||
//~^ ERROR if and else have incompatible types | ||
} | ||
} | ||
|
||
fn main() {} |
58 changes: 58 additions & 0 deletions
58
src/test/ui/point-to-type-err-cause-on-impl-trait-return.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
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,58 @@ | ||
error[E0308]: mismatched types | ||
--> $DIR/point-to-type-err-cause-on-impl-trait-return.rs:5:5 | ||
| | ||
LL | return 0i32; | ||
| ---- expected because of this statement | ||
LL | } | ||
LL | 1u32 | ||
| ^^^^ expected i32, found u32 | ||
| | ||
= note: expected type `i32` | ||
found type `u32` | ||
|
||
error[E0308]: mismatched types | ||
--> $DIR/point-to-type-err-cause-on-impl-trait-return.rs:13:16 | ||
| | ||
LL | return 0i32; | ||
| ---- expected because of this statement | ||
LL | } else { | ||
LL | return 1u32; | ||
| ^^^^ expected i32, found u32 | ||
| | ||
= note: expected type `i32` | ||
found type `u32` | ||
|
||
error[E0308]: mismatched types | ||
--> $DIR/point-to-type-err-cause-on-impl-trait-return.rs:19:5 | ||
| | ||
LL | / if false { | ||
LL | | //~^ ERROR mismatched types | ||
LL | | return 0i32; | ||
| | ---- expected because of this statement | ||
LL | | } else { | ||
LL | | 1u32 | ||
LL | | } | ||
| |_____^ expected i32, found u32 | ||
| | ||
= note: expected type `i32` | ||
found type `u32` | ||
|
||
error[E0308]: if and else have incompatible types | ||
--> $DIR/point-to-type-err-cause-on-impl-trait-return.rs:31:9 | ||
| | ||
LL | / if false { | ||
LL | | 0i32 | ||
| | ---- expected because of this | ||
LL | | } else { | ||
LL | | 1u32 | ||
| | ^^^^ expected i32, found u32 | ||
LL | | //~^ ERROR if and else have incompatible types | ||
LL | | } | ||
| |_____- if and else have incompatible types | ||
| | ||
= note: expected type `i32` | ||
found type `u32` | ||
|
||
error: aborting due to 4 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
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