Incorrect Type Alias picked in Compilation Error Message
Open
Nobody has claimed this yet.
A-diagnostics
T-compiler
- Dominant language
- Rust
- Stars
- 119k
- Forks
- 16.1k
- PR merge metrics
- PR metrics pending
Description
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
Contributor guide
First steps
- Read the whole issue, then the project's contributing guide.
- Comment on the issue to say you are picking it up — it saves two people doing the same work.
- Fork the repository and make your change on a branch.
- Open a pull request that references the issue number.
Research direction
Reproduce the diagnostic using the example in services/src/abc.rs with rustc 1.83.0, focusing on how the compiler chooses names for aliased types in the mismatched-types message. Done means the same case reports String rather than the unrelated ExecId alias, with regression coverage for this behavior.
Written by the indexing model from the issue text.
Assessment
- Tech stack
- rust
- Domain
- compilers
- Issue type
- Bug
- Difficulty
- 4/5
- Estimated time
- 3-5 days
- Activity status
- Quiet
- Clarity
- Mostly clear
- Newbie friendliness
- 45/100