Stream: t-compiler/wg-nll

Topic: polonius debugging


nikomatsakis (Sep 27 2018 at 21:47, on Zulip):

@lqd if you were inclined to do some polonius hacking... one thing I would like is to improve the debugging output

nikomatsakis (Sep 27 2018 at 21:47, on Zulip):

e.g., for this test failure, I get

nikomatsakis (Sep 27 2018 at 21:47, on Zulip):
  left: `{Point { index: 1 }: [Loan { index: 0 }]}`,
 right: `{}`', src/test.rs:186:5
nikomatsakis (Sep 27 2018 at 21:47, on Zulip):

but what I would like to see is Point { index: 1 } written as mid(BB1) or whatever

nikomatsakis (Sep 27 2018 at 21:47, on Zulip):

tbh I'm not entirely sure which point is :)

nikomatsakis (Sep 27 2018 at 21:47, on Zulip):

I guess we could just put the "program" into thread-local data

nikomatsakis (Sep 27 2018 at 21:47, on Zulip):

so we can access it from the Debug impl

nikomatsakis (Sep 27 2018 at 21:48, on Zulip):

or else we can write some wrappers

nikomatsakis (Sep 27 2018 at 21:48, on Zulip):

e.g., foo.debug_in(program)

lqd (Sep 27 2018 at 21:48, on Zulip):

it is quite obscure

lqd (Sep 27 2018 at 21:49, on Zulip):

I will looking into it!

lqd (Sep 27 2018 at 21:50, on Zulip):

(I've had the same problem before, and I go through the InternerTables to go back to the original string input: the untern function)

lqd (Sep 27 2018 at 21:53, on Zulip):

@nikomatsakis for example, in the program tests: here

nikomatsakis (Sep 27 2018 at 21:55, on Zulip):

I've never quite gotten a pattern I like

nikomatsakis (Sep 27 2018 at 21:55, on Zulip):

I think in my ideal world

nikomatsakis (Sep 27 2018 at 21:55, on Zulip):

we'd have a DebugWith trait

nikomatsakis (Sep 27 2018 at 21:55, on Zulip):

and a derive for it

nikomatsakis (Sep 27 2018 at 21:56, on Zulip):

which takes some context as argument

nikomatsakis (Sep 27 2018 at 21:56, on Zulip):

i.e., the types would not implement Debug

nikomatsakis (Sep 27 2018 at 21:56, on Zulip):

but DebugWith

nikomatsakis (Sep 27 2018 at 21:56, on Zulip):

and then you would do format!("{:?}", foo.debug_with(&interner)) or whatever

nikomatsakis (Sep 27 2018 at 21:56, on Zulip):

where debug_with would return some wrapper that implements Debug

nikomatsakis (Sep 27 2018 at 21:57, on Zulip):

but I've never tried this pattern out at scale to see how it feels :)

nikomatsakis (Sep 27 2018 at 21:57, on Zulip):

mostly because usually i am too busy trying to get something done

nikomatsakis (Sep 27 2018 at 21:57, on Zulip):

..kind of like right now

lqd (Sep 27 2018 at 21:57, on Zulip):

maybe we can try it in polonius (it wouldn't be that big of a scale)

nikomatsakis (Sep 27 2018 at 21:58, on Zulip):

I also need to learn how to write a custom derive

nikomatsakis (Sep 27 2018 at 21:58, on Zulip):

I was searching for that recently and found it surprisingly ill-documented

nikomatsakis (Sep 27 2018 at 21:59, on Zulip):

presumably syn or something makes it easy :)

nikomatsakis (Sep 27 2018 at 21:59, on Zulip):

I've always wanted a "meta-derive", where you can annotate traits with the derive pattern you want, and it will generate the derive for you...

nikomatsakis (Sep 27 2018 at 21:59, on Zulip):

..since for me at least it's usually one of a few options...

nikomatsakis (Sep 27 2018 at 21:59, on Zulip):

/me rambles

nikomatsakis (Sep 27 2018 at 22:00, on Zulip):

ok, I gotta run

lqd (Sep 27 2018 at 22:00, on Zulip):

dtolnay has interesting tests/accessory crates helping out, as always :)

lqd (Sep 27 2018 at 22:05, on Zulip):

(and of course the example in reflect is for a Debug custom derive :joy: )

Last update: Nov 22 2019 at 00:25UTC