Skip to content

Commit 5c84cd3

Browse files
committed
Use sym constansts for PrimitiveTypeTable keys
1 parent 4e212c6 commit 5c84cd3

File tree

2 files changed

+22
-25
lines changed

2 files changed

+22
-25
lines changed

src/librustc_resolve/lib.rs

+20-25
Original file line numberDiff line numberDiff line change
@@ -1518,37 +1518,32 @@ impl<'a> NameBinding<'a> {
15181518
///
15191519
/// All other types are defined somewhere and possibly imported, but the primitive ones need
15201520
/// special handling, since they have no place of origin.
1521-
#[derive(Default)]
15221521
struct PrimitiveTypeTable {
15231522
primitive_types: FxHashMap<Name, PrimTy>,
15241523
}
15251524

15261525
impl PrimitiveTypeTable {
15271526
fn new() -> PrimitiveTypeTable {
1528-
let mut table = PrimitiveTypeTable::default();
1529-
1530-
table.intern("bool", Bool);
1531-
table.intern("char", Char);
1532-
table.intern("f32", Float(FloatTy::F32));
1533-
table.intern("f64", Float(FloatTy::F64));
1534-
table.intern("isize", Int(IntTy::Isize));
1535-
table.intern("i8", Int(IntTy::I8));
1536-
table.intern("i16", Int(IntTy::I16));
1537-
table.intern("i32", Int(IntTy::I32));
1538-
table.intern("i64", Int(IntTy::I64));
1539-
table.intern("i128", Int(IntTy::I128));
1540-
table.intern("str", Str);
1541-
table.intern("usize", Uint(UintTy::Usize));
1542-
table.intern("u8", Uint(UintTy::U8));
1543-
table.intern("u16", Uint(UintTy::U16));
1544-
table.intern("u32", Uint(UintTy::U32));
1545-
table.intern("u64", Uint(UintTy::U64));
1546-
table.intern("u128", Uint(UintTy::U128));
1547-
table
1548-
}
1549-
1550-
fn intern(&mut self, string: &str, primitive_type: PrimTy) {
1551-
self.primitive_types.insert(Symbol::intern(string), primitive_type);
1527+
let mut table = FxHashMap::default();
1528+
1529+
table.insert(sym::bool, Bool);
1530+
table.insert(sym::char, Char);
1531+
table.insert(sym::f32, Float(FloatTy::F32));
1532+
table.insert(sym::f64, Float(FloatTy::F64));
1533+
table.insert(sym::isize, Int(IntTy::Isize));
1534+
table.insert(sym::i8, Int(IntTy::I8));
1535+
table.insert(sym::i16, Int(IntTy::I16));
1536+
table.insert(sym::i32, Int(IntTy::I32));
1537+
table.insert(sym::i64, Int(IntTy::I64));
1538+
table.insert(sym::i128, Int(IntTy::I128));
1539+
table.insert(sym::str, Str);
1540+
table.insert(sym::usize, Uint(UintTy::Usize));
1541+
table.insert(sym::u8, Uint(UintTy::U8));
1542+
table.insert(sym::u16, Uint(UintTy::U16));
1543+
table.insert(sym::u32, Uint(UintTy::U32));
1544+
table.insert(sym::u64, Uint(UintTy::U64));
1545+
table.insert(sym::u128, Uint(UintTy::U128));
1546+
Self { primitive_types: table }
15521547
}
15531548
}
15541549

src/libsyntax_pos/symbol.rs

+2
Original file line numberDiff line numberDiff line change
@@ -157,6 +157,7 @@ symbols! {
157157
bin,
158158
bind_by_move_pattern_guards,
159159
block,
160+
bool,
160161
borrowck_graphviz_postflow,
161162
borrowck_graphviz_preflow,
162163
box_patterns,
@@ -171,6 +172,7 @@ symbols! {
171172
cfg_target_has_atomic,
172173
cfg_target_thread_local,
173174
cfg_target_vendor,
175+
char,
174176
clone,
175177
Clone,
176178
clone_closures,

0 commit comments

Comments
 (0)