Skip to content

Work around rustdoc ICE caused by intra-doc links in deprecated notes#1688

Closed
leighmcculloch wants to merge 1 commit into
mainfrom
work-around-rust-151411
Closed

Work around rustdoc ICE caused by intra-doc links in deprecated notes#1688
leighmcculloch wants to merge 1 commit into
mainfrom
work-around-rust-151411

Conversation

@leighmcculloch
Copy link
Copy Markdown
Member

@leighmcculloch leighmcculloch commented Jan 20, 2026

What

Remove or escape square brackets in #[deprecated(note = "...")] attributes that were being parsed as intra-doc links by rustdoc.

Why

Running cargo +nightly doc causes 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:

@leighmcculloch leighmcculloch requested a review from a team January 20, 2026 14:05
@leighmcculloch leighmcculloch marked this pull request as ready for review January 20, 2026 14:05
@leighmcculloch leighmcculloch changed the title Fix rustdoc ICE caused by intra-doc links in deprecated notes Work around rustdoc ICE caused by intra-doc links in deprecated notes Jan 20, 2026
Copy link
Copy Markdown
Contributor

Copilot AI left a comment

Choose a reason for hiding this comment

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

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

Comment thread soroban-sdk/src/events.rs
/// - [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")]
Copy link

Copilot AI Jan 20, 2026

Choose a reason for hiding this comment

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

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:

  1. Removing the brackets entirely: use the contractevent macro on a contract event type
  2. 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.

Suggested change
#[deprecated(note = "use the #\\[contractevent\\] macro on a contract event type")]
#[deprecated(note = "use the contractevent macro on a contract event type")]

Copilot uses AI. Check for mistakes.
@leighmcculloch
Copy link
Copy Markdown
Member Author

The ICE has been fixed in rust nightly so this is no longer needed.

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

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

3 participants