Stream: t-compiler/wg-rls-2.0

Topic: .chalk writer


detrumi (Jul 13 2020 at 21:14, on Zulip):

After trying to add support for writing .chalk files (https://github.com/rust-analyzer/rust-analyzer/pull/5347), I was a bit surprised how much output there was: https://gist.github.com/detrumi/cfd07de16f9192af3ee7a13d9b04bbc0

detrumi (Jul 13 2020 at 21:17, on Zulip):

This of course writes out all impls in the program, maybe there's a way to only write out parts of the program 'related' to a goal, whatever that might mean?

Florian Diebold (Jul 13 2020 at 21:41, on Zulip):

isn't that the idea of the LoggingIrDatabase?

Florian Diebold (Jul 13 2020 at 21:42, on Zulip):

I assume we would need to wrap our db in that before solving a goal, and then write out the file afterwards. there'd need to be some way of selecting the goal

detrumi (Jul 13 2020 at 21:42, on Zulip):

Ah, somehow I'd totally missed that. Yeah, you're right

detrumi (Jul 13 2020 at 21:44, on Zulip):

And looks like you can use the Display impl for LoggingRustIrDatabase as well to avoid gathering ids manually

detrumi (Jul 13 2020 at 21:55, on Zulip):

Right, so you can indeed just do this:

println!("{}", LoggingRustIrDatabase::new(ChalkContext { db, krate }));
Jack Huey (Jul 13 2020 at 22:34, on Zulip):

Hehe yeah

Jack Huey (Jul 13 2020 at 22:35, on Zulip):

It's actually super simple :)

Jack Huey (Jul 13 2020 at 22:35, on Zulip):

Well actually

Jack Huey (Jul 13 2020 at 22:35, on Zulip):

You would have to do let db = LoggingRustIrDatabase::new(ChalkContext { db, krate })

Jack Huey (Jul 13 2020 at 22:35, on Zulip):

solve a goal

Jack Huey (Jul 13 2020 at 22:35, on Zulip):

then print

detrumi (Jul 19 2020 at 12:18, on Zulip):
thread 'main' panicked at 'internal error: entered unreachable code', crates/ra_hir_ty/src/traits/chalk.rs:57:9

Looks like the .chalk writer is hitting the unreachable!() in RustIrDatabase::adt_repr

detrumi (Jul 19 2020 at 12:35, on Zulip):

Wait what, how did that star get there? impl ::core::marker::Copy for star {}
(nvm, it's actually a struct star and not actually a *)

Florian Diebold (Jul 19 2020 at 12:56, on Zulip):

huh, I missed that this method even exists, but also it doesn't seem to be actually used in Chalk for any logic? but we should just make it return default instead of calling unreachable

detrumi (Jul 19 2020 at 13:29, on Zulip):

@Florian Diebold Sounds good, filed https://github.com/rust-analyzer/rust-analyzer/pull/5437

Last update: Sep 27 2020 at 14:30UTC