Skip to content

Commit c99f1b9

Browse files
committed
Skip layout query when computing integer type size during mangling
1 parent f8ac8fd commit c99f1b9

File tree

1 file changed

+5
-5
lines changed
  • compiler/rustc_symbol_mangling/src

1 file changed

+5
-5
lines changed

compiler/rustc_symbol_mangling/src/v0.rs

+5-5
Original file line numberDiff line numberDiff line change
@@ -3,9 +3,11 @@ use rustc_data_structures::fx::{FxHashMap, FxHashSet};
33
use rustc_hir as hir;
44
use rustc_hir::def_id::{CrateNum, DefId};
55
use rustc_hir::definitions::{DefPathData, DisambiguatedDefPathData};
6+
use rustc_middle::ty::layout::IntegerExt;
67
use rustc_middle::ty::print::{Print, Printer};
78
use rustc_middle::ty::subst::{GenericArg, GenericArgKind, Subst};
89
use rustc_middle::ty::{self, FloatTy, Instance, IntTy, Ty, TyCtxt, TypeFoldable, UintTy};
10+
use rustc_target::abi::Integer;
911
use rustc_target::spec::abi::Abi;
1012

1113
use std::fmt::Write;
@@ -553,11 +555,9 @@ impl Printer<'tcx> for SymbolMangler<'tcx> {
553555
ty::Uint(_) | ty::Bool | ty::Char => {
554556
ct.try_eval_bits(self.tcx, ty::ParamEnv::reveal_all(), ct.ty)
555557
}
556-
ty::Int(_) => {
557-
let param_env = ty::ParamEnv::reveal_all();
558-
ct.try_eval_bits(self.tcx, param_env, ct.ty).and_then(|b| {
559-
let sz = self.tcx.layout_of(param_env.and(ct.ty)).ok()?.size;
560-
let val = sz.sign_extend(b) as i128;
558+
ty::Int(ity) => {
559+
ct.try_eval_bits(self.tcx, ty::ParamEnv::reveal_all(), ct.ty).and_then(|b| {
560+
let val = Integer::from_int_ty(&self.tcx, *ity).size().sign_extend(b) as i128;
561561
if val < 0 {
562562
neg = true;
563563
}

0 commit comments

Comments
 (0)