Skip to content

Commit 513d392

Browse files
committed
rustc: Replace &'a TyCtxt<'tcx> with a TyCtxt<'a, 'tcx> wrapper.
1 parent 8fc2c46 commit 513d392

File tree

147 files changed

+1331
-1338
lines changed

Some content is hidden

Large Commits have some content hidden by default. Use the searchbox below for content that may be hidden.

147 files changed

+1331
-1338
lines changed

src/librustc/cfg/construct.rs

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -19,7 +19,7 @@ use syntax::ptr::P;
1919
use hir::{self, PatKind};
2020

2121
struct CFGBuilder<'a, 'tcx: 'a> {
22-
tcx: &'a TyCtxt<'tcx>,
22+
tcx: TyCtxt<'a, 'tcx>,
2323
graph: CFGGraph,
2424
fn_exit: CFGIndex,
2525
loop_scopes: Vec<LoopScope>,
@@ -32,7 +32,7 @@ struct LoopScope {
3232
break_index: CFGIndex, // where to go on a `break
3333
}
3434

35-
pub fn construct(tcx: &TyCtxt,
35+
pub fn construct(tcx: TyCtxt,
3636
blk: &hir::Block) -> CFG {
3737
let mut graph = graph::Graph::new();
3838
let entry = graph.add_node(CFGNodeData::Entry);

src/librustc/cfg/mod.rs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -58,7 +58,7 @@ pub type CFGNode = graph::Node<CFGNodeData>;
5858
pub type CFGEdge = graph::Edge<CFGEdgeData>;
5959

6060
impl CFG {
61-
pub fn new(tcx: &TyCtxt,
61+
pub fn new(tcx: TyCtxt,
6262
blk: &hir::Block) -> CFG {
6363
construct::construct(tcx, blk)
6464
}

src/librustc/dep_graph/visit.rs

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -22,13 +22,13 @@ use super::dep_node::DepNode;
2222
/// read edge from the corresponding AST node. This is used in
2323
/// compiler passes to automatically record the item that they are
2424
/// working on.
25-
pub fn visit_all_items_in_krate<'tcx,V,F>(tcx: &TyCtxt<'tcx>,
26-
mut dep_node_fn: F,
27-
visitor: &mut V)
25+
pub fn visit_all_items_in_krate<'a, 'tcx, V, F>(tcx: TyCtxt<'a, 'tcx>,
26+
mut dep_node_fn: F,
27+
visitor: &mut V)
2828
where F: FnMut(DefId) -> DepNode<DefId>, V: Visitor<'tcx>
2929
{
3030
struct TrackingVisitor<'visit, 'tcx: 'visit, F: 'visit, V: 'visit> {
31-
tcx: &'visit TyCtxt<'tcx>,
31+
tcx: TyCtxt<'visit, 'tcx>,
3232
dep_node_fn: &'visit mut F,
3333
visitor: &'visit mut V
3434
}

src/librustc/hir/pat_util.rs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -209,7 +209,7 @@ pub fn simple_name<'a>(pat: &'a hir::Pat) -> Option<ast::Name> {
209209
}
210210
}
211211

212-
pub fn def_to_path(tcx: &TyCtxt, id: DefId) -> hir::Path {
212+
pub fn def_to_path(tcx: TyCtxt, id: DefId) -> hir::Path {
213213
let name = tcx.item_name(id);
214214
hir::Path::from_ident(DUMMY_SP, hir::Ident::from_name(name))
215215
}

src/librustc/infer/bivariate.rs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -45,7 +45,7 @@ impl<'a, 'tcx> Bivariate<'a, 'tcx> {
4545
impl<'a, 'tcx> TypeRelation<'a, 'tcx> for Bivariate<'a, 'tcx> {
4646
fn tag(&self) -> &'static str { "Bivariate" }
4747

48-
fn tcx(&self) -> &'a TyCtxt<'tcx> { self.fields.tcx() }
48+
fn tcx(&self) -> TyCtxt<'a, 'tcx> { self.fields.tcx() }
4949

5050
fn a_is_expected(&self) -> bool { self.fields.a_is_expected }
5151

src/librustc/infer/combine.rs

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -151,7 +151,7 @@ fn unify_float_variable(&self,
151151
}
152152

153153
impl<'a, 'tcx> CombineFields<'a, 'tcx> {
154-
pub fn tcx(&self) -> &'a TyCtxt<'tcx> {
154+
pub fn tcx(&self) -> TyCtxt<'a, 'tcx> {
155155
self.infcx.tcx
156156
}
157157

@@ -300,7 +300,7 @@ struct Generalizer<'cx, 'tcx:'cx> {
300300
}
301301

302302
impl<'cx, 'tcx> ty::fold::TypeFolder<'tcx> for Generalizer<'cx, 'tcx> {
303-
fn tcx(&self) -> &TyCtxt<'tcx> {
303+
fn tcx<'a>(&'a self) -> TyCtxt<'a, 'tcx> {
304304
self.infcx.tcx
305305
}
306306

src/librustc/infer/equate.rs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -36,7 +36,7 @@ impl<'a, 'tcx> Equate<'a, 'tcx> {
3636
impl<'a, 'tcx> TypeRelation<'a,'tcx> for Equate<'a, 'tcx> {
3737
fn tag(&self) -> &'static str { "Equate" }
3838

39-
fn tcx(&self) -> &'a TyCtxt<'tcx> { self.fields.tcx() }
39+
fn tcx(&self) -> TyCtxt<'a, 'tcx> { self.fields.tcx() }
4040

4141
fn a_is_expected(&self) -> bool { self.fields.a_is_expected }
4242

src/librustc/infer/error_reporting.rs

Lines changed: 7 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -95,8 +95,8 @@ use syntax::codemap::{self, Pos, Span};
9595
use syntax::parse::token;
9696
use syntax::ptr::P;
9797

98-
impl<'tcx> TyCtxt<'tcx> {
99-
pub fn note_and_explain_region(&self,
98+
impl<'a, 'tcx> TyCtxt<'a, 'tcx> {
99+
pub fn note_and_explain_region(self,
100100
err: &mut DiagnosticBuilder,
101101
prefix: &str,
102102
region: ty::Region,
@@ -112,7 +112,7 @@ impl<'tcx> TyCtxt<'tcx> {
112112
}
113113
}
114114

115-
fn explain_span(tcx: &TyCtxt, heading: &str, span: Span)
115+
fn explain_span(tcx: TyCtxt, heading: &str, span: Span)
116116
-> (String, Option<Span>) {
117117
let lo = tcx.sess.codemap().lookup_char_pos_adj(span.lo);
118118
(format!("the {} at {}:{}", heading, lo.line, lo.col.to_usize()),
@@ -474,7 +474,7 @@ impl<'a, 'tcx> ErrorReporting<'tcx> for InferCtxt<'a, 'tcx> {
474474
}
475475
}
476476

477-
fn free_regions_from_same_fn(tcx: &TyCtxt,
477+
fn free_regions_from_same_fn(tcx: TyCtxt,
478478
sub: Region,
479479
sup: Region)
480480
-> Option<FreeRegionsFromSameFn> {
@@ -1109,7 +1109,7 @@ struct RebuildPathInfo<'a> {
11091109
}
11101110

11111111
struct Rebuilder<'a, 'tcx: 'a> {
1112-
tcx: &'a TyCtxt<'tcx>,
1112+
tcx: TyCtxt<'a, 'tcx>,
11131113
fn_decl: &'a hir::FnDecl,
11141114
expl_self_opt: Option<&'a hir::ExplicitSelf_>,
11151115
generics: &'a hir::Generics,
@@ -1125,7 +1125,7 @@ enum FreshOrKept {
11251125
}
11261126

11271127
impl<'a, 'tcx> Rebuilder<'a, 'tcx> {
1128-
fn new(tcx: &'a TyCtxt<'tcx>,
1128+
fn new(tcx: TyCtxt<'a, 'tcx>,
11291129
fn_decl: &'a hir::FnDecl,
11301130
expl_self_opt: Option<&'a hir::ExplicitSelf_>,
11311131
generics: &'a hir::Generics,
@@ -1929,7 +1929,7 @@ impl<'tcx> Resolvable<'tcx> for ty::PolyTraitRef<'tcx> {
19291929
}
19301930
}
19311931

1932-
fn lifetimes_in_scope(tcx: &TyCtxt,
1932+
fn lifetimes_in_scope(tcx: TyCtxt,
19331933
scope_id: ast::NodeId)
19341934
-> Vec<hir::LifetimeDef> {
19351935
let mut taken = Vec::new();

src/librustc/infer/freshen.rs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -78,7 +78,7 @@ impl<'a, 'tcx> TypeFreshener<'a, 'tcx> {
7878
}
7979

8080
impl<'a, 'tcx> TypeFolder<'tcx> for TypeFreshener<'a, 'tcx> {
81-
fn tcx<'b>(&'b self) -> &'b TyCtxt<'tcx> {
81+
fn tcx<'b>(&'b self) -> TyCtxt<'b, 'tcx> {
8282
self.infcx.tcx
8383
}
8484

src/librustc/infer/glb.rs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -36,7 +36,7 @@ impl<'a, 'tcx> Glb<'a, 'tcx> {
3636
impl<'a, 'tcx> TypeRelation<'a, 'tcx> for Glb<'a, 'tcx> {
3737
fn tag(&self) -> &'static str { "Glb" }
3838

39-
fn tcx(&self) -> &'a TyCtxt<'tcx> { self.fields.tcx() }
39+
fn tcx(&self) -> TyCtxt<'a, 'tcx> { self.fields.tcx() }
4040

4141
fn a_is_expected(&self) -> bool { self.fields.a_is_expected }
4242

src/librustc/infer/higher_ranked/mod.rs

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -329,10 +329,10 @@ fn is_var_in_set(new_vars: &[ty::RegionVid], r: ty::Region) -> bool {
329329
}
330330
}
331331

332-
fn fold_regions_in<'tcx, T, F>(tcx: &TyCtxt<'tcx>,
333-
unbound_value: &T,
334-
mut fldr: F)
335-
-> T
332+
fn fold_regions_in<'a, 'tcx, T, F>(tcx: TyCtxt<'a, 'tcx>,
333+
unbound_value: &T,
334+
mut fldr: F)
335+
-> T
336336
where T: TypeFoldable<'tcx>,
337337
F: FnMut(ty::Region, ty::DebruijnIndex) -> ty::Region,
338338
{

src/librustc/infer/lub.rs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -36,7 +36,7 @@ impl<'a, 'tcx> Lub<'a, 'tcx> {
3636
impl<'a, 'tcx> TypeRelation<'a, 'tcx> for Lub<'a, 'tcx> {
3737
fn tag(&self) -> &'static str { "Lub" }
3838

39-
fn tcx(&self) -> &'a TyCtxt<'tcx> { self.fields.tcx() }
39+
fn tcx(&self) -> TyCtxt<'a, 'tcx> { self.fields.tcx() }
4040

4141
fn a_is_expected(&self) -> bool { self.fields.a_is_expected }
4242

src/librustc/infer/mod.rs

Lines changed: 7 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -74,7 +74,7 @@ pub type UnitResult<'tcx> = RelateResult<'tcx, ()>; // "unify result"
7474
pub type FixupResult<T> = Result<T, FixupError>; // "fixup result"
7575

7676
pub struct InferCtxt<'a, 'tcx: 'a> {
77-
pub tcx: &'a TyCtxt<'tcx>,
77+
pub tcx: TyCtxt<'a, 'tcx>,
7878

7979
pub tables: &'a RefCell<ty::Tables<'tcx>>,
8080

@@ -385,7 +385,7 @@ impl fmt::Display for FixupError {
385385
}
386386

387387
impl<'a, 'tcx> InferCtxt<'a, 'tcx> {
388-
pub fn new(tcx: &'a TyCtxt<'tcx>,
388+
pub fn new(tcx: TyCtxt<'a, 'tcx>,
389389
tables: &'a RefCell<ty::Tables<'tcx>>,
390390
param_env: Option<ty::ParameterEnvironment<'a, 'tcx>>,
391391
projection_mode: ProjectionMode)
@@ -406,7 +406,7 @@ impl<'a, 'tcx> InferCtxt<'a, 'tcx> {
406406
}
407407
}
408408

409-
pub fn normalizing(tcx: &'a TyCtxt<'tcx>,
409+
pub fn normalizing(tcx: TyCtxt<'a, 'tcx>,
410410
tables: &'a RefCell<ty::Tables<'tcx>>,
411411
projection_mode: ProjectionMode)
412412
-> Self {
@@ -441,8 +441,8 @@ pub struct CombinedSnapshot {
441441
}
442442

443443
// NOTE: Callable from trans only!
444-
impl<'tcx> TyCtxt<'tcx> {
445-
pub fn normalize_associated_type<T>(&self, value: &T) -> T
444+
impl<'a, 'tcx> TyCtxt<'a, 'tcx> {
445+
pub fn normalize_associated_type<T>(self, value: &T) -> T
446446
where T : TypeFoldable<'tcx>
447447
{
448448
debug!("normalize_associated_type(t={:?})", value);
@@ -1523,7 +1523,7 @@ pub fn drain_fulfillment_cx<T>(&self,
15231523
}
15241524
}
15251525

1526-
impl<'tcx> TypeTrace<'tcx> {
1526+
impl<'a, 'tcx> TypeTrace<'tcx> {
15271527
pub fn span(&self) -> Span {
15281528
self.origin.span()
15291529
}
@@ -1539,7 +1539,7 @@ impl<'tcx> TypeTrace<'tcx> {
15391539
}
15401540
}
15411541

1542-
pub fn dummy(tcx: &TyCtxt<'tcx>) -> TypeTrace<'tcx> {
1542+
pub fn dummy(tcx: TyCtxt<'a, 'tcx>) -> TypeTrace<'tcx> {
15431543
TypeTrace {
15441544
origin: TypeOrigin::Misc(codemap::DUMMY_SP),
15451545
values: Types(ExpectedFound {

src/librustc/infer/region_inference/graphviz.rs

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -119,7 +119,7 @@ pub fn maybe_print_constraints_for<'a, 'tcx>(region_vars: &RegionVarBindings<'a,
119119
}
120120

121121
struct ConstraintGraph<'a, 'tcx: 'a> {
122-
tcx: &'a TyCtxt<'tcx>,
122+
tcx: TyCtxt<'a, 'tcx>,
123123
graph_name: String,
124124
map: &'a FnvHashMap<Constraint, SubregionOrigin<'tcx>>,
125125
node_ids: FnvHashMap<Node, usize>,
@@ -139,7 +139,7 @@ enum Edge {
139139
}
140140

141141
impl<'a, 'tcx> ConstraintGraph<'a, 'tcx> {
142-
fn new(tcx: &'a TyCtxt<'tcx>,
142+
fn new(tcx: TyCtxt<'a, 'tcx>,
143143
name: String,
144144
map: &'a ConstraintMap<'tcx>)
145145
-> ConstraintGraph<'a, 'tcx> {
@@ -258,7 +258,7 @@ impl<'a, 'tcx> dot::GraphWalk<'a> for ConstraintGraph<'a, 'tcx> {
258258

259259
pub type ConstraintMap<'tcx> = FnvHashMap<Constraint, SubregionOrigin<'tcx>>;
260260

261-
fn dump_region_constraints_to<'a, 'tcx: 'a>(tcx: &'a TyCtxt<'tcx>,
261+
fn dump_region_constraints_to<'a, 'tcx: 'a>(tcx: TyCtxt<'a, 'tcx>,
262262
map: &ConstraintMap<'tcx>,
263263
path: &str)
264264
-> io::Result<()> {

src/librustc/infer/region_inference/mod.rs

Lines changed: 9 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -191,7 +191,7 @@ impl SameRegions {
191191
pub type CombineMap = FnvHashMap<TwoRegions, RegionVid>;
192192

193193
pub struct RegionVarBindings<'a, 'tcx: 'a> {
194-
tcx: &'a TyCtxt<'tcx>,
194+
tcx: TyCtxt<'a, 'tcx>,
195195
var_origins: RefCell<Vec<RegionVariableOrigin>>,
196196

197197
// Constraints of the form `A <= B` introduced by the region
@@ -254,7 +254,7 @@ pub struct RegionSnapshot {
254254
}
255255

256256
impl<'a, 'tcx> RegionVarBindings<'a, 'tcx> {
257-
pub fn new(tcx: &'a TyCtxt<'tcx>) -> RegionVarBindings<'a, 'tcx> {
257+
pub fn new(tcx: TyCtxt<'a, 'tcx>) -> RegionVarBindings<'a, 'tcx> {
258258
RegionVarBindings {
259259
tcx: tcx,
260260
var_origins: RefCell::new(Vec::new()),
@@ -1362,8 +1362,8 @@ impl<'tcx> fmt::Display for GenericKind<'tcx> {
13621362
}
13631363
}
13641364

1365-
impl<'tcx> GenericKind<'tcx> {
1366-
pub fn to_ty(&self, tcx: &TyCtxt<'tcx>) -> Ty<'tcx> {
1365+
impl<'a, 'tcx> GenericKind<'tcx> {
1366+
pub fn to_ty(&self, tcx: TyCtxt<'a, 'tcx>) -> Ty<'tcx> {
13671367
match *self {
13681368
GenericKind::Param(ref p) => p.to_ty(tcx),
13691369
GenericKind::Projection(ref p) => tcx.mk_projection(p.trait_ref.clone(), p.item_name),
@@ -1424,12 +1424,11 @@ impl VerifyBound {
14241424
}
14251425
}
14261426

1427-
fn is_met<'tcx>(&self,
1428-
tcx: &TyCtxt<'tcx>,
1429-
free_regions: &FreeRegionMap,
1430-
var_values: &Vec<VarValue>,
1431-
min: ty::Region)
1432-
-> bool {
1427+
fn is_met(&self, tcx: TyCtxt,
1428+
free_regions: &FreeRegionMap,
1429+
var_values: &Vec<VarValue>,
1430+
min: ty::Region)
1431+
-> bool {
14331432
match self {
14341433
&VerifyBound::AnyRegion(ref rs) =>
14351434
rs.iter()

src/librustc/infer/resolve.rs

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -30,7 +30,7 @@ impl<'a, 'tcx> OpportunisticTypeResolver<'a, 'tcx> {
3030
}
3131

3232
impl<'a, 'tcx> ty::fold::TypeFolder<'tcx> for OpportunisticTypeResolver<'a, 'tcx> {
33-
fn tcx(&self) -> &TyCtxt<'tcx> {
33+
fn tcx<'b>(&'b self) -> TyCtxt<'b, 'tcx> {
3434
self.infcx.tcx
3535
}
3636

@@ -58,7 +58,7 @@ impl<'a, 'tcx> OpportunisticTypeAndRegionResolver<'a, 'tcx> {
5858
}
5959

6060
impl<'a, 'tcx> ty::fold::TypeFolder<'tcx> for OpportunisticTypeAndRegionResolver<'a, 'tcx> {
61-
fn tcx(&self) -> &TyCtxt<'tcx> {
61+
fn tcx<'b>(&'b self) -> TyCtxt<'b, 'tcx> {
6262
self.infcx.tcx
6363
}
6464

@@ -104,7 +104,7 @@ struct FullTypeResolver<'a, 'tcx:'a> {
104104
}
105105

106106
impl<'a, 'tcx> ty::fold::TypeFolder<'tcx> for FullTypeResolver<'a, 'tcx> {
107-
fn tcx(&self) -> &TyCtxt<'tcx> {
107+
fn tcx<'b>(&'b self) -> TyCtxt<'b, 'tcx> {
108108
self.infcx.tcx
109109
}
110110

src/librustc/infer/sub.rs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -36,7 +36,7 @@ impl<'a, 'tcx> Sub<'a, 'tcx> {
3636

3737
impl<'a, 'tcx> TypeRelation<'a, 'tcx> for Sub<'a, 'tcx> {
3838
fn tag(&self) -> &'static str { "Sub" }
39-
fn tcx(&self) -> &'a TyCtxt<'tcx> { self.fields.infcx.tcx }
39+
fn tcx(&self) -> TyCtxt<'a, 'tcx> { self.fields.infcx.tcx }
4040
fn a_is_expected(&self) -> bool { self.fields.a_is_expected }
4141

4242
fn with_cause<F,R>(&mut self, cause: Cause, f: F) -> R

src/librustc/infer/unify_key.rs

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -13,7 +13,7 @@ use ty::{self, IntVarValue, Ty, TyCtxt};
1313
use rustc_data_structures::unify::{Combine, UnifyKey};
1414

1515
pub trait ToType<'tcx> {
16-
fn to_type(&self, tcx: &TyCtxt<'tcx>) -> Ty<'tcx>;
16+
fn to_type<'a>(&self, tcx: TyCtxt<'a, 'tcx>) -> Ty<'tcx>;
1717
}
1818

1919
impl UnifyKey for ty::IntVid {
@@ -51,7 +51,7 @@ impl UnifyKey for ty::RegionVid {
5151
}
5252

5353
impl<'tcx> ToType<'tcx> for IntVarValue {
54-
fn to_type(&self, tcx: &TyCtxt<'tcx>) -> Ty<'tcx> {
54+
fn to_type<'a>(&self, tcx: TyCtxt<'a, 'tcx>) -> Ty<'tcx> {
5555
match *self {
5656
ty::IntType(i) => tcx.mk_mach_int(i),
5757
ty::UintType(i) => tcx.mk_mach_uint(i),
@@ -69,7 +69,7 @@ impl UnifyKey for ty::FloatVid {
6969
}
7070

7171
impl<'tcx> ToType<'tcx> for ast::FloatTy {
72-
fn to_type(&self, tcx: &TyCtxt<'tcx>) -> Ty<'tcx> {
72+
fn to_type<'a>(&self, tcx: TyCtxt<'a, 'tcx>) -> Ty<'tcx> {
7373
tcx.mk_mach_float(*self)
7474
}
7575
}

0 commit comments

Comments
 (0)