rust-lang / rust

Empowering everyone to build reliable and efficient software.
https://www.rust-lang.org
Other
95.18k stars 12.27k forks source link

Wrong import hint #125547

Open nxcy opened 1 month ago

nxcy commented 1 month ago

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

workingjubilee commented 1 month ago

Oh I see, it doesn't follow the reexport.