Skip to content

&-ptr should be less used in compiler errors #25426

Closed
@barosl

Description

@barosl

When comparing mismatched types, today's rustc prints &-ptr when one of the types is a reference. For example,

 expected `&i32`,
    found `f64`
(expected &-ptr,
    found f64) [E0308]
expected `core::result::Result<_, &str>`,
    found `core::result::Result<i32, collections::string::String>`
(expected &-ptr,
    found struct `collections::string::String`) [E0308]

There might be reasons for this, but it's inconvenient in many cases. If the compiler is giving attention to the &-difference of the two types, it should print &-ptr only when the two compared types could be deduced from one type. (e.g. &i32 and i32) But in general, if those two types are fairly distinct, just printing the full type name would be much more handy.

Metadata

Metadata

Assignees

No one assigned

    Labels

    A-diagnosticsArea: Messages for errors, warnings, and lints

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions