Skip to content

Conversation

@GuillaumeGomez
Copy link
Member

Finally took the time to write this lint. We need to have a compiler context in order to be able to emit the lint, but I'm not sure if DiagCtxtHandle doesn't provide it somehow... Anyway, I'm expecting performance regression because we keep the compiler and its internals around for much longer, stacking doctests memory on top of the allocated memory to the current crate (which is why I'd really love to see if it's possible to emit lints from DiagCtxtHandle somehow, gonna investigate).

Also: both lint name and lint message are very much up to debate.

r? @fmease

@rustbot rustbot added S-waiting-on-author Status: This is awaiting some action (such as code changes or more information) from the author. T-rustdoc Relevant to the rustdoc team, which will review and decide on the PR/issue. labels Nov 12, 2025
@rustbot
Copy link
Collaborator

rustbot commented Nov 12, 2025

fmease is currently at their maximum review capacity.
They may take a while to respond.

@GuillaumeGomez
Copy link
Member Author

@bors2 try @rust-timer queue

@rust-timer

This comment has been minimized.

@rust-bors

This comment has been minimized.

rust-bors bot added a commit that referenced this pull request Nov 12, 2025
…compilation, r=<try>

Add new `failed_merged_doctest_compilation` rustdoc lint
@rustbot rustbot added the S-waiting-on-perf Status: Waiting on a perf run to be completed. label Nov 12, 2025
@rust-log-analyzer
Copy link
Collaborator

The job pr-check-2 failed! Check out the build log: (web) (plain enhanced) (plain)

Click to see the possible cause of the failure (guessed by this bot)

error: doctest failed, to rerun pass `-p alloc --doc`

Caused by:
  process didn't exit successfully: `/checkout/obj/build/bootstrap/debug/rustdoc --edition=2024 --crate-type lib --color always --crate-name alloc --test library/alloc/src/lib.rs --test-run-directory /checkout/library/alloc --target x86_64-unknown-linux-gnu -L dependency=/checkout/obj/build/x86_64-unknown-linux-gnu/stage1-std/x86_64-unknown-linux-gnu/release/deps -L dependency=/checkout/obj/build/x86_64-unknown-linux-gnu/stage1-std/release/deps -L native=/checkout/obj/build/x86_64-unknown-linux-gnu/stage1-std/x86_64-unknown-linux-gnu/release/build/compiler_builtins-ab4e95d684d268d9/out --test-args -Z --test-args unstable-options --test-args --format --test-args json --warn=unexpected_cfgs --check-cfg 'cfg(no_global_oom_handling)' --check-cfg 'cfg(no_rc)' --check-cfg 'cfg(no_sync)' --extern 'priv:alloc=/checkout/obj/build/x86_64-unknown-linux-gnu/stage1-std/x86_64-unknown-linux-gnu/release/deps/liballoc-7ba7b7a48df3e66b.rlib' --extern 'priv:compiler_builtins=/checkout/obj/build/x86_64-unknown-linux-gnu/stage1-std/x86_64-unknown-linux-gnu/release/deps/libcompiler_builtins-646e9c051dbeece2.rlib' --extern core=/checkout/obj/build/x86_64-unknown-linux-gnu/stage1-std/x86_64-unknown-linux-gnu/release/deps/libcore-116781e8a0b7fefc.rlib -C embed-bitcode=no --cfg 'feature="compiler-builtins-c"' --check-cfg 'cfg(docsrs,test)' --check-cfg 'cfg(feature, values("compiler-builtins-c", "compiler-builtins-mem", "compiler-builtins-no-f16-f128", "optimize_for_size"))' -Csymbol-mangling-version=legacy '--check-cfg=cfg(feature,values(any()))' -Zunstable-options -Dwarnings '-Wrustdoc::invalid_codeblock_attributes' --crate-version '1.93.0-nightly (e7571561e 2025-11-12)' '-Zcrate-attr=doc(html_root_url="https://doc.rust-lang.org/nightly/")' '-Zcrate-attr=warn(rust_2018_idioms)' --error-format human -Zunstable-options` (exit status: 1)
note: test exited abnormally; to see the full output pass --no-capture to the harness.
Bootstrap failed while executing `test --stage 1 core alloc std test proc_macro`
Build completed unsuccessfully in 0:06:41
  local time: Wed Nov 12 14:43:10 UTC 2025
  network time: Wed, 12 Nov 2025 14:43:10 GMT
##[error]Process completed with exit code 1.

@GuillaumeGomez
Copy link
Member Author

Another thing I thought: should we display errors?

@rust-bors
Copy link
Contributor

rust-bors bot commented Nov 12, 2025

☀️ Try build successful (CI)
Build commit: fa55e90 (fa55e9058b427aeb73ae208b2105b8e21713b3b3, parent: 95aeb4696545eb4c9cbb68516f2912770e3846ea)

@rust-timer

This comment has been minimized.

@rust-timer
Copy link
Collaborator

Finished benchmarking commit (fa55e90): comparison URL.

Overall result: no relevant changes - no action needed

Benchmarking this pull request means it may be perf-sensitive – we'll automatically label it not fit for rolling up. You can override this, but we strongly advise not to, due to possible changes in compiler perf.

@bors rollup=never
@rustbot label: -S-waiting-on-perf -perf-regression

Instruction count

This benchmark run did not return any relevant results for this metric.

Max RSS (memory usage)

Results (primary 1.5%)

A less reliable metric. May be of interest, but not used to determine the overall result above.

mean range count
Regressions ❌
(primary)
1.5% [1.5%, 1.5%] 1
Regressions ❌
(secondary)
- - 0
Improvements ✅
(primary)
- - 0
Improvements ✅
(secondary)
- - 0
All ❌✅ (primary) 1.5% [1.5%, 1.5%] 1

Cycles

Results (secondary -1.1%)

A less reliable metric. May be of interest, but not used to determine the overall result above.

mean range count
Regressions ❌
(primary)
- - 0
Regressions ❌
(secondary)
4.4% [4.4%, 4.4%] 1
Improvements ✅
(primary)
- - 0
Improvements ✅
(secondary)
-2.5% [-2.8%, -2.1%] 4
All ❌✅ (primary) - - 0

Binary size

This benchmark run did not return any relevant results for this metric.

Bootstrap: 474.976s -> 474.831s (-0.03%)
Artifact size: 391.06 MiB -> 391.05 MiB (-0.00%)

@rustbot rustbot removed the S-waiting-on-perf Status: Waiting on a perf run to be completed. label Nov 12, 2025
@bors
Copy link
Collaborator

bors commented Dec 12, 2025

☔ The latest upstream changes (presumably #149891) made this pull request unmergeable. Please resolve the merge conflicts.

Copy link
Member

@fmease fmease left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

What's the status of this PR? I've only given it a cursory glance. Perf came back clean, so does that mean the current approach can be taken or are there still other blockers?

Would you like me to review this code? I didn't review it so far because of the draft status & the failed CI (the failure seems to stem from lib alloc containing two unmergeable doctests).

View changes since this review

mergeable_tests: FxIndexMap<MergeableTestKey, Vec<(DocTestBuilder, ScrapedDocTest)>>,
// We pass this argument so we can drop it manually before using `exit`.
mut temp_dir: Option<TempDir>,
tcx: Option<TyCtxt<'_>>,
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

(preliminary review) this is always Some(_); I'm probably missing sth.

continue;
}
if let Some(tcx) = tcx {
tcx.node_span_lint(
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

[…] I'd really love to see if it's possible to emit lints from DiagCtxtHandle somehow,

That's not possible, it doesn't contain the necessary information. DiagCtxtHandle just stores low-level things in order to properly emit diagnostics. For lints on the other hand we need to be able to check if they were suppressed via lint control attributes or flags (allow, expect) which form a hierarchy (apart from that, it needs access to the query system (so TyCtxt) & some other data that's stored in the Session).

Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I haven't taken a deeper look at the code yet, so I'm not fully up to speed re. all the constraints that are imposed here but I can say that if lack of access to TyCtxt is a problem (as you've alluded to in the PR description), consider "buffering" the lint instead of calling node_span_lint eagerly. That's what rustc also does / has to do for early lints, it just puts them into a vector and emits them at a later point where TyCtxt is available.

Hopefully this is relevant ^^' I've yet to take a proper look. Of course if you want to avoid keeping TyCtxt or Session or XYZ alive for a longer time, buffering won't help.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

S-waiting-on-author Status: This is awaiting some action (such as code changes or more information) from the author. T-rustdoc Relevant to the rustdoc team, which will review and decide on the PR/issue.

Projects

None yet

Development

Successfully merging this pull request may close these issues.

6 participants