Skip to content

docs: h2_mux_internals quotes field syntax that no longer compiles, and no citation rule can catch stale code inside prose #1424

Closed

Description

@FlorentinDUBOIS

doc/h2_mux_internals.md quotes field-access syntax that no longer compiles. The H2 sans-io
extraction series made those fields private to their new modules, and this document was not swept.

Confirmed at 595920e91c4528f0554410b904b45d543c88e467:

Correction: the drain example in the original report was wrong

The first version of this issue also claimed self.drain.draining = true; was broken, with
draining private to h2_drain.rs. That is not true on main, and it was my error. At
595920e9:

  • pub drain: H2DrainState — lib/src/protocol/mux/h2.rs:1721
  • pub draining: bool — lib/src/protocol/mux/h2.rs:1643
  • the assignment itself compiles and appears at h2.rs:4803, h2.rs:4885, h2.rs:6195 and
    lib/src/protocol/mux/mod.rs:2631
  • lib/src/protocol/mux/h2_drain.rs does not exist on main

No E0616 is possible there. That example describes the unmerged refactor/h2-goaway-drain branch
(#1425), not main. The HPACK half above is real and is the defect this issue is about.

The correction does not weaken the point — it sharpens it. I wrote a false claim about private
fields in the issue reporting false claims about private fields, and nothing caught it either.

Why this survives every gate

check_doc_citations.py has three rules. Rule 1 proves a cited line is non-blank and in range. The
drift rule compares text at (path, spans) pairs that existed at the base. The third checks cited
test names resolve to a real fn.

None of them inspects the code quoted in the prose. So a document can carry a correct line
number beside a snippet that is two refactors out of date, and every check passes.

This is a distinct failure from a drifted citation, and arguably worse: a wrong line number
eventually lands somewhere obviously irrelevant and gets noticed, while stale syntax next to a
resolving citation reads as authoritative. A reader copying it gets a compile error and assumes
they made the mistake.

Worth distinguishing when fixing

Several passages look identical to the defect and are correct:

  • Prose that deliberately shows unreachable syntax to prove a point — "self.streams.remove(...)
    cannot even be written from h2.rs; it fails with E0609" — is right and must stay.
  • Code blocks reproducing a method from inside its own module's impl, where self is that type
    and the fields are its own, are right.
  • A field of the same name on a different type — Context.streams is a Vec<Stream> on Context,
    untouched by any extraction — is right.

Only genuine ConnectionH2-side access to a now-private field is wrong.

A durable fix rather than a sweep

Sweeping fixes today's instances and does nothing about the next four extraction steps. The question
is whether the citation checker can close the class.

Measured on this tree: the guarded surface holds 215 fenced blocks, 27 of them Rust. Whole-tree
literal matching locates 7 of the 27 — the other 20 are deliberately abbreviated, composite or
simplified, so a rule comparing all of them fires on 20 of 27 and gets silenced. Only 4 of the 27
carry a file.rs:NNN citation in their prose, and none of those are in this file. rustdoc
doctests cannot substitute: a doctest compiles as a separate crate against the public API, and every
snippet at issue reads a private field of a private type inside impl ConnectionH2.

So the rule that closes it is opt-in: a fenced block names the lines it quotes in its info string,
and the checker compares them. Zero false positives by construction, and the annotation is an
ordinary citation, so a pinned block is range-checked by rule 1 immediately and drift-checked by
rule 2 from the next commit onward.

Two limits, both worth stating up front:

  • A pin guards the quote, not the claim beside it. The review of the fix found five wrong
    explanations sitting next to blocks the checker was certifying byte-exact.
  • Opt-in means a quote nobody pins is a quote nobody checks; this rule would not have caught the
    four blocks above on its own.

What I verified, and what I did not

Verified by reading at 595920e9: the quoted syntax in doc/h2_mux_internals.md, and the private
declarations of the HPACK coder and scratch fields in hpack_state.rs.

Not verified originally: I did not compile the snippets, nor audit every other document under
doc/ for the same shape — which is exactly how the incorrect drain example above got in.

Activity

  1. added 4 commits that reference this issue on Sep 22, 2026
    4311952
    c140210
    c33c2a3
    274fe86
  2. added a commit that references this issue on Sep 22, 2026
    c335057
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type

    Projects

    No projects

      Milestone

      No milestone

      Relationships

      None yet

      Development

      No branches or pull requests

      Issue actions