Stream: t-compiler/wg-rls-2.0

Topic: how to debug assertion?


Roland Kuhn (May 28 2020 at 16:05, on Zulip):

I’m hitting this assertion with left=1 and right=2 (in a moderately complex codebase, of course, that is not yet public). Any ideas on how to proceed?

matklad (May 28 2020 at 16:07, on Zulip):

The first thing to do would be to summon @Florian Diebold :P

Then, run rust-analyzer analysis-stats . (batch analysis) to check if it reproduces the problem reliably

matklad (May 28 2020 at 16:07, on Zulip):

if it does, the next thing to do would be to minize the test case

Roland Kuhn (May 28 2020 at 16:10, on Zulip):

ah, so how do I run rust-analyzer again? (now on Linux … )

Florian Diebold (May 28 2020 at 16:11, on Zulip):

yeah, that. if analysis-stats crashes, you should be able to see the last function it was analyzing, and then you can run it with -o that_function to only analyze one function, which should be much faster and still crash

Florian Diebold (May 28 2020 at 16:11, on Zulip):

you should be able to run it from wherever VSCode downloaded it (someone who knows about VSCode can probably tell us the path)

Roland Kuhn (May 28 2020 at 16:12, on Zulip):

hmm, looking …

Laurențiu Nicola (May 28 2020 at 16:13, on Zulip):

https://rust-analyzer.github.io/manual.html#vs-code

matklad (May 28 2020 at 16:13, on Zulip):

~/.config/Code/User/globalStorage/matklad.rust-analyzer/rust-analyzer-linux

Laurențiu Nicola (May 28 2020 at 16:13, on Zulip):

Don't we rename it to rust-analyzer? :slight_smile:

Roland Kuhn (May 28 2020 at 16:14, on Zulip):

there is no ~/.config/Code … I’m running this via Code server remote

Florian Diebold (May 28 2020 at 16:14, on Zulip):

you could also just download the binary from github and put it anywhere though

Roland Kuhn (May 28 2020 at 16:18, on Zulip):

(downloaded the binary because I couldn’t find it on that host)

Database loaded, 251 roots, 376.796722ms
Crates in this dir: 1
Total modules found: 33
Total declarations: 478
Total functions: 319
Item Collection: 14.546484276s, 0b allocated 0b resident
50/319 15% processing: util::flow::distinctthread 'main' panicked at 'assertion failed: `(left == right)`
  left: `1`,
 right: `2`', crates/ra_hir_ty/src/lib.rs:524:9

so I guess that points me to the distinct method I happen to have on my Flow in the flow module, right?

Florian Diebold (May 28 2020 at 16:19, on Zulip):

yes. so -o util::flow::distinct should also crash

Roland Kuhn (May 28 2020 at 16:20, on Zulip):

the thing is I have multiple distinct methods on different types in that module

Florian Diebold (May 28 2020 at 16:21, on Zulip):

hmm yeah that's not ideal, you could try giving them unique names? unless it changes the name resolution inside the function it should probably still reproduce the crash

Roland Kuhn (May 28 2020 at 16:21, on Zulip):

yes, that crashes as well; I have several errors (am in the middle of a refactoring), will see if fixing the errors removes this crash

Roland Kuhn (May 28 2020 at 16:32, on Zulip):

@Florian Diebold So I have a trait Flow<'a, T> and I added another type parameter to it. Several methods needed updated type signatures, and after I’d done those the crash went away.

Roland Kuhn (May 28 2020 at 16:33, on Zulip):

now I still have many errors related to this change in other modules, but those don’t crash the analyzer

Florian Diebold (May 28 2020 at 16:34, on Zulip):

hm yeah it's probably not as straightforward as having a trait and using it with the wrong number of type parameters

Roland Kuhn (May 28 2020 at 16:34, on Zulip):

not sure whether you are being ironic

Roland Kuhn (May 28 2020 at 16:35, on Zulip):

of course I need to fix my type errors, but the analyzer crashing makes that experience quite a bit more annoying; the primary reason to use rust-analyzer is that it so awesomely supports refactorings

Florian Diebold (May 28 2020 at 16:37, on Zulip):

I'm not being ironic, I'm pretty sure this has to be a bit more complicated

Florian Diebold (May 28 2020 at 16:37, on Zulip):

yeah, this is a bug we need to fix, doesn't matter whether there are type errors or not

Florian Diebold (May 28 2020 at 16:41, on Zulip):

or, maybe not complicated, but some edge case...

Roland Kuhn (May 28 2020 at 16:46, on Zulip):

Ah, yes, makes sense (I don’t know you well enough yet, so had to ask). I’m making such changes often and this was the first one to crash; perhaps the lifetime parameter plays into it.

Roland Kuhn (May 28 2020 at 16:47, on Zulip):

I’ll try to minimize later, now I need to finish that one feature (as always)

Last update: Sep 27 2020 at 13:30UTC