Rollup merge of #123922 - TDecking:base_n_magic_removal, r=jieyouxu

Remove magic constants when using `base_n`.

Some use cases of `base_n` use number literals instead of the predefined constants. The latter are more descriptive so it might be better to use those instead.
This commit is contained in:
许杰友 Jieyou Xu (Joe) 2024-04-15 16:56:17 +01:00 committed by GitHub
commit 1870e2d09f
No known key found for this signature in database
GPG Key ID: B5690EEEBB952194
2 changed files with 3 additions and 3 deletions

View File

@ -736,7 +736,7 @@ fn encode_ty_name(tcx: TyCtxt<'_>, def_id: DefId) -> String {
/// <https://rust-lang.github.io/rfcs/2603-rust-symbol-name-mangling-v0.html>).
fn to_disambiguator(num: u64) -> String {
if let Some(num) = num.checked_sub(1) {
format!("s{}_", base_n::encode(num as u128, 62))
format!("s{}_", base_n::encode(num as u128, base_n::ALPHANUMERIC_ONLY))
} else {
"s_".to_string()
}
@ -746,7 +746,7 @@ fn to_disambiguator(num: u64) -> String {
/// <https://itanium-cxx-abi.github.io/cxx-abi/abi.html#mangle.seq-id>).
fn to_seq_id(num: usize) -> String {
if let Some(num) = num.checked_sub(1) {
base_n::encode(num as u128, 36).to_uppercase()
base_n::encode(num as u128, base_n::CASE_INSENSITIVE).to_uppercase()
} else {
"".to_string()
}

View File

@ -831,7 +831,7 @@ fn path_generic_args(
/// e.g. `1` becomes `"0_"`, `62` becomes `"Z_"`, etc.
pub(crate) fn push_integer_62(x: u64, output: &mut String) {
if let Some(x) = x.checked_sub(1) {
base_n::push_str(x as u128, 62, output);
base_n::push_str(x as u128, base_n::ALPHANUMERIC_ONLY, output);
}
output.push('_');
}