Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Only suggest removal of as_* and to_ conversion methods on E0308 #120473

Merged
merged 1 commit into from
Feb 5, 2024

Commits on Jan 29, 2024

  1. Only suggest removal of as_* and to_ conversion methods on E0308

    Instead of
    
    ```
    error[E0308]: mismatched types
     --> tests/ui/suggestions/only-suggest-removal-of-conversion-method-calls.rs:9:5
      |
    4 | fn get_name() -> String {
      |                  ------ expected `String` because of return type
    ...
    9 |     your_name.trim() //~ ERROR E0308
      |     ^^^^^^^^^^^^^^^^ expected `String`, found `&str`
      |
    help: try removing the method call
      |
    9 -     your_name.trim()
    9 +     your_name
    ```
    
    output
    
    ```
    error[E0308]: mismatched types
      --> $DIR/only-suggest-removal-of-conversion-method-calls.rs:9:5
       |
    LL | fn get_name() -> String {
       |                  ------ expected `String` because of return type
    ...
    LL |     your_name.trim()
       |     ^^^^^^^^^^^^^^^^- help: try using a conversion method: `.to_string()`
       |     |
       |     expected `String`, found `&str`
    ```
    
    Fix rust-lang#114329.
    estebank committed Jan 29, 2024
    Configuration menu
    Copy the full SHA
    44d8ecb View commit details
    Browse the repository at this point in the history