Stream: t-compiler/wg-rls-2.0

Topic: vim configuration for rustc dev


Santiago Pastorino (May 13 2020 at 13:43, on Zulip):

I wanted to try out vim+RLS in Rustc itself

Santiago Pastorino (May 13 2020 at 13:44, on Zulip):

I'm using coc and coc-rust-analyzer

Santiago Pastorino (May 13 2020 at 13:44, on Zulip):

have placed this ...

Santiago Pastorino (May 13 2020 at 13:44, on Zulip):
{
    "rust-analyzer.checkOnSave.overrideCommand": [
        "./x.py",
        "check",
        "--stage 1",
        "--json-output"
    ]
}
Santiago Pastorino (May 13 2020 at 13:44, on Zulip):

in .vim directory on the workspace

Santiago Pastorino (May 13 2020 at 13:45, on Zulip):

but doesn't seem to work

Santiago Pastorino (May 13 2020 at 13:45, on Zulip):

was someone able to make it work

matklad (May 13 2020 at 13:46, on Zulip):

"--stage", "1" rather than "--stage 1"?

Santiago Pastorino (May 13 2020 at 13:46, on Zulip):

yeah, was wondering about that

Santiago Pastorino (May 13 2020 at 13:46, on Zulip):

I'm also wondering if this is not related to the fact that I've placed .vim inside rustc dir

Santiago Pastorino (May 13 2020 at 13:47, on Zulip):

but I'm actually working in librustc_mir

Santiago Pastorino (May 13 2020 at 13:47, on Zulip):

so probably the workspace config that vim is looking for should be in librustc_mir

Santiago Pastorino (May 13 2020 at 13:47, on Zulip):

trying those things out

matklad (May 13 2020 at 13:48, on Zulip):

Can you see the log from the LSP? Might be a good way to figure out what's wrong

Santiago Pastorino (May 13 2020 at 13:49, on Zulip):

yeah have done zero investigation to be honest

Santiago Pastorino (May 13 2020 at 13:49, on Zulip):

where is the log file typically located?

matklad (May 13 2020 at 13:51, on Zulip):

Logging protocol requests is a client-side thing

matklad (May 13 2020 at 13:52, on Zulip):

So, I don't know how is it set up in coc-vim unfortunately. In VS Code, you enable "rust-analyzer.trace.server": "verbose", setting and then see the log in the UI

Santiago Pastorino (May 13 2020 at 13:53, on Zulip):

let me try setting that to verbose and seeing what happens

Santiago Pastorino (May 13 2020 at 13:56, on Zulip):

ok both things were wrong :)

Santiago Pastorino (May 13 2020 at 13:57, on Zulip):

I meant, it needed "--stage", "1" and also the problem is related to what I'm saying, I'd need to place the config on each crate or find a better way to set up this on all subdirectories under rustc main dir

matklad (May 13 2020 at 13:58, on Zulip):

@Santiago Pastorino if you got client-side logging working, could you add the instructions to do this here? https://github.com/rust-analyzer/rust-analyzer/blob/master/docs/user/readme.adoc#coc-rust-analyzer

Santiago Pastorino (May 13 2020 at 13:58, on Zulip):

didn't try the logging because I realized by testing about the problem

Santiago Pastorino (May 13 2020 at 13:58, on Zulip):

but could try to enable logging

Santiago Pastorino (May 13 2020 at 13:58, on Zulip):

let me check

matklad (May 13 2020 at 13:59, on Zulip):

(in general, any improvements to the docs are welcome ;) )

Santiago Pastorino (May 13 2020 at 14:00, on Zulip):

have enabled it and no idea where is storing logs

Santiago Pastorino (May 13 2020 at 14:00, on Zulip):

searching

Santiago Pastorino (May 13 2020 at 14:46, on Zulip):

btw, forgot to report back here, my problem seemed to be that in order to have the top level coc configuration and the workspace coc configuration merged you need to reload coc after starting vim and loading an rs file

Santiago Pastorino (May 13 2020 at 14:47, on Zulip):

if someone has a better solution would be great to hear that

simulacrum (May 13 2020 at 14:49, on Zulip):

check should not need a stage argument, it's ignored entirely to my knowledge

Santiago Pastorino (May 13 2020 at 14:54, on Zulip):

@simulacrum to be honest I have no idea how check differs from build

Santiago Pastorino (May 13 2020 at 14:54, on Zulip):

I meant, other than the obvious thing that it just checks :)

simulacrum (May 13 2020 at 14:54, on Zulip):

cargo check vs. cargo build, really, except because we can't produce binaries from cargo check you are limited entirely to stage 0 basically

Santiago Pastorino (May 13 2020 at 14:54, on Zulip):

but talking about stages and params

Santiago Pastorino (May 13 2020 at 14:55, on Zulip):

for instance if I do ./x.py build --stage 1 src/libstd, edit a fail to make the compilation fail and then do ./x.py check --stage 1 src/libstd check does nothing

simulacrum (May 13 2020 at 14:56, on Zulip):

hm that rather sounds like a bug, to be honest

simulacrum (May 13 2020 at 14:56, on Zulip):

(or maybe I misunderstood you)

Santiago Pastorino (May 13 2020 at 14:57, on Zulip):

try that out :)

Santiago Pastorino (May 13 2020 at 14:57, on Zulip):

run ./x.py build --stage 1 src/libstd

simulacrum (May 13 2020 at 14:57, on Zulip):

I don't really have the time to wait that long

Santiago Pastorino (May 13 2020 at 14:57, on Zulip):

:P

simulacrum (May 13 2020 at 14:57, on Zulip):

if you post logs somewhere I can take a look later

Santiago Pastorino (May 13 2020 at 14:57, on Zulip):

but in any case, if you run that, edit a fail and then run check it doesn't file

simulacrum (May 13 2020 at 14:58, on Zulip):

is check compiling though?

simulacrum (May 13 2020 at 14:58, on Zulip):

it might also be that your rust-analyzer check is running check already

simulacrum (May 13 2020 at 14:58, on Zulip):

so when you run it manually it goes "hey everything seems to have passed"

simulacrum (May 13 2020 at 14:58, on Zulip):

though iirc cargo should print the error in that case

Santiago Pastorino (May 13 2020 at 14:58, on Zulip):

no no, this is different than the editor thing I'm talking about

Santiago Pastorino (May 13 2020 at 14:58, on Zulip):

the editor is even closed

Santiago Pastorino (May 13 2020 at 14:59, on Zulip):

let me show you because I have a build just opened

Santiago Pastorino (May 13 2020 at 14:59, on Zulip):

going to edit the file with Rust unconfigured

simulacrum (May 13 2020 at 14:59, on Zulip):

I kicked off x.py build locally at least

Santiago Pastorino (May 13 2020 at 14:59, on Zulip):

I've seen this in the past

Santiago Pastorino (May 13 2020 at 15:00, on Zulip):

this is why I never use check

simulacrum (May 13 2020 at 15:00, on Zulip):

what file did you edit?

Santiago Pastorino (May 13 2020 at 15:02, on Zulip):
[santiago@galago rust3 (master)]$ RUST_BACKTRACE=1 ./x.py build --stage 1 src/libstd
Updating only changed submodules
Submodules updated in 0.02 seconds
    Finished dev [unoptimized] target(s) in 0.16s
Building stage0 std artifacts (x86_64-unknown-linux-gnu -> x86_64-unknown-linux-gnu)
    Finished release [optimized + debuginfo] target(s) in 0.15s
Copying stage0 std from stage0 (x86_64-unknown-linux-gnu -> x86_64-unknown-linux-gnu / x86_64-unknown-linux-gnu)
Building stage0 compiler artifacts (x86_64-unknown-linux-gnu -> x86_64-unknown-linux-gnu)
    Finished release [optimized + debuginfo] target(s) in 0.18s
Copying stage0 rustc from stage0 (x86_64-unknown-linux-gnu -> x86_64-unknown-linux-gnu / x86_64-unknown-linux-gnu)
Assembling stage1 compiler (x86_64-unknown-linux-gnu)
Building stage1 std artifacts (x86_64-unknown-linux-gnu -> x86_64-unknown-linux-gnu)
    Finished release [optimized + debuginfo] target(s) in 0.15s
Copying stage1 std from stage1 (x86_64-unknown-linux-gnu -> x86_64-unknown-linux-gnu / x86_64-unknown-linux-gnu)
Build completed successfully in 0:00:01
[santiago@galago rust3 (master)]$ vim src/librustc_driver/lib.rs
[santiago@galago rust3 (master)]$ git diff
diff --git a/src/librustc_driver/lib.rs b/src/librustc_driver/lib.rs
index 913ccf8e680..26416ca7713 100644
--- a/src/librustc_driver/lib.rs
+++ b/src/librustc_driver/lib.rs
@@ -15,7 +15,6 @@ extern crate lazy_static;

 pub extern crate rustc_plugin_impl as plugin;

-use rustc_ast::ast;
 use rustc_codegen_ssa::{traits::CodegenBackend, CodegenResults};
 use rustc_data_structures::profiling::print_time_passes_entry;
 use rustc_data_structures::sync::SeqCst;
[santiago@galago rust3 (master)]$ RUST_BACKTRACE=1 ./x.py check --stage 1 src/libstd
Updating only changed submodules
Submodules updated in 0.02 seconds
    Finished dev [unoptimized] target(s) in 0.14s
Checking std artifacts (x86_64-unknown-linux-gnu -> x86_64-unknown-linux-gnu)
    Finished release [optimized + debuginfo] target(s) in 0.17s
Build completed successfully in 0:00:01
[santiago@galago rust3 (master)]$ RUST_BACKTRACE=1 ./x.py build --stage 1 src/libstd
Updating only changed submodules
Submodules updated in 0.01 seconds
    Finished dev [unoptimized] target(s) in 0.12s
Building stage0 std artifacts (x86_64-unknown-linux-gnu -> x86_64-unknown-linux-gnu)
    Finished release [optimized + debuginfo] target(s) in 0.13s
Copying stage0 std from stage0 (x86_64-unknown-linux-gnu -> x86_64-unknown-linux-gnu / x86_64-unknown-linux-gnu)
Building stage0 compiler artifacts (x86_64-unknown-linux-gnu -> x86_64-unknown-linux-gnu)
   Compiling rustc_driver v0.0.0 (/home/santiago/src/oss/rust3/src/librustc_driver)
error[E0433]: failed to resolve: use of undeclared type or module `ast`
    --> src/librustc_driver/lib.rs:1076:79
     |
1076 | fn parse_crate_attrs<'a>(sess: &'a Session, input: &Input) -> PResult<'a, Vec<ast::Attribute>> {
     |                                                                               ^^^ use of undeclared type or module `ast`

error: aborting due to previous error

For more information about this error, try `rustc --explain E0433`.
error: could not compile `rustc_driver`.

To learn more, run the command again with --verbose.
command did not execute successfully: "/home/santiago/src/oss/rust3/build/x86_64-unknown-linux-gnu/stage0/bin/cargo" "build" "--target" "x86_64-unknown-linux-gnu" "-Zbinary-dep-depinfo" "-j" "8" "--release" "--features" " llvm" "--manifest-path" "/home/santiago/src/oss/rust3/src/rustc/Cargo.toml" "--message-format" "json-render-diagnostics"
expected success, got: exit code: 101
failed to run: /home/santiago/src/oss/rust3/build/bootstrap/debug/bootstrap build --stage 1 src/libstd
Build completed unsuccessfully in 0:00:01
Santiago Pastorino (May 13 2020 at 15:03, on Zulip):

maybe related https://github.com/rust-lang/rust/issues/69337

simulacrum (May 13 2020 at 15:06, on Zulip):

and you run x.py check?

simulacrum (May 13 2020 at 15:06, on Zulip):

or some arguments?

simulacrum (May 13 2020 at 15:06, on Zulip):

@Santiago Pastorino I have a theory -- you ran x.py check --stage 1 src/libstd

simulacrum (May 13 2020 at 15:07, on Zulip):

but that only checks libstd

simulacrum (May 13 2020 at 15:07, on Zulip):

because stage 1 is ignored

simulacrum (May 13 2020 at 15:07, on Zulip):

so you've essentially done the same as x.py build --stage 0 src/libstd

simulacrum (May 13 2020 at 15:07, on Zulip):

(except with a check)

simulacrum (May 13 2020 at 15:07, on Zulip):

I should file a PR banning --stage to check, I guess

Santiago Pastorino (May 13 2020 at 15:07, on Zulip):

:+1:

Santiago Pastorino (May 13 2020 at 15:08, on Zulip):

is there a reason why --stage doesn't work with check?

simulacrum (May 13 2020 at 15:08, on Zulip):

as I mentioned you can't produce binaries with check

simulacrum (May 13 2020 at 15:09, on Zulip):

so if you actually did do --stage 1 src/libstd we'd need to do basically x.py build --stage 0 src/rustc && x.py check --stage 1 src/libstd but that's not usually helpful and I didn't want to spend development time making it work

Santiago Pastorino (May 13 2020 at 15:09, on Zulip):

ahh I see

Santiago Pastorino (May 13 2020 at 15:09, on Zulip):

makes sense

Santiago Pastorino (May 14 2020 at 20:57, on Zulip):

btw created this https://github.com/neoclide/coc.nvim/issues/1926

Santiago Pastorino (May 16 2020 at 23:04, on Zulip):

this issue was fixed https://github.com/neoclide/coc.nvim/commit/9704f8d076426177dcbd92067dc76bafa266f852

Last update: Oct 28 2020 at 18:15UTC