Skip to content

Commit d358cca

Browse files
Don't intern str
1 parent 8dabf5d commit d358cca

File tree

7 files changed

+20
-9
lines changed

7 files changed

+20
-9
lines changed

compiler/rustc_codegen_gcc/src/common.rs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -133,7 +133,7 @@ impl<'gcc, 'tcx> ConstMethods<'tcx> for CodegenCx<'gcc, 'tcx> {
133133
.1;
134134
let len = s.len();
135135
let cs = self.const_ptrcast(str_global.get_address(None),
136-
self.type_ptr_to(self.layout_of(self.tcx.types.str_).gcc_type(self, true)),
136+
self.type_ptr_to(self.layout_of(self.tcx.mk_str()).gcc_type(self, true)),
137137
);
138138
(cs, self.const_usize(len as u64))
139139
}

compiler/rustc_codegen_llvm/src/common.rs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -205,7 +205,7 @@ impl<'ll, 'tcx> ConstMethods<'tcx> for CodegenCx<'ll, 'tcx> {
205205
let len = s.len();
206206
let cs = consts::ptrcast(
207207
str_global,
208-
self.type_ptr_to(self.layout_of(self.tcx.types.str_).llvm_type(self)),
208+
self.type_ptr_to(self.layout_of(self.tcx.mk_str()).llvm_type(self)),
209209
);
210210
(cs, self.const_usize(len as u64))
211211
}

compiler/rustc_const_eval/src/interpret/place.rs

Lines changed: 3 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -759,10 +759,9 @@ where
759759
let meta = Scalar::from_machine_usize(u64::try_from(str.len()).unwrap(), self);
760760
let mplace = MemPlace { ptr: ptr.into(), meta: MemPlaceMeta::Meta(meta) };
761761

762-
let ty = self.tcx.mk_ref(
763-
self.tcx.lifetimes.re_static,
764-
ty::TypeAndMut { ty: self.tcx.types.str_, mutbl },
765-
);
762+
let ty = self
763+
.tcx
764+
.mk_ref(self.tcx.lifetimes.re_static, ty::TypeAndMut { ty: self.tcx.mk_str(), mutbl });
766765
let layout = self.layout_of(ty).unwrap();
767766
Ok(MPlaceTy { mplace, layout, align: layout.align.abi })
768767
}

compiler/rustc_hir_analysis/src/astconv/mod.rs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -2819,7 +2819,7 @@ impl<'o, 'tcx> dyn AstConv<'tcx> + 'o {
28192819
hir::PrimTy::Int(it) => tcx.mk_mach_int(ty::int_ty(it)),
28202820
hir::PrimTy::Uint(uit) => tcx.mk_mach_uint(ty::uint_ty(uit)),
28212821
hir::PrimTy::Float(ft) => tcx.mk_mach_float(ty::float_ty(ft)),
2822-
hir::PrimTy::Str => tcx.types.str_,
2822+
hir::PrimTy::Str => tcx.mk_str(),
28232823
}
28242824
}
28252825
Res::Err => {

compiler/rustc_middle/src/ty/context.rs

Lines changed: 6 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1665,7 +1665,7 @@ impl<'tcx> TyCtxt<'tcx> {
16651665

16661666
#[inline]
16671667
pub fn mk_static_str(self) -> Ty<'tcx> {
1668-
self.mk_imm_ref(self.lifetimes.re_static, self.types.str_)
1668+
self.mk_imm_ref(self.lifetimes.re_static, self.mk_str())
16691669
}
16701670

16711671
#[inline]
@@ -1897,6 +1897,11 @@ impl<'tcx> TyCtxt<'tcx> {
18971897
self.mk_ty(Param(ParamTy { index, name }))
18981898
}
18991899

1900+
#[inline]
1901+
pub fn mk_str(self) -> Ty<'tcx> {
1902+
self.mk_ty(Str)
1903+
}
1904+
19001905
pub fn mk_param_from_def(self, param: &ty::GenericParamDef) -> GenericArg<'tcx> {
19011906
match param.kind {
19021907
GenericParamDefKind::Lifetime => {

compiler/rustc_mir_build/src/build/matches/test.rs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -245,7 +245,7 @@ impl<'a, 'tcx> Builder<'a, 'tcx> {
245245
}
246246
let re_erased = tcx.lifetimes.re_erased;
247247
let ref_string = self.temp(tcx.mk_imm_ref(re_erased, ty), test.span);
248-
let ref_str_ty = tcx.mk_imm_ref(re_erased, tcx.types.str_);
248+
let ref_str_ty = tcx.mk_imm_ref(re_erased, tcx.mk_str());
249249
let ref_str = self.temp(ref_str_ty, test.span);
250250
let deref = tcx.require_lang_item(LangItem::Deref, None);
251251
let method = trait_method(tcx, deref, sym::deref, [ty]);

tests/codegen/function-arguments.rs

Lines changed: 7 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,7 @@
11
// compile-flags: -O -C no-prepopulate-passes
22

33
#![crate_type = "lib"]
4+
#![feature(dyn_star)]
45

56
use std::mem::MaybeUninit;
67
use std::num::NonZeroU64;
@@ -279,3 +280,9 @@ pub fn enum_id_1(x: Option<Result<u16, u16>>) -> Option<Result<u16, u16>> {
279280
pub fn enum_id_2(x: Option<u8>) -> Option<u8> {
280281
x
281282
}
283+
284+
// CHECK: { {{i8\*|ptr}}, {{i8\*|ptr}} } @dyn_star({{i8\*|ptr}} noundef %x.0, {{i8\*|ptr}} noalias noundef readonly align {{.*}} dereferenceable({{.*}}) %x.1)
285+
#[no_mangle]
286+
pub fn dyn_star(x: dyn* Drop) -> dyn* Drop {
287+
x
288+
}

0 commit comments

Comments
 (0)