Skip to content

Commit d78b33a

Browse files
committed
Remove LocalInternedString uses from librustc_codegen_llvm.
1 parent b50db34 commit d78b33a

File tree

5 files changed

+20
-20
lines changed

5 files changed

+20
-20
lines changed

src/librustc_codegen_llvm/builder.rs

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -5,7 +5,6 @@ use crate::context::CodegenCx;
55
use crate::type_::Type;
66
use crate::type_of::LayoutLlvmExt;
77
use crate::value::Value;
8-
use syntax::symbol::LocalInternedString;
98
use rustc_codegen_ssa::common::{IntPredicate, TypeKind, RealPredicate};
109
use rustc_codegen_ssa::MemFlags;
1110
use libc::{c_uint, c_char};
@@ -24,6 +23,7 @@ use std::ffi::CStr;
2423
use std::ops::{Deref, Range};
2524
use std::ptr;
2625
use std::iter::TrustedLen;
26+
use syntax::symbol::Symbol;
2727

2828
// All Builders must have an llfn associated with them
2929
#[must_use]
@@ -1082,8 +1082,8 @@ impl StaticBuilderMethods for Builder<'a, 'll, 'tcx> {
10821082

10831083
fn static_panic_msg(
10841084
&mut self,
1085-
msg: Option<LocalInternedString>,
1086-
filename: LocalInternedString,
1085+
msg: Option<Symbol>,
1086+
filename: Symbol,
10871087
line: Self::Value,
10881088
col: Self::Value,
10891089
kind: &str,

src/librustc_codegen_llvm/common.rs

Lines changed: 7 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -17,7 +17,7 @@ use rustc_codegen_ssa::mir::place::PlaceRef;
1717

1818
use libc::{c_uint, c_char};
1919

20-
use syntax::symbol::LocalInternedString;
20+
use syntax::symbol::Symbol;
2121
use syntax::ast::Mutability;
2222

2323
pub use crate::context::CodegenCx;
@@ -122,17 +122,18 @@ impl CodegenCx<'ll, 'tcx> {
122122

123123
fn const_cstr(
124124
&self,
125-
s: LocalInternedString,
125+
s: Symbol,
126126
null_terminated: bool,
127127
) -> &'ll Value {
128128
unsafe {
129129
if let Some(&llval) = self.const_cstr_cache.borrow().get(&s) {
130130
return llval;
131131
}
132132

133+
let s_str = s.as_str();
133134
let sc = llvm::LLVMConstStringInContext(self.llcx,
134-
s.as_ptr() as *const c_char,
135-
s.len() as c_uint,
135+
s_str.as_ptr() as *const c_char,
136+
s_str.len() as c_uint,
136137
!null_terminated as Bool);
137138
let sym = self.generate_local_symbol_name("str");
138139
let g = self.define_global(&sym[..], self.val_ty(sc)).unwrap_or_else(||{
@@ -147,8 +148,8 @@ impl CodegenCx<'ll, 'tcx> {
147148
}
148149
}
149150

150-
pub fn const_str_slice(&self, s: LocalInternedString) -> &'ll Value {
151-
let len = s.len();
151+
pub fn const_str_slice(&self, s: Symbol) -> &'ll Value {
152+
let len = s.as_str().len();
152153
let cs = consts::ptrcast(self.const_cstr(s, false),
153154
self.type_ptr_to(self.layout_of(self.tcx.mk_str()).llvm_type(self)));
154155
self.const_fat_ptr(cs, self.const_usize(len as u64))

src/librustc_codegen_llvm/context.rs

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -29,7 +29,7 @@ use std::cell::{Cell, RefCell};
2929
use std::iter;
3030
use std::str;
3131
use std::sync::Arc;
32-
use syntax::symbol::LocalInternedString;
32+
use syntax::symbol::Symbol;
3333
use syntax::source_map::{DUMMY_SP, Span};
3434
use crate::abi::Abi;
3535

@@ -52,7 +52,7 @@ pub struct CodegenCx<'ll, 'tcx> {
5252
pub vtables:
5353
RefCell<FxHashMap<(Ty<'tcx>, Option<ty::PolyExistentialTraitRef<'tcx>>), &'ll Value>>,
5454
/// Cache of constant strings,
55-
pub const_cstr_cache: RefCell<FxHashMap<LocalInternedString, &'ll Value>>,
55+
pub const_cstr_cache: RefCell<FxHashMap<Symbol, &'ll Value>>,
5656

5757
/// Reverse-direction for const ptrs cast from globals.
5858
/// Key is a Value holding a *T,

src/librustc_codegen_ssa/mir/block.rs

Lines changed: 5 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -14,7 +14,7 @@ use crate::traits::*;
1414

1515
use std::borrow::Cow;
1616

17-
use syntax::symbol::LocalInternedString;
17+
use syntax::symbol::Symbol;
1818
use syntax_pos::Pos;
1919

2020
use super::{FunctionCx, LocalRef};
@@ -397,7 +397,7 @@ impl<'a, 'tcx, Bx: BuilderMethods<'a, 'tcx>> FunctionCx<'a, 'tcx, Bx> {
397397

398398
// Get the location information.
399399
let loc = bx.sess().source_map().lookup_char_pos(span.lo());
400-
let filename = LocalInternedString::intern(&loc.file.name.to_string());
400+
let filename = Symbol::intern(&loc.file.name.to_string());
401401
let line = bx.const_u32(loc.line as u32);
402402
let col = bx.const_u32(loc.col.to_usize() as u32 + 1);
403403

@@ -418,8 +418,7 @@ impl<'a, 'tcx, Bx: BuilderMethods<'a, 'tcx>> FunctionCx<'a, 'tcx, Bx> {
418418
vec![file_line_col, index, len])
419419
}
420420
_ => {
421-
let str = msg.description();
422-
let msg_str = LocalInternedString::intern(str);
421+
let msg_str = Symbol::intern(msg.description());
423422
let msg_file_line_col = bx.static_panic_msg(
424423
Some(msg_str),
425424
filename,
@@ -531,15 +530,15 @@ impl<'a, 'tcx, Bx: BuilderMethods<'a, 'tcx>> FunctionCx<'a, 'tcx, Bx> {
531530
let layout = bx.layout_of(ty);
532531
if layout.abi.is_uninhabited() {
533532
let loc = bx.sess().source_map().lookup_char_pos(span.lo());
534-
let filename = LocalInternedString::intern(&loc.file.name.to_string());
533+
let filename = Symbol::intern(&loc.file.name.to_string());
535534
let line = bx.const_u32(loc.line as u32);
536535
let col = bx.const_u32(loc.col.to_usize() as u32 + 1);
537536

538537
let str = format!(
539538
"Attempted to instantiate uninhabited type {}",
540539
ty
541540
);
542-
let msg_str = LocalInternedString::intern(&str);
541+
let msg_str = Symbol::intern(&str);
543542
let msg_file_line_col = bx.static_panic_msg(
544543
Some(msg_str),
545544
filename,

src/librustc_codegen_ssa/traits/statics.rs

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,5 @@
11
use super::BackendTypes;
2-
use syntax_pos::symbol::LocalInternedString;
2+
use syntax_pos::symbol::Symbol;
33
use rustc::hir::def_id::DefId;
44
use rustc::ty::layout::Align;
55

@@ -12,8 +12,8 @@ pub trait StaticBuilderMethods: BackendTypes {
1212
fn get_static(&mut self, def_id: DefId) -> Self::Value;
1313
fn static_panic_msg(
1414
&mut self,
15-
msg: Option<LocalInternedString>,
16-
filename: LocalInternedString,
15+
msg: Option<Symbol>,
16+
filename: Symbol,
1717
line: Self::Value,
1818
col: Self::Value,
1919
kind: &str,

0 commit comments

Comments
 (0)