Skip to content

Types reversed when using ref #46609

Closed
Closed
@antoyo

Description

@antoyo

Hello.
The mismatched types error message shows the types in the wrong positions (they are reversed) when using ref.
For instance, this code:

fn main() {
    let var = 10i32;
    let ref string: String = var;
}

This shows the following message:

12 |     let ref string: String = var;
   |                              ^^^ expected i32, found struct `std::string::String`
   |
   = note: expected type `i32`
              found type `std::string::String`

In my opinion, the right message should be:

12 |     let ref string: String = var;
   |                              ^^^ expected struct `std::string::String`, found i32
   |
   = note: expected type `std::string::String`
              found type `i32`

(which is the message we actually see without ref)

This happens on both stable and nightly.
Thanks to fix this issue.

Metadata

Metadata

Labels

No labels
No labels

Type

No type

Projects

No projects

Milestone

No milestone

Relationships

None yet

Development

No branches or pull requests

Issue actions