Stream: t-compiler

Topic: renaming TyCtxt


Zoxc (Dec 07 2018 at 13:28, on Zulip):

I think we should add two aliases for TyCtxt and start using them:

type Qx<'qx> = TyCtxt<'static, 'qx, 'qx>;
type Lx<'qx, 'lx> = TyCtxt<'static, 'qx, 'lx>;

In the future we might want to make these separate type so we could drop the local interner field from Qx.

eddyb (Dec 07 2018 at 13:32, on Zulip):

I'm not sure that's the best distinction

eddyb (Dec 07 2018 at 13:32, on Zulip):

also, the lifetime order is wrong (as it has been pointed out for a while)

eddyb (Dec 07 2018 at 13:33, on Zulip):

and I'd make 'a equal to (the current) 'tcx not 'static, just to keep a few things simpler

eddyb (Dec 07 2018 at 13:33, on Zulip):

also, there's a real question of whether we need the local split at all anymore

eddyb (Dec 07 2018 at 13:34, on Zulip):

4 years ago or so, when I gathered the stats that led to the split, for librustc I found something like 90% of the interner entries had inference variables in them

eddyb (Dec 07 2018 at 13:35, on Zulip):

I wonder if Chalk and everything else change the calculus here

eddyb (Dec 07 2018 at 13:51, on Zulip):

also, the naming scheme I used in rustc_codegen_llvm would mean qx: QueryCx, not qx: Qx

eddyb (Dec 07 2018 at 13:52, on Zulip):

that is, the type is written less often and should be more descriptive than the variable names

eddyb (Dec 07 2018 at 13:52, on Zulip):

Cx is enough to indicate "context"

eddyb (Dec 07 2018 at 13:53, on Zulip):

lx: LocalCx doesn't seem so bad, and we can relatively easily rename it if we find something better

eddyb (Dec 07 2018 at 14:01, on Zulip):

although it still looks... off to me

eddyb (Dec 07 2018 at 14:01, on Zulip):

tx: TyCx might be better

eddyb (Dec 07 2018 at 14:02, on Zulip):

not to mention you don't want to take a QueryCx if you want to perform a query, as we have no way to automate what we currently call .global_tcx()

eddyb (Dec 07 2018 at 14:04, on Zulip):

maybe if we make them references we can do some trickery - I remember not being able to pull off something sensible but maybe that's because I wanted access to the fields on GlobalCtxt - if we move hir to a method that might not be a problem anymore?

eddyb (Dec 07 2018 at 14:05, on Zulip):

I guess you'd still not want to have a cyclic Deref impl and it wouldn't even work meh

Zoxc (Dec 07 2018 at 14:16, on Zulip):

What do you mean you don't want a QueryCx if you want to perform a query?

eddyb (Dec 07 2018 at 16:23, on Zulip):

because it's too restrictive

eddyb (Dec 07 2018 at 16:23, on Zulip):

I can't just pass a local context to it

eddyb (Dec 07 2018 at 16:24, on Zulip):

in today's terms, TyCtxt<'_, 'tcx, 'tcx> is unnecessarily restrictive as a function argument type

nikomatsakis (Dec 12 2018 at 15:37, on Zulip):

btw, in Salsa we adopted the term "database" instead of "context", with the acronym db... I sort of like it better

nikomatsakis (Dec 12 2018 at 15:38, on Zulip):

re: whether the global/local split is worthwhile, I've been wondering that. I think that for Chalk integration -- which requires ultimately "inference variables" that persist beyond an individual function etc -- I'd ultimately rather not use TyVar but just keep everything in the global arena, but it's not entirely clear yet

nikomatsakis (Dec 12 2018 at 15:38, on Zulip):

In any case I think we should think carefully about the names -- this is a chance to make the compiler more accessible

Esteban K├╝ber (Dec 13 2018 at 16:28, on Zulip):

BTW, in some places we use db for diagnostic builder, instead of err.

Last update: Nov 21 2019 at 14:10UTC