Stream: t-compiler/rust-analyzer

Topic: Small pitfall that tripped me over

Charles Lew (Aug 15 2020 at 16:30, on Zulip):

Today i finally realized that my vs code ra extension is very outdated... Vscode is not updating it properly, because my local installed version is 0.2.202001xx-dev and the newest version is 0.2.273, so vscode thinks my installed version is newer. I reinstalled it.

Charles Lew (Aug 15 2020 at 16:52, on Zulip):

Another small thing i'm not sure if it is worth reporting:
the highlight seems a little... inconsistent.

Jeremy Kolb (Aug 16 2020 at 15:26, on Zulip):

You can use the "Inspect Tokens and Scopes" command to see if the tokens are the right type re highlighting

Charles Lew (Aug 17 2020 at 01:57, on Zulip):


I think there's something incorrect here...

bjorn3 (Aug 17 2020 at 08:21, on Zulip):

Semantic highlighting is disabled it seems. This means that the language definition in vscode is used, which highlights Eq and similar identifiers differently independent of the location.

Charles Lew (Aug 17 2020 at 14:18, on Zulip):

Thanks! After i change to Semantic Highlighting setting from default "configuredByTheme" to "true", it looks much better now :)

Charles Lew (Aug 17 2020 at 17:02, on Zulip):

(Reusing this topic) I'm curious about the newly added CHALK_PRINT feature. I have set the environment variables CHALK_DEBUG and CHALK_PRINT and ... nothing happens. What do i need to do to show logs of rust-analyzer-server in a vscode pane?

detrumi (Aug 17 2020 at 17:42, on Zulip):

Hm, did debug output break? Not seeing any either (even in analysis-stats for example)

detrumi (Aug 17 2020 at 17:51, on Zulip):

Yeah, at some point debug output stopped working, and it wasn't my PR that introduced CHALK_PRINT

detrumi (Aug 17 2020 at 17:52, on Zulip):

For example, this used to give debug output, and now doesn't:

RA_LOG=ra_hir_ty=debug CHALK_DEBUG=2 cargo run --release -p rust-analyzer -- analysis-stats .
detrumi (Aug 17 2020 at 17:54, on Zulip):

Going to bisect

Florian Diebold (Aug 17 2020 at 18:02, on Zulip):

we don't set up tracing yet in the rust-analyzer binary

Florian Diebold (Aug 17 2020 at 18:02, on Zulip):

so the chalk debug logging is only working in tests since the move to tracing

detrumi (Aug 17 2020 at 18:02, on Zulip):

It's one of the crate renames, I think

detrumi (Aug 17 2020 at 18:03, on Zulip):

[6a77ec7bbe6ddbf663dce9529d11d1bb56c5489a] Rename ra_hir_ty -> hir_ty

detrumi (Aug 17 2020 at 18:04, on Zulip):

@Florian Diebold debug output was working when I started, but broke after rebasing. Bisecting pointed to the crate rename

detrumi (Aug 17 2020 at 18:05, on Zulip):

Unless I misunderstand what you're saying

Florian Diebold (Aug 17 2020 at 18:06, on Zulip):

I find it hard to imagine that would have an effect

Florian Diebold (Aug 17 2020 at 18:06, on Zulip):

what kind of debug output was working for you?

detrumi (Aug 17 2020 at 18:06, on Zulip):

Stuff like this, using the command I wrote above:

[DEBUG ra_hir_ty::traits::chalk] impls_for_trait Deref
[DEBUG ra_hir_ty::traits::chalk] impls_for_trait returned 0 impls
[DEBUG ra_hir_ty::traits] solve(UCanonical { canonical: Canonical { value: InEnvironment { environment: Env([]), goal: Implemented({fn __action993}: Deref) }, binders: [] }, universes: 1 }) => None
4/4604 32% processing: parser::__action1465[INFO  ra_hir_ty::traits] trait_solve_query(Implements(fn __action994(&str, (usize, (), usize), (usize, (), usize), (usize, Option<WellKnownTrait>, usize), (usize, &str, usize), (usize, Identifier, usize), (usize, Vec<VariableKind>, usize), (usize, Vec<QuantifiedWhereClause>, usize), (usize, &str, usize), (usize, Vec<AssocTyDefn>, usize), (usize, &str, usize)) -> TraitDefn: Deref))
detrumi (Aug 17 2020 at 18:07, on Zulip):

Same command did show a lot of such output before the crate rename, and no debug output after

Florian Diebold (Aug 17 2020 at 18:07, on Zulip):

ok, that's just the RA logging. I would expect that to be working right now

Florian Diebold (Aug 17 2020 at 18:08, on Zulip):

what I was saying is that CHALK_DEBUG logging hasn't worked in RA since the tracing move

Florian Diebold (Aug 17 2020 at 18:08, on Zulip):

except in tests, because I set it up there

detrumi (Aug 17 2020 at 18:09, on Zulip):

Ah right, yeah I didn't even notice that. Though CHALK_PRINT should still work since it's done on RA's side

Florian Diebold (Aug 17 2020 at 18:11, on Zulip):

Maybe you're setting a module filter that needs to be updated?

detrumi (Aug 17 2020 at 18:12, on Zulip):

Oh wow, yeah big oof

detrumi (Aug 17 2020 at 18:13, on Zulip):

Makes sense that RA_LOG=ra_hir_ty=debug isn't working any more -.-

detrumi (Aug 17 2020 at 18:14, on Zulip):

Okay, back on topic

detrumi (Aug 17 2020 at 18:14, on Zulip):

@Charles Lew did you also set RA_LOG?

detrumi (Aug 17 2020 at 18:28, on Zulip):

@Charles Lew Got it: set RA_LOG=hir_ty=debug and CHALK_PRINT=1, then you should see debug output and printed chalk programs in the "Rust Analyzer Language Server" output

detrumi (Aug 17 2020 at 18:31, on Zulip):


Charles Lew (Aug 18 2020 at 01:06, on Zulip):

Thanks! Let me try it out.

Charles Lew (Aug 18 2020 at 01:16, on Zulip):

It's working fine! Thank you so much!

Last update: Jul 27 2021 at 21:00UTC