Work around rustdoc ICE caused by intra-doc links in deprecated notes#1688
Work around rustdoc ICE caused by intra-doc links in deprecated notes#1688leighmcculloch wants to merge 1 commit into
Conversation
There was a problem hiding this comment.
Pull request overview
This PR fixes a rustdoc Internal Compiler Error (ICE) caused by intra-doc link syntax in #[deprecated(note = "...")] attributes. The issue occurs when rustdoc attempts to resolve bracketed text as intra-doc links in deprecated notes, which can cause crashes when the links are invalid or problematic.
Changes:
- Removed bracket syntax from deprecated notes in 5 files to prevent rustdoc from attempting intra-doc link resolution
- Most changes simply remove brackets (e.g.,
[Env::try_invoke]→Env::try_invoke) - One file attempts to escape brackets with backslashes, which may cause display issues
Reviewed changes
Copilot reviewed 5 out of 5 changed files in this pull request and generated 1 comment.
Show a summary per file
| File | Description |
|---|---|
| soroban-sdk/src/testutils/arbitrary.rs | Removed brackets from Env::try_invoke reference in deprecated note |
| soroban-sdk/src/symbol.rs | Removed brackets from symbol_short!() reference in deprecated note |
| soroban-sdk/src/logs.rs | Removed brackets from Logs::add reference in deprecated note |
| soroban-sdk/src/events.rs | Attempted to escape brackets with backslashes in #[contractevent] reference |
| soroban-sdk/src/env.rs | Removed brackets from Env::logs and Env::register_stellar_asset_contract_v2 references in deprecated notes |
| /// - [Bytes]/[BytesN][crate::BytesN] longer than 32 bytes | ||
| /// - [contracttype] | ||
| #[deprecated(note = "use the #[contractevent] macro on a contract event type")] | ||
| #[deprecated(note = "use the #\\[contractevent\\] macro on a contract event type")] |
There was a problem hiding this comment.
The escaping approach used here may be incorrect. With #\\[contractevent\\], the double backslashes will be interpreted as literal backslashes, causing the deprecated message to display as use the #\[contractevent\] macro instead of use the #[contractevent] macro.
Consider either:
- Removing the brackets entirely:
use the contractevent macro on a contract event type - Using a different phrasing:
use the 'contractevent' attribute macro on a contract event type
This would be consistent with the approach taken in the other files where brackets were simply removed rather than escaped.
| #[deprecated(note = "use the #\\[contractevent\\] macro on a contract event type")] | |
| #[deprecated(note = "use the contractevent macro on a contract event type")] |
|
The ICE has been fixed in rust nightly so this is no longer needed. |
What
Remove or escape square brackets in
#[deprecated(note = "...")]attributes that were being parsed as intra-doc links by rustdoc.Why
Running
cargo +nightly doccauses an internal compiler error (ICE) in rustdoc when it attempts to resolve intra-doc links like[Env::try_invoke]within#[deprecated]attribute notes. When the deprecated item is re-exported via glob import (pub use module::*), rustdoc fails to resolve the link in the correct scope and panics instead of gracefully handling the unresolved link.This is a workaround for a bug in rustdoc that has been reported upstream:
This workaround is to unblock PRs on this repo, such as: