Skip to content
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

Use Cargo.toml instead of rust-project.json #1935

Closed
mo8it opened this issue Mar 30, 2024 · 6 comments · Fixed by #1931
Closed

Use Cargo.toml instead of rust-project.json #1935

mo8it opened this issue Mar 30, 2024 · 6 comments · Fixed by #1931
Assignees
Milestone

Comments

@mo8it
Copy link
Contributor

mo8it commented Mar 30, 2024

We can generate a Cargo.toml file containing a [[bin]] entry for every exercise.

This should make things much smoother and less hacky, especially because we have many issues related to the language server.

This should also enable us to use Cargo instead of rustc to run the exercises. That would especially make Clippy exercises less of a trouble. This approach also allows us to easily add dependencies to the exercises in case we want to do so in the future.

@mo8it
Copy link
Contributor Author

mo8it commented Apr 4, 2024

Done in the v6 branch :D

@mo8it mo8it closed this as completed Apr 4, 2024
@antoineco
Copy link

@mo8it I just tried the v6 branch and love the improvements from this PR, so first of all thank you for the impressive work!

I have a question regarding this statement:

we have many issues related to the language server

If anything, the current state of v6 seem to actually degrade the language server experience. Inside a fresh Git clone of the branch on Linux, rust-analyzer (latest stable) no longer emits diagnostics while editing an exercise.
Are there still any upcoming changes related to language server for v6, or am I doing something wrong?

@mo8it
Copy link
Contributor Author

mo8it commented Apr 20, 2024

Thanks for your feedback 🥰

Yes, you are right, if you just clone the repository and try to edit the exercises, the language server will not work. This is one downside of the current approach. But this only affects developing exercises.

The new method of doing Rustlings is to install Rustlings using cargo install rustlings (not published yet), then running rustlings init. No repo cloning happens. Instead, the directory rustlings/ will be created where you find the exercises. The language server works there out of the box :)

I need to add a warning when people try to work on the exercises from the repository. Thanks pointing this out.

@antoineco
Copy link

antoineco commented Apr 20, 2024

Indeed Cargo.toml looks a lot more like what I'd expect now, appreciate the tip about rustlings init 👍

I spotted one issue though; out of the box, the language server is still showing the following diagnostic for every exercise file:

file not included in crate hierarchy [unlinked-file]

This is solved by editing the exercises' paths inside Cargo.toml:

 bin = [
- { name = "intro1", path = "../exercises/00_intro/intro1.rs" },
+ { name = "intro2", path = "exercises/00_intro/intro2.rs" },
- { name = "intro1", path = "../exercises/00_intro/intro1.rs" },
+ { name = "intro2", path = "exercises/00_intro/intro2.rs" },
 ...

I can open a new issue if you prefer. In this case, feel free to hide my comment as "off topic".

@mo8it
Copy link
Contributor Author

mo8it commented Apr 20, 2024

Good catch! Thank you very much :D

It was without the prefix ../, but I messed it up at some point 😅
BTW, the v6 branch is not even in the beta phase yet. I really appreciate your excitement to try it out and your reporting of issues, but just to let you know that a beta version will be released in the next days :D

@mo8it
Copy link
Contributor Author

mo8it commented May 1, 2024

@antoineco In case you want to test the beta release of v6, here is the issue for feedback with instruction of how to install it: #1960

MadLittleMods added a commit to MadLittleMods/rustlings that referenced this issue Oct 14, 2024
…e repo directly

> Yes, you are right, if you just clone the repository and try to edit the exercises, the language server will not work. This is one downside of the current approach. But this only affects developing exercises.
>
> The new method of doing Rustlings is to install Rustlings using `cargo install rustlings` (not published yet), then running `rustlings init`. No repo cloning happens. Instead, the directory `rustlings/` will be created where you find the exercises. The language server works there out of the box :)
>
> I need to add a warning when people try to work on the exercises from the repository. Thanks pointing this out.
>
> -- @mo8it, rust-lang#1935 (comment)

Other references:

 - Previous `rustlings lsp` command: rust-lang#1026
 - The changelog says "LSP support out of the box", https://github.com/rust-lang/rustlings/blob/main/CHANGELOG.md#lsp-support-out-of-the-box
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging a pull request may close this issue.

2 participants