Skip to content

deprecate std::char constants and functions#153873

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

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

Conversation

@folkertdev
Copy link
Copy Markdown
Contributor

@folkertdev folkertdev commented Mar 14, 2026

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 Nominated for discussion during a libs-api team meeting. 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.

Copy link
Copy Markdown
Contributor

@pitaj pitaj Mar 15, 2026

Choose a reason for hiding this comment

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

They already are associated consts: https://doc.rust-lang.org/stable/std/primitive.char.html#associatedconstant.MAX_LEN_UTF8

And were stabilized under the feature char_max_len_assoc

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.

Nice, these can probably just be removed then.

similar to how constants in those modules for numeric types have been deprecated
@rustbot
Copy link
Copy Markdown
Collaborator

rustbot commented Mar 15, 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.

@Amanieu
Copy link
Copy Markdown
Member

Amanieu commented Mar 17, 2026

@rfcbot merge libs-api

@Amanieu Amanieu removed the I-libs-api-nominated Nominated for discussion during a libs-api team meeting. label Mar 17, 2026
@rust-rfcbot
Copy link
Copy Markdown
Collaborator

rust-rfcbot commented Mar 17, 2026

Team member @Amanieu has proposed to merge this. The next step is review by the rest of the tagged team members:

No concerns currently listed.

Once a majority of reviewers approve (and at most 2 approvals are outstanding), this will enter its final comment period. If you spot a major issue that hasn't been raised at any point in this process, please speak up!

See this document for info about what commands tagged team members can give me.

@rust-rfcbot rust-rfcbot added proposed-final-comment-period Proposed to merge/close by relevant subteam, see T-<team> label. Will enter FCP once signed off. disposition-merge This issue / PR is in PFCP or FCP with a disposition to merge it. labels Mar 17, 2026
@folkertdev folkertdev added the T-libs-api Relevant to the library API team, which will review and decide on the PR/issue. label Mar 24, 2026
@joshtriplett
Copy link
Copy Markdown
Member

joshtriplett commented Apr 7, 2026

The only downside of a deprecation is that we still don't support use char::REPLACEMENT_CHARACTER; for associated constants. But still, 👍.

@joshtriplett
Copy link
Copy Markdown
Member

@rfcbot reviewed

@rust-rfcbot rust-rfcbot added final-comment-period In the final comment period and will be merged soon unless new substantive objections are raised. and removed proposed-final-comment-period Proposed to merge/close by relevant subteam, see T-<team> label. Will enter FCP once signed off. labels Apr 7, 2026
@rust-rfcbot
Copy link
Copy Markdown
Collaborator

🔔 This is now entering its final comment period, as per the review above. 🔔

@RalfJung
Copy link
Copy Markdown
Member

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

What do you mean by "method equivalents"? They link to associated const alternatives, not methods.

@folkertdev
Copy link
Copy Markdown
Contributor Author

Must have been a copy-paste error. fixed.

@rust-rfcbot rust-rfcbot added finished-final-comment-period The final comment period is finished for this PR / Issue. to-announce Announce this issue on triage meeting and removed final-comment-period In the final comment period and will be merged soon unless new substantive objections are raised. labels Apr 17, 2026
@rust-rfcbot
Copy link
Copy Markdown
Collaborator

The final comment period, with a disposition to merge, as per the review above, is now complete.

As the automated representative of the governance process, I would like to thank the author for their work and everyone else who contributed.

@folkertdev
Copy link
Copy Markdown
Contributor Author

r? libs

@Mark-Simulacrum
Copy link
Copy Markdown
Member

@bors r+ rollup

@rust-bors
Copy link
Copy Markdown
Contributor

rust-bors Bot commented Apr 18, 2026

📌 Commit ee9b61c has been approved by Mark-Simulacrum

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 Apr 18, 2026
jhpratt added a commit to jhpratt/rust that referenced this pull request Apr 19, 2026
…ark-Simulacrum

deprecate `std::char` constants and functions

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 &rust-lang#96;std::char::{MIN, MAX}&rust-lang#96; be deprecated?](https://rust-lang.zulipchat.com/#narrow/channel/219381-t-libs/topic/should.20.60std.3A.3Achar.3A.3A.7BMIN.2C.20MAX.7D.60.20be.20deprecated.3F/with/579444750).

r? libs-api
rust-bors Bot pushed a commit that referenced this pull request Apr 19, 2026
Rollup of 8 pull requests

Successful merges:

 - #155370 (Add regression test for dead code elimination with drop + panic)
 - #154823 (Replace the spdx-rs dependency with a minimal in-tree SPDX tag-value parser)
 - #155352 (triagebot.toml: Sync `assign.owners` with `autolabel."T-compiler"`)
 - #155431 (Add temporary scope to assert_matches)
 - #152995 (ACP Implementation of PermissionsExt for Windows )
 - #153873 (deprecate `std::char` constants and functions)
 - #154654 (Move `std::io::ErrorKind` to `core::io`)
 - #154865 (libtest: use binary search for --exact test filtering)
jhpratt added a commit to jhpratt/rust that referenced this pull request Apr 19, 2026
…ark-Simulacrum

deprecate `std::char` constants and functions

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 &rust-lang#96;std::char::{MIN, MAX}&rust-lang#96; be deprecated?](https://rust-lang.zulipchat.com/#narrow/channel/219381-t-libs/topic/should.20.60std.3A.3Achar.3A.3A.7BMIN.2C.20MAX.7D.60.20be.20deprecated.3F/with/579444750).

r? libs-api
rust-bors Bot pushed a commit that referenced this pull request Apr 19, 2026
Rollup of 9 pull requests

Successful merges:

 - #155370 (Add regression test for dead code elimination with drop + panic)
 - #154823 (Replace the spdx-rs dependency with a minimal in-tree SPDX tag-value parser)
 - #154972 (Implement `core::arch::return_address` and tests)
 - #155294 (Add test for coalescing of diagnostic attribute duplicates)
 - #155352 (triagebot.toml: Sync `assign.owners` with `autolabel."T-compiler"`)
 - #155431 (Add temporary scope to assert_matches)
 - #152995 (ACP Implementation of PermissionsExt for Windows )
 - #153873 (deprecate `std::char` constants and functions)
 - #154865 (libtest: use binary search for --exact test filtering)
jhpratt added a commit to jhpratt/rust that referenced this pull request Apr 19, 2026
…ark-Simulacrum

deprecate `std::char` constants and functions

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 &rust-lang#96;std::char::{MIN, MAX}&rust-lang#96; be deprecated?](https://rust-lang.zulipchat.com/#narrow/channel/219381-t-libs/topic/should.20.60std.3A.3Achar.3A.3A.7BMIN.2C.20MAX.7D.60.20be.20deprecated.3F/with/579444750).

r? libs-api
rust-bors Bot pushed a commit that referenced this pull request Apr 19, 2026
Rollup of 10 pull requests

Successful merges:

 - #155370 (Add regression test for dead code elimination with drop + panic)
 - #154823 (Replace the spdx-rs dependency with a minimal in-tree SPDX tag-value parser)
 - #155294 (Add test for coalescing of diagnostic attribute duplicates)
 - #155352 (triagebot.toml: Sync `assign.owners` with `autolabel."T-compiler"`)
 - #155431 (Add temporary scope to assert_matches)
 - #152995 (ACP Implementation of PermissionsExt for Windows )
 - #153873 (deprecate `std::char` constants and functions)
 - #154865 (libtest: use binary search for --exact test filtering)
 - #154979 (add #[must_use] macros for floats)
 - #155504 (Remove `AttributeLintKind` variants - part 2)
rust-bors Bot pushed a commit that referenced this pull request Apr 19, 2026
…uwer

Rollup of 12 pull requests

Successful merges:

 - #155370 (Add regression test for dead code elimination with drop + panic)
 - #154823 (Replace the spdx-rs dependency with a minimal in-tree SPDX tag-value parser)
 - #155294 (Add test for coalescing of diagnostic attribute duplicates)
 - #155352 (triagebot.toml: Sync `assign.owners` with `autolabel."T-compiler"`)
 - #155431 (Add temporary scope to assert_matches)
 - #153873 (deprecate `std::char` constants and functions)
 - #154865 (libtest: use binary search for --exact test filtering)
 - #154979 (add #[must_use] macros for floats)
 - #155486 (c-variadic: add roundtrip test)
 - #155504 (Remove `AttributeLintKind` variants - part 2)
 - #155510 (Update Tidy python executable path)
 - #155514 (codegen-options docs: remove -Csoft-float)
@rust-bors rust-bors Bot merged commit b07688d into rust-lang:main Apr 19, 2026
11 checks passed
@rustbot rustbot added this to the 1.97.0 milestone Apr 19, 2026
rust-timer added a commit that referenced this pull request Apr 19, 2026
Rollup merge of #153873 - folkertdev:deprecate-char-max, r=Mark-Simulacrum

deprecate `std::char` constants and functions

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 &#96;std::char::{MIN, MAX}&#96; be deprecated?](https://rust-lang.zulipchat.com/#narrow/channel/219381-t-libs/topic/should.20.60std.3A.3Achar.3A.3A.7BMIN.2C.20MAX.7D.60.20be.20deprecated.3F/with/579444750).

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

Labels

disposition-merge This issue / PR is in PFCP or FCP with a disposition to merge it. finished-final-comment-period The final comment period is finished for this PR / Issue. S-waiting-on-bors Status: Waiting on bors to run and complete tests. Bors will change the label on completion. T-libs Relevant to the library team, which will review and decide on the PR/issue. T-libs-api Relevant to the library API team, which will review and decide on the PR/issue. to-announce Announce this issue on triage meeting

Projects

None yet

Development

Successfully merging this pull request may close these issues.

10 participants