From 5c84cd37cbfc16ef80bbad1f6416419d3cf06df6 Mon Sep 17 00:00:00 2001 From: Matthew Jasper Date: Thu, 13 Jun 2019 21:14:58 +0100 Subject: [PATCH] Use `sym` constansts for `PrimitiveTypeTable` keys --- src/librustc_resolve/lib.rs | 45 +++++++++++++++++-------------------- src/libsyntax_pos/symbol.rs | 2 ++ 2 files changed, 22 insertions(+), 25 deletions(-) diff --git a/src/librustc_resolve/lib.rs b/src/librustc_resolve/lib.rs index 18f3c0285c2..77b0dd00cf4 100644 --- a/src/librustc_resolve/lib.rs +++ b/src/librustc_resolve/lib.rs @@ -1518,37 +1518,32 @@ fn may_appear_after(&self, invoc_parent_expansion: Mark, binding: &NameBinding<' /// /// All other types are defined somewhere and possibly imported, but the primitive ones need /// special handling, since they have no place of origin. -#[derive(Default)] struct PrimitiveTypeTable { primitive_types: FxHashMap, } impl PrimitiveTypeTable { fn new() -> PrimitiveTypeTable { - let mut table = PrimitiveTypeTable::default(); - - table.intern("bool", Bool); - table.intern("char", Char); - table.intern("f32", Float(FloatTy::F32)); - table.intern("f64", Float(FloatTy::F64)); - table.intern("isize", Int(IntTy::Isize)); - table.intern("i8", Int(IntTy::I8)); - table.intern("i16", Int(IntTy::I16)); - table.intern("i32", Int(IntTy::I32)); - table.intern("i64", Int(IntTy::I64)); - table.intern("i128", Int(IntTy::I128)); - table.intern("str", Str); - table.intern("usize", Uint(UintTy::Usize)); - table.intern("u8", Uint(UintTy::U8)); - table.intern("u16", Uint(UintTy::U16)); - table.intern("u32", Uint(UintTy::U32)); - table.intern("u64", Uint(UintTy::U64)); - table.intern("u128", Uint(UintTy::U128)); - table - } - - fn intern(&mut self, string: &str, primitive_type: PrimTy) { - self.primitive_types.insert(Symbol::intern(string), primitive_type); + let mut table = FxHashMap::default(); + + table.insert(sym::bool, Bool); + table.insert(sym::char, Char); + table.insert(sym::f32, Float(FloatTy::F32)); + table.insert(sym::f64, Float(FloatTy::F64)); + table.insert(sym::isize, Int(IntTy::Isize)); + table.insert(sym::i8, Int(IntTy::I8)); + table.insert(sym::i16, Int(IntTy::I16)); + table.insert(sym::i32, Int(IntTy::I32)); + table.insert(sym::i64, Int(IntTy::I64)); + table.insert(sym::i128, Int(IntTy::I128)); + table.insert(sym::str, Str); + table.insert(sym::usize, Uint(UintTy::Usize)); + table.insert(sym::u8, Uint(UintTy::U8)); + table.insert(sym::u16, Uint(UintTy::U16)); + table.insert(sym::u32, Uint(UintTy::U32)); + table.insert(sym::u64, Uint(UintTy::U64)); + table.insert(sym::u128, Uint(UintTy::U128)); + Self { primitive_types: table } } } diff --git a/src/libsyntax_pos/symbol.rs b/src/libsyntax_pos/symbol.rs index 03dc113b89f..b6a3e37fae6 100644 --- a/src/libsyntax_pos/symbol.rs +++ b/src/libsyntax_pos/symbol.rs @@ -157,6 +157,7 @@ bin, bind_by_move_pattern_guards, block, + bool, borrowck_graphviz_postflow, borrowck_graphviz_preflow, box_patterns, @@ -171,6 +172,7 @@ cfg_target_has_atomic, cfg_target_thread_local, cfg_target_vendor, + char, clone, Clone, clone_closures, -- 2.44.0