Stream: t-compiler/wg-mir-opt

Topic: passing tcx around for interning


Santiago Pastorino (Oct 11 2019 at 12:29, on Zulip):

was talking with @oli about a problem that is starting to show up when you intern projections

Santiago Pastorino (Oct 11 2019 at 12:29, on Zulip):

you need to pass tcx: TyCtxt<'tcx> around in a lot of places

Santiago Pastorino (Oct 11 2019 at 12:30, on Zulip):

one is that MutVisitor is going to need a blank tcx() -> TyCtxt<'tcx> and implementors can roll their own thing

Santiago Pastorino (Oct 11 2019 at 12:30, on Zulip):

that's not thaat bad

Santiago Pastorino (Oct 11 2019 at 12:31, on Zulip):

besides needing to implement it in a lot of cases that are not even going to use it because they don't need to reintern place because they don't mutate it

Santiago Pastorino (Oct 11 2019 at 12:32, on Zulip):

but one of the main problems is https://github.com/rust-lang/rust/blob/master/src/librustc/mir/mod.rs#L1862-L1894

Santiago Pastorino (Oct 11 2019 at 12:32, on Zulip):

passing tcx there may be kind of a pain

Santiago Pastorino (Oct 11 2019 at 12:32, on Zulip):

unsure if I should follow that path or is there any smarter idea

Santiago Pastorino (Oct 11 2019 at 12:39, on Zulip):

/cc @eddyb @nikomatsakis

oli (Oct 11 2019 at 12:41, on Zulip):

It's probably not too bad to fiddle through TyCtxt. Alternatively we can have tcx.mk_place that takes a PlaceBase and a Vec<PlaceElem> and just require the caller to work with TyCtxt directly instead of offering convenience functions

nikomatsakis (Oct 11 2019 at 20:41, on Zulip):

this is aways the annoying question

nikomatsakis (Oct 11 2019 at 20:41, on Zulip):

whether to do tcx.foo(a, b) or a.foo(tcx, b)

nikomatsakis (Oct 11 2019 at 20:41, on Zulip):

I can never make up my mind which I like better

nikomatsakis (Oct 11 2019 at 20:42, on Zulip):

mostly I feel there is a missing language feature (maybe like scala implicits) to enable a.foo(b) while still passing (implicitly) the tcx

nikomatsakis (Oct 11 2019 at 20:42, on Zulip):

but oh well

nikomatsakis (Oct 11 2019 at 20:42, on Zulip):

certainly not unique to Rust

Santiago Pastorino (Oct 11 2019 at 20:53, on Zulip):

was tempted to do some weird thing with ty::tls::with(|tcx| tcx.intern_place_elems(...), ty)

Santiago Pastorino (Oct 11 2019 at 20:53, on Zulip):

that gives lifetimes problems but I'm pretty sure that can be hacked with some unsafe sorcery :P

Last update: Nov 17 2019 at 07:35UTC