Wrong import hint
Open
Nobody has claimed this yet.
A-diagnostics
A-suggestion-diagnostics
C-bug
T-compiler
- Dominant language
- Rust
- Stars
- 119k
- Forks
- 16.1k
- PR merge metrics
- PR metrics pending
Description
I tried this code:
https://github.com/rust-lang/rust-analyzer/issues/17293
I expected to see this happen:
...
help: trait `Interface` which provides `cast` is implemented but not in scope; perhaps you want to import it
|
+ use windows::core::Interface;
|
...
Instead, this happened:
error[E0599]: no method named `cast` found for struct `IDXGISwapChain1` in the current scope
--> src\main.rs:107:36
|
107 | let y: IDXGISwapChain3 = x.cast()?;
| ^^^^ method not found in `IDXGISwapChain1`
|
::: C:\Users\nxcy\.cargo\registry\src\index.crates.io-6f17d22bba15001f\windows-core-0.56.0\src\interface.rs:80:8
|
80 | fn cast<T: Interface>(&self) -> Result<T> {
| ---- the method is available for `IDXGISwapChain1` here
|
= help: items from traits can only be used if the trait is in scope
help: trait `Interface` which provides `cast` is implemented but not in scope; perhaps you want to import it
|
3 + use windows::windows_core::interface::Interface;
|
Meta
rustc --version --verbose:
rustc 1.78.0 (9b00956e5 2024-04-29)
binary: rustc
commit-hash: 9b00956e56009bab2aa15d7bff10916599e3d6d6
commit-date: 2024-04-29
host: x86_64-pc-windows-msvc
release: 1.78.0
LLVM version: 18.1.2
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
Start with the linked reproduction and the diagnostic at src\main.rs:107:36, then inspect how rustc generates the E0599 trait-import suggestion shown in the report. Compare the suggested windows::core::interface::Interface path with the expected import; done means the hint points to the correct import for this case and the regression is covered by a test.
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
- Stale
- Clarity
- Mostly clear
- Newbie friendliness
- 25/100