Skip to content

Commit 6f629d3

Browse files
committed
Rollup merge of rust-lang#49913 - varkor:RegionParameterDef-InternedString, r=petrochenkov
Use InternedString rather than Name for RegionParameterDef This makes it consistent with `TypeParameterDef`.
2 parents 44a71e2 + 6234d41 commit 6f629d3

File tree

8 files changed

+21
-21
lines changed

8 files changed

+21
-21
lines changed

src/librustc/infer/mod.rs

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -35,6 +35,7 @@ use std::fmt;
3535
use syntax::ast;
3636
use errors::DiagnosticBuilder;
3737
use syntax_pos::{self, Span};
38+
use syntax_pos::symbol::InternedString;
3839
use util::nodemap::FxHashMap;
3940
use arena::DroplessArena;
4041

@@ -343,7 +344,7 @@ pub enum RegionVariableOrigin {
343344
Coercion(Span),
344345

345346
// Region variables created as the values for early-bound regions
346-
EarlyBoundRegion(Span, ast::Name),
347+
EarlyBoundRegion(Span, InternedString),
347348

348349
// Region variables created for bound regions
349350
// in a function or method that is called

src/librustc/ty/mod.rs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -728,7 +728,7 @@ pub struct TypeParameterDef {
728728

729729
#[derive(Copy, Clone, RustcEncodable, RustcDecodable)]
730730
pub struct RegionParameterDef {
731-
pub name: Name,
731+
pub name: InternedString,
732732
pub def_id: DefId,
733733
pub index: u32,
734734

src/librustc/ty/sty.rs

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -58,7 +58,7 @@ pub enum BoundRegion {
5858
///
5959
/// The def-id is needed to distinguish free regions in
6060
/// the event of shadowing.
61-
BrNamed(DefId, Name),
61+
BrNamed(DefId, InternedString),
6262

6363
/// Fresh bound identifiers created during GLB computations.
6464
BrFresh(u32),
@@ -1058,7 +1058,7 @@ impl<'tcx> serialize::UseSpecializedDecodable for Region<'tcx> {}
10581058
pub struct EarlyBoundRegion {
10591059
pub def_id: DefId,
10601060
pub index: u32,
1061-
pub name: Name,
1061+
pub name: InternedString,
10621062
}
10631063

10641064
#[derive(Clone, Copy, PartialEq, Eq, Hash, RustcEncodable, RustcDecodable)]

src/librustc/util/ppaux.rs

Lines changed: 8 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -30,7 +30,7 @@ use std::usize;
3030
use rustc_data_structures::indexed_vec::Idx;
3131
use syntax::abi::Abi;
3232
use syntax::ast::CRATE_NODE_ID;
33-
use syntax::symbol::Symbol;
33+
use syntax::symbol::{Symbol, InternedString};
3434
use hir;
3535

3636
macro_rules! gen_display_debug_body {
@@ -130,7 +130,7 @@ macro_rules! print {
130130
}
131131

132132

133-
struct LateBoundRegionNameCollector(FxHashSet<Symbol>);
133+
struct LateBoundRegionNameCollector(FxHashSet<InternedString>);
134134
impl<'tcx> ty::fold::TypeVisitor<'tcx> for LateBoundRegionNameCollector {
135135
fn visit_region(&mut self, r: ty::Region<'tcx>) -> bool {
136136
match *r {
@@ -148,7 +148,7 @@ pub struct PrintContext {
148148
is_debug: bool,
149149
is_verbose: bool,
150150
identify_regions: bool,
151-
used_region_names: Option<FxHashSet<Symbol>>,
151+
used_region_names: Option<FxHashSet<InternedString>>,
152152
region_index: usize,
153153
binder_depth: usize,
154154
}
@@ -440,12 +440,12 @@ impl PrintContext {
440440
lifted: Option<ty::Binder<U>>) -> fmt::Result
441441
where T: Print, U: Print + TypeFoldable<'tcx>, F: fmt::Write
442442
{
443-
fn name_by_region_index(index: usize) -> Symbol {
443+
fn name_by_region_index(index: usize) -> InternedString {
444444
match index {
445445
0 => Symbol::intern("'r"),
446446
1 => Symbol::intern("'s"),
447447
i => Symbol::intern(&format!("'t{}", i-2)),
448-
}
448+
}.as_str()
449449
}
450450

451451
// Replace any anonymous late-bound regions with named
@@ -493,8 +493,7 @@ impl PrintContext {
493493
}
494494
};
495495
let _ = write!(f, "{}", name);
496-
ty::BrNamed(tcx.hir.local_def_id(CRATE_NODE_ID),
497-
name)
496+
ty::BrNamed(tcx.hir.local_def_id(CRATE_NODE_ID), name)
498497
}
499498
};
500499
tcx.mk_region(ty::ReLateBound(ty::DebruijnIndex::new(1), br))
@@ -510,7 +509,7 @@ impl PrintContext {
510509
result
511510
}
512511

513-
fn is_name_used(&self, name: &Symbol) -> bool {
512+
fn is_name_used(&self, name: &InternedString) -> bool {
514513
match self.used_region_names {
515514
Some(ref names) => names.contains(name),
516515
None => false,
@@ -697,7 +696,7 @@ define_print! {
697696
BrAnon(n) => write!(f, "BrAnon({:?})", n),
698697
BrFresh(n) => write!(f, "BrFresh({:?})", n),
699698
BrNamed(did, name) => {
700-
write!(f, "BrNamed({:?}:{:?}, {:?})",
699+
write!(f, "BrNamed({:?}:{:?}, {})",
701700
did.krate, did.index, name)
702701
}
703702
BrEnv => write!(f, "BrEnv"),

src/librustc_driver/test.rs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -307,7 +307,7 @@ impl<'a, 'gcx, 'tcx> Env<'a, 'gcx, 'tcx> {
307307
}
308308

309309
pub fn re_early_bound(&self, index: u32, name: &'static str) -> ty::Region<'tcx> {
310-
let name = Symbol::intern(name);
310+
let name = Symbol::intern(name).as_str();
311311
self.infcx.tcx.mk_region(ty::ReEarlyBound(ty::EarlyBoundRegion {
312312
def_id: self.infcx.tcx.hir.local_def_id(ast::CRATE_NODE_ID),
313313
index,

src/librustc_typeck/astconv.rs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -100,7 +100,7 @@ impl<'o, 'gcx: 'tcx, 'tcx> AstConv<'gcx, 'tcx>+'o {
100100
{
101101
let tcx = self.tcx();
102102
let lifetime_name = |def_id| {
103-
tcx.hir.name(tcx.hir.as_local_node_id(def_id).unwrap())
103+
tcx.hir.name(tcx.hir.as_local_node_id(def_id).unwrap()).as_str()
104104
};
105105

106106
let hir_id = tcx.hir.node_to_hir_id(lifetime.id);

src/librustc_typeck/collect.rs

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -886,7 +886,7 @@ fn generics_of<'a, 'tcx>(tcx: TyCtxt<'a, 'tcx, 'tcx>,
886886
let early_lifetimes = early_bound_lifetimes_from_generics(tcx, ast_generics);
887887
let regions = early_lifetimes.enumerate().map(|(i, l)| {
888888
ty::RegionParameterDef {
889-
name: l.lifetime.name.name(),
889+
name: l.lifetime.name.name().as_str(),
890890
index: own_start + i as u32,
891891
def_id: tcx.hir.local_def_id(l.lifetime.id),
892892
pure_wrt_drop: l.pure_wrt_drop,
@@ -1427,7 +1427,7 @@ pub fn explicit_predicates_of<'a, 'tcx>(tcx: TyCtxt<'a, 'tcx, 'tcx>,
14271427
let region = tcx.mk_region(ty::ReEarlyBound(ty::EarlyBoundRegion {
14281428
def_id: tcx.hir.local_def_id(param.lifetime.id),
14291429
index,
1430-
name: param.lifetime.name.name(),
1430+
name: param.lifetime.name.name().as_str(),
14311431
}));
14321432
index += 1;
14331433

src/librustdoc/clean/auto_trait.rs

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -224,7 +224,7 @@ impl<'a, 'tcx, 'rcx> AutoTraitFinder<'a, 'tcx, 'rcx> {
224224
let name = if p.name == "" {
225225
hir::LifetimeName::Static
226226
} else {
227-
hir::LifetimeName::Name(p.name)
227+
hir::LifetimeName::Name(Symbol::intern(&p.name))
228228
};
229229

230230
hir::Lifetime {
@@ -407,7 +407,7 @@ impl<'a, 'tcx, 'rcx> AutoTraitFinder<'a, 'tcx, 'rcx> {
407407
let names_map: FxHashMap<String, Lifetime> = generics
408408
.regions
409409
.iter()
410-
.map(|l| (l.name.as_str().to_string(), l.clean(self.cx)))
410+
.map(|l| (l.name.to_string(), l.clean(self.cx)))
411411
.collect();
412412

413413
let body_ids: FxHashSet<_> = infcx
@@ -728,7 +728,7 @@ impl<'a, 'tcx, 'rcx> AutoTraitFinder<'a, 'tcx, 'rcx> {
728728

729729
fn region_name(&self, region: Region) -> Option<String> {
730730
match region {
731-
&ty::ReEarlyBound(r) => Some(r.name.as_str().to_string()),
731+
&ty::ReEarlyBound(r) => Some(r.name.to_string()),
732732
_ => None,
733733
}
734734
}
@@ -1005,7 +1005,7 @@ impl<'a, 'tcx, 'rcx> AutoTraitFinder<'a, 'tcx, 'rcx> {
10051005
// We only care about late bound regions, as we need to add them
10061006
// to the 'for<>' section
10071007
&ty::ReLateBound(_, ty::BoundRegion::BrNamed(_, name)) => {
1008-
Some(GenericParam::Lifetime(Lifetime(name.as_str().to_string())))
1008+
Some(GenericParam::Lifetime(Lifetime(name.to_string())))
10091009
}
10101010
&ty::ReVar(_) | &ty::ReEarlyBound(_) => None,
10111011
_ => panic!("Unexpected region type {:?}", r),

0 commit comments

Comments
 (0)