-
Notifications
You must be signed in to change notification settings - Fork 1.7k
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: thiserror::Error
#6053
Comments
You can enable proc-macro support using {
"rust-analyzer.cargo.loadOutDirsFromCheck": true,
"rust-analyzer.procMacro.enable": true,
} |
I had the same issue with derive macro imports after the latest update with an existing project, but cleaning the target, rebuilding the project and reloading the editor solved it. I still don't get any information on hover (it's stuck at "Loading..."), but I don't know if that was already the case in the previous version. |
I thought, I had this enabled but apparently it was only in workspace settings of another workspace 🤦 . Fixed for me at least |
This worked for me! Is there any reason this isn't enabled by default? It seems like this is a fairly common use case/language feature. |
PS: cargo check is enabled by default, so maybe the security aspect is moot. |
That already happens with |
Enabling those options worked for me but they made RA super slow to the point where I can't use it, and have to put up with the errors for now. |
You can use |
I seem to be getting the unresolved import error for |
Do you also have |
Yes. Sorry, I should have posted my config: {
"rust-analyzer.updates.channel": "nightly",
"rust-analyzer.procMacro.enable": true,
"rust-analyzer.cargo.loadOutDirsFromCheck": true,
"rust-analyzer.inlayHints.parameterHints": false,
} This just started happening today when I updated to the latest nightly. (My previous comment has the version) |
Same here. Additionally, it seems that cargo will stop checking at all if |
I worked around this issue thus: |
They're all working now 🎉 (the |
Now we only need a stable release. |
The fix for this has been included in the last two stable releases, as far as I can see. |
This is still happening to me with things like: use derivative::Derivative;
use strum_macros::EnumIter; Is that a separate issue or should this be reopened? |
@teohhanhui did you enable build script and proc macro support as in #6053 (comment)? |
|
I'm also getting this error in neovim with the built in lsp client but it's happening on a trait from the std lib rather than an external library. The autocompeltion also seems to not be working for the My nvim_lsp config:
|
That is a duplicate of #6038. |
Ah thanks, I'll follow that issue as well |
Indeed derivative is the same issue. Thanks #[cfg_attr(not(test), proc_macro_derive(Derivative, attributes(derivative)))]
pub fn derivative(input: TokenStream) -> TokenStream { |
This is still happening for the original issue on latest nightly. Enabling use thiserror::Error;
..
#[derive(Error, Debug)] // <-- on 'Error': proc macro returned error: Server closed
#[error("{0}")]
struct Foo(String); |
Which rustc version are you using? |
I'll try updating to latest. EDIT:
|
I think there was an abi breaking change on rustc nightly. Either switch to stable or wait for this change to land on stable such that rust-analyzer can adapt to it. |
@aaomidi Confirm your bug in maybe related to #[cfg_attr(not(test), proc_macro_derive(Derivative, attributes(derivative)))]
pub fn derivative(input: TokenStream) -> TokenStream {
let mut errors = proc_macro2::TokenStream::new();
let mut output = match syn::parse::<syn::DeriveInput>(input) {
Ok(parsed) => {
ast::Input::from_ast(&parsed, &mut errors)
.map(|mut input| derive_impls(&mut input, &mut errors))
.unwrap_or_default()
},
Err(error) => {
errors.extend(error.to_compile_error());
Default::default()
}
};
output.extend(errors);
output.into()
} |
Using LunarVim rust-ls.lua
|
I changed it accordingly. It should be okay now. |
Im getting this currently with ed25519_dalek |
@OfekShochat that's probably #7243 |
yes it is, looked at it |
I tried to add the suggested fixes above in this issue but I'm still getting the same issue. Is there something else that I am missing?
I'm also using rust-analyzer |
In the latest version of rust-analyzer (on nvim+coc, but a coworker is reporting the same thing on VSCode), I'm getting the following error from rust-analyzer.
[rust-analyzer] [E] unresolved import
This happens even though a regular build of the project finishes just fine.
thiserror::Error
is a derive macro without an accompanying trait (c.f.serde::Serialize
, which is a derive macro and also a trait, which does not cause an error).Could there be a regression with importing derive macro traits?
The text was updated successfully, but these errors were encountered: