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

recognize and support rust-script #9609

Closed
gwpl opened this issue Jul 15, 2021 · 12 comments
Closed

recognize and support rust-script #9609

gwpl opened this issue Jul 15, 2021 · 12 comments
Labels
C-support Category: support questions

Comments

@gwpl
Copy link

gwpl commented Jul 15, 2021

Could you consider recognizing and supporting rust script files?
https://rust-script.org/

@bjorn3
Copy link
Member

bjorn3 commented Jul 15, 2021

Rust script is for one off scripts. It allows you to write an entire program in a single file while still supporting arbitrary cargo dependencies. It is not a "language" that you can embed in an existing program like a game. It also doesn't make compilation any faster. You just write a regular cargo based project except that Cargo.toml is part ofmain.rs and you likely can't write the source in more than a single file.

@lnicola
Copy link
Member

lnicola commented Jul 16, 2021

We could actually implement this and it would be useful for one-off scripts, since we already have two project model implementations.

On the other hand, we run cargo metadata for dependency resolution (among other things), so we would have to replicate most of the rust-script logic: extracting the Cargo.toml snippet and source code into a temporary project, then running cargo metadata here.

And then we'd also have to support other rust-script features like templates, and I'm pretty sure we shouldn't do that.

@bjorn3
Copy link
Member

bjorn3 commented Jul 16, 2021

🤦 (:facepalm:) I thought this was on the Bevy repo, not the rust-analyzer repo. Please disregard my previous comment.

@gwpl
Copy link
Author

gwpl commented Jul 17, 2021

Maybe there is possibility for two projects to collaborate to make it work?
fornwall/rust-script#26
e.g. rust-script to repackage/refactor some logic into libraries, that would match rust-analyzer for easy integration?

@lnicola
Copy link
Member

lnicola commented Jul 17, 2021

I think there will always be the possibility of another took like that to show up, using a different syntax for dependencies.

@fornwall
Copy link

I'm happy to help out with discussing and implementing changes to rust-script that could help out with implementing support in rust-analyzer, whether that be adding library functionality, CLI options, or changing/removing functionality to present a leaner and more minimal script runner functionality in general.

And then we'd also have to support other rust-script features like templates, and I'm pretty sure we shouldn't do that.

Agreed! Note that templates currently only works for snippets passed directly to rust-script (as in rust-script -t grabbag -e "mem::size_of::<Box<Read>>()"), and not for script files. And that's probably good to avoid making script files non-portable. Specifying a path to a local crate may provide enough functionality for those who need it without tying it to some rust-script specific template. See fornwall/rust-script#12.

@epage
Copy link

epage commented Jul 20, 2023

I'm assuming #15318 takes precedence over this?

Granted, right now the two systems are fairly related (though we haven't finalized how to embed manifests yet). The main new thing is that cargo +nightly -Zscript metadata --manifest-path foo.rs now works.

@gwpl
Copy link
Author

gwpl commented Jul 26, 2023

To me two are definitely related!
Thank you!

1 similar comment
@gwpl
Copy link
Author

gwpl commented Jul 26, 2023

To me two are definitely related!
Thank you!

@gwpl
Copy link
Author

gwpl commented Jul 26, 2023

Just maybe for the context on importance - in light of adoption of LLMs (like OpenAI GPT-4 , LLaMA 2 , Starcoder...), tools that help them to work with Rust , I believe will help in Rust adoption in organizations (due to improving software economics).

Therefore my hypothesis is that it's way easier for models to operate on standalone files, where everything is in one file, self contained, and people to use it that way (e.g. copy&paste to/from chat interface).

Cross-linking:
Given that here is a thread on a topic about Rust script on openai forum:
https://community.openai.com/t/how-to-generate-modify-rust-scripts-sourcecode-with-openai-api/267190
in case you find topic related/engaging.

@MiSawa
Copy link

MiSawa commented Sep 2, 2023

FYI, I've created a language server for rust-script a while ago. It mostly just forwards request to rust-analyzer, except it invokes rust-script --package (path of script) to obtain the generated project directory and sets up linkedProject for the project. This definitely isn't a perfect solution, but works at least better than nothing until this/#15318 is done.

@Veykril
Copy link
Member

Veykril commented Apr 7, 2024

Closing in favor of #15318

@Veykril Veykril closed this as completed Apr 7, 2024
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
C-support Category: support questions
Projects
None yet
Development

No branches or pull requests

7 participants