Skip to content

Incorrect Type Alias picked in Compilation Error Message #138055

Open
@mmohit-bc

Description

@mmohit-bc

Code

So, I have a 

`create(filename).expect(format!("This failed {}", &filename));`

and somewhere I had declared `pub use String as ExecId;` in some module somewhere.

As a result, the error I am getting is a misleading compilation error message:

I understand `ExecId` is also String alias but it is unrelated thing.

Current output

error[E0308]: mismatched types
   --> services/src/abc.rs:218:25
    |
218 |                   .expect(format!("This failed {}",
    |  _________________________^
219 | |                                             &filename));
    | |_____________________________________________________________________^ expected `&str`, found `ExecId`
    |

Desired output

error[E0308]: mismatched types
   --> services/src/abc.rs:218:25
    |
218 |                   .expect(format!("This failed {}",
    |  _________________________^
219 | |                                             &filename));
    | |_____________________________________________________________________^ expected `&str`, found `String`
    |

Rationale and extra context

No response

Other cases

Rust Version

rustc 1.83.0 (90b35a623 2024-11-26) (Homebrew)
binary: rustc
commit-hash: 90b35a6239c3d8bdabc530a6a0816f7ff89a0aaf
commit-date: 2024-11-26
host: aarch64-apple-darwin
release: 1.83.0
LLVM version: 19.1.6

Anything else?

No response

Activity

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Metadata

Metadata

Assignees

No one assigned

    Labels

    A-diagnosticsArea: Messages for errors, warnings, and lintsT-compilerRelevant to the compiler team, which will review and decide on the PR/issue.

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions