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:
commit
c95bcbc9d5
5 changed files with 48 additions and 14 deletions
|
|
@ -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 `()`
|
||||
|
|
||||
|
|
|
|||
|
|
@ -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`
|
||||
|
|
||||
|
|
|
|||
|
|
@ -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 `()`
|
||||
|
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue