Stream: t-compiler

Topic: Removing `mir_const_qualif`


ecstatic-morse (Oct 26 2019 at 15:33, on Zulip):

The mir_const_qualif query computes the value of NeedsDrop, HasMutInterior etc. on the final value of a const so we know whether e.g. &CONST is promotable. However it also returns a second value, a bitset of promotable locals, that is not used anywhere except promotion.

I want to make the qualifs in the final value an output of mir_validated instead and remove mir_const_qualif. This will make the code that does promotion more regular across const, static, const fn, etc. and will save a bit of space in the query cache. It will also help me fix a bug with [expr; 2] promotion in consts (#65732), since the logic for promotion in a const will have full access to the list of promotion Candidates instead of just a bitset of promotable locals with no context.

Does anyone foresee a problem with this? This is my first time modifying queries. The only difference in evaluation order is that mir_validated will be called on a const if a reference to it is encountered in another MIR body. I don't think this can result in a query cycle where one did not exist before.

ecstatic-morse (Oct 26 2019 at 22:40, on Zulip):

as_local_hir_id is returning None for MaybeUninitialized::UNINIT on the following query stack. Is there something I need to make sure gets executed first?

query stack during panic:
#0 [mir_built] processing `core::mem::MaybeUninit::<T>::UNINIT`
#1 [unsafety_check_result] processing `core::mem::MaybeUninit::<T>::UNINIT`
#2 [mir_const] processing `core::mem::MaybeUninit::<T>::UNINIT`
#3 [mir_validated] processing `core::mem::MaybeUninit::<T>::UNINIT`
#4 [mir_validated] processing `collections::btree::node::LeafNode::<K, V>::new`
#5 [mir_borrowck] processing `collections::btree::node::LeafNode::<K, V>::new`
#6 [analysis] running analysis passes on this crate
ecstatic-morse (Oct 26 2019 at 22:42, on Zulip):

Ah, I guess it's because one is in a different crate from the other.

ecstatic-morse (Oct 26 2019 at 23:01, on Zulip):

So what I really want is for one function to generate the results for two queries, specifically mir_validated and mir_const_qualif. The result of mir_validated is a Steal, which is not Rustc{En,De}codable, but I need to cache the result of mir_const_qualif on disk I think. This means I can't combine the two.

Last update: Nov 16 2019 at 01:05UTC