Skip to content

Commit bd7f301

Browse files
committed
Use the existing static and env symbols instead of interning.
1 parent 1eb5390 commit bd7f301

File tree

3 files changed

+7
-8
lines changed

3 files changed

+7
-8
lines changed

compiler/rustc_borrowck/src/type_check/mod.rs

Lines changed: 2 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -35,6 +35,7 @@ use rustc_middle::ty::{
3535
OpaqueHiddenType, OpaqueTypeKey, RegionVid, Ty, TyCtxt, UserType, UserTypeAnnotationIndex,
3636
};
3737
use rustc_span::def_id::CRATE_DEF_ID;
38+
use rustc_span::symbol::sym;
3839
use rustc_span::{Span, DUMMY_SP};
3940
use rustc_target::abi::{FieldIdx, FIRST_VARIANT};
4041
use rustc_trait_selection::traits::query::type_op::custom::scrape_region_constraints;
@@ -1347,9 +1348,7 @@ impl<'a, 'tcx> TypeChecker<'a, 'tcx> {
13471348
BoundRegionInfo::Name(Symbol::intern("anon"))
13481349
}
13491350
ty::BoundRegionKind::BrNamed(_, name) => BoundRegionInfo::Name(name),
1350-
ty::BoundRegionKind::BrEnv => {
1351-
BoundRegionInfo::Name(Symbol::intern("env"))
1352-
}
1351+
ty::BoundRegionKind::BrEnv => BoundRegionInfo::Name(sym::env),
13531352
};
13541353

13551354
RegionCtxt::LateBound(reg_info)

compiler/rustc_borrowck/src/type_check/relate_tys.rs

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -4,6 +4,7 @@ use rustc_infer::traits::PredicateObligations;
44
use rustc_middle::mir::ConstraintCategory;
55
use rustc_middle::ty::relate::TypeRelation;
66
use rustc_middle::ty::{self, Ty};
7+
use rustc_span::symbol::sym;
78
use rustc_span::{Span, Symbol};
89
use rustc_trait_selection::traits::query::Fallible;
910

@@ -127,7 +128,7 @@ impl<'tcx> TypeRelatingDelegate<'tcx> for NllTypeRelatingDelegate<'_, '_, 'tcx>
127128
ty::BoundRegionKind::BrAnon(Some(span)) => BoundRegionInfo::Span(span),
128129
ty::BoundRegionKind::BrAnon(..) => BoundRegionInfo::Name(Symbol::intern("anon")),
129130
ty::BoundRegionKind::BrNamed(_, name) => BoundRegionInfo::Name(name),
130-
ty::BoundRegionKind::BrEnv => BoundRegionInfo::Name(Symbol::intern("env")),
131+
ty::BoundRegionKind::BrEnv => BoundRegionInfo::Name(sym::env),
131132
};
132133

133134
let reg_var =

compiler/rustc_borrowck/src/universal_regions.rs

Lines changed: 3 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -24,6 +24,7 @@ use rustc_infer::infer::NllRegionVariableOrigin;
2424
use rustc_middle::ty::fold::TypeFoldable;
2525
use rustc_middle::ty::{self, InlineConstSubsts, InlineConstSubstsParts, RegionVid, Ty, TyCtxt};
2626
use rustc_middle::ty::{InternalSubsts, SubstsRef};
27+
use rustc_span::symbol::kw;
2728
use rustc_span::Symbol;
2829
use std::iter;
2930

@@ -404,10 +405,8 @@ impl<'cx, 'tcx> UniversalRegionsBuilder<'cx, 'tcx> {
404405
assert_eq!(FIRST_GLOBAL_INDEX, self.infcx.num_region_vars());
405406

406407
// Create the "global" region that is always free in all contexts: 'static.
407-
let fr_static = self
408-
.infcx
409-
.next_nll_region_var(FR, || RegionCtxt::Free(Symbol::intern("static")))
410-
.to_region_vid();
408+
let fr_static =
409+
self.infcx.next_nll_region_var(FR, || RegionCtxt::Free(kw::Static)).to_region_vid();
411410

412411
// We've now added all the global regions. The next ones we
413412
// add will be external.

0 commit comments

Comments
 (0)