ONiel
January 31, 2021, 2:18am
1
I have switched from Vim to Atom now to program in Rust, just for a while. In Atom I have installed the ide-rust-plugin. But I keep getting this error:
rust-analyzer failed to load workspace: Failed to find sysroot for Cargo.toml file /Users/niel/Sites/kaddo/Cargo.toml. Is rust-src installed?: could not find libcore in sysroot path /Users/niel/.rustup/toolchains/stable-x86_64-apple-darwin/lib/rustlib/src/rust/src/
Rust (rust-analyzer) /Users/niel/Sites/kaddo/
I have rust-src installed by running the following commands:
rustup update
rustup component add rust-src
rustup component add rust-src --toolchain nightly
But the error keeps existing after restarting Atom.
/Users/niel/.rustup/toolchains/stable-x86_64-apple-darwin/lib/rustlib/src/rust/src/ contains a folder called llvm-project.
/Users/niel/.rustup/toolchains contains:
1.41.0-x86_64-apple-darwin stable-x86_64-apple-darwin
nightly-x86_64-apple-darwin
1.41.0... does contain some files with the name rustc in it. Maybe I have to switch to that version somehow?
ONiel
January 31, 2021, 2:24am
2
I was able to switch toolchains doing the following:
rustup default nightly-x86_64-apple-darwin
However, I cant switch versions because than my project and it's libraries won't compile.
Atom's ide-rust plugin sets the RUST_SRC_PATH environment variable to a now wrong value. There's a PR to fix this, but it seems it hasn't been merged yet. The directory the error is complaining about is IIRC the wrong one. But current versions of rust-analyzer ignore the RUST_SRC_PATH variable when it doesn't point to a valid sysroot. What version of rust-analyzer do you have installed? (Running rust-analyzer --version should tell you.) Does /Users/niel/.rustup/toolchains/stable-x86_64-apple-darwin/lib/rustlib/src/rust/library exist and contain something?
ONiel
January 31, 2021, 5:43pm
4
My version is rust-analyzer 0d03fe6 and the folder contains:
alloc rustc-std-workspace-alloc
backtrace rustc-std-workspace-core
core rustc-std-workspace-std
panic_abort std
panic_unwind stdarch
proc_macro term
profiler_builtins test
rtstartup unwind
bjorn3
January 31, 2021, 6:38pm
5
ONiel:
rust-analyzer 0d03fe6
That version is from 13 September 2020:
committed 05:28PM - 13 Sep 20 UTC
5971: Implement async blocks r=flodiebold a=oxalica
Fix #4018
@flodiebold al… ready gave a generic guide in the issue. Here's some concern about implementation detail:
- Chalk doesn't support generator type yet.
- Adding generator type as a brand new type (ctor) can be complex and need to *re-introduced* builtin impls. (Like how we implement closures before native closure support of chalk, which is already removed in #5401 )
- The output type of async block should be known after type inference of the whole body.
- We cannot directly get the type from source like return-positon-impl-trait. But we still need to provide trait bounds when chalk asking for `opaque_ty_data`.
- During the inference, the output type of async block can be temporary unknown and participate the later inference.
`let a = async { None }; let _: i32 = a.await.unwrap();`
So in this PR, the type of async blocks is inferred as an opaque type parameterized by the `Future::Output` type it should be, like what we do with closure type.
And it really works now.
Well, I still have some questions:
- The bounds `AsyncBlockImplType<T>: Future<Output = T>` is currently generated in `opaque_ty_data`. I'm not sure if we should put this code here.
- Type of async block is now rendered as `impl Future<Output = OutputType>`. Do we need to special display to hint that it's a async block? Note that closure type has its special format, instead of `impl Fn(..) -> ..` or function type.
Co-authored-by: oxalica <oxalicc@pm.me>
Try updating it.
ONiel
January 31, 2021, 8:17pm
6
I did the following:
$ git clone https://github.com/rust-analyzer/rust-analyzer.git && cd rust-analyzer
$ cargo xtask install --server
and moved it to /Users/niel/.local/bin.
Version is now rust-analyzer 286d90d. Still get the same error when I restart Atom though.
ONiel
February 2, 2021, 12:32am
7
I think I'm going to switch to Sublime Text. Atom and it's Rust-plugins are not cutting it anymore...
I do:
#[derive(Serialize, Deserialize)]
#[serde(rename_all = "camelCase")]
struct Link {
href: String,
r#type: String,
}
r# to escape the type-keyword and my whole code coloring goes blank.