Skip to content

Move #[doc(inline)] and #[doc(no_inline)] validation into rustc_attr_parsing - #163673

Merged
rust-bors[bot] merged 7 commits into
rust-lang:mainfrom
darkraider01:doc-inline-validation
Oct 6, 2026
Merged

rust-bors[bot] merged 7 commits into
rust-lang:mainfrom
darkraider01:doc-inline-validation

Conversation

@darkraider01

@darkraider01 darkraider01 commented Oct 2, 2026 •

Copy link
Copy Markdown
Contributor

View all comments

Part of #153101

This migrates #[doc(inline)] and #[doc(no_inline)] validation from rustc_passes into DocParser in rustc_attr_parsing. It checks for conflicting inlining attributes and non-use targets, and tweaks rustdoc's early abort so lowering errors don't suppress other attribute diagnostics, also added new UI tests in doc-inline-validation.rs.

@rustbot

rustbot commented Oct 2, 2026

Copy link
Copy Markdown
Collaborator

Some changes occurred in compiler/rustc_passes/src/check_attr.rs

cc @jdonszelmann, @JonathanBrouwer

Some changes occurred in compiler/rustc_attr_parsing

cc @jdonszelmann, @JonathanBrouwer

@rustbot rustbot added A-attributes Area: Attributes (`#[…]`, `#![…]`) S-waiting-on-review Status: Awaiting review from the assignee but also interested parties. T-compiler Relevant to the compiler team, which will review and decide on the PR/issue. T-rustdoc Relevant to the rustdoc team, which will review and decide on the PR/issue. labels Oct 2, 2026
@rustbot

rustbot commented Oct 2, 2026

Copy link
Copy Markdown
Collaborator

r? @oli-obk

rustbot has assigned @oli-obk.
They will have a look at your PR within the next two weeks and either review your PR or reassign to another reviewer.

Use r? to explicitly pick a reviewer

Why was this reviewer chosen?

The reviewer was selected based on:

  • Owners of files modified in this PR: compiler
  • compiler expanded to 77 candidates
  • Random selection from 19 candidates

Comment thread src/librustdoc/core.rs
@@ -367,13 +367,14 @@ pub(crate) fn run_global_ctxt(

// NOTE: These are copy/pasted from typeck/lib.rs and should be kept in sync with those changes.
tcx.sess.time("wf_checking", || tcx.ensure_ok().check_type_wf(()));
tcx.sess.time("check_mod_attrs", || {

@darkraider01 darkraider01 Oct 2, 2026 •

Copy link
Copy Markdown
Contributor Author

Choose a reason for hiding this comment

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

Had to move this before abort_if_errors. Since conflicting attributes are caught during lowering now, rustdoc was exiting early and swallowing the other errors in invalid-doc-attr.rs.

View changes since the review

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

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

@GuillaumeGomez could you confirm this is ok? I'm not familiar with why this abort_if_errors is there

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

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

I'm surprised this change is needed. If the rustdoc tests pass and the perf check is happy, then so am I.

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

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

Just double-checked and yes, seems ok. We'll wait for tests to confirm but seems fine.

}
}

fn deferred_finalize_check(&self) -> Option<(FinalizeCheckFn, Span)> {

@darkraider01 darkraider01 Oct 2, 2026 •

Copy link
Copy Markdown
Contributor Author

Choose a reason for hiding this comment

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

Deferred this check since we need the resolved target from FinalizeCheckContext to check if it's actually a use item.

View changes since the review

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

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

Is the resolved target needed? I don't see where you're using it

Copy link
Copy Markdown
Contributor Author

Choose a reason for hiding this comment

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

Sorry, I confused the item’s syntactic target with the resolved import target. This only checks Use or ExternCrate, which FinalizeContext already provides. I’ll move it into finalize.

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

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

You can also consider putting it in parse_inline

Copy link
Copy Markdown
Contributor Author

Choose a reason for hiding this comment

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

Moved the conflict check into parse_inline and made inline an Option. The target check is still deferred since finalize takes an immutable context. That also avoids an extra target lint when the attributes already conflict.

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

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

I think you should also just be able to put the target check in the inline parser right?

Copy link
Copy Markdown
Contributor Author

Choose a reason for hiding this comment

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

Yes, AcceptContext already has the target and can emit the lint. I’ll move that check into parse_inline and remove the deferred callback.

@rust-log-analyzer

This comment has been minimized.

@rust-log-analyzer

This comment has been minimized.

@JonathanBrouwer

Copy link
Copy Markdown
Member

r? me

}
}

fn finalize_check(cx: &mut FinalizeCheckContext<'_, '_>, _attr_span: Span) {

@JonathanBrouwer JonathanBrouwer Oct 5, 2026 •

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

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

Can we move this logic to the inline parser?
Then we can solve this comment and make inline an Option

// at the same time as the other doc attributes, we store a list instead of using `Option`.

View changes since the review

Comment thread src/librustdoc/core.rs
@@ -367,13 +367,14 @@ pub(crate) fn run_global_ctxt(

// NOTE: These are copy/pasted from typeck/lib.rs and should be kept in sync with those changes.
tcx.sess.time("wf_checking", || tcx.ensure_ok().check_type_wf(()));
tcx.sess.time("check_mod_attrs", || {

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

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

@GuillaumeGomez could you confirm this is ok? I'm not familiar with why this abort_if_errors is there

@rustbot rustbot added S-waiting-on-author Status: This is awaiting some action (such as code changes or more information) from the author. and removed S-waiting-on-review Status: Awaiting review from the assignee but also interested parties. labels Oct 5, 2026
@rustbot

rustbot commented Oct 5, 2026

Copy link
Copy Markdown
Collaborator

Reminder, once the PR becomes ready for a review, use @rustbot ready.

@GuillaumeGomez

Copy link
Copy Markdown
Member

@bors try @rust-timer queue

@rust-timer

This comment has been minimized.

@rustbot rustbot added the S-waiting-on-perf Status: Waiting on a perf run to be completed. label Oct 5, 2026
@rust-bors

This comment has been minimized.

rust-bors Bot pushed a commit that referenced this pull request Oct 5, 2026
Move #[doc(inline)] and #[doc(no_inline)] validation into rustc_attr_parsing
@GuillaumeGomez

Copy link
Copy Markdown
Member

Actually it's completely unneeded. Sorry for the noise. ^^'

@bors try-

@rust-bors

rust-bors Bot commented Oct 5, 2026

Copy link
Copy Markdown
Contributor

Unknown command "try-". Run @bors help or go to https://bors.rust-lang.org/help to see available commands.

@rust-bors

rust-bors Bot commented Oct 5, 2026

Copy link
Copy Markdown
Contributor

☀️ Try build successful (CI)
Build commit: 61e9eef (61e9eefe54c9e382b1ccf541d9f4ae2942d9c4d3)
Base parent: 602727f (602727f26878dcf9eb2999e2f58e5df1269ff47e)

@rust-timer

This comment has been minimized.

@rustbot

rustbot commented Oct 5, 2026

Copy link
Copy Markdown
Collaborator

Some changes occurred in compiler/rustc_attr_ir

cc @jdonszelmann, @JonathanBrouwer

@rustbot rustbot added the A-rustdoc-json Area: Rustdoc JSON backend label Oct 5, 2026
@darkraider01

Copy link
Copy Markdown
Contributor Author

@rustbot ready

@rustbot rustbot added S-waiting-on-review Status: Awaiting review from the assignee but also interested parties. and removed S-waiting-on-author Status: This is awaiting some action (such as code changes or more information) from the author. labels Oct 5, 2026
pub(crate) struct DocParser {
attribute: DocAttribute,
nb_doc_attrs: usize,
inline_conflict: bool,

@JonathanBrouwer JonathanBrouwer Oct 5, 2026 •

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

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

Is this needed?
I'd lean toward emitting multiple diagnostics if there are multiple wrong attributes being fine

View changes since the review

@darkraider01 darkraider01 Oct 5, 2026 •

Copy link
Copy Markdown
Contributor Author

Choose a reason for hiding this comment

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

Moved the target check into parse_inline and removed the conflict flag and deferred callback. It now reports multiple diagnostics when multiple attributes are invalid, and I’ve updated the tests accordingly.
@rustbot ready

Comment thread compiler/rustc_attr_ir/src/data_structures.rs
@rustbot rustbot added S-waiting-on-author Status: This is awaiting some action (such as code changes or more information) from the author. and removed S-waiting-on-review Status: Awaiting review from the assignee but also interested parties. labels Oct 5, 2026
@rust-timer

Copy link
Copy Markdown
Collaborator

Finished benchmarking commit (61e9eef): comparison URL.

Overall result: no relevant changes - no action needed

Benchmarking means the PR may be perf-sensitive. Consider adding rollup=never if this change is not fit for rolling up.

@rustbot label: -S-waiting-on-perf -perf-regression

Instruction count

This perf run didn't have relevant results for this metric.

Max RSS (memory usage)

Results (secondary 1.6%)

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)
6.5% [6.5%, 6.5%] 1
Improvements ✅
(primary)
- - 0
Improvements ✅
(secondary)
-3.3% [-3.3%, -3.3%] 1
All ❌✅ (primary) - - 0

Cycles

Results (primary -2.2%, secondary 3.2%)

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)
3.2% [2.3%, 4.1%] 2
Improvements ✅
(primary)
-2.2% [-2.2%, -2.2%] 1
Improvements ✅
(secondary)
- - 0
All ❌✅ (primary) -2.2% [-2.2%, -2.2%] 1

Binary size

This perf run didn't have relevant results for this metric.

Bootstrap: 490.152s -> 492.034s (0.38%)
Artifact size: 408.63 MiB -> 408.69 MiB (0.01%)

@rustbot rustbot removed the S-waiting-on-perf Status: Waiting on a perf run to be completed. label Oct 5, 2026
@rustbot rustbot added S-waiting-on-review Status: Awaiting review from the assignee but also interested parties. and removed S-waiting-on-author Status: This is awaiting some action (such as code changes or more information) from the author. labels Oct 5, 2026

@JonathanBrouwer JonathanBrouwer left a comment •

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

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

@bors r+ rollup
Thanks a lot for the work!

View changes since this review

@rust-bors

rust-bors Bot commented Oct 5, 2026

Copy link
Copy Markdown
Contributor

📌 Commit 5d640cb has been approved by JonathanBrouwer

It is now in the queue for this repository.

@rust-bors rust-bors Bot added S-waiting-on-bors Status: Waiting on bors to run and complete tests. Bors will change the label on completion. and removed S-waiting-on-review Status: Awaiting review from the assignee but also interested parties. labels Oct 5, 2026
JonathanBrouwer added a commit to JonathanBrouwer/rust that referenced this pull request Oct 5, 2026
…, r=JonathanBrouwer

Move #[doc(inline)] and #[doc(no_inline)] validation into rustc_attr_parsing

Part of rust-lang#153101

This migrates `#[doc(inline)]` and `#[doc(no_inline)]` validation from `rustc_passes` into `DocParser` in `rustc_attr_parsing`. It checks for conflicting inlining attributes and non-use targets, and tweaks rustdoc's early abort so lowering errors don't suppress other attribute diagnostics, also added new UI tests in doc-inline-validation.rs.
rust-bors Bot pushed a commit that referenced this pull request Oct 5, 2026
…uwer

Rollup of 4 pull requests

Successful merges:

 - #160915 ([rustdoc] Fix how `Deref` items is handled.)
 - #163267 (fix `VisibleForLeakCheck` in `RegionOutlives` fast path)
 - #163673 (Move #[doc(inline)] and #[doc(no_inline)] validation into rustc_attr_parsing)
 - #163814 (Add some comments and docs related to `AllocatorNightly`)
rust-bors Bot pushed a commit that referenced this pull request Oct 5, 2026
…uwer

Rollup of 5 pull requests

Successful merges:

 - #160915 ([rustdoc] Fix how `Deref` items is handled.)
 - #163267 (fix `VisibleForLeakCheck` in `RegionOutlives` fast path)
 - #163673 (Move #[doc(inline)] and #[doc(no_inline)] validation into rustc_attr_parsing)
 - #163795 (When documenting without a specified `--edition`, emit a message)
 - #163814 (Add some comments and docs related to `AllocatorNightly`)
rust-bors Bot pushed a commit that referenced this pull request Oct 5, 2026
…uwer

Rollup of 5 pull requests

Successful merges:

 - #160915 ([rustdoc] Fix how `Deref` items is handled.)
 - #163267 (fix `VisibleForLeakCheck` in `RegionOutlives` fast path)
 - #163673 (Move #[doc(inline)] and #[doc(no_inline)] validation into rustc_attr_parsing)
 - #163795 (When documenting without a specified `--edition`, emit a message)
 - #163814 (Add some comments and docs related to `AllocatorNightly`)
rust-bors Bot pushed a commit that referenced this pull request Oct 5, 2026
…uwer

Rollup of 5 pull requests

Successful merges:

 - #160915 ([rustdoc] Fix how `Deref` items is handled.)
 - #163267 (fix `VisibleForLeakCheck` in `RegionOutlives` fast path)
 - #163673 (Move #[doc(inline)] and #[doc(no_inline)] validation into rustc_attr_parsing)
 - #163795 (When documenting without a specified `--edition`, emit a message)
 - #163814 (Add some comments and docs related to `AllocatorNightly`)
@rust-bors
rust-bors Bot merged commit 84ed8b9 into rust-lang:main Oct 6, 2026
14 checks passed
@rustbot rustbot added this to the 1.101.0 milestone Oct 6, 2026
rust-bors Bot pushed a commit that referenced this pull request Oct 6, 2026
Rollup merge of #163673 - darkraider01:doc-inline-validation, r=JonathanBrouwer

Move #[doc(inline)] and #[doc(no_inline)] validation into rustc_attr_parsing

Part of #153101

This migrates `#[doc(inline)]` and `#[doc(no_inline)]` validation from `rustc_passes` into `DocParser` in `rustc_attr_parsing`. It checks for conflicting inlining attributes and non-use targets, and tweaks rustdoc's early abort so lowering errors don't suppress other attribute diagnostics, also added new UI tests in doc-inline-validation.rs.
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

A-attributes Area: Attributes (`#[…]`, `#![…]`) A-rustdoc-json Area: Rustdoc JSON backend S-waiting-on-bors Status: Waiting on bors to run and complete tests. Bors will change the label on completion. T-compiler Relevant to the compiler team, which will review and decide on the PR/issue. 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.

7 participants