list-envelope discovery gives pub(super) and pub(in …) functions the key of the previous function
Summary
The registry-free list-cut discovery does not recognize functions declared pub(super) fn or pub(in …) fn. It assigns each cut in such a function to the previous fn it does recognize. The enclosing_item key can then name the wrong function.
Where
Checked on main at 8876c44b4.
crates/aft/tests/list_envelope_conformance/support.rs,extract_item_name: the prefix list haspub(crate) fn,pub fn,fnand theasyncforms. It does not havepub(super) fnorpub(in …) fn.enclosing_itemthen walks back to the nearest recognized item.crates/aft/tests/list_envelope_drift_guard.rs,extract_item_name: the same prefix set.
Sites with the wrong key today
| Cut | Real enclosing function | Key the scanner gives |
|---|---|---|
commands/semantic_search/external_exact.rs:324 (skipped_foreign_mounts) |
pub(super) fn sweep (:310) |
files_with_hits (:234) |
commands/semantic_search/external_exact.rs:325 |
sweep |
files_with_hits |
commands/semantic_search/external_exact.rs:583 (.skip(offset).take(top_k)) |
pub(super) fn reply (:574) |
rank_hits (:547) |
commands/semantic_search/external_pattern.rs:150 (results.truncate(SEMANTIC_ENUMERATION_LIMIT)) |
pub(super) fn semantic_results (:115) |
semantic_index (:103) |
The first one is visible in list_surfaces.rs:1028-1031: the exclusion entry has enclosing_item: "files_with_hits", but its location_or_primitive names external_exact::sweep.
Reproduction
I wrote a script that copies the scanner's prefix rule. It compares that rule with a rule that also accepts pub(super) and pub(in …) . Over the 324 cut sites it checks, it gives these four differences. All other keys are the same.
Effect
- An exclusion or surface entry must use a key that does not agree with the code. A reader cannot match the entry to its function.
- If the real function moves or is renamed, the key does not change. If the wrong function is renamed, a registered cut appears as unregistered.
Suggested fix
Accept any pub(...) visibility before fn, const, static, struct and enum in both extract_item_name functions (for example, strip a leading pub( … ) group before the prefix match). Then change the key of the external_exact.rs exclusion to sweep, and the keys of any registered entries for the other three sites.
The fix is included in v0.64.0. Both list-cut scanners now share a parser that recognizes restricted visibility, and the affected registry keys use the actual function names. Regression tests cover pub(super) and pub(in …) attribution in both scanners. Please reopen if you still see incorrect attribution.