Skip to content

Commit b3aa5e3

Browse files
committed
add str to common types
1 parent 4512721 commit b3aa5e3

File tree

3 files changed

+5
-8
lines changed

3 files changed

+5
-8
lines changed

src/librustc_codegen_llvm/common.rs

+1-1
Original file line numberDiff line numberDiff line change
@@ -206,7 +206,7 @@ impl ConstMethods<'tcx> for CodegenCx<'ll, 'tcx> {
206206
let len = s.as_str().len();
207207
let cs = consts::ptrcast(
208208
self.const_cstr(s, false),
209-
self.type_ptr_to(self.layout_of(self.tcx.mk_str()).llvm_type(self)),
209+
self.type_ptr_to(self.layout_of(self.tcx.types.str_).llvm_type(self)),
210210
);
211211
(cs, self.const_usize(len as u64))
212212
}

src/librustc_middle/ty/context.rs

+3-6
Original file line numberDiff line numberDiff line change
@@ -156,6 +156,7 @@ pub struct CommonTypes<'tcx> {
156156
pub u128: Ty<'tcx>,
157157
pub f32: Ty<'tcx>,
158158
pub f64: Ty<'tcx>,
159+
pub str_: Ty<'tcx>,
159160
pub never: Ty<'tcx>,
160161
pub self_param: Ty<'tcx>,
161162
pub err: Ty<'tcx>,
@@ -832,6 +833,7 @@ impl<'tcx> CommonTypes<'tcx> {
832833
u128: mk(Uint(ast::UintTy::U128)),
833834
f32: mk(Float(ast::FloatTy::F32)),
834835
f64: mk(Float(ast::FloatTy::F64)),
836+
str_: mk(Str),
835837
self_param: mk(ty::Param(ty::ParamTy { index: 0, name: kw::SelfUpper })),
836838

837839
trait_object_dummy_self: mk(Infer(ty::FreshTy(0))),
@@ -2121,14 +2123,9 @@ impl<'tcx> TyCtxt<'tcx> {
21212123
}
21222124
}
21232125

2124-
#[inline]
2125-
pub fn mk_str(self) -> Ty<'tcx> {
2126-
self.mk_ty(Str)
2127-
}
2128-
21292126
#[inline]
21302127
pub fn mk_static_str(self) -> Ty<'tcx> {
2131-
self.mk_imm_ref(self.lifetimes.re_static, self.mk_str())
2128+
self.mk_imm_ref(self.lifetimes.re_static, self.types.str_)
21322129
}
21332130

21342131
#[inline]

src/librustc_typeck/astconv.rs

+1-1
Original file line numberDiff line numberDiff line change
@@ -2698,7 +2698,7 @@ impl<'o, 'tcx> dyn AstConv<'tcx> + 'o {
26982698
hir::PrimTy::Int(it) => tcx.mk_mach_int(it),
26992699
hir::PrimTy::Uint(uit) => tcx.mk_mach_uint(uit),
27002700
hir::PrimTy::Float(ft) => tcx.mk_mach_float(ft),
2701-
hir::PrimTy::Str => tcx.mk_str(),
2701+
hir::PrimTy::Str => tcx.types.str_,
27022702
}
27032703
}
27042704
Res::Err => {

0 commit comments

Comments
 (0)