diff options
| author | Manish Goregaokar <manishsmail@gmail.com> | 2020-06-19 19:42:47 -0700 |
|---|---|---|
| committer | GitHub <noreply@github.com> | 2020-06-19 19:42:47 -0700 |
| commit | 218b90f6438b775e9626ac37f26e9f1dbd2be945 (patch) | |
| tree | 20e00640812b59bc2c14a836cc9afbdff4e08a9f | |
| parent | 5c9cd82454e099b368275292f214daa11541879e (diff) | |
| parent | b3aa5e38107df9e9b16a0a003afaa3d12d80bb86 (diff) | |
| download | rust-218b90f6438b775e9626ac37f26e9f1dbd2be945.tar.gz rust-218b90f6438b775e9626ac37f26e9f1dbd2be945.zip | |
Rollup merge of #72689 - lcnr:common_str, r=estebank
add str to common types I already expected this to be the case and it may slightly improve perf. Afaict if we ever want to change str into a lang item this would have to get reverted. As that would be fairly simple I don't believe this to cause any problems in the future.
| -rw-r--r-- | src/librustc_codegen_llvm/common.rs | 2 | ||||
| -rw-r--r-- | src/librustc_middle/ty/context.rs | 9 | ||||
| -rw-r--r-- | src/librustc_typeck/astconv.rs | 2 |
3 files changed, 5 insertions, 8 deletions
diff --git a/src/librustc_codegen_llvm/common.rs b/src/librustc_codegen_llvm/common.rs index a5cda5949ee..64140747871 100644 --- a/src/librustc_codegen_llvm/common.rs +++ b/src/librustc_codegen_llvm/common.rs @@ -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)) } diff --git a/src/librustc_middle/ty/context.rs b/src/librustc_middle/ty/context.rs index c77c7b95bc0..672a3a484e5 100644 --- a/src/librustc_middle/ty/context.rs +++ b/src/librustc_middle/ty/context.rs @@ -143,6 +143,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>, @@ -816,6 +817,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))), @@ -2150,13 +2152,8 @@ 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] diff --git a/src/librustc_typeck/astconv.rs b/src/librustc_typeck/astconv.rs index 7cdcb2face8..b592d30c37d 100644 --- a/src/librustc_typeck/astconv.rs +++ b/src/librustc_typeck/astconv.rs @@ -2787,7 +2787,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 => { |
