Skip to content

Conversation

@folkertdev
Copy link
Contributor

fixes #98342
r? @GuillaumeGomez

Renders intra-doc links in the note text of the #[deprecated] attribute. It is quite natural to suggest some other function to use there. So e.g.

#[deprecated(since = "0.0.0", note = "use [`std::mem::size_of`] instead")]

renders as

Screenshot from 2026-01-06 12-08-21

@rustbot rustbot added 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. T-rustdoc-frontend Relevant to the rustdoc-frontend team, which will review and decide on the web UI/UX output. labels Jan 6, 2026
Comment on lines +413 to +414
let (doc_fragments, other_attrs) =
attrs_to_doc_fragments(attrs.iter().map(|attr| (attr, None)), false);
Copy link
Contributor Author

Choose a reason for hiding this comment

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

the final argument switched from true to false here, which keeps the other attributes. That probably has perf consequences, but I did not want to just make up a doc fragment for the deprecation note.

@rust-log-analyzer

This comment has been minimized.

@folkertdev folkertdev force-pushed the deprecated-doc-intra-link branch from 65c9218 to aacb3d5 Compare January 6, 2026 11:59
@GuillaumeGomez
Copy link
Member

Very solid start, thanks! Can you add a rustdoc-ui tests to check what happens when an intra-doc link on a deprecated item cannot be resolved please? Then once done I'll do a final review and I think it's ready for merge.

While I'm at it, gonna run a perf check.

@bors try @rust-timer queue

@rust-timer

This comment has been minimized.

rust-bors bot added a commit that referenced this pull request Jan 6, 2026
@rust-bors

This comment has been minimized.

@rustbot rustbot added the S-waiting-on-perf Status: Waiting on a perf run to be completed. label Jan 6, 2026
@folkertdev folkertdev force-pushed the deprecated-doc-intra-link branch from aacb3d5 to 3663ab8 Compare January 6, 2026 16:18
error: unresolved link to `TypeAlias::hoge`
--> $DIR/deprecated.rs:4:1
|
LL | pub struct A;
Copy link
Member

Choose a reason for hiding this comment

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

Seems like the span is wrong.

Copy link
Contributor Author

Choose a reason for hiding this comment

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

Right, I figured out a simple way to at least to a bit better. Now the span of all attributes (including comments) is used.

Getting it to use just the span of #[deprecated] is not worth the trouble I think. At least to me it looks like that would be very invasive.

Copy link
Member

Choose a reason for hiding this comment

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

I'm surprised: we have the spans of the note, so why not use it instead of the whole attribute? Unless I missed something from https://doc.rust-lang.org/nightly/nightly-rustc/rustc_hir/attrs/struct.Deprecation.html ?

Copy link
Contributor Author

Choose a reason for hiding this comment

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

That struct does not yet have the Span, but the tricky part is integrating it into report_diagnostic.

Copy link
Member

Choose a reason for hiding this comment

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

Oh you're right, my bad. Do you want to add it or should it be done in a follow-up?

Copy link
Contributor Author

Choose a reason for hiding this comment

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

I don't really want to mess with report_diagnostic.

Copy link
Member

Choose a reason for hiding this comment

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

It's ok. It's already an improvement. Then please open an issue linking to this PR (and tag me on it so I can tackle in the next days), fix the CI error and then we're ready to go. :)

Copy link
Contributor Author

@folkertdev folkertdev Jan 6, 2026

Choose a reason for hiding this comment

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

CI is happy now and I created #150735

Copy link
Member

Choose a reason for hiding this comment

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

Thanks!

@rust-bors
Copy link
Contributor

rust-bors bot commented Jan 6, 2026

☀️ Try build successful (CI)
Build commit: a46cf6f (a46cf6f778e320a082226a26a4d62e5b14b55775, parent: da476f1942868cdf94ed88b01ea31170cfe95047)

@rust-timer

This comment has been minimized.

@rust-timer
Copy link
Collaborator

Finished benchmarking commit (a46cf6f): comparison URL.

Overall result: ✅ improvements - 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

Our most reliable metric. Used to determine the overall result above. However, even this metric can be noisy.

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

Max RSS (memory usage)

Results (primary 1.1%, secondary -0.8%)

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

mean range count
Regressions ❌
(primary)
1.1% [1.1%, 1.1%] 1
Regressions ❌
(secondary)
2.4% [2.4%, 2.4%] 1
Improvements ✅
(primary)
- - 0
Improvements ✅
(secondary)
-2.4% [-2.7%, -2.2%] 2
All ❌✅ (primary) 1.1% [1.1%, 1.1%] 1

Cycles

Results (secondary 3.9%)

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.9% [2.3%, 6.1%] 5
Improvements ✅
(primary)
- - 0
Improvements ✅
(secondary)
- - 0
All ❌✅ (primary) - - 0

Binary size

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

Bootstrap: 473.133s -> 473.03s (-0.02%)
Artifact size: 390.77 MiB -> 390.78 MiB (0.00%)

@rustbot rustbot removed the S-waiting-on-perf Status: Waiting on a perf run to be completed. label Jan 6, 2026
@folkertdev folkertdev force-pushed the deprecated-doc-intra-link branch from 3663ab8 to fc8a382 Compare January 6, 2026 18:41
@rust-log-analyzer

This comment has been minimized.

@GuillaumeGomez
Copy link
Member

Looks all good to me, thanks!

@bors r+ rollup

@bors
Copy link
Collaborator

bors commented Jan 7, 2026

📌 Commit c01b87b has been approved by GuillaumeGomez

It is now in the queue for this repository.

@bors
Copy link
Collaborator

bors commented Jan 7, 2026

🌲 The tree is currently closed for pull requests below priority 1000. This pull request will be tested once the tree is reopened.

@bors bors 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 Jan 7, 2026
Kobzol added a commit to Kobzol/rust that referenced this pull request Jan 7, 2026
@matthiaskrgr
Copy link
Member

@bors r-
may need rebase or something? #150796 (comment)

@rust-bors rust-bors bot 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-bors Status: Waiting on bors to run and complete tests. Bors will change the label on completion. labels Jan 8, 2026
@rust-bors
Copy link
Contributor

rust-bors bot commented Jan 8, 2026

Commit c01b87b has been unapproved.

@folkertdev folkertdev force-pushed the deprecated-doc-intra-link branch from c01b87b to 3be74a7 Compare January 8, 2026 10:36
@rustbot
Copy link
Collaborator

rustbot commented Jan 8, 2026

This PR was rebased onto a different main commit. Here's a range-diff highlighting what actually changed.

Rebasing is a normal part of keeping PRs up to date, so no action is needed—this note is just to help reviewers.

@folkertdev
Copy link
Contributor Author

Some files were moved around in #150645, a rebase fixed that.

@bors r=GuillaumeGomez

@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-author Status: This is awaiting some action (such as code changes or more information) from the author. labels Jan 8, 2026
@rust-bors
Copy link
Contributor

rust-bors bot commented Jan 8, 2026

📌 Commit 3be74a7 has been approved by GuillaumeGomez

It is now in the queue for this repository.

matthiaskrgr added a commit to matthiaskrgr/rust that referenced this pull request Jan 8, 2026
…aumeGomez

Deprecated doc intra link

fixes rust-lang#98342
r? @GuillaumeGomez

Renders intra-doc links in the note text of the `#[deprecated]` attribute. It is quite natural to suggest some other function to use there. So e.g.

```rust
#[deprecated(since = "0.0.0", note = "use [`std::mem::size_of`] instead")]
```

renders as

<img width="431" height="74" alt="Screenshot from 2026-01-06 12-08-21" src="https://github.com/user-attachments/assets/8f608f08-13ee-4bbf-a631-6008058a51e2" />
rust-bors bot added a commit that referenced this pull request Jan 8, 2026
Rollup of 12 pull requests

Successful merges:

 - #149961 (tidy: add if-installed prefix condition to extra checks system)
 - #150475 (std: sys: fs: uefi: Implement initial File)
 - #150533 (std: sys: fs: uefi: Implement remove_dir_all)
 - #150549 (fix missing_panics_doc in `std::os::fd::owned`)
 - #150699 (MGCA: Support literals as direct const arguments)
 - #150721 (Deprecated doc intra link)
 - #150752 (Update libc to v0.2.180)
 - #150802 (Minor cleanups to fn_abi_new_uncached)
 - #150803 (compiler-builtins subtree update)
 - #150809 (Update `literal-escaper` version to `0.0.7`)
 - #150811 (Store defids instead of symbol names in the aliases list)
 - #150825 (Query associated_item_def_ids when needed)

r? @ghost
matthiaskrgr added a commit to matthiaskrgr/rust that referenced this pull request Jan 8, 2026
…aumeGomez

Deprecated doc intra link

fixes rust-lang#98342
r? @GuillaumeGomez

Renders intra-doc links in the note text of the `#[deprecated]` attribute. It is quite natural to suggest some other function to use there. So e.g.

```rust
#[deprecated(since = "0.0.0", note = "use [`std::mem::size_of`] instead")]
```

renders as

<img width="431" height="74" alt="Screenshot from 2026-01-06 12-08-21" src="https://github.com/user-attachments/assets/8f608f08-13ee-4bbf-a631-6008058a51e2" />
matthiaskrgr added a commit to matthiaskrgr/rust that referenced this pull request Jan 8, 2026
…aumeGomez

Deprecated doc intra link

fixes rust-lang#98342
r? @GuillaumeGomez

Renders intra-doc links in the note text of the `#[deprecated]` attribute. It is quite natural to suggest some other function to use there. So e.g.

```rust
#[deprecated(since = "0.0.0", note = "use [`std::mem::size_of`] instead")]
```

renders as

<img width="431" height="74" alt="Screenshot from 2026-01-06 12-08-21" src="https://github.com/user-attachments/assets/8f608f08-13ee-4bbf-a631-6008058a51e2" />
matthiaskrgr added a commit to matthiaskrgr/rust that referenced this pull request Jan 8, 2026
…aumeGomez

Deprecated doc intra link

fixes rust-lang#98342
r? @GuillaumeGomez

Renders intra-doc links in the note text of the `#[deprecated]` attribute. It is quite natural to suggest some other function to use there. So e.g.

```rust
#[deprecated(since = "0.0.0", note = "use [`std::mem::size_of`] instead")]
```

renders as

<img width="431" height="74" alt="Screenshot from 2026-01-06 12-08-21" src="https://github.com/user-attachments/assets/8f608f08-13ee-4bbf-a631-6008058a51e2" />
matthiaskrgr added a commit to matthiaskrgr/rust that referenced this pull request Jan 8, 2026
…aumeGomez

Deprecated doc intra link

fixes rust-lang#98342
r? @GuillaumeGomez

Renders intra-doc links in the note text of the `#[deprecated]` attribute. It is quite natural to suggest some other function to use there. So e.g.

```rust
#[deprecated(since = "0.0.0", note = "use [`std::mem::size_of`] instead")]
```

renders as

<img width="431" height="74" alt="Screenshot from 2026-01-06 12-08-21" src="https://github.com/user-attachments/assets/8f608f08-13ee-4bbf-a631-6008058a51e2" />
matthiaskrgr added a commit to matthiaskrgr/rust that referenced this pull request Jan 8, 2026
…aumeGomez

Deprecated doc intra link

fixes rust-lang#98342
r? @GuillaumeGomez

Renders intra-doc links in the note text of the `#[deprecated]` attribute. It is quite natural to suggest some other function to use there. So e.g.

```rust
#[deprecated(since = "0.0.0", note = "use [`std::mem::size_of`] instead")]
```

renders as

<img width="431" height="74" alt="Screenshot from 2026-01-06 12-08-21" src="https://github.com/user-attachments/assets/8f608f08-13ee-4bbf-a631-6008058a51e2" />
matthiaskrgr added a commit to matthiaskrgr/rust that referenced this pull request Jan 8, 2026
…aumeGomez

Deprecated doc intra link

fixes rust-lang#98342
r? @GuillaumeGomez

Renders intra-doc links in the note text of the `#[deprecated]` attribute. It is quite natural to suggest some other function to use there. So e.g.

```rust
#[deprecated(since = "0.0.0", note = "use [`std::mem::size_of`] instead")]
```

renders as

<img width="431" height="74" alt="Screenshot from 2026-01-06 12-08-21" src="https://github.com/user-attachments/assets/8f608f08-13ee-4bbf-a631-6008058a51e2" />
rust-bors bot added a commit that referenced this pull request Jan 8, 2026
Rollup of 11 pull requests

Successful merges:

 - #149961 (tidy: add if-installed prefix condition to extra checks system)
 - #150475 (std: sys: fs: uefi: Implement initial File)
 - #150533 (std: sys: fs: uefi: Implement remove_dir_all)
 - #150549 (fix missing_panics_doc in `std::os::fd::owned`)
 - #150699 (MGCA: Support literals as direct const arguments)
 - #150721 (Deprecated doc intra link)
 - #150802 (Minor cleanups to fn_abi_new_uncached)
 - #150803 (compiler-builtins subtree update)
 - #150809 (Update `literal-escaper` version to `0.0.7`)
 - #150811 (Store defids instead of symbol names in the aliases list)
 - #150825 (Query associated_item_def_ids when needed)

r? @ghost
@rust-bors rust-bors bot merged commit d763ffa into rust-lang:main Jan 9, 2026
11 checks passed
@rustbot rustbot added this to the 1.94.0 milestone Jan 9, 2026
rust-timer added a commit that referenced this pull request Jan 9, 2026
Rollup merge of #150721 - deprecated-doc-intra-link, r=GuillaumeGomez

Deprecated doc intra link

fixes #98342
r? @GuillaumeGomez

Renders intra-doc links in the note text of the `#[deprecated]` attribute. It is quite natural to suggest some other function to use there. So e.g.

```rust
#[deprecated(since = "0.0.0", note = "use [`std::mem::size_of`] instead")]
```

renders as

<img width="431" height="74" alt="Screenshot from 2026-01-06 12-08-21" src="https://github.com/user-attachments/assets/8f608f08-13ee-4bbf-a631-6008058a51e2" />
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

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. T-rustdoc-frontend Relevant to the rustdoc-frontend team, which will review and decide on the web UI/UX output.

Projects

None yet

Development

Successfully merging this pull request may close these issues.

Intra-doc links don't work inside deprecated notes

7 participants