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

rust-analyzer does not work with sing-file program #19073

Closed
NewUserHa opened this issue Jan 29, 2025 · 9 comments
Closed

rust-analyzer does not work with sing-file program #19073

NewUserHa opened this issue Jan 29, 2025 · 9 comments
Labels
C-bug Category: bug

Comments

@NewUserHa
Copy link

rust-analyzer version: rust-analyzer version: 0.3.2284-standalone (1f86729 2025-01-28) [c:\Users\user.vscode\extensions\rust-lang.rust-analyzer-0.3.2284-win32-x64\server\rust-analyzer.exe]

rustc version: rustc 1.84.0 (9fc6b4312 2025-01-07)

editor or extension: vscode 1.95.3

relevant settings: not set

repository link (if public, optional):

code snippet to reproduce:

fn main(){
    prin
}

vscode rust analyzer output

2025-01-30T19:26:59.6380447+08:00 ERROR FetchWorkspaceError: rust-analyzer failed to fetch workspace
2025-01-30T19:27:20.3397039+08:00 ERROR FetchWorkspaceError: rust-analyzer failed to fetch workspace
2025-01-30T19:27:37.8238752+08:00 ERROR FetchWorkspaceError: rust-analyzer failed to fetch workspace
@NewUserHa NewUserHa added the C-bug Category: bug label Jan 29, 2025
@ChayimFriedman2
Copy link
Contributor

Do you have a Cargo project?

@NewUserHa
Copy link
Author

it works with a cargo.toml, but it does not work without that. it should work according to #12310 (comment)

@ChayimFriedman2
Copy link
Contributor

No it should not. Very basic features work, autocomplete atc. do not.

@ChayimFriedman2 ChayimFriedman2 closed this as not planned Won't fix, can't repro, duplicate, stale Jan 30, 2025
@NewUserHa
Copy link
Author

No. Nothing of the features works.

the rust-analyzer should work like all other language servers that work for single file program, to be friendly to write small programs, like small tests

@ChayimFriedman2
Copy link
Contributor

Parsing etc. should work (I don't know the set of features that work exactly, but anything requiring semantic information is not there).

rust-analyzer depends on Cargo, and it's probably not going to change. Cargo script will make this better though.

@NewUserHa
Copy link
Author

this depends on cargo.toml is very inconvenient for small programs with rust.

maybe could add a feature to quickly switch to a dummy cargo.toml for situation like quick experiments, startups, and small single file programs, in the pannel from the bottom at vscode toolbars

@ChayimFriedman2
Copy link
Contributor

Cargo script will handle that, once stabilized.

@NewUserHa
Copy link
Author

Thanks

but the rust-analyzer is stucked at loading and no error is printed with lines below

#!cargo

//! ```cargo
//! ```

fn main(){
    prin
}
[Error - 17:00:31 AM] Server process exited with code 0.

@Veykril
Copy link
Member

Veykril commented Jan 31, 2025

To support cargo scripts you currently need to point rust-analyzer to the rust file via the linkedProjects config. Lazy loading is yet to be properly implemented and that will take some time after other refactors are done

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
C-bug Category: bug
Projects
None yet
Development

No branches or pull requests

3 participants