Skip to content

Commit b5122d5

Browse files
committed
rustc: Always refer to TyCtxt as tcx.
1 parent 6dbb0e8 commit b5122d5

File tree

9 files changed

+143
-143
lines changed

9 files changed

+143
-143
lines changed

src/librustc/middle/liveness.rs

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -169,8 +169,8 @@ enum LiveNodeKind {
169169
ExitNode
170170
}
171171

172-
fn live_node_kind_to_string(lnk: LiveNodeKind, cx: &TyCtxt) -> String {
173-
let cm = cx.sess.codemap();
172+
fn live_node_kind_to_string(lnk: LiveNodeKind, tcx: &TyCtxt) -> String {
173+
let cm = tcx.sess.codemap();
174174
match lnk {
175175
FreeVarNode(s) => {
176176
format!("Free var node [{}]", cm.span_to_string(s))

src/librustc/ty/adjustment.rs

Lines changed: 11 additions & 11 deletions
Original file line numberDiff line numberDiff line change
@@ -138,7 +138,7 @@ pub enum CustomCoerceUnsized {
138138

139139
impl<'tcx> ty::TyS<'tcx> {
140140
/// See `expr_ty_adjusted`
141-
pub fn adjust<F>(&'tcx self, cx: &TyCtxt<'tcx>,
141+
pub fn adjust<F>(&'tcx self, tcx: &TyCtxt<'tcx>,
142142
span: Span,
143143
expr_id: ast::NodeId,
144144
adjustment: Option<&AutoAdjustment<'tcx>>,
@@ -156,7 +156,7 @@ impl<'tcx> ty::TyS<'tcx> {
156156
AdjustReifyFnPointer => {
157157
match self.sty {
158158
ty::TyFnDef(_, _, b) => {
159-
cx.mk_ty(ty::TyFnPtr(b))
159+
tcx.mk_ty(ty::TyFnPtr(b))
160160
}
161161
_ => {
162162
bug!("AdjustReifyFnPointer adjustment on non-fn-item: {:?}",
@@ -167,7 +167,7 @@ impl<'tcx> ty::TyS<'tcx> {
167167

168168
AdjustUnsafeFnPointer => {
169169
match self.sty {
170-
ty::TyFnPtr(b) => cx.safe_to_unsafe_fn_ty(b),
170+
ty::TyFnPtr(b) => tcx.safe_to_unsafe_fn_ty(b),
171171
ref b => {
172172
bug!("AdjustUnsafeFnPointer adjustment on non-fn-ptr: {:?}",
173173
b);
@@ -177,7 +177,7 @@ impl<'tcx> ty::TyS<'tcx> {
177177

178178
AdjustMutToConstPointer => {
179179
match self.sty {
180-
ty::TyRawPtr(mt) => cx.mk_ptr(ty::TypeAndMut {
180+
ty::TyRawPtr(mt) => tcx.mk_ptr(ty::TypeAndMut {
181181
ty: mt.ty,
182182
mutbl: hir::MutImmutable
183183
}),
@@ -194,7 +194,7 @@ impl<'tcx> ty::TyS<'tcx> {
194194
if !adjusted_ty.references_error() {
195195
for i in 0..adj.autoderefs {
196196
adjusted_ty =
197-
adjusted_ty.adjust_for_autoderef(cx,
197+
adjusted_ty.adjust_for_autoderef(tcx,
198198
expr_id,
199199
span,
200200
i as u32,
@@ -205,7 +205,7 @@ impl<'tcx> ty::TyS<'tcx> {
205205
if let Some(target) = adj.unsize {
206206
target
207207
} else {
208-
adjusted_ty.adjust_for_autoref(cx, adj.autoref)
208+
adjusted_ty.adjust_for_autoref(tcx, adj.autoref)
209209
}
210210
}
211211
}
@@ -215,7 +215,7 @@ impl<'tcx> ty::TyS<'tcx> {
215215
}
216216

217217
pub fn adjust_for_autoderef<F>(&'tcx self,
218-
cx: &TyCtxt<'tcx>,
218+
tcx: &TyCtxt<'tcx>,
219219
expr_id: ast::NodeId,
220220
expr_span: Span,
221221
autoderef: u32, // how many autoderefs so far?
@@ -228,7 +228,7 @@ impl<'tcx> ty::TyS<'tcx> {
228228
if let Some(method_ty) = method_type(method_call) {
229229
// Method calls always have all late-bound regions
230230
// fully instantiated.
231-
let fn_ret = cx.no_late_bound_regions(&method_ty.fn_ret()).unwrap();
231+
let fn_ret = tcx.no_late_bound_regions(&method_ty.fn_ret()).unwrap();
232232
adjusted_ty = fn_ret.unwrap();
233233
}
234234
match adjusted_ty.builtin_deref(true, NoPreference) {
@@ -243,16 +243,16 @@ impl<'tcx> ty::TyS<'tcx> {
243243
}
244244
}
245245

246-
pub fn adjust_for_autoref(&'tcx self, cx: &TyCtxt<'tcx>,
246+
pub fn adjust_for_autoref(&'tcx self, tcx: &TyCtxt<'tcx>,
247247
autoref: Option<AutoRef<'tcx>>)
248248
-> Ty<'tcx> {
249249
match autoref {
250250
None => self,
251251
Some(AutoPtr(r, m)) => {
252-
cx.mk_ref(r, TypeAndMut { ty: self, mutbl: m })
252+
tcx.mk_ref(r, TypeAndMut { ty: self, mutbl: m })
253253
}
254254
Some(AutoUnsafe(m)) => {
255-
cx.mk_ptr(TypeAndMut { ty: self, mutbl: m })
255+
tcx.mk_ptr(TypeAndMut { ty: self, mutbl: m })
256256
}
257257
}
258258
}

src/librustc/ty/contents.rs

Lines changed: 15 additions & 15 deletions
Original file line numberDiff line numberDiff line change
@@ -140,14 +140,14 @@ impl fmt::Debug for TypeContents {
140140
}
141141

142142
impl<'tcx> ty::TyS<'tcx> {
143-
pub fn type_contents(&'tcx self, cx: &TyCtxt<'tcx>) -> TypeContents {
144-
return cx.tc_cache.memoize(self, || tc_ty(cx, self, &mut FnvHashMap()));
143+
pub fn type_contents(&'tcx self, tcx: &TyCtxt<'tcx>) -> TypeContents {
144+
return tcx.tc_cache.memoize(self, || tc_ty(tcx, self, &mut FnvHashMap()));
145145

146-
fn tc_ty<'tcx>(cx: &TyCtxt<'tcx>,
146+
fn tc_ty<'tcx>(tcx: &TyCtxt<'tcx>,
147147
ty: Ty<'tcx>,
148148
cache: &mut FnvHashMap<Ty<'tcx>, TypeContents>) -> TypeContents
149149
{
150-
// Subtle: Note that we are *not* using cx.tc_cache here but rather a
150+
// Subtle: Note that we are *not* using tcx.tc_cache here but rather a
151151
// private cache for this walk. This is needed in the case of cyclic
152152
// types like:
153153
//
@@ -163,7 +163,7 @@ impl<'tcx> ty::TyS<'tcx> {
163163
// The problem is, as we are doing the computation, we will also
164164
// compute an *intermediate* contents for, e.g., Option<List> of
165165
// TC::None. This is ok during the computation of List itself, but if
166-
// we stored this intermediate value into cx.tc_cache, then later
166+
// we stored this intermediate value into tcx.tc_cache, then later
167167
// requests for the contents of Option<List> would also yield TC::None
168168
// which is incorrect. This value was computed based on the crutch
169169
// value for the type contents of list. The correct value is
@@ -172,7 +172,7 @@ impl<'tcx> ty::TyS<'tcx> {
172172
Some(tc) => { return *tc; }
173173
None => {}
174174
}
175-
match cx.tc_cache.borrow().get(&ty) { // Must check both caches!
175+
match tcx.tc_cache.borrow().get(&ty) { // Must check both caches!
176176
Some(tc) => { return *tc; }
177177
None => {}
178178
}
@@ -192,7 +192,7 @@ impl<'tcx> ty::TyS<'tcx> {
192192
}
193193

194194
ty::TyBox(typ) => {
195-
tc_ty(cx, typ, cache).owned_pointer()
195+
tc_ty(tcx, typ, cache).owned_pointer()
196196
}
197197

198198
ty::TyTrait(_) => {
@@ -208,36 +208,36 @@ impl<'tcx> ty::TyS<'tcx> {
208208
}
209209

210210
ty::TyArray(ty, _) => {
211-
tc_ty(cx, ty, cache)
211+
tc_ty(tcx, ty, cache)
212212
}
213213

214214
ty::TySlice(ty) => {
215-
tc_ty(cx, ty, cache)
215+
tc_ty(tcx, ty, cache)
216216
}
217217
ty::TyStr => TC::None,
218218

219219
ty::TyClosure(_, ref substs) => {
220-
TypeContents::union(&substs.upvar_tys, |ty| tc_ty(cx, &ty, cache))
220+
TypeContents::union(&substs.upvar_tys, |ty| tc_ty(tcx, &ty, cache))
221221
}
222222

223223
ty::TyTuple(ref tys) => {
224224
TypeContents::union(&tys[..],
225-
|ty| tc_ty(cx, *ty, cache))
225+
|ty| tc_ty(tcx, *ty, cache))
226226
}
227227

228228
ty::TyStruct(def, substs) | ty::TyEnum(def, substs) => {
229229
let mut res =
230230
TypeContents::union(&def.variants, |v| {
231231
TypeContents::union(&v.fields, |f| {
232-
tc_ty(cx, f.ty(cx, substs), cache)
232+
tc_ty(tcx, f.ty(tcx, substs), cache)
233233
})
234234
});
235235

236236
if def.has_dtor() {
237237
res = res | TC::OwnsDtor;
238238
}
239239

240-
apply_lang_items(cx, def.did, res)
240+
apply_lang_items(tcx, def.did, res)
241241
}
242242

243243
ty::TyProjection(..) |
@@ -255,9 +255,9 @@ impl<'tcx> ty::TyS<'tcx> {
255255
result
256256
}
257257

258-
fn apply_lang_items(cx: &TyCtxt, did: DefId, tc: TypeContents)
258+
fn apply_lang_items(tcx: &TyCtxt, did: DefId, tc: TypeContents)
259259
-> TypeContents {
260-
if Some(did) == cx.lang_items.unsafe_cell_type() {
260+
if Some(did) == tcx.lang_items.unsafe_cell_type() {
261261
tc | TC::InteriorUnsafe
262262
} else {
263263
tc

src/librustc/ty/error.rs

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -211,13 +211,13 @@ impl<'tcx> fmt::Display for TypeError<'tcx> {
211211
}
212212

213213
impl<'tcx> ty::TyS<'tcx> {
214-
fn sort_string(&self, cx: &TyCtxt) -> String {
214+
fn sort_string(&self, tcx: &TyCtxt) -> String {
215215
match self.sty {
216216
ty::TyBool | ty::TyChar | ty::TyInt(_) |
217217
ty::TyUint(_) | ty::TyFloat(_) | ty::TyStr => self.to_string(),
218218
ty::TyTuple(ref tys) if tys.is_empty() => self.to_string(),
219219

220-
ty::TyEnum(def, _) => format!("enum `{}`", cx.item_path_str(def.did)),
220+
ty::TyEnum(def, _) => format!("enum `{}`", tcx.item_path_str(def.did)),
221221
ty::TyBox(_) => "box".to_string(),
222222
ty::TyArray(_, n) => format!("array of {} elements", n),
223223
ty::TySlice(_) => "slice".to_string(),
@@ -226,10 +226,10 @@ impl<'tcx> ty::TyS<'tcx> {
226226
ty::TyFnDef(..) => format!("fn item"),
227227
ty::TyFnPtr(_) => "fn pointer".to_string(),
228228
ty::TyTrait(ref inner) => {
229-
format!("trait {}", cx.item_path_str(inner.principal_def_id()))
229+
format!("trait {}", tcx.item_path_str(inner.principal_def_id()))
230230
}
231231
ty::TyStruct(def, _) => {
232-
format!("struct `{}`", cx.item_path_str(def.did))
232+
format!("struct `{}`", tcx.item_path_str(def.did))
233233
}
234234
ty::TyClosure(..) => "closure".to_string(),
235235
ty::TyTuple(_) => "tuple".to_string(),

0 commit comments

Comments
 (0)