Skip to content

Commit 1870e2d

Browse files
authored
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.
2 parents b1d1e08 + e5cf30c commit 1870e2d

File tree

2 files changed

+3
-3
lines changed
  • compiler
    • rustc_sanitizers/src/cfi/typeid/itanium_cxx_abi
    • rustc_symbol_mangling/src

2 files changed

+3
-3
lines changed

compiler/rustc_sanitizers/src/cfi/typeid/itanium_cxx_abi/encode.rs

+2-2
Original file line numberDiff line numberDiff line change
@@ -736,7 +736,7 @@ fn encode_ty_name(tcx: TyCtxt<'_>, def_id: DefId) -> String {
736736
/// <https://rust-lang.github.io/rfcs/2603-rust-symbol-name-mangling-v0.html>).
737737
fn to_disambiguator(num: u64) -> String {
738738
if let Some(num) = num.checked_sub(1) {
739-
format!("s{}_", base_n::encode(num as u128, 62))
739+
format!("s{}_", base_n::encode(num as u128, base_n::ALPHANUMERIC_ONLY))
740740
} else {
741741
"s_".to_string()
742742
}
@@ -746,7 +746,7 @@ fn to_disambiguator(num: u64) -> String {
746746
/// <https://itanium-cxx-abi.github.io/cxx-abi/abi.html#mangle.seq-id>).
747747
fn to_seq_id(num: usize) -> String {
748748
if let Some(num) = num.checked_sub(1) {
749-
base_n::encode(num as u128, 36).to_uppercase()
749+
base_n::encode(num as u128, base_n::CASE_INSENSITIVE).to_uppercase()
750750
} else {
751751
"".to_string()
752752
}

compiler/rustc_symbol_mangling/src/v0.rs

+1-1
Original file line numberDiff line numberDiff line change
@@ -831,7 +831,7 @@ impl<'tcx> Printer<'tcx> for SymbolMangler<'tcx> {
831831
/// e.g. `1` becomes `"0_"`, `62` becomes `"Z_"`, etc.
832832
pub(crate) fn push_integer_62(x: u64, output: &mut String) {
833833
if let Some(x) = x.checked_sub(1) {
834-
base_n::push_str(x as u128, 62, output);
834+
base_n::push_str(x as u128, base_n::ALPHANUMERIC_ONLY, output);
835835
}
836836
output.push('_');
837837
}

0 commit comments

Comments
 (0)