]> git.lizzy.rs Git - rust.git/commitdiff
Use InternedString rather than Name for RegionParameterDef
authorvarkor <github@varkor.com>
Thu, 12 Apr 2018 20:16:26 +0000 (21:16 +0100)
committervarkor <github@varkor.com>
Fri, 13 Apr 2018 17:41:40 +0000 (18:41 +0100)
This makes it consistent with TypeParameterDef.

src/librustc/infer/mod.rs
src/librustc/ty/mod.rs
src/librustc/ty/sty.rs
src/librustc/util/ppaux.rs
src/librustc_driver/test.rs
src/librustc_typeck/astconv.rs
src/librustc_typeck/collect.rs
src/librustdoc/clean/auto_trait.rs

index 032a5c59d2dcaac063b1e11b2687fab781ad75b9..84bf9cc84e7373499419c79f7d4b9682840801aa 100644 (file)
@@ -35,6 +35,7 @@
 use syntax::ast;
 use errors::DiagnosticBuilder;
 use syntax_pos::{self, Span};
+use syntax_pos::symbol::InternedString;
 use util::nodemap::FxHashMap;
 use arena::DroplessArena;
 
@@ -343,7 +344,7 @@ pub enum RegionVariableOrigin {
     Coercion(Span),
 
     // Region variables created as the values for early-bound regions
-    EarlyBoundRegion(Span, ast::Name),
+    EarlyBoundRegion(Span, InternedString),
 
     // Region variables created for bound regions
     // in a function or method that is called
index 33b59eda7ce2ccb6ba54b27a3a3016f4e0afc7c0..77106fd61adf66567a43a3a7dcd8403a117ddb35 100644 (file)
@@ -728,7 +728,7 @@ pub struct TypeParameterDef {
 
 #[derive(Copy, Clone, RustcEncodable, RustcDecodable)]
 pub struct RegionParameterDef {
-    pub name: Name,
+    pub name: InternedString,
     pub def_id: DefId,
     pub index: u32,
 
index 7a9174cbfaf73206619e80f66ffed4ded7a94384..d68393956efd1a51ece763e6e8e1314eb1cae533 100644 (file)
@@ -58,7 +58,7 @@ pub enum BoundRegion {
     ///
     /// The def-id is needed to distinguish free regions in
     /// the event of shadowing.
-    BrNamed(DefId, Name),
+    BrNamed(DefId, InternedString),
 
     /// Fresh bound identifiers created during GLB computations.
     BrFresh(u32),
@@ -1058,7 +1058,7 @@ impl<'tcx> serialize::UseSpecializedDecodable for Region<'tcx> {}
 pub struct EarlyBoundRegion {
     pub def_id: DefId,
     pub index: u32,
-    pub name: Name,
+    pub name: InternedString,
 }
 
 #[derive(Clone, Copy, PartialEq, Eq, Hash, RustcEncodable, RustcDecodable)]
index d27cda4040e5646bf249eeb85e7564efe8c4a6f0..dd478967b185a3539762868eb3f91beb6c979771 100644 (file)
@@ -30,7 +30,7 @@
 use rustc_data_structures::indexed_vec::Idx;
 use syntax::abi::Abi;
 use syntax::ast::CRATE_NODE_ID;
-use syntax::symbol::Symbol;
+use syntax::symbol::{Symbol, InternedString};
 use hir;
 
 macro_rules! gen_display_debug_body {
@@ -130,7 +130,7 @@ macro_rules! print {
 }
 
 
-struct LateBoundRegionNameCollector(FxHashSet<Symbol>);
+struct LateBoundRegionNameCollector(FxHashSet<InternedString>);
 impl<'tcx> ty::fold::TypeVisitor<'tcx> for LateBoundRegionNameCollector {
     fn visit_region(&mut self, r: ty::Region<'tcx>) -> bool {
         match *r {
@@ -148,7 +148,7 @@ pub struct PrintContext {
     is_debug: bool,
     is_verbose: bool,
     identify_regions: bool,
-    used_region_names: Option<FxHashSet<Symbol>>,
+    used_region_names: Option<FxHashSet<InternedString>>,
     region_index: usize,
     binder_depth: usize,
 }
@@ -440,12 +440,12 @@ fn in_binder<'a, 'gcx, 'tcx, T, U, F>(&mut self,
                                           lifted: Option<ty::Binder<U>>) -> fmt::Result
         where T: Print, U: Print + TypeFoldable<'tcx>, F: fmt::Write
     {
-        fn name_by_region_index(index: usize) -> Symbol {
+        fn name_by_region_index(index: usize) -> InternedString {
             match index {
                 0 => Symbol::intern("'r"),
                 1 => Symbol::intern("'s"),
                 i => Symbol::intern(&format!("'t{}", i-2)),
-            }
+            }.as_str()
         }
 
         // Replace any anonymous late-bound regions with named
@@ -493,8 +493,7 @@ fn name_by_region_index(index: usize) -> Symbol {
                         }
                     };
                     let _ = write!(f, "{}", name);
-                    ty::BrNamed(tcx.hir.local_def_id(CRATE_NODE_ID),
-                                name)
+                    ty::BrNamed(tcx.hir.local_def_id(CRATE_NODE_ID), name)
                 }
             };
             tcx.mk_region(ty::ReLateBound(ty::DebruijnIndex::new(1), br))
@@ -510,7 +509,7 @@ fn name_by_region_index(index: usize) -> Symbol {
         result
     }
 
-    fn is_name_used(&self, name: &Symbol) -> bool {
+    fn is_name_used(&self, name: &InternedString) -> bool {
         match self.used_region_names {
             Some(ref names) => names.contains(name),
             None => false,
@@ -697,7 +696,7 @@ fn fmt(&self, f: &mut fmt::Formatter) -> fmt::Result {
                 BrAnon(n) => write!(f, "BrAnon({:?})", n),
                 BrFresh(n) => write!(f, "BrFresh({:?})", n),
                 BrNamed(did, name) => {
-                    write!(f, "BrNamed({:?}:{:?}, {:?})",
+                    write!(f, "BrNamed({:?}:{:?}, {})",
                            did.krate, did.index, name)
                 }
                 BrEnv => write!(f, "BrEnv"),
index 971855ee2d007256b58be8846212e5ca1fd1e461..5aae895ccc4d5e1bfe0b8c61459b1d12060293a3 100644 (file)
@@ -307,7 +307,7 @@ pub fn t_param(&self, index: u32) -> Ty<'tcx> {
     }
 
     pub fn re_early_bound(&self, index: u32, name: &'static str) -> ty::Region<'tcx> {
-        let name = Symbol::intern(name);
+        let name = Symbol::intern(name).as_str();
         self.infcx.tcx.mk_region(ty::ReEarlyBound(ty::EarlyBoundRegion {
             def_id: self.infcx.tcx.hir.local_def_id(ast::CRATE_NODE_ID),
             index,
index c4ea543ab36b6d8cd33cf831b7c2db4b8ec7e0e9..36debf677da2b5873128fb4fc2223894843bb638 100644 (file)
@@ -100,7 +100,7 @@ pub fn ast_region_to_region(&self,
     {
         let tcx = self.tcx();
         let lifetime_name = |def_id| {
-            tcx.hir.name(tcx.hir.as_local_node_id(def_id).unwrap())
+            tcx.hir.name(tcx.hir.as_local_node_id(def_id).unwrap()).as_str()
         };
 
         let hir_id = tcx.hir.node_to_hir_id(lifetime.id);
index a4f820d1fdcf9553488b85b9da013929f9307f47..4f797c8c861ea622e333f9d69ffb37b875586359 100644 (file)
@@ -885,7 +885,7 @@ fn generics_of<'a, 'tcx>(tcx: TyCtxt<'a, 'tcx, 'tcx>,
     let early_lifetimes = early_bound_lifetimes_from_generics(tcx, ast_generics);
     let regions = early_lifetimes.enumerate().map(|(i, l)| {
         ty::RegionParameterDef {
-            name: l.lifetime.name.name(),
+            name: l.lifetime.name.name().as_str(),
             index: own_start + i as u32,
             def_id: tcx.hir.local_def_id(l.lifetime.id),
             pure_wrt_drop: l.pure_wrt_drop,
@@ -1422,7 +1422,7 @@ fn explicit_predicates_of<'a, 'tcx>(tcx: TyCtxt<'a, 'tcx, 'tcx>,
         let region = tcx.mk_region(ty::ReEarlyBound(ty::EarlyBoundRegion {
             def_id: tcx.hir.local_def_id(param.lifetime.id),
             index,
-            name: param.lifetime.name.name(),
+            name: param.lifetime.name.name().as_str(),
         }));
         index += 1;
 
index 888148352c70a46a26d432213771912302c6ad7d..52d5dbe3f05891384af205b80851cb6dcb93f1ab 100644 (file)
@@ -224,7 +224,7 @@ fn generics_to_path_params(&self, generics: ty::Generics) -> hir::PathParameters
                     let name = if p.name == "" {
                         hir::LifetimeName::Static
                     } else {
-                        hir::LifetimeName::Name(p.name)
+                        hir::LifetimeName::Name(Symbol::intern(&p.name))
                     };
 
                     hir::Lifetime {
@@ -407,7 +407,7 @@ fn find_auto_trait_generics(
             let names_map: FxHashMap<String, Lifetime> = generics
                 .regions
                 .iter()
-                .map(|l| (l.name.as_str().to_string(), l.clean(self.cx)))
+                .map(|l| (l.name.to_string(), l.clean(self.cx)))
                 .collect();
 
             let body_ids: FxHashSet<_> = infcx
@@ -728,7 +728,7 @@ fn get_lifetime(&self, region: Region, names_map: &FxHashMap<String, Lifetime>)
 
     fn region_name(&self, region: Region) -> Option<String> {
         match region {
-            &ty::ReEarlyBound(r) => Some(r.name.as_str().to_string()),
+            &ty::ReEarlyBound(r) => Some(r.name.to_string()),
             _ => None,
         }
     }
@@ -1005,7 +1005,7 @@ fn extract_for_generics<'b, 'c, 'd>(
                         // We only care about late bound regions, as we need to add them
                         // to the 'for<>' section
                         &ty::ReLateBound(_, ty::BoundRegion::BrNamed(_, name)) => {
-                            Some(GenericParam::Lifetime(Lifetime(name.as_str().to_string())))
+                            Some(GenericParam::Lifetime(Lifetime(name.to_string())))
                         }
                         &ty::ReVar(_) | &ty::ReEarlyBound(_) => None,
                         _ => panic!("Unexpected region type {:?}", r),