Repository: rust
Issue: Help message to use `U::try_from(t)` when use `U::from(t)` to expect `Result<U, E>`
Labels: A-diagnostics,T-compiler

Related to #103148

The issue is that there is no help message telling you that `Result<T, E>` is available in the trait `TryFrom` when you use `T::from` to receive `Result` (of course you have to make sure it is there first)

Given the following code: ([playground](https://play.rust-lang.org/?version=nightly&mode=debug&edition=2021&gist=1e82e2cfd989cd68f03106e5860124c9))

```rust
struct Foo;

impl TryFrom<Foo> for i32 {
    type Error = ();

    fn try_from(_: Foo) -> Result<Self, Self::Error> {
        Ok(2)
    }
}

fn main() {
    // let num: Result<i32, _> = Foo.into(); // use try_into will fix this
    let num: Result<i32, _> = i32::from(Foo); // use try_from will fix this

    println!("{num:?}");
}
```

The current output is:

```
error[[E0277]](https://doc.rust-lang.org/stable/error-index.html#E0277): the trait bound `i32: From<Foo>` is not satisfied
  --> src/main.rs:15:31
   |
15 |     let num: Result<i32, _> = i32::from(Foo);
   |                               ^^^^^^^^^ the trait `From<Foo>` is not implemented for `i32`
   |
   = help: the following other types implement trait `From<T>`:
             <f32 as From<i16>>
             <f32 as From<i8>>
             <f32 as From<u16>>
             <f32 as From<u8>>
             <f64 as From<f32>>
             <f64 as From<i16>>
             <f64 as From<i32>>
             <f64 as From<i8>>
           and 67 others

error[[E0308]](https://doc.rust-lang.org/stable/error-index.html#E0308): mismatched types
  --> src/main.rs:15:31
   |
15 |     let num: Result<i32, _> = i32::from(Foo);
   |              --------------   ^^^^^^^^^^^^^^ expected enum `Result`, found `i32`
   |              |
   |              expected due to this
   |
   = note: expected enum `Result<i32, _>`
              found type `i32`
help: try wrapping the expression in a variant of `Result`
   |
15 |     let num: Result<i32, _> = Ok(i32::from(Foo));
   |                               +++              +
15 |     let num: Result<i32, _> = Err(i32::from(Foo));
   |                               ++++              +
```

<!-- The following is not always necessary. -->
Ideally the output should look like:

```
error[[E0277]](https://doc.rust-lang.org/stable/error-index.html#E0277): the trait bound `i32: From<Foo>` is not satisfied
  --> src/main.rs:15:31
   |
15 |     let num: Result<i32, _> = i32::from(Foo);
   |                               ^^^^^^^^^ the trait `From<Foo>` is not implemented for `i32`
   |
   = help: the following other types implement trait `From<T>`:
             <f32 as From<i16>>
             <f32 as From<i8>>
             <f32 as From<u16>>
             <f32 as From<u8>>
             <f64 as From<f32>>
             <f64 as From<i16>>
             <f64 as From<i32>>
             <f64 as From<i8>>
           and 67 others
help: `TryFrom<Foo>` is implemented for `i32`
   |
15 | let num: Result<i32, _> = i32::try_from(Foo));
   |                                ~~~~~~~~


error[[E0308]](https://doc.rust-lang.org/stable/error-index.html#E0308): mismatched types
  --> src/main.rs:15:31
   |
15 |     let num: Result<i32, _> = i32::from(Foo);
   |              --------------   ^^^^^^^^^^^^^^ expected enum `Result`, found `i32`
   |              |
   |              expected due to this
   |
   = note: expected enum `Result<i32, _>`
              found type `i32`
help: try wrapping the expression in a variant of `Result`
   |
15 |     let num: Result<i32, _> = Ok(i32::from(Foo));
   |                               +++              +
15 |     let num: Result<i32, _> = Err(i32::from(Foo));
   |                               ++++              +
```

<!--
If the problem is not self-explanatory, please provide a rationale for the
change.
-->

<!--
If dramatically different output is caused by small changes, consider also
adding them here.

If you're using the stable version of the compiler, you should also check if the
bug also exists in the beta or nightly versions. The output might also be
different depending on the Edition.
-->


<!-- TRIAGEBOT_START -->

<!-- TRIAGEBOT_ASSIGN_START -->

<!-- TRIAGEBOT_ASSIGN_DATA_START$${"user":"Absobel"}$$TRIAGEBOT_ASSIGN_DATA_END -->

<!-- TRIAGEBOT_ASSIGN_END -->
<!-- TRIAGEBOT_END -->