@@ -22,7 +22,7 @@ use middle::def::Def;
22
22
use middle:: subst:: Subst ;
23
23
use middle:: def_id:: DefId ;
24
24
use middle:: pat_util:: def_to_path;
25
- use middle:: ty:: { self , Ty } ;
25
+ use middle:: ty:: { self , Ty , TyCtxt } ;
26
26
use middle:: astconv_util:: ast_ty_to_prim_ty;
27
27
use util:: num:: ToPrimitive ;
28
28
use util:: nodemap:: NodeMap ;
@@ -46,7 +46,7 @@ use std::mem::transmute;
46
46
use std:: { i8, i16, i32, i64, u8, u16, u32, u64} ;
47
47
use std:: rc:: Rc ;
48
48
49
- fn lookup_variant_by_id < ' a > ( tcx : & ' a ty :: ctxt ,
49
+ fn lookup_variant_by_id < ' a > ( tcx : & ' a TyCtxt ,
50
50
enum_def : DefId ,
51
51
variant_def : DefId )
52
52
-> Option < & ' a Expr > {
@@ -84,7 +84,7 @@ fn lookup_variant_by_id<'a>(tcx: &'a ty::ctxt,
84
84
/// `maybe_ref_id` and `param_substs` are optional and are used for
85
85
/// finding substitutions in associated constants. This generally
86
86
/// happens in late/trans const evaluation.
87
- pub fn lookup_const_by_id < ' a , ' tcx : ' a > ( tcx : & ' a ty :: ctxt < ' tcx > ,
87
+ pub fn lookup_const_by_id < ' a , ' tcx : ' a > ( tcx : & ' a TyCtxt < ' tcx > ,
88
88
def_id : DefId ,
89
89
maybe_ref_id : Option < ast:: NodeId > ,
90
90
param_substs : Option < & ' tcx subst:: Substs < ' tcx > > )
@@ -189,7 +189,7 @@ pub fn lookup_const_by_id<'a, 'tcx: 'a>(tcx: &'a ty::ctxt<'tcx>,
189
189
}
190
190
}
191
191
192
- fn inline_const_fn_from_external_crate ( tcx : & ty :: ctxt , def_id : DefId )
192
+ fn inline_const_fn_from_external_crate ( tcx : & TyCtxt , def_id : DefId )
193
193
-> Option < ast:: NodeId > {
194
194
match tcx. extern_const_fns . borrow ( ) . get ( & def_id) {
195
195
Some ( & ast:: DUMMY_NODE_ID ) => return None ,
@@ -212,7 +212,7 @@ fn inline_const_fn_from_external_crate(tcx: &ty::ctxt, def_id: DefId)
212
212
fn_id
213
213
}
214
214
215
- pub fn lookup_const_fn_by_id < ' tcx > ( tcx : & ty :: ctxt < ' tcx > , def_id : DefId )
215
+ pub fn lookup_const_fn_by_id < ' tcx > ( tcx : & TyCtxt < ' tcx > , def_id : DefId )
216
216
-> Option < FnLikeNode < ' tcx > >
217
217
{
218
218
let fn_id = if let Some ( node_id) = tcx. map . as_local_node_id ( def_id) {
@@ -322,7 +322,7 @@ impl ConstVal {
322
322
}
323
323
}
324
324
325
- pub fn const_expr_to_pat ( tcx : & ty :: ctxt , expr : & Expr , span : Span ) -> P < hir:: Pat > {
325
+ pub fn const_expr_to_pat ( tcx : & TyCtxt , expr : & Expr , span : Span ) -> P < hir:: Pat > {
326
326
let pat = match expr. node {
327
327
hir:: ExprTup ( ref exprs) =>
328
328
PatKind :: Tup ( exprs. iter ( ) . map ( |expr| const_expr_to_pat ( tcx, & expr, span) ) . collect ( ) ) ,
@@ -382,7 +382,7 @@ pub fn const_expr_to_pat(tcx: &ty::ctxt, expr: &Expr, span: Span) -> P<hir::Pat>
382
382
P ( hir:: Pat { id : expr. id , node : pat, span : span } )
383
383
}
384
384
385
- pub fn eval_const_expr ( tcx : & ty :: ctxt , e : & Expr ) -> ConstVal {
385
+ pub fn eval_const_expr ( tcx : & TyCtxt , e : & Expr ) -> ConstVal {
386
386
match eval_const_expr_partial ( tcx, e, ExprTypeChecked , None ) {
387
387
Ok ( r) => r,
388
388
Err ( s) => tcx. sess . span_fatal ( s. span , & s. description ( ) )
@@ -542,7 +542,7 @@ pub enum IntTy { I8, I16, I32, I64 }
542
542
pub enum UintTy { U8 , U16 , U32 , U64 }
543
543
544
544
impl IntTy {
545
- pub fn from ( tcx : & ty :: ctxt , t : ast:: IntTy ) -> IntTy {
545
+ pub fn from ( tcx : & TyCtxt , t : ast:: IntTy ) -> IntTy {
546
546
let t = if let ast:: IntTy :: Is = t {
547
547
tcx. sess . target . int_type
548
548
} else {
@@ -559,7 +559,7 @@ impl IntTy {
559
559
}
560
560
561
561
impl UintTy {
562
- pub fn from ( tcx : & ty :: ctxt , t : ast:: UintTy ) -> UintTy {
562
+ pub fn from ( tcx : & TyCtxt , t : ast:: UintTy ) -> UintTy {
563
563
let t = if let ast:: UintTy :: Us = t {
564
564
tcx. sess . target . uint_type
565
565
} else {
@@ -810,7 +810,7 @@ pub_fn_checked_op!{ const_uint_checked_shr_via_int(a: u64, b: i64,.. UintTy) {
810
810
/// guaranteed to be evaluatable. `ty_hint` is usually ExprTypeChecked,
811
811
/// but a few places need to evaluate constants during type-checking, like
812
812
/// computing the length of an array. (See also the FIXME above EvalHint.)
813
- pub fn eval_const_expr_partial < ' tcx > ( tcx : & ty :: ctxt < ' tcx > ,
813
+ pub fn eval_const_expr_partial < ' tcx > ( tcx : & TyCtxt < ' tcx > ,
814
814
e : & Expr ,
815
815
ty_hint : EvalHint < ' tcx > ,
816
816
fn_args : FnArgMap ) -> EvalResult {
@@ -1222,7 +1222,7 @@ pub fn eval_const_expr_partial<'tcx>(tcx: &ty::ctxt<'tcx>,
1222
1222
Ok ( result)
1223
1223
}
1224
1224
1225
- fn impl_or_trait_container ( tcx : & ty :: ctxt , def_id : DefId ) -> ty:: ImplOrTraitItemContainer {
1225
+ fn impl_or_trait_container ( tcx : & TyCtxt , def_id : DefId ) -> ty:: ImplOrTraitItemContainer {
1226
1226
// This is intended to be equivalent to tcx.impl_or_trait_item(def_id).container()
1227
1227
// for local def_id, but it can be called before tcx.impl_or_trait_items is complete.
1228
1228
if let Some ( node_id) = tcx. map . as_local_node_id ( def_id) {
@@ -1239,7 +1239,7 @@ fn impl_or_trait_container(tcx: &ty::ctxt, def_id: DefId) -> ty::ImplOrTraitItem
1239
1239
panic ! ( "{:?} is not local" , def_id) ;
1240
1240
}
1241
1241
1242
- fn resolve_trait_associated_const < ' a , ' tcx : ' a > ( tcx : & ' a ty :: ctxt < ' tcx > ,
1242
+ fn resolve_trait_associated_const < ' a , ' tcx : ' a > ( tcx : & ' a TyCtxt < ' tcx > ,
1243
1243
ti : & ' tcx hir:: TraitItem ,
1244
1244
trait_id : DefId ,
1245
1245
rcvr_substs : subst:: Substs < ' tcx > )
@@ -1289,7 +1289,7 @@ fn resolve_trait_associated_const<'a, 'tcx: 'a>(tcx: &'a ty::ctxt<'tcx>,
1289
1289
}
1290
1290
}
1291
1291
1292
- fn cast_const < ' tcx > ( tcx : & ty :: ctxt < ' tcx > , val : ConstVal , ty : Ty ) -> CastResult {
1292
+ fn cast_const < ' tcx > ( tcx : & TyCtxt < ' tcx > , val : ConstVal , ty : Ty ) -> CastResult {
1293
1293
macro_rules! convert_val {
1294
1294
( $intermediate_ty: ty, $const_type: ident, $target_ty: ty) => {
1295
1295
match val {
@@ -1385,7 +1385,7 @@ pub fn compare_const_vals(a: &ConstVal, b: &ConstVal) -> Option<Ordering> {
1385
1385
} )
1386
1386
}
1387
1387
1388
- pub fn compare_lit_exprs < ' tcx > ( tcx : & ty :: ctxt < ' tcx > ,
1388
+ pub fn compare_lit_exprs < ' tcx > ( tcx : & TyCtxt < ' tcx > ,
1389
1389
a : & Expr ,
1390
1390
b : & Expr ) -> Option < Ordering > {
1391
1391
let a = match eval_const_expr_partial ( tcx, a, ExprTypeChecked , None ) {
0 commit comments