-
Notifications
You must be signed in to change notification settings - Fork 1.6k
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Unresolved import for platform specific modules #6038
Comments
We seem to have trouble finding/expanding the |
Oh, it's because we don't load the sysroot correctly. We just add a bunch of hard-coded path dependencies to libstd without looking at its |
I'm also seeing this issue for
in the 2020-09-21 release. |
Same issue. |
@iulianR you can disable that warning in the preferences (the experimental diagnostics key). EDIT: |
I am running into this too, if I use the above disable though, won't that disable all unresolved import errors? That doesn't seem to be desirable. Is there any other options? I assume it happens because rust-analyzer is set to build for all targets, and the import isn't available on some targets |
No, it happens because
You can only disable the unresolved import diagnostic entirely (although check-on-save will still display rustc's unresolved import messages, regardless of how r-a diagnostics are configured) |
This is (unsurprisingly) also broken for |
It "used to work" in the sense that this diagnostic didn't show up, because the diagnostic wasn't implemented yet. You can make it not show up again with the setting mentioned above; you'll still get unresolved import errors from rustc. But at least we're now aware that rust-analyzer can't actually resolve these imports. |
The diagnostic is already marked as experimental fwiw, so unless you opt into the experimental ones this shouldn't show up. |
I guess I'll take your word for it that it never worked, but I was pretty sure I had autocomplete for some parts of core::arch in the past. Huh.
Hrm, I don't remember opting into experimental diagnostics anywhere. |
Oh, turns out the experimental ones are on by default |
Disabling that caused the error to go away for me. This works as a temporary workaround. Thanks. |
Is there documentation on disabling diagnostics in editors that aren't VSCode? I can't tell from this thread if Thanks for rust-analyzer, it's wonderful. |
It's a rust-analyzer option, but configuring it is client-dependant. If you're using coc.vim, you can use the same setting, otherwise it might be called diagnostics/enabled, without the program name. If you figure it out and have the time, we'll probably accept client-specific documentation pull requests. |
The proper fix I think is: * move rust-lang/rust library crates to a separate workspace * when packaging rust-src component, vendor sources of external deps
#6294 papers over this issue |
The proper fix I think is: * move rust-lang/rust library crates to a separate workspace * when packaging rust-src component, vendor sources of external deps
|
Oh. Well. Is there a separate bug for that? How tractable is it to fix in r-a? If it's very hard to fix in r-a I could do a patch to change stdarch itself to not use #[path] in the name of simplifying things for tooling probably, since usually the alternative there is just a slightly more complex |
…imulacrum Avoid `cfg_if` in `std::os` rust-analyzer cannot currently load the `cfg_if` crate, which means that rust-analyzer is unable to see `std::os::{unix, windows, linux}` here. This works around that by avoiding `cfg_if`; the `#[cfg]` expressions are simple enough to reasonably write by hand. Fixes rust-lang/rust-analyzer#6038
…imulacrum Avoid `cfg_if` in `std::os` rust-analyzer cannot currently load the `cfg_if` crate, which means that rust-analyzer is unable to see `std::os::{unix, windows, linux}` here. This works around that by avoiding `cfg_if`; the `#[cfg]` expressions are simple enough to reasonably write by hand. Fixes rust-lang/rust-analyzer#6038
…imulacrum Avoid `cfg_if` in `std::os` rust-analyzer cannot currently load the `cfg_if` crate, which means that rust-analyzer is unable to see `std::os::{unix, windows, linux}` here. This works around that by avoiding `cfg_if`; the `#[cfg]` expressions are simple enough to reasonably write by hand. Fixes rust-lang/rust-analyzer#6038
…imulacrum Avoid `cfg_if` in `std::os` rust-analyzer cannot currently load the `cfg_if` crate, which means that rust-analyzer is unable to see `std::os::{unix, windows, linux}` here. This works around that by avoiding `cfg_if`; the `#[cfg]` expressions are simple enough to reasonably write by hand. Fixes rust-lang/rust-analyzer#6038
@jonas-schievink this doesn't seem to work for me even after rust-lang/rust#81969: |
Oh, there's plenty more in |
Ugh, how annoying |
Has something happened? I was successfully using the "add cfg-if in your dependency tree" method, but since today it no longer works, I again get unresolved import errors in vscode for Version 0.2.513 of the vscode rust-analyzer extension, and |
I'm encountering this issue when doing |
Move all `sys::ext` modules to `os` This PR moves all `sys::ext` modules to `os`, centralizing the location of all `os` code and simplifying the dependencies between `os` and `sys`. Because this also removes all uses `cfg_if!` on publicly exported items, where after rust-lang#81969 there were still a few left, this should properly work around rust-lang/rust-analyzer#6038. `@rustbot` label: +T-libs-impl
Move all `sys::ext` modules to `os` This PR moves all `sys::ext` modules to `os`, centralizing the location of all `os` code and simplifying the dependencies between `os` and `sys`. Because this also removes all uses `cfg_if!` on publicly exported items, where after rust-lang#81969 there were still a few left, this should properly work around rust-lang/rust-analyzer#6038. `@rustbot` label: +T-libs-impl
rust-lang/rust#84200 just got merged, which also removed more |
Looks like this block still causes problems with However, |
Move all `sys::ext` modules to `os` This PR moves all `sys::ext` modules to `os`, centralizing the location of all `os` code and simplifying the dependencies between `os` and `sys`. Because this also removes all uses `cfg_if!` on publicly exported items, where after #81969 there were still a few left, this should properly work around rust-lang/rust-analyzer#6038. `@rustbot` label: +T-libs-impl
I'm no longer seeing any errors! (latest toolchain Rust 1.53, nightly rust-analyzer) 🥳🥳🥳 |
Works for me only with git rust-analyzer (pretty much current nightly) and nightly rust 1.55 (nightly-x86_64-unknown-linux-gnu, 1.53 stable didn't work) |
Cool, looks like we can close this then. The more general problem on the r-a side is tracked in #7637. |
I'm still having this issue on my FreeBSD box with |
I tried to search if it was reported but didn't found anything.
When importing the platform specific modules in
std::os
rust-analyzer gives me the following error:unresolved import
. Also those modules don't show up for auto-complete.When the module is used outside
use
statement, there is no error, but the semantic token are of the typeunresolvedReference
.RA version
Latest master branch
Example
The text was updated successfully, but these errors were encountered: