add str to common types
This commit is contained in:
parent
4512721156
commit
b3aa5e3810
3 changed files with 5 additions and 8 deletions
|
@ -206,7 +206,7 @@ impl ConstMethods<'tcx> for CodegenCx<'ll, 'tcx> {
|
|||
let len = s.as_str().len();
|
||||
let cs = consts::ptrcast(
|
||||
self.const_cstr(s, false),
|
||||
self.type_ptr_to(self.layout_of(self.tcx.mk_str()).llvm_type(self)),
|
||||
self.type_ptr_to(self.layout_of(self.tcx.types.str_).llvm_type(self)),
|
||||
);
|
||||
(cs, self.const_usize(len as u64))
|
||||
}
|
||||
|
|
|
@ -156,6 +156,7 @@ pub struct CommonTypes<'tcx> {
|
|||
pub u128: Ty<'tcx>,
|
||||
pub f32: Ty<'tcx>,
|
||||
pub f64: Ty<'tcx>,
|
||||
pub str_: Ty<'tcx>,
|
||||
pub never: Ty<'tcx>,
|
||||
pub self_param: Ty<'tcx>,
|
||||
pub err: Ty<'tcx>,
|
||||
|
@ -832,6 +833,7 @@ impl<'tcx> CommonTypes<'tcx> {
|
|||
u128: mk(Uint(ast::UintTy::U128)),
|
||||
f32: mk(Float(ast::FloatTy::F32)),
|
||||
f64: mk(Float(ast::FloatTy::F64)),
|
||||
str_: mk(Str),
|
||||
self_param: mk(ty::Param(ty::ParamTy { index: 0, name: kw::SelfUpper })),
|
||||
|
||||
trait_object_dummy_self: mk(Infer(ty::FreshTy(0))),
|
||||
|
@ -2121,14 +2123,9 @@ impl<'tcx> TyCtxt<'tcx> {
|
|||
}
|
||||
}
|
||||
|
||||
#[inline]
|
||||
pub fn mk_str(self) -> Ty<'tcx> {
|
||||
self.mk_ty(Str)
|
||||
}
|
||||
|
||||
#[inline]
|
||||
pub fn mk_static_str(self) -> Ty<'tcx> {
|
||||
self.mk_imm_ref(self.lifetimes.re_static, self.mk_str())
|
||||
self.mk_imm_ref(self.lifetimes.re_static, self.types.str_)
|
||||
}
|
||||
|
||||
#[inline]
|
||||
|
|
|
@ -2698,7 +2698,7 @@ impl<'o, 'tcx> dyn AstConv<'tcx> + 'o {
|
|||
hir::PrimTy::Int(it) => tcx.mk_mach_int(it),
|
||||
hir::PrimTy::Uint(uit) => tcx.mk_mach_uint(uit),
|
||||
hir::PrimTy::Float(ft) => tcx.mk_mach_float(ft),
|
||||
hir::PrimTy::Str => tcx.mk_str(),
|
||||
hir::PrimTy::Str => tcx.types.str_,
|
||||
}
|
||||
}
|
||||
Res::Err => {
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue