rust-lang / rust-analyzer

A Rust compiler front-end for IDEs
https://rust-analyzer.github.io/
Apache License 2.0
14.09k stars 1.57k forks source link

unresolved import for use std::os::unix::net::{UnixListener, UnixStream}; #9459

Closed gipsyh closed 2 years ago

gipsyh commented 3 years ago

when use std::os::unix::net::{UnixListener, UnixStream};

it report unresolved import

but cargo actually can compile

lnicola commented 3 years ago

CC #6038

This works with nightly, but that has other issues (proc macros not working).

trindadegm commented 3 years ago

I have this problem on windows now: use std::os::windows::io::RawSocket; was not working. However, after reading #6038, I figured adding cfg-if in the dev-dependencies (or regular dependencies but I don't really need that) would make it work again. Before that I though naively that rust-analyzer was not getting the right target or something and set "rust-analyzer.cargo.target": "x86_64-pc-windows-msvc". I went searching through the github issues after I realized the problem was something else.

I just removed those settings and the cfg-if and the error comes back. Adding just the cfg-if is enough to get it working again.

PatchMixolydic commented 3 years ago

Also happened on nightly Rust Analyzer with rustc 1.53. Fixed by updating to rustc 1.54. rust-analyzer.serverVersion:

rust-analyzer version: c5ddc35a4 2021-08-14 nightly

rustc -Vv:

rustc 1.53.0 (53cb7b09b 2021-06-17)
binary: rustc
commit-hash: 53cb7b09b00cbea8754ffb78e7e3cb521cb8af4b
commit-date: 2021-06-17
host: x86_64-unknown-linux-gnu
release: 1.53.0
LLVM version: 12.0.1
sbzi1020 commented 3 years ago

I have been used rustc 1.54 and have the same problem, but after I updated to rustc 1.55(the latest version) and it was fixed.

flodiebold commented 2 years ago

This has been fixed (for some time, I guess).