This makes it consistent with TypeParameterDef.
use syntax::ast;
use errors::DiagnosticBuilder;
use syntax_pos::{self, Span};
+use syntax_pos::symbol::InternedString;
use util::nodemap::FxHashMap;
use arena::DroplessArena;
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
#[derive(Copy, Clone, RustcEncodable, RustcDecodable)]
pub struct RegionParameterDef {
- pub name: Name,
+ pub name: InternedString,
pub def_id: DefId,
pub index: u32,
///
/// 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),
pub struct EarlyBoundRegion {
pub def_id: DefId,
pub index: u32,
- pub name: Name,
+ pub name: InternedString,
}
#[derive(Clone, Copy, PartialEq, Eq, Hash, RustcEncodable, RustcDecodable)]
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 {
}
-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 {
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,
}
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
}
};
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))
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,
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"),
}
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,
{
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);
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,
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;
let name = if p.name == "" {
hir::LifetimeName::Static
} else {
- hir::LifetimeName::Name(p.name)
+ hir::LifetimeName::Name(Symbol::intern(&p.name))
};
hir::Lifetime {
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
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,
}
}
// 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),