We should strive to handle the "only touched one item" case very well, which means either knowing the exact modified range, or inferring it through a series of heuristics.
The current DefPath machinery doesn't know how to properly understand things like e.g. impls haven't changed, and would assume that adding an impl invalidates later ones in the same module.
If we only apply the existing machinery between the "leftover" old and new items that didn't have a match in their "source tokens hash", we should be able to get overall more consistent DefId matches, even in trickier situations where, for example, the whole file was moved around.
Original source could also be used, but ignoring whitespace & comments seems useful.
One way I can see us proceeding is by gathering some statistics of the hit/miss rate of this scheme for typical editing scenarios, and the cost of actually doing the hashing.
We can probably compute the hash for each Item after finishing parsing it, from its tokens field (which is there for proc macros, but it should be fine to reuse for our purposes).
cc @nikomatsakis @michaelwoerister
We should strive to handle the "only touched one item" case very well, which means either knowing the exact modified range, or inferring it through a series of heuristics.
The current
DefPathmachinery doesn't know how to properly understand things like e.g.impls haven't changed, and would assume that adding an impl invalidates later ones in the same module.If we only apply the existing machinery between the "leftover" old and new items that didn't have a match in their "source tokens hash", we should be able to get overall more consistent
DefIdmatches, even in trickier situations where, for example, the whole file was moved around.Original source could also be used, but ignoring whitespace & comments seems useful.
One way I can see us proceeding is by gathering some statistics of the hit/miss rate of this scheme for typical editing scenarios, and the cost of actually doing the hashing.
We can probably compute the hash for each
Itemafter finishing parsing it, from itstokensfield (which is there for proc macros, but it should be fine to reuse for our purposes).cc @nikomatsakis @michaelwoerister