Stream: t-compiler/wg-rls-2.0

Topic: nondeterminism in tests?


Laurențiu Nicola (May 28 2019 at 18:36, on Zulip):
thread 'hover::tests::hover_shows_fn_signature' panicked at 'assertion failed: `(left == right)`
  left: `"pub fn foo() -> u32"`,
 right: `"pub fn foo() -> &str"`', crates/ra_ide_api/src/hover.rs:162:13
matklad (May 29 2019 at 06:39, on Zulip):

huh, that seems bad!

matklad (May 29 2019 at 06:44, on Zulip):

@Laurențiu Nicola I can't reproduce it locally. Which version of Rust are you using (I think nightly's hash-brown could have changed things)

Laurențiu Nicola (May 29 2019 at 06:47, on Zulip):

a nightly

Laurențiu Nicola (May 29 2019 at 06:47, on Zulip):

rustc 1.36.0-nightly (7158ed9cb 2019-05-15)

matklad (May 29 2019 at 06:54, on Zulip):

Aha, will try to look into that!

Laurențiu Nicola (May 29 2019 at 06:55, on Zulip):

no worries, I tried to check whether they're sorted, but didn't see anything

matklad (May 29 2019 at 06:57, on Zulip):

ah, yeah, this is much better than I've expected, we don't have a non-deterministic type inference, it's just the test itself that relies on the order of iteration

matklad (May 29 2019 at 06:58, on Zulip):

In the let hover = analysis.hover(position).unwrap().unwrap();

matklad (May 29 2019 at 06:58, on Zulip):

We basically should add hover.sort(), adjust the tests, and make sure all #[derive(Ord)] are present to actually be able to sort hovers

matklad (May 29 2019 at 06:59, on Zulip):

I wonder how many projects will be broken in practice due to different order of iteration.... ? :D

I've already fixed a couple of similar bugs when I was trying the nightly out

Laurențiu Nicola (May 29 2019 at 07:04, on Zulip):

Sure, but in the long run do we want to prioritize or sort hover references before showing them?

Laurențiu Nicola (May 29 2019 at 07:06, on Zulip):

And wasn't there a random seed used by hashmaps that should change the iteration order from one run to another?

matklad (May 29 2019 at 07:08, on Zulip):

Maybe? I don't know an obvious rule to sort hovers though, and I don't think that's really important, so sorting in tests seems fine

matklad (May 29 2019 at 07:08, on Zulip):

And wasn't there a random seed used by hashmaps that should change the iteration order from one run to another?

Good observation! I think, because we are using FxHashMap, we don't do randomization

matklad (May 29 2019 at 07:09, on Zulip):

we probably should though...

matklad (May 29 2019 at 07:09, on Zulip):

at least for tests

Laurențiu Nicola (May 29 2019 at 07:10, on Zulip):

Sorting only in the test should work for now, though

matklad (May 29 2019 at 07:10, on Zulip):

agree!

Last update: Nov 19 2019 at 17:40UTC