-
Notifications
You must be signed in to change notification settings - Fork 168
Lib crate isn't recognized #686
Comments
It would be nice to know how I can work around this issue because VS Code will stop displaying errors for new code as long as there are still old ones. This means I have to manually build the project to see if it compiles. VS Code thinks there are still unfixed errors and doesn't even attempt to compile it again (that's what I'm assuming). |
Same issue here. Running |
Until this issue is fixed in
|
An alternative solution is to reload as per #715 Newer versions may not suffer from this, although I've not tested it |
Reloading VSCode worked for me |
i get these private field errors even after making the respective changesa as mentioned above: error[E0616]: field error: aborting due to 2 previous errors For more information about this error, try |
Remember to modify the file lib.rs, designating the variables and functions used in main.rs to pub after spliting that part of code into a seperate file lib.rs. |
It is still happening. |
Still a bug, and also discovered whilst working through the book :( Bizzarely, re-loading VS code also fixed the issue for me. |
Seems like most of the people who came here for this bug is doing the RUST BOOK studies 😄 (including me) |
I am getting this as well. Reloading helps. |
Reloading helps for me but i noticed vscode cant "see" the types. I know the intellisense is not that important, but its a really convinient way to look for my modules. For example the vscode does not know the query is a string. Not showing any error but it feels wrong a little. :) |
this is still an issue. however, it's not necessary to reload the full vscode window. press ctrl+shift+p and type "rust", select "Rust: Restart the Rust server". i feel like this is definitely an issue with the language server not recognizing newly created files whatsoever. this happens all the time whenever you create a new rs file. |
It is still happening. |
@DerGernTod I agree, I just hit this and reloading the server seems to pick up new files. |
It is still happening. |
Seems to be a bug with some sort of caching on rust server. It can't detect the creation of a new lib inside de package, thus not finding the new lib as a valid import. That's the reason why restarting code's window or restarting rust server works, it goes through the files and dependencies to get all valid imports. Now, this is just a guess, I'm doing the tutorial same as everyone here, but it's something around what I would implement in order to improve performance. So it's a bug, but can easily be worked around and most likely improves performance by a lot. |
You could give |
Cargo.toml add [workspace] [package] [workspace] [dependencies] |
Still happening, and reloading fix it |
邮件已经收到,我会尽快回复。
|
I'm currently working through the book and found what seems to be a bug in the VS Code extension. I'm in part 3 of building this cli-application and have just moved some logic from
main.rs
tolib.rs
. Just like it says in the book, I useduse minigrep::Config
andminigrep::run
to refer to the stuff defined inlib.rs
. It works perfectly fine if I build/run it with cargo but VS Code shows the following errors:For
use minigrep::Config;
For
minigrep::run(config)
:Here's the code in
main.rs
:Probably unnecessary but here's
lib.rs
:Again, building and running it with cargo works perfectly fine and the package name defined in
Cargo.toml
isminigrep
, just like it's supposed to be. In case it's not obvious, it was all done step-by-step following the book.The text was updated successfully, but these errors were encountered: