Skip to content

deprecate std::char constants and functions - #153873

Merged
rust-bors[bot] merged 1 commit into
rust-lang:mainfrom
folkertdev:deprecate-char-max
Apr 19, 2026
Merged

deprecate std::char constants and functions#153873
rust-bors[bot] merged 1 commit into
rust-lang:mainfrom
folkertdev:deprecate-char-max

Conversation

@folkertdev

@folkertdev folkertdev commented Mar 14, 2026

Copy link
Copy Markdown
Contributor

similar to how constants in those modules for numeric types have been deprecated. The std::char module contains:

Three stable constants that this PR deprecates. These already link to their associated constant equivalents.

  • MAX
  • REPLACEMENT_CHARACTER
  • UNICODE_VERSION

two unstable constants that this PR removes. The constants are already stablized as associated constants on char.

  • MAX_LEN_UTF8
  • MAX_LEN_UTF16

Four stable functions that this PR deprecates. These already link to their method equivalents.

  • fn decode_utf16
  • fn from_digit
  • fn from_u32
  • fn from_u32_unchecked⚠

discussion at #t-libs > should `std::char::{MIN, MAX}` be deprecated?.

r? libs-api

@folkertdev folkertdev added the I-libs-api-nominated [DEPRECATED; DO NOT USE] label Mar 14, 2026
@rustbot rustbot added S-waiting-on-review Status: Awaiting review from the assignee but also interested parties. T-libs Relevant to the library team, which will review and decide on the PR/issue. labels Mar 14, 2026
@folkertdev folkertdev changed the title deprecate std::char::MAX deprecate std::char constants and functions Mar 14, 2026
@rust-log-analyzer

This comment has been minimized.

Comment on lines -98 to -106
/// The maximum number of bytes required to [encode](char::encode_utf8) a `char` to
/// UTF-8 encoding.
#[unstable(feature = "char_max_len", issue = "121714")]
pub const MAX_LEN_UTF8: usize = char::MAX_LEN_UTF8;

/// The maximum number of two-byte units required to [encode](char::encode_utf16) a `char`
/// to UTF-16 encoding.
#[unstable(feature = "char_max_len", issue = "121714")]
pub const MAX_LEN_UTF16: usize = char::MAX_LEN_UTF16;

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.

There is currently no core::char::consts module, so currently these constants are just gone. Should they be added as associated consts, or should that core::char::consts module be added?

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.

note to self: the consts being gone completely is the cause of the char_max_len CI failure.

@pitaj pitaj Mar 15, 2026

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

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