Rollup merge of #71409 - estebank:point-at-ret-question-mark-op, r=petrochenkov

Point at the return type on `.into()` failure caused by `?`

Fix #35946.
This commit is contained in:
Dylan DPC 2020-04-27 03:26:13 +02:00 committed by GitHub
commit c95bcbc9d5
No known key found for this signature in database
GPG key ID: 4AEE18F83AFDEB23
5 changed files with 48 additions and 14 deletions

View file

@ -1,6 +1,8 @@
error[E0277]: `?` couldn't convert the error to `()`
--> $DIR/issue-32709.rs:4:11
|
LL | fn a() -> Result<i32, ()> {
| --------------- expected `()` because of this
LL | Err(5)?;
| ^ the trait `std::convert::From<{integer}>` is not implemented for `()`
|

View file

@ -1,6 +1,9 @@
error[E0277]: `?` couldn't convert the error to `()`
--> $DIR/option-to-result.rs:5:6
|
LL | fn test_result() -> Result<(),()> {
| ------------- expected `()` because of this
LL | let a:Option<()> = Some(());
LL | a?;
| ^ the trait `std::convert::From<std::option::NoneError>` is not implemented for `()`
|
@ -14,6 +17,9 @@ LL | a.ok_or_else(|| /* error value */)?;
error[E0277]: `?` couldn't convert the error to `std::option::NoneError`
--> $DIR/option-to-result.rs:11:6
|
LL | fn test_option() -> Option<i32>{
| ----------- expected `std::option::NoneError` because of this
LL | let a:Result<i32, i32> = Ok(5);
LL | a?;
| ^ the trait `std::convert::From<i32>` is not implemented for `std::option::NoneError`
|

View file

@ -1,6 +1,9 @@
error[E0277]: `?` couldn't convert the error to `()`
--> $DIR/try-on-option.rs:7:6
|
LL | fn foo() -> Result<u32, ()> {
| --------------- expected `()` because of this
LL | let x: Option<u32> = None;
LL | x?;
| ^ the trait `std::convert::From<std::option::NoneError>` is not implemented for `()`
|