Repository: rust
Issue: Invalid method call removal suggested when collecting `&str`s into `String`s
Labels: A-diagnostics,T-compiler

### Code

```Rust
fn main() {
    String::new().lines().collect::<Vec<String>>();
}
```

### Current output

```Shell
error[E0277]: a value of type `Vec<String>` cannot be built from an iterator over elements of type `&str`
    --> src/main.rs:2:37
     |
2    |     String::new().lines().collect::<Vec<String>>();
     |                           -------   ^^^^^^^^^^^ value of type `Vec<String>` cannot be built from `std::iter::Iterator<Item=&str>`
     |                           |
     |                           required by a bound introduced by this call
     |
     = help: the trait `FromIterator<&str>` is not implemented for `Vec<String>`
             but trait `FromIterator<String>` is implemented for it
     = help: for that trait implementation, expected `String`, found `&str`
note: the method call chain might not have had the expected associated types
    --> src/main.rs:2:19
     |
2    |     String::new().lines().collect::<Vec<String>>();
     |     ------------- ^^^^^^^ `Iterator::Item` is `&str` here
     |     |
     |     this expression has type `String`
note: required by a bound in `collect`
    --> /playground/.rustup/toolchains/nightly-x86_64-unknown-linux-gnu/lib/rustlib/src/rust/library/core/src/iter/traits/iterator.rs:1967:19
     |
1967 |     fn collect<B: FromIterator<Self::Item>>(self) -> B
     |                   ^^^^^^^^^^^^^^^^^^^^^^^^ required by this bound in `Iterator::collect`
help: consider removing this method call, as the receiver has type `String` and `String: FromIterator<&str>` trivially holds
     |
2    -     String::new().lines().collect::<Vec<String>>();
2    +     String::new().collect::<Vec<String>>();
     |
```

### Desired output

```Shell
error[E0277]: a value of type `Vec<String>` cannot be built from an iterator over elements of type `&str`
    --> src/main.rs:2:37
     |
2    |     String::new().lines().collect::<Vec<String>>();
     |                           -------   ^^^^^^^^^^^ value of type `Vec<String>` cannot be built from `std::iter::Iterator<Item=&str>`
     |                           |
     |                           required by a bound introduced by this call
     |
     = help: the trait `FromIterator<&str>` is not implemented for `Vec<String>`
             but trait `FromIterator<String>` is implemented for it
     = help: for that trait implementation, expected `String`, found `&str`
note: the method call chain might not have had the expected associated types
    --> src/main.rs:2:19
     |
2    |     String::new().lines().collect::<Vec<String>>();
     |     ------------- ^^^^^^^ `Iterator::Item` is `&str` here
     |     |
     |     this expression has type `String`
note: required by a bound in `collect`
    --> /playground/.rustup/toolchains/nightly-x86_64-unknown-linux-gnu/lib/rustlib/src/rust/library/core/src/iter/traits/iterator.rs:1967:19
     |
1967 |     fn collect<B: FromIterator<Self::Item>>(self) -> B
     |                   ^^^^^^^^^^^^^^^^^^^^^^^^ required by this bound in `Iterator::collect`
help: consider changing this type to `&str`
     |
2    -     String::new().lines().collect::<Vec<String>>();
2    +     String::new().lines().collect::<Vec<&str>>();
     |
help: consider converting `&str` to `String` with `ToString::to_string`
``
```

### Rationale and extra context

Current suggestion produces invalid code and changes the semantics of the program.

### Other cases

```Rust

```

### Rust Version

```Shell
1.84.0-nightly (2024-11-21 b19329a37cedf2027517)
```

### Anything else?

_No response_