Re: [PATCH] rust: doctest: fix line numbers after crate-level attributes
From: Younes Akhouayri
Date: Mon Nov 02 2026 - 14:45:32 EST
On Mon, 2 Nov 2026 15:26:29 +0100, Miguel Ojeda wrote:
> If what we want is for people to simply notice, then I was thinking of
> just `unwrap()`ping like others we have around there.
>
> Having said that, it can be annoying and confusing if someone writes a
> doctest and has to figure out what to change in these scripts (scripts
> that they may not even know they exist...).
>
> Ideally, I think we would have a "warning" somehow, i.e. something
> that doesn't stop people from working but that will get noticed.
Makes sense.
Note that a doctest author cannot really trigger this check: it only
looks at the first line of rustdoc's output, which rustdoc writes
itself, so in practice only a toolchain change would hit it.
The generator's stderr already ends up in the build log (only rustdoc's
stdout is sent to /dev/null in rust/Makefile), so for v2 I'll do: if the
output starts with `#![allow(unused)]`, subtract the moved lines with a
plain `- 1`; otherwise print a single warning naming the test and the
script, and apply no adjustment, so things keep working as today with
possibly wrong line numbers. I'll also note in the comment that only
single-line attributes are handled.
Best regards,
Younes