diff options
| author | Jeffrey Seyfried <jeffrey.seyfried@gmail.com> | 2016-02-29 23:36:51 +0000 | 
|---|---|---|
| committer | Jeffrey Seyfried <jeffrey.seyfried@gmail.com> | 2016-03-03 07:37:56 +0000 | 
| commit | 37ba66a66e07ce62a743b61f83d1b7bf38f1f88b (patch) | |
| tree | 4519aaeb50b395e70d1106583a1b7a424a928807 /src/librustc | |
| parent | 7cee8b9ffb6a2dac7e2f729988c2324e2f8ac10f (diff) | |
| download | rust-37ba66a66e07ce62a743b61f83d1b7bf38f1f88b.tar.gz rust-37ba66a66e07ce62a743b61f83d1b7bf38f1f88b.zip  | |
Rename middle::ty::ctxt to TyCtxt
Diffstat (limited to 'src/librustc')
58 files changed, 359 insertions, 362 deletions
diff --git a/src/librustc/dep_graph/mod.rs b/src/librustc/dep_graph/mod.rs index a4d222d24ca..2fad161652f 100644 --- a/src/librustc/dep_graph/mod.rs +++ b/src/librustc/dep_graph/mod.rs @@ -10,7 +10,7 @@ use self::thread::{DepGraphThreadData, DepMessage}; use middle::def_id::DefId; -use middle::ty; +use middle::ty::TyCtxt; use rustc_front::hir; use rustc_front::intravisit::Visitor; use std::rc::Rc; @@ -181,13 +181,13 @@ pub use self::query::DepGraphQuery; /// read edge from the corresponding AST node. This is used in /// compiler passes to automatically record the item that they are /// working on. -pub fn visit_all_items_in_krate<'tcx,V,F>(tcx: &ty::ctxt<'tcx>, +pub fn visit_all_items_in_krate<'tcx,V,F>(tcx: &TyCtxt<'tcx>, mut dep_node_fn: F, visitor: &mut V) where F: FnMut(DefId) -> DepNode, V: Visitor<'tcx> { struct TrackingVisitor<'visit, 'tcx: 'visit, F: 'visit, V: 'visit> { - tcx: &'visit ty::ctxt<'tcx>, + tcx: &'visit TyCtxt<'tcx>, dep_node_fn: &'visit mut F, visitor: &'visit mut V } diff --git a/src/librustc/lint/context.rs b/src/librustc/lint/context.rs index fb5413114b7..d492f692703 100644 --- a/src/librustc/lint/context.rs +++ b/src/librustc/lint/context.rs @@ -27,7 +27,7 @@ use self::TargetLint::*; use dep_graph::DepNode; use middle::privacy::AccessLevels; -use middle::ty; +use middle::ty::TyCtxt; use session::{config, early_error, Session}; use lint::{Level, LevelSource, Lint, LintId, LintArray, LintPass}; use lint::{EarlyLintPass, EarlyLintPassObject, LateLintPass, LateLintPassObject}; @@ -298,7 +298,7 @@ impl LintStore { /// Context for lint checking after type checking. pub struct LateContext<'a, 'tcx: 'a> { /// Type context we're checking in. - pub tcx: &'a ty::ctxt<'tcx>, + pub tcx: &'a TyCtxt<'tcx>, /// The crate being checked. pub krate: &'a hir::Crate, @@ -662,7 +662,7 @@ impl<'a> EarlyContext<'a> { } impl<'a, 'tcx> LateContext<'a, 'tcx> { - fn new(tcx: &'a ty::ctxt<'tcx>, + fn new(tcx: &'a TyCtxt<'tcx>, krate: &'a hir::Crate, access_levels: &'a AccessLevels) -> LateContext<'a, 'tcx> { // We want to own the lint store, so move it out of the session. @@ -1249,7 +1249,7 @@ fn check_lint_name_cmdline(sess: &Session, lint_cx: &LintStore, /// Perform lint checking on a crate. /// /// Consumes the `lint_store` field of the `Session`. -pub fn check_crate(tcx: &ty::ctxt, access_levels: &AccessLevels) { +pub fn check_crate(tcx: &TyCtxt, access_levels: &AccessLevels) { let _task = tcx.dep_graph.in_task(DepNode::LateLintCheck); let krate = tcx.map.krate(); diff --git a/src/librustc/middle/astconv_util.rs b/src/librustc/middle/astconv_util.rs index 8b1bdc31beb..e17aaaca16e 100644 --- a/src/librustc/middle/astconv_util.rs +++ b/src/librustc/middle/astconv_util.rs @@ -15,12 +15,12 @@ */ use middle::def::Def; -use middle::ty::{self, Ty}; +use middle::ty::{Ty, TyCtxt}; use syntax::codemap::Span; use rustc_front::hir as ast; -pub fn prohibit_type_params(tcx: &ty::ctxt, segments: &[ast::PathSegment]) { +pub fn prohibit_type_params(tcx: &TyCtxt, segments: &[ast::PathSegment]) { for segment in segments { for typ in segment.parameters.types() { span_err!(tcx.sess, typ.span, E0109, @@ -39,13 +39,13 @@ pub fn prohibit_type_params(tcx: &ty::ctxt, segments: &[ast::PathSegment]) { } } -pub fn prohibit_projection(tcx: &ty::ctxt, span: Span) +pub fn prohibit_projection(tcx: &TyCtxt, span: Span) { span_err!(tcx.sess, span, E0229, "associated type bindings are not allowed here"); } -pub fn prim_ty_to_ty<'tcx>(tcx: &ty::ctxt<'tcx>, +pub fn prim_ty_to_ty<'tcx>(tcx: &TyCtxt<'tcx>, segments: &[ast::PathSegment], nty: ast::PrimTy) -> Ty<'tcx> { @@ -62,7 +62,7 @@ pub fn prim_ty_to_ty<'tcx>(tcx: &ty::ctxt<'tcx>, /// If a type in the AST is a primitive type, return the ty::Ty corresponding /// to it. -pub fn ast_ty_to_prim_ty<'tcx>(tcx: &ty::ctxt<'tcx>, ast_ty: &ast::Ty) +pub fn ast_ty_to_prim_ty<'tcx>(tcx: &TyCtxt<'tcx>, ast_ty: &ast::Ty) -> Option<Ty<'tcx>> { if let ast::TyPath(None, ref path) = ast_ty.node { let def = match tcx.def_map.borrow().get(&ast_ty.id) { diff --git a/src/librustc/middle/cfg/construct.rs b/src/librustc/middle/cfg/construct.rs index 701a4596908..a6fb5c02f54 100644 --- a/src/librustc/middle/cfg/construct.rs +++ b/src/librustc/middle/cfg/construct.rs @@ -12,14 +12,14 @@ use rustc_data_structures::graph; use middle::cfg::*; use middle::def::Def; use middle::pat_util; -use middle::ty; +use middle::ty::{self, TyCtxt}; use syntax::ast; use syntax::ptr::P; use rustc_front::hir::{self, PatKind}; struct CFGBuilder<'a, 'tcx: 'a> { - tcx: &'a ty::ctxt<'tcx>, + tcx: &'a TyCtxt<'tcx>, graph: CFGGraph, fn_exit: CFGIndex, loop_scopes: Vec<LoopScope>, @@ -32,7 +32,7 @@ struct LoopScope { break_index: CFGIndex, // where to go on a `break } -pub fn construct(tcx: &ty::ctxt, +pub fn construct(tcx: &TyCtxt, blk: &hir::Block) -> CFG { let mut graph = graph::Graph::new(); let entry = graph.add_node(CFGNodeData::Entry); diff --git a/src/librustc/middle/cfg/mod.rs b/src/librustc/middle/cfg/mod.rs index ac84d3dec94..394633c5911 100644 --- a/src/librustc/middle/cfg/mod.rs +++ b/src/librustc/middle/cfg/mod.rs @@ -12,7 +12,7 @@ //! Uses `Graph` as the underlying representation. use rustc_data_structures::graph; -use middle::ty; +use middle::ty::TyCtxt; use syntax::ast; use rustc_front::hir; @@ -58,7 +58,7 @@ pub type CFGNode = graph::Node<CFGNodeData>; pub type CFGEdge = graph::Edge<CFGEdgeData>; impl CFG { - pub fn new(tcx: &ty::ctxt, + pub fn new(tcx: &TyCtxt, blk: &hir::Block) -> CFG { construct::construct(tcx, blk) } diff --git a/src/librustc/middle/check_match.rs b/src/librustc/middle/check_match.rs index 246a4e9f28f..be8793bac5d 100644 --- a/src/librustc/middle/check_match.rs +++ b/src/librustc/middle/check_match.rs @@ -107,7 +107,7 @@ impl<'a> FromIterator<Vec<&'a Pat>> for Matrix<'a> { //NOTE: appears to be the only place other then InferCtxt to contain a ParamEnv pub struct MatchCheckCtxt<'a, 'tcx: 'a> { - pub tcx: &'a ty::ctxt<'tcx>, + pub tcx: &'a TyCtxt<'tcx>, pub param_env: ParameterEnvironment<'a, 'tcx>, } @@ -154,7 +154,7 @@ impl<'a, 'tcx, 'v> Visitor<'v> for MatchCheckCtxt<'a, 'tcx> { } } -pub fn check_crate(tcx: &ty::ctxt) { +pub fn check_crate(tcx: &TyCtxt) { tcx.visit_all_items_in_krate(DepNode::MatchCheck, &mut MatchCheckCtxt { tcx: tcx, param_env: tcx.empty_parameter_environment(), @@ -433,13 +433,13 @@ fn const_val_to_expr(value: &ConstVal) -> P<hir::Expr> { } pub struct StaticInliner<'a, 'tcx: 'a> { - pub tcx: &'a ty::ctxt<'tcx>, + pub tcx: &'a TyCtxt<'tcx>, pub failed: bool, pub renaming_map: Option<&'a mut FnvHashMap<(NodeId, Span), NodeId>>, } impl<'a, 'tcx> StaticInliner<'a, 'tcx> { - pub fn new<'b>(tcx: &'b ty::ctxt<'tcx>, + pub fn new<'b>(tcx: &'b TyCtxt<'tcx>, renaming_map: Option<&'b mut FnvHashMap<(NodeId, Span), NodeId>>) -> StaticInliner<'b, 'tcx> { StaticInliner { diff --git a/src/librustc/middle/const_eval.rs b/src/librustc/middle/const_eval.rs index 3d28f3a8a3f..06030c00211 100644 --- a/src/librustc/middle/const_eval.rs +++ b/src/librustc/middle/const_eval.rs @@ -22,7 +22,7 @@ use middle::def::Def; use middle::subst::Subst; use middle::def_id::DefId; use middle::pat_util::def_to_path; -use middle::ty::{self, Ty}; +use middle::ty::{self, Ty, TyCtxt}; use middle::astconv_util::ast_ty_to_prim_ty; use util::num::ToPrimitive; use util::nodemap::NodeMap; @@ -46,7 +46,7 @@ use std::mem::transmute; use std::{i8, i16, i32, i64, u8, u16, u32, u64}; use std::rc::Rc; -fn lookup_variant_by_id<'a>(tcx: &'a ty::ctxt, +fn lookup_variant_by_id<'a>(tcx: &'a TyCtxt, enum_def: DefId, variant_def: DefId) -> Option<&'a Expr> { @@ -84,7 +84,7 @@ fn lookup_variant_by_id<'a>(tcx: &'a ty::ctxt, /// `maybe_ref_id` and `param_substs` are optional and are used for /// finding substitutions in associated constants. This generally /// happens in late/trans const evaluation. -pub fn lookup_const_by_id<'a, 'tcx: 'a>(tcx: &'a ty::ctxt<'tcx>, +pub fn lookup_const_by_id<'a, 'tcx: 'a>(tcx: &'a TyCtxt<'tcx>, def_id: DefId, maybe_ref_id: Option<ast::NodeId>, 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>, } } -fn inline_const_fn_from_external_crate(tcx: &ty::ctxt, def_id: DefId) +fn inline_const_fn_from_external_crate(tcx: &TyCtxt, def_id: DefId) -> Option<ast::NodeId> { match tcx.extern_const_fns.borrow().get(&def_id) { Some(&ast::DUMMY_NODE_ID) => return None, @@ -212,7 +212,7 @@ fn inline_const_fn_from_external_crate(tcx: &ty::ctxt, def_id: DefId) fn_id } -pub fn lookup_const_fn_by_id<'tcx>(tcx: &ty::ctxt<'tcx>, def_id: DefId) +pub fn lookup_const_fn_by_id<'tcx>(tcx: &TyCtxt<'tcx>, def_id: DefId) -> Option<FnLikeNode<'tcx>> { let fn_id = if let Some(node_id) = tcx.map.as_local_node_id(def_id) { @@ -322,7 +322,7 @@ impl ConstVal { } } -pub fn const_expr_to_pat(tcx: &ty::ctxt, expr: &Expr, span: Span) -> P<hir::Pat> { +pub fn const_expr_to_pat(tcx: &TyCtxt, expr: &Expr, span: Span) -> P<hir::Pat> { let pat = match expr.node { hir::ExprTup(ref exprs) => 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> P(hir::Pat { id: expr.id, node: pat, span: span }) } -pub fn eval_const_expr(tcx: &ty::ctxt, e: &Expr) -> ConstVal { +pub fn eval_const_expr(tcx: &TyCtxt, e: &Expr) -> ConstVal { match eval_const_expr_partial(tcx, e, ExprTypeChecked, None) { Ok(r) => r, Err(s) => tcx.sess.span_fatal(s.span, &s.description()) @@ -542,7 +542,7 @@ pub enum IntTy { I8, I16, I32, I64 } pub enum UintTy { U8, U16, U32, U64 } impl IntTy { - pub fn from(tcx: &ty::ctxt, t: ast::IntTy) -> IntTy { + pub fn from(tcx: &TyCtxt, t: ast::IntTy) -> IntTy { let t = if let ast::IntTy::Is = t { tcx.sess.target.int_type } else { @@ -559,7 +559,7 @@ impl IntTy { } impl UintTy { - pub fn from(tcx: &ty::ctxt, t: ast::UintTy) -> UintTy { + pub fn from(tcx: &TyCtxt, t: ast::UintTy) -> UintTy { let t = if let ast::UintTy::Us = t { tcx.sess.target.uint_type } else { @@ -810,7 +810,7 @@ pub_fn_checked_op!{ const_uint_checked_shr_via_int(a: u64, b: i64,.. UintTy) { /// guaranteed to be evaluatable. `ty_hint` is usually ExprTypeChecked, /// but a few places need to evaluate constants during type-checking, like /// computing the length of an array. (See also the FIXME above EvalHint.) -pub fn eval_const_expr_partial<'tcx>(tcx: &ty::ctxt<'tcx>, +pub fn eval_const_expr_partial<'tcx>(tcx: &TyCtxt<'tcx>, e: &Expr, ty_hint: EvalHint<'tcx>, fn_args: FnArgMap) -> EvalResult { @@ -1222,7 +1222,7 @@ pub fn eval_const_expr_partial<'tcx>(tcx: &ty::ctxt<'tcx>, Ok(result) } -fn impl_or_trait_container(tcx: &ty::ctxt, def_id: DefId) -> ty::ImplOrTraitItemContainer { +fn impl_or_trait_container(tcx: &TyCtxt, def_id: DefId) -> ty::ImplOrTraitItemContainer { // This is intended to be equivalent to tcx.impl_or_trait_item(def_id).container() // for local def_id, but it can be called before tcx.impl_or_trait_items is complete. 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 panic!("{:?} is not local", def_id); } -fn resolve_trait_associated_const<'a, 'tcx: 'a>(tcx: &'a ty::ctxt<'tcx>, +fn resolve_trait_associated_const<'a, 'tcx: 'a>(tcx: &'a TyCtxt<'tcx>, ti: &'tcx hir::TraitItem, trait_id: DefId, rcvr_substs: subst::Substs<'tcx>) @@ -1289,7 +1289,7 @@ fn resolve_trait_associated_const<'a, 'tcx: 'a>(tcx: &'a ty::ctxt<'tcx>, } } -fn cast_const<'tcx>(tcx: &ty::ctxt<'tcx>, val: ConstVal, ty: Ty) -> CastResult { +fn cast_const<'tcx>(tcx: &TyCtxt<'tcx>, val: ConstVal, ty: Ty) -> CastResult { macro_rules! convert_val { ($intermediate_ty:ty, $const_type:ident, $target_ty:ty) => { match val { @@ -1385,7 +1385,7 @@ pub fn compare_const_vals(a: &ConstVal, b: &ConstVal) -> Option<Ordering> { }) } -pub fn compare_lit_exprs<'tcx>(tcx: &ty::ctxt<'tcx>, +pub fn compare_lit_exprs<'tcx>(tcx: &TyCtxt<'tcx>, a: &Expr, b: &Expr) -> Option<Ordering> { let a = match eval_const_expr_partial(tcx, a, ExprTypeChecked, None) { diff --git a/src/librustc/middle/cstore.rs b/src/librustc/middle/cstore.rs index 3b72685eca3..3af987df3a8 100644 --- a/src/librustc/middle/cstore.rs +++ b/src/librustc/middle/cstore.rs @@ -26,7 +26,7 @@ use back::svh::Svh; use front::map as hir_map; use middle::def::{self, Def}; use middle::lang_items; -use middle::ty::{self, Ty, VariantKind}; +use middle::ty::{self, Ty, TyCtxt, VariantKind}; use middle::def_id::{DefId, DefIndex}; use mir::repr::Mir; use mir::mir_map::MirMap; @@ -137,49 +137,49 @@ pub trait CrateStore<'tcx> : Any { // item info fn stability(&self, def: DefId) -> Option<attr::Stability>; fn deprecation(&self, def: DefId) -> Option<attr::Deprecation>; - fn closure_kind(&self, tcx: &ty::ctxt<'tcx>, def_id: DefId) + fn closure_kind(&self, tcx: &TyCtxt<'tcx>, def_id: DefId) -> ty::ClosureKind; - fn closure_ty(&self, tcx: &ty::ctxt<'tcx>, def_id: DefId) + fn closure_ty(&self, tcx: &TyCtxt<'tcx>, def_id: DefId) -> ty::ClosureTy<'tcx>; fn item_variances(&self, def: DefId) -> ty::ItemVariances; fn repr_attrs(&self, def: DefId) -> Vec<attr::ReprAttr>; - fn item_type(&self, tcx: &ty::ctxt<'tcx>, def: DefId) + fn item_type(&self, tcx: &TyCtxt<'tcx>, def: DefId) -> ty::TypeScheme<'tcx>; fn item_path(&self, def: DefId) -> Vec<hir_map::PathElem>; fn extern_item_path(&self, def: DefId) -> Vec<hir_map::PathElem>; fn item_name(&self, def: DefId) -> ast::Name; - fn item_predicates(&self, tcx: &ty::ctxt<'tcx>, def: DefId) + fn item_predicates(&self, tcx: &TyCtxt<'tcx>, def: DefId) -> ty::GenericPredicates<'tcx>; - fn item_super_predicates(&self, tcx: &ty::ctxt<'tcx>, def: DefId) + fn item_super_predicates(&self, tcx: &TyCtxt<'tcx>, def: DefId) -> ty::GenericPredicates<'tcx>; fn item_attrs(&self, def_id: DefId) -> Vec<ast::Attribute>; fn item_symbol(&self, def: DefId) -> String; - fn trait_def(&self, tcx: &ty::ctxt<'tcx>, def: DefId)-> ty::TraitDef<'tcx>; - fn adt_def(&self, tcx: &ty::ctxt<'tcx>, def: DefId) -> ty::AdtDefMaster<'tcx>; + fn trait_def(&self, tcx: &TyCtxt<'tcx>, def: DefId)-> ty::TraitDef<'tcx>; + fn adt_def(&self, tcx: &TyCtxt<'tcx>, def: DefId) -> ty::AdtDefMaster<'tcx>; fn method_arg_names(&self, did: DefId) -> Vec<String>; fn inherent_implementations_for_type(&self, def_id: DefId) -> Vec<DefId>; // trait info fn implementations_of_trait(&self, def_id: DefId) -> Vec<DefId>; - fn provided_trait_methods(&self, tcx: &ty::ctxt<'tcx>, def: DefId) + fn provided_trait_methods(&self, tcx: &TyCtxt<'tcx>, def: DefId) -> Vec<Rc<ty::Method<'tcx>>>; fn trait_item_def_ids(&self, def: DefId) -> Vec<ty::ImplOrTraitItemId>; // impl info fn impl_items(&self, impl_def_id: DefId) -> Vec<ty::ImplOrTraitItemId>; - fn impl_trait_ref(&self, tcx: &ty::ctxt<'tcx>, def: DefId) + fn impl_trait_ref(&self, tcx: &TyCtxt<'tcx>, def: DefId) -> Option<ty::TraitRef<'tcx>>; fn impl_polarity(&self, def: DefId) -> Option<hir::ImplPolarity>; fn custom_coerce_unsized_kind(&self, def: DefId) -> Option<ty::adjustment::CustomCoerceUnsized>; - fn associated_consts(&self, tcx: &ty::ctxt<'tcx>, def: DefId) + fn associated_consts(&self, tcx: &TyCtxt<'tcx>, def: DefId) -> Vec<Rc<ty::AssociatedConst<'tcx>>>; // trait/impl-item info - fn trait_of_item(&self, tcx: &ty::ctxt<'tcx>, def_id: DefId) + fn trait_of_item(&self, tcx: &TyCtxt<'tcx>, def_id: DefId) -> Option<DefId>; - fn impl_or_trait_item(&self, tcx: &ty::ctxt<'tcx>, def: DefId) + fn impl_or_trait_item(&self, tcx: &TyCtxt<'tcx>, def: DefId) -> ty::ImplOrTraitItem<'tcx>; // flags @@ -187,7 +187,7 @@ pub trait CrateStore<'tcx> : Any { fn is_defaulted_trait(&self, did: DefId) -> bool; fn is_impl(&self, did: DefId) -> bool; fn is_default_impl(&self, impl_did: DefId) -> bool; - fn is_extern_item(&self, tcx: &ty::ctxt<'tcx>, did: DefId) -> bool; + fn is_extern_item(&self, tcx: &TyCtxt<'tcx>, did: DefId) -> bool; fn is_static_method(&self, did: DefId) -> bool; fn is_statically_included_foreign_item(&self, id: ast::NodeId) -> bool; fn is_typedef(&self, did: DefId) -> bool; @@ -219,9 +219,9 @@ pub trait CrateStore<'tcx> : Any { fn crate_top_level_items(&self, cnum: ast::CrateNum) -> Vec<ChildItem>; // misc. metadata - fn maybe_get_item_ast(&'tcx self, tcx: &ty::ctxt<'tcx>, def: DefId) + fn maybe_get_item_ast(&'tcx self, tcx: &TyCtxt<'tcx>, def: DefId) -> FoundAst<'tcx>; - fn maybe_get_item_mir(&self, tcx: &ty::ctxt<'tcx>, def: DefId) + fn maybe_get_item_mir(&self, tcx: &TyCtxt<'tcx>, def: DefId) -> Option<Mir<'tcx>>; fn is_item_mir_available(&self, def: DefId) -> bool; @@ -234,12 +234,12 @@ pub trait CrateStore<'tcx> : Any { // utility functions fn metadata_filename(&self) -> &str; fn metadata_section_name(&self, target: &Target) -> &str; - fn encode_type(&self, tcx: &ty::ctxt<'tcx>, ty: Ty<'tcx>) -> Vec<u8>; + fn encode_type(&self, tcx: &TyCtxt<'tcx>, ty: Ty<'tcx>) -> Vec<u8>; fn used_crates(&self, prefer: LinkagePreference) -> Vec<(ast::CrateNum, Option<PathBuf>)>; fn used_crate_source(&self, cnum: ast::CrateNum) -> CrateSource; fn extern_mod_stmt_cnum(&self, emod_id: ast::NodeId) -> Option<ast::CrateNum>; fn encode_metadata(&self, - tcx: &ty::ctxt<'tcx>, + tcx: &TyCtxt<'tcx>, reexports: &def::ExportMap, item_symbols: &RefCell<NodeMap<String>>, link_meta: &LinkMeta, @@ -302,33 +302,33 @@ impl<'tcx> CrateStore<'tcx> for DummyCrateStore { // item info fn stability(&self, def: DefId) -> Option<attr::Stability> { unimplemented!() } fn deprecation(&self, def: DefId) -> Option<attr::Deprecation> { unimplemented!() } - fn closure_kind(&self, tcx: &ty::ctxt<'tcx>, def_id: DefId) + fn closure_kind(&self, tcx: &TyCtxt<'tcx>, def_id: DefId) -> ty::ClosureKind { unimplemented!() } - fn closure_ty(&self, tcx: &ty::ctxt<'tcx>, def_id: DefId) + fn closure_ty(&self, tcx: &TyCtxt<'tcx>, def_id: DefId) -> ty::ClosureTy<'tcx> { unimplemented!() } fn item_variances(&self, def: DefId) -> ty::ItemVariances { unimplemented!() } fn repr_attrs(&self, def: DefId) -> Vec<attr::ReprAttr> { unimplemented!() } - fn item_type(&self, tcx: &ty::ctxt<'tcx>, def: DefId) + fn item_type(&self, tcx: &TyCtxt<'tcx>, def: DefId) -> ty::TypeScheme<'tcx> { unimplemented!() } fn item_path(&self, def: DefId) -> Vec<hir_map::PathElem> { unimplemented!() } fn extern_item_path(&self, def: DefId) -> Vec<hir_map::PathElem> { unimplemented!() } fn item_name(&self, def: DefId) -> ast::Name { unimplemented!() } - fn item_predicates(&self, tcx: &ty::ctxt<'tcx>, def: DefId) + fn item_predicates(&self, tcx: &TyCtxt<'tcx>, def: DefId) -> ty::GenericPredicates<'tcx> { unimplemented!() } - fn item_super_predicates(&self, tcx: &ty::ctxt<'tcx>, def: DefId) + fn item_super_predicates(&self, tcx: &TyCtxt<'tcx>, def: DefId) -> ty::GenericPredicates<'tcx> { unimplemented!() } fn item_attrs(&self, def_id: DefId) -> Vec<ast::Attribute> { unimplemented!() } fn item_symbol(&self, def: DefId) -> String { unimplemented!() } - fn trait_def(&self, tcx: &ty::ctxt<'tcx>, def: DefId)-> ty::TraitDef<'tcx> + fn trait_def(&self, tcx: &TyCtxt<'tcx>, def: DefId)-> ty::TraitDef<'tcx> { unimplemented!() } - fn adt_def(&self, tcx: &ty::ctxt<'tcx>, def: DefId) -> ty::AdtDefMaster<'tcx> + fn adt_def(&self, tcx: &TyCtxt<'tcx>, def: DefId) -> ty::AdtDefMaster<'tcx> { unimplemented!() } fn method_arg_names(&self, did: DefId) -> Vec<String> { unimplemented!() } fn inherent_implementations_for_type(&self, def_id: DefId) -> Vec<DefId> { vec![] } // trait info fn implementations_of_trait(&self, def_id: DefId) -> Vec<DefId> { vec![] } - fn provided_trait_methods(&self, tcx: &ty::ctxt<'tcx>, def: DefId) + fn provided_trait_methods(&self, tcx: &TyCtxt<'tcx>, def: DefId) -> Vec<Rc<ty::Method<'tcx>>> { unimplemented!() } fn trait_item_def_ids(&self, def: DefId) -> Vec<ty::ImplOrTraitItemId> { unimplemented!() } @@ -336,19 +336,19 @@ impl<'tcx> CrateStore<'tcx> for DummyCrateStore { // impl info fn impl_items(&self, impl_def_id: DefId) -> Vec<ty::ImplOrTraitItemId> { unimplemented!() } - fn impl_trait_ref(&self, tcx: &ty::ctxt<'tcx>, def: DefId) + fn impl_trait_ref(&self, tcx: &TyCtxt<'tcx>, def: DefId) -> Option<ty::TraitRef<'tcx>> { unimplemented!() } fn impl_polarity(&self, def: DefId) -> Option<hir::ImplPolarity> { unimplemented!() } fn custom_coerce_unsized_kind(&self, def: DefId) -> Option<ty::adjustment::CustomCoerceUnsized> { unimplemented!() } - fn associated_consts(&self, tcx: &ty::ctxt<'tcx>, def: DefId) + fn associated_consts(&self, tcx: &TyCtxt<'tcx>, def: DefId) -> Vec<Rc<ty::AssociatedConst<'tcx>>> { unimplemented!() } // trait/impl-item info - fn trait_of_item(&self, tcx: &ty::ctxt<'tcx>, def_id: DefId) + fn trait_of_item(&self, tcx: &TyCtxt<'tcx>, def_id: DefId) -> Option<DefId> { unimplemented!() } - fn impl_or_trait_item(&self, tcx: &ty::ctxt<'tcx>, def: DefId) + fn impl_or_trait_item(&self, tcx: &TyCtxt<'tcx>, def: DefId) -> ty::ImplOrTraitItem<'tcx> { unimplemented!() } // flags @@ -356,7 +356,7 @@ impl<'tcx> CrateStore<'tcx> for DummyCrateStore { fn is_defaulted_trait(&self, did: DefId) -> bool { unimplemented!() } fn is_impl(&self, did: DefId) -> bool { unimplemented!() } fn is_default_impl(&self, impl_did: DefId) -> bool { unimplemented!() } - fn is_extern_item(&self, tcx: &ty::ctxt<'tcx>, did: DefId) -> bool { unimplemented!() } + fn is_extern_item(&self, tcx: &TyCtxt<'tcx>, did: DefId) -> bool { unimplemented!() } fn is_static_method(&self, did: DefId) -> bool { unimplemented!() } fn is_statically_included_foreign_item(&self, id: ast::NodeId) -> bool { false } fn is_typedef(&self, did: DefId) -> bool { unimplemented!() } @@ -398,9 +398,9 @@ impl<'tcx> CrateStore<'tcx> for DummyCrateStore { { unimplemented!() } // misc. metadata - fn maybe_get_item_ast(&'tcx self, tcx: &ty::ctxt<'tcx>, def: DefId) + fn maybe_get_item_ast(&'tcx self, tcx: &TyCtxt<'tcx>, def: DefId) -> FoundAst<'tcx> { unimplemented!() } - fn maybe_get_item_mir(&self, tcx: &ty::ctxt<'tcx>, def: DefId) + fn maybe_get_item_mir(&self, tcx: &TyCtxt<'tcx>, def: DefId) -> Option<Mir<'tcx>> { unimplemented!() } fn is_item_mir_available(&self, def: DefId) -> bool { unimplemented!() @@ -415,14 +415,14 @@ impl<'tcx> CrateStore<'tcx> for DummyCrateStore { // utility functions fn metadata_filename(&self) -> &str { unimplemented!() } fn metadata_section_name(&self, target: &Target) -> &str { unimplemented!() } - fn encode_type(&self, tcx: &ty::ctxt<'tcx>, ty: Ty<'tcx>) -> Vec<u8> + fn encode_type(&self, tcx: &TyCtxt<'tcx>, ty: Ty<'tcx>) -> Vec<u8> { unimplemented!() } fn used_crates(&self, prefer: LinkagePreference) -> Vec<(ast::CrateNum, Option<PathBuf>)> { vec![] } fn used_crate_source(&self, cnum: ast::CrateNum) -> CrateSource { unimplemented!() } fn extern_mod_stmt_cnum(&self, emod_id: ast::NodeId) -> Option<ast::CrateNum> { None } fn encode_metadata(&self, - tcx: &ty::ctxt<'tcx>, + tcx: &TyCtxt<'tcx>, reexports: &def::ExportMap, item_symbols: &RefCell<NodeMap<String>>, link_meta: &LinkMeta, @@ -439,7 +439,7 @@ impl<'tcx> CrateStore<'tcx> for DummyCrateStore { /// be available to them. For example, we can automatically translate def-id and /// span information during decoding because the decoding context knows which /// crate the data is decoded from. Or it allows to make ty::Ty decodable -/// because the context has access to the ty::ctxt that is needed for creating +/// because the context has access to the TyCtxt that is needed for creating /// ty::Ty instances. /// /// Note, however, that this only works for RBML-based encoding and decoding at @@ -450,12 +450,12 @@ pub mod tls { use serialize; use std::cell::Cell; use std::mem; - use middle::ty::{self, Ty}; + use middle::ty::{self, Ty, TyCtxt}; use middle::subst::Substs; use middle::def_id::DefId; pub trait EncodingContext<'tcx> { - fn tcx<'a>(&'a self) -> &'a ty::ctxt<'tcx>; + fn tcx<'a>(&'a self) -> &'a TyCtxt<'tcx>; fn encode_ty(&self, encoder: &mut OpaqueEncoder, t: Ty<'tcx>); fn encode_substs(&self, encoder: &mut OpaqueEncoder, substs: &Substs<'tcx>); } @@ -522,7 +522,7 @@ pub mod tls { } pub trait DecodingContext<'tcx> { - fn tcx<'a>(&'a self) -> &'a ty::ctxt<'tcx>; + fn tcx<'a>(&'a self) -> &'a TyCtxt<'tcx>; fn decode_ty(&self, decoder: &mut OpaqueDecoder) -> ty::Ty<'tcx>; fn decode_substs(&self, decoder: &mut OpaqueDecoder) -> Substs<'tcx>; fn translate_def_id(&self, def_id: DefId) -> DefId; diff --git a/src/librustc/middle/dataflow.rs b/src/librustc/middle/dataflow.rs index 3fc45c575f0..c746fab3ea1 100644 --- a/src/librustc/middle/dataflow.rs +++ b/src/librustc/middle/dataflow.rs @@ -16,7 +16,7 @@ use middle::cfg; use middle::cfg::CFGIndex; -use middle::ty; +use middle::ty::TyCtxt; use std::io; use std::mem; use std::usize; @@ -38,7 +38,7 @@ pub enum EntryOrExit { #[derive(Clone)] pub struct DataFlowContext<'a, 'tcx: 'a, O> { - tcx: &'a ty::ctxt<'tcx>, + tcx: &'a TyCtxt<'tcx>, /// a name for the analysis using this dataflow instance analysis_name: &'static str, @@ -223,7 +223,7 @@ pub enum KillFrom { } impl<'a, 'tcx, O:DataFlowOperator> DataFlowContext<'a, 'tcx, O> { - pub fn new(tcx: &'a ty::ctxt<'tcx>, + pub fn new(tcx: &'a TyCtxt<'tcx>, analysis_name: &'static str, decl: Option<&hir::FnDecl>, cfg: &cfg::CFG, diff --git a/src/librustc/middle/dead.rs b/src/librustc/middle/dead.rs index eefefed5f2d..f1b38ea8b81 100644 --- a/src/librustc/middle/dead.rs +++ b/src/librustc/middle/dead.rs @@ -18,6 +18,7 @@ use rustc_front::hir::{self, PatKind}; use rustc_front::intravisit::{self, Visitor}; use middle::{pat_util, privacy, ty}; +use middle::ty::TyCtxt; use middle::def::Def; use middle::def_id::{DefId}; use lint; @@ -30,7 +31,7 @@ use syntax::attr::{self, AttrMetaMethods}; // explored. For example, if it's a live NodeItem that is a // function, then we should explore its block to check for codes that // may need to be marked as live. -fn should_explore(tcx: &ty::ctxt, node_id: ast::NodeId) -> bool { +fn should_explore(tcx: &TyCtxt, node_id: ast::NodeId) -> bool { match tcx.map.find(node_id) { Some(ast_map::NodeItem(..)) | Some(ast_map::NodeImplItem(..)) | @@ -44,7 +45,7 @@ fn should_explore(tcx: &ty::ctxt, node_id: ast::NodeId) -> bool { struct MarkSymbolVisitor<'a, 'tcx: 'a> { worklist: Vec<ast::NodeId>, - tcx: &'a ty::ctxt<'tcx>, + tcx: &'a TyCtxt<'tcx>, live_symbols: Box<HashSet<ast::NodeId>>, struct_has_extern_repr: bool, ignore_non_const_paths: bool, @@ -53,7 +54,7 @@ struct MarkSymbolVisitor<'a, 'tcx: 'a> { } impl<'a, 'tcx> MarkSymbolVisitor<'a, 'tcx> { - fn new(tcx: &'a ty::ctxt<'tcx>, + fn new(tcx: &'a TyCtxt<'tcx>, worklist: Vec<ast::NodeId>) -> MarkSymbolVisitor<'a, 'tcx> { MarkSymbolVisitor { worklist: worklist, @@ -367,7 +368,7 @@ impl<'v> Visitor<'v> for LifeSeeder { } } -fn create_and_seed_worklist(tcx: &ty::ctxt, +fn create_and_seed_worklist(tcx: &TyCtxt, access_levels: &privacy::AccessLevels, krate: &hir::Crate) -> Vec<ast::NodeId> { let mut worklist = Vec::new(); @@ -390,7 +391,7 @@ fn create_and_seed_worklist(tcx: &ty::ctxt, return life_seeder.worklist; } -fn find_live(tcx: &ty::ctxt, +fn find_live(tcx: &TyCtxt, access_levels: &privacy::AccessLevels, krate: &hir::Crate) -> Box<HashSet<ast::NodeId>> { @@ -410,7 +411,7 @@ fn get_struct_ctor_id(item: &hir::Item) -> Option<ast::NodeId> { } struct DeadVisitor<'a, 'tcx: 'a> { - tcx: &'a ty::ctxt<'tcx>, + tcx: &'a TyCtxt<'tcx>, live_symbols: Box<HashSet<ast::NodeId>>, } @@ -587,7 +588,7 @@ impl<'a, 'tcx, 'v> Visitor<'v> for DeadVisitor<'a, 'tcx> { } } -pub fn check_crate(tcx: &ty::ctxt, access_levels: &privacy::AccessLevels) { +pub fn check_crate(tcx: &TyCtxt, access_levels: &privacy::AccessLevels) { let _task = tcx.dep_graph.in_task(DepNode::DeadCheck); let krate = tcx.map.krate(); let live_symbols = find_live(tcx, access_levels, krate); diff --git a/src/librustc/middle/effect.rs b/src/librustc/middle/effect.rs index c27d029374a..e3d05388f52 100644 --- a/src/librustc/middle/effect.rs +++ b/src/librustc/middle/effect.rs @@ -14,7 +14,7 @@ use self::RootUnsafeContext::*; use dep_graph::DepNode; use middle::def::Def; -use middle::ty::{self, Ty}; +use middle::ty::{self, Ty, TyCtxt}; use middle::ty::MethodCall; use syntax::ast; @@ -50,7 +50,7 @@ fn type_is_unsafe_function(ty: Ty) -> bool { } struct EffectCheckVisitor<'a, 'tcx: 'a> { - tcx: &'a ty::ctxt<'tcx>, + tcx: &'a TyCtxt<'tcx>, /// Whether we're in an unsafe context. unsafe_context: UnsafeContext, @@ -182,7 +182,7 @@ impl<'a, 'tcx, 'v> Visitor<'v> for EffectCheckVisitor<'a, 'tcx> { } } -pub fn check_crate(tcx: &ty::ctxt) { +pub fn check_crate(tcx: &TyCtxt) { let _task = tcx.dep_graph.in_task(DepNode::EffectCheck); let mut visitor = EffectCheckVisitor { diff --git a/src/librustc/middle/expr_use_visitor.rs b/src/librustc/middle/expr_use_visitor.rs index 93cc158cd12..8b042e73e79 100644 --- a/src/librustc/middle/expr_use_visitor.rs +++ b/src/librustc/middle/expr_use_visitor.rs @@ -24,8 +24,7 @@ use middle::def::Def; use middle::def_id::{DefId}; use middle::infer; use middle::mem_categorization as mc; -use middle::ty; -use middle::ty::adjustment; +use middle::ty::{self, TyCtxt, adjustment}; use rustc_front::hir::{self, PatKind}; @@ -210,7 +209,7 @@ enum OverloadedCallType { } impl OverloadedCallType { - fn from_trait_id(tcx: &ty::ctxt, trait_id: DefId) + fn from_trait_id(tcx: &TyCtxt, trait_id: DefId) -> OverloadedCallType { for &(maybe_function_trait, overloaded_call_type) in &[ (tcx.lang_items.fn_once_trait(), FnOnceOverloadedCall), @@ -228,7 +227,7 @@ impl OverloadedCallType { tcx.sess.bug("overloaded call didn't map to known function trait") } - fn from_method_id(tcx: &ty::ctxt, method_id: DefId) + fn from_method_id(tcx: &TyCtxt, method_id: DefId) -> OverloadedCallType { let method = tcx.impl_or_trait_item(method_id); OverloadedCallType::from_trait_id(tcx, method.container().id()) @@ -307,7 +306,7 @@ impl<'d,'t,'a,'tcx> ExprUseVisitor<'d,'t,'a,'tcx> { } } - fn tcx(&self) -> &'t ty::ctxt<'tcx> { + fn tcx(&self) -> &'t TyCtxt<'tcx> { self.typer.tcx } diff --git a/src/librustc/middle/free_region.rs b/src/librustc/middle/free_region.rs index face6d62934..cb45a3e2507 100644 --- a/src/librustc/middle/free_region.rs +++ b/src/librustc/middle/free_region.rs @@ -15,7 +15,7 @@ //! `TransitiveRelation` type and use that to decide when one free //! region outlives another and so forth. -use middle::ty::{self, FreeRegion, Region}; +use middle::ty::{self, TyCtxt, FreeRegion, Region}; use middle::ty::wf::ImpliedBound; use rustc_data_structures::transitive_relation::TransitiveRelation; @@ -49,7 +49,7 @@ impl FreeRegionMap { } pub fn relate_free_regions_from_predicates<'tcx>(&mut self, - tcx: &ty::ctxt<'tcx>, + tcx: &TyCtxt<'tcx>, predicates: &[ty::Predicate<'tcx>]) { debug!("relate_free_regions_from_predicates(predicates={:?})", predicates); for predicate in predicates { @@ -121,7 +121,7 @@ impl FreeRegionMap { /// Determines whether one region is a subregion of another. This is intended to run *after /// inference* and sadly the logic is somewhat duplicated with the code in infer.rs. pub fn is_subregion_of(&self, - tcx: &ty::ctxt, + tcx: &TyCtxt, sub_region: ty::Region, super_region: ty::Region) -> bool { diff --git a/src/librustc/middle/infer/bivariate.rs b/src/librustc/middle/infer/bivariate.rs index 2d9432b75e7..cb6542856be 100644 --- a/src/librustc/middle/infer/bivariate.rs +++ b/src/librustc/middle/infer/bivariate.rs @@ -28,7 +28,7 @@ use super::combine::{self, CombineFields}; use super::type_variable::{BiTo}; -use middle::ty::{self, Ty}; +use middle::ty::{self, Ty, TyCtxt}; use middle::ty::TyVar; use middle::ty::relate::{Relate, RelateResult, TypeRelation}; @@ -45,7 +45,7 @@ impl<'a, 'tcx> Bivariate<'a, 'tcx> { impl<'a, 'tcx> TypeRelation<'a, 'tcx> for Bivariate<'a, 'tcx> { fn tag(&self) -> &'static str { "Bivariate" } - fn tcx(&self) -> &'a ty::ctxt<'tcx> { self.fields.tcx() } + fn tcx(&self) -> &'a TyCtxt<'tcx> { self.fields.tcx() } fn a_is_expected(&self) -> bool { self.fields.a_is_expected } diff --git a/src/librustc/middle/infer/combine.rs b/src/librustc/middle/infer/combine.rs index faf1bdb0ce5..cd4a2eb2d93 100644 --- a/src/librustc/middle/infer/combine.rs +++ b/src/librustc/middle/infer/combine.rs @@ -42,7 +42,7 @@ use super::{MiscVariable, TypeTrace}; use super::type_variable::{RelationDir, BiTo, EqTo, SubtypeOf, SupertypeOf}; use middle::ty::{IntType, UintType}; -use middle::ty::{self, Ty}; +use middle::ty::{self, Ty, TyCtxt}; use middle::ty::error::TypeError; use middle::ty::fold::{TypeFolder, TypeFoldable}; use middle::ty::relate::{Relate, RelateResult, TypeRelation}; @@ -149,7 +149,7 @@ fn unify_float_variable<'a,'tcx>(infcx: &InferCtxt<'a,'tcx>, } impl<'a, 'tcx> CombineFields<'a, 'tcx> { - pub fn tcx(&self) -> &'a ty::ctxt<'tcx> { + pub fn tcx(&self) -> &'a TyCtxt<'tcx> { self.infcx.tcx } @@ -293,7 +293,7 @@ struct Generalizer<'cx, 'tcx:'cx> { } impl<'cx, 'tcx> ty::fold::TypeFolder<'tcx> for Generalizer<'cx, 'tcx> { - fn tcx(&self) -> &ty::ctxt<'tcx> { + fn tcx(&self) -> &TyCtxt<'tcx> { self.infcx.tcx } diff --git a/src/librustc/middle/infer/equate.rs b/src/librustc/middle/infer/equate.rs index d1dad4921ae..a10568d1fa3 100644 --- a/src/librustc/middle/infer/equate.rs +++ b/src/librustc/middle/infer/equate.rs @@ -13,7 +13,7 @@ use super::higher_ranked::HigherRankedRelations; use super::{Subtype}; use super::type_variable::{EqTo}; -use middle::ty::{self, Ty}; +use middle::ty::{self, Ty, TyCtxt}; use middle::ty::TyVar; use middle::ty::relate::{Relate, RelateResult, TypeRelation}; @@ -31,7 +31,7 @@ impl<'a, 'tcx> Equate<'a, 'tcx> { impl<'a, 'tcx> TypeRelation<'a,'tcx> for Equate<'a, 'tcx> { fn tag(&self) -> &'static str { "Equate" } - fn tcx(&self) -> &'a ty::ctxt<'tcx> { self.fields.tcx() } + fn tcx(&self) -> &'a TyCtxt<'tcx> { self.fields.tcx() } fn a_is_expected(&self) -> bool { self.fields.a_is_expected } diff --git a/src/librustc/middle/infer/error_reporting.rs b/src/librustc/middle/infer/error_reporting.rs index 8c578bcd3d2..2f1af4184e5 100644 --- a/src/librustc/middle/infer/error_reporting.rs +++ b/src/librustc/middle/infer/error_reporting.rs @@ -82,7 +82,7 @@ use middle::def_id::DefId; use middle::infer::{self, TypeOrigin}; use middle::region; use middle::subst; -use middle::ty::{self, Ty, TypeFoldable}; +use middle::ty::{self, Ty, TyCtxt, TypeFoldable}; use middle::ty::{Region, ReFree}; use middle::ty::error::TypeError; @@ -95,7 +95,7 @@ use syntax::codemap::{self, Pos, Span}; use syntax::parse::token; use syntax::ptr::P; -impl<'tcx> ty::ctxt<'tcx> { +impl<'tcx> TyCtxt<'tcx> { pub fn note_and_explain_region(&self, err: &mut DiagnosticBuilder, prefix: &str, @@ -112,7 +112,7 @@ impl<'tcx> ty::ctxt<'tcx> { } } - fn explain_span(tcx: &ty::ctxt, heading: &str, span: Span) + fn explain_span(tcx: &TyCtxt, heading: &str, span: Span) -> (String, Option<Span>) { let lo = tcx.sess.codemap().lookup_char_pos_adj(span.lo); (format!("the {} at {}:{}", heading, lo.line, lo.col.to_usize()), @@ -419,7 +419,7 @@ impl<'a, 'tcx> ErrorReporting<'tcx> for InferCtxt<'a, 'tcx> { } } - fn free_regions_from_same_fn(tcx: &ty::ctxt, + fn free_regions_from_same_fn(tcx: &TyCtxt, sub: Region, sup: Region) -> Option<FreeRegionsFromSameFn> { @@ -1057,7 +1057,7 @@ struct RebuildPathInfo<'a> { } struct Rebuilder<'a, 'tcx: 'a> { - tcx: &'a ty::ctxt<'tcx>, + tcx: &'a TyCtxt<'tcx>, fn_decl: &'a hir::FnDecl, expl_self_opt: Option<&'a hir::ExplicitSelf_>, generics: &'a hir::Generics, @@ -1073,7 +1073,7 @@ enum FreshOrKept { } impl<'a, 'tcx> Rebuilder<'a, 'tcx> { - fn new(tcx: &'a ty::ctxt<'tcx>, + fn new(tcx: &'a TyCtxt<'tcx>, fn_decl: &'a hir::FnDecl, expl_self_opt: Option<&'a hir::ExplicitSelf_>, generics: &'a hir::Generics, @@ -1877,7 +1877,7 @@ impl<'tcx> Resolvable<'tcx> for ty::PolyTraitRef<'tcx> { } } -fn lifetimes_in_scope(tcx: &ty::ctxt, +fn lifetimes_in_scope(tcx: &TyCtxt, scope_id: ast::NodeId) -> Vec<hir::LifetimeDef> { let mut taken = Vec::new(); diff --git a/src/librustc/middle/infer/freshen.rs b/src/librustc/middle/infer/freshen.rs index 76dd62383f1..b64fa688d51 100644 --- a/src/librustc/middle/infer/freshen.rs +++ b/src/librustc/middle/infer/freshen.rs @@ -30,7 +30,7 @@ //! variable only once, and it does so as soon as it can, so it is reasonable to ask what the type //! inferencer knows "so far". -use middle::ty::{self, Ty, TypeFoldable}; +use middle::ty::{self, Ty, TyCtxt, TypeFoldable}; use middle::ty::fold::TypeFolder; use std::collections::hash_map::{self, Entry}; @@ -78,7 +78,7 @@ impl<'a, 'tcx> TypeFreshener<'a, 'tcx> { } impl<'a, 'tcx> TypeFolder<'tcx> for TypeFreshener<'a, 'tcx> { - fn tcx<'b>(&'b self) -> &'b ty::ctxt<'tcx> { + fn tcx<'b>(&'b self) -> &'b TyCtxt<'tcx> { self.infcx.tcx } diff --git a/src/librustc/middle/infer/glb.rs b/src/librustc/middle/infer/glb.rs index 0035f31e8db..82803acd393 100644 --- a/src/librustc/middle/infer/glb.rs +++ b/src/librustc/middle/infer/glb.rs @@ -14,7 +14,7 @@ use super::InferCtxt; use super::lattice::{self, LatticeDir}; use super::Subtype; -use middle::ty::{self, Ty}; +use middle::ty::{self, Ty, TyCtxt}; use middle::ty::relate::{Relate, RelateResult, TypeRelation}; /// "Greatest lower bound" (common subtype) @@ -31,7 +31,7 @@ impl<'a, 'tcx> Glb<'a, 'tcx> { impl<'a, 'tcx> TypeRelation<'a, 'tcx> for Glb<'a, 'tcx> { fn tag(&self) -> &'static str { "Glb" } - fn tcx(&self) -> &'a ty::ctxt<'tcx> { self.fields.tcx() } + fn tcx(&self) -> &'a TyCtxt<'tcx> { self.fields.tcx() } fn a_is_expected(&self) -> bool { self.fields.a_is_expected } diff --git a/src/librustc/middle/infer/higher_ranked/mod.rs b/src/librustc/middle/infer/higher_ranked/mod.rs index e8f542db933..9b6625886a4 100644 --- a/src/librustc/middle/infer/higher_ranked/mod.rs +++ b/src/librustc/middle/infer/higher_ranked/mod.rs @@ -14,7 +14,7 @@ use super::{CombinedSnapshot, InferCtxt, HigherRankedType, SkolemizationMap}; use super::combine::CombineFields; -use middle::ty::{self, Binder, TypeFoldable}; +use middle::ty::{self, TyCtxt, Binder, TypeFoldable}; use middle::ty::error::TypeError; use middle::ty::relate::{Relate, RelateResult, TypeRelation}; use syntax::codemap::Span; @@ -351,7 +351,7 @@ fn is_var_in_set(new_vars: &[ty::RegionVid], r: ty::Region) -> bool { } } -fn fold_regions_in<'tcx, T, F>(tcx: &ty::ctxt<'tcx>, +fn fold_regions_in<'tcx, T, F>(tcx: &TyCtxt<'tcx>, unbound_value: &T, mut fldr: F) -> T diff --git a/src/librustc/middle/infer/lub.rs b/src/librustc/middle/infer/lub.rs index 238dad65ef0..2ab0b92e42a 100644 --- a/src/librustc/middle/infer/lub.rs +++ b/src/librustc/middle/infer/lub.rs @@ -14,7 +14,7 @@ use super::InferCtxt; use super::lattice::{self, LatticeDir}; use super::Subtype; -use middle::ty::{self, Ty}; +use middle::ty::{self, Ty, TyCtxt}; use middle::ty::relate::{Relate, RelateResult, TypeRelation}; /// "Least upper bound" (common supertype) @@ -31,7 +31,7 @@ impl<'a, 'tcx> Lub<'a, 'tcx> { impl<'a, 'tcx> TypeRelation<'a, 'tcx> for Lub<'a, 'tcx> { fn tag(&self) -> &'static str { "Lub" } - fn tcx(&self) -> &'a ty::ctxt<'tcx> { self.fields.tcx() } + fn tcx(&self) -> &'a TyCtxt<'tcx> { self.fields.tcx() } fn a_is_expected(&self) -> bool { self.fields.a_is_expected } diff --git a/src/librustc/middle/infer/mod.rs b/src/librustc/middle/infer/mod.rs index 26ea5454693..b9a5b32b71d 100644 --- a/src/librustc/middle/infer/mod.rs +++ b/src/librustc/middle/infer/mod.rs @@ -30,7 +30,7 @@ use middle::subst::Subst; use middle::traits; use middle::ty::adjustment; use middle::ty::{TyVid, IntVid, FloatVid}; -use middle::ty::{self, Ty}; +use middle::ty::{self, Ty, TyCtxt}; use middle::ty::error::{ExpectedFound, TypeError, UnconstrainedNumeric}; use middle::ty::fold::{TypeFolder, TypeFoldable}; use middle::ty::relate::{Relate, RelateResult, TypeRelation}; @@ -68,7 +68,7 @@ pub type UnitResult<'tcx> = RelateResult<'tcx, ()>; // "unify result" pub type FixupResult<T> = Result<T, FixupError>; // "fixup result" pub struct InferCtxt<'a, 'tcx: 'a> { - pub tcx: &'a ty::ctxt<'tcx>, + pub tcx: &'a TyCtxt<'tcx>, pub tables: &'a RefCell<ty::Tables<'tcx>>, @@ -352,7 +352,7 @@ pub fn fixup_err_to_string(f: FixupError) -> String { } } -pub fn new_infer_ctxt<'a, 'tcx>(tcx: &'a ty::ctxt<'tcx>, +pub fn new_infer_ctxt<'a, 'tcx>(tcx: &'a TyCtxt<'tcx>, tables: &'a RefCell<ty::Tables<'tcx>>, param_env: Option<ty::ParameterEnvironment<'a, 'tcx>>) -> InferCtxt<'a, 'tcx> { @@ -370,7 +370,7 @@ pub fn new_infer_ctxt<'a, 'tcx>(tcx: &'a ty::ctxt<'tcx>, } } -pub fn normalizing_infer_ctxt<'a, 'tcx>(tcx: &'a ty::ctxt<'tcx>, +pub fn normalizing_infer_ctxt<'a, 'tcx>(tcx: &'a TyCtxt<'tcx>, tables: &'a RefCell<ty::Tables<'tcx>>) -> InferCtxt<'a, 'tcx> { let mut infcx = new_infer_ctxt(tcx, tables, None); @@ -501,7 +501,7 @@ pub struct CombinedSnapshot { region_vars_snapshot: RegionSnapshot, } -pub fn normalize_associated_type<'tcx,T>(tcx: &ty::ctxt<'tcx>, value: &T) -> T +pub fn normalize_associated_type<'tcx,T>(tcx: &TyCtxt<'tcx>, value: &T) -> T where T : TypeFoldable<'tcx> { debug!("normalize_associated_type(t={:?})", value); @@ -1553,7 +1553,7 @@ impl<'tcx> TypeTrace<'tcx> { } } - pub fn dummy(tcx: &ty::ctxt<'tcx>) -> TypeTrace<'tcx> { + pub fn dummy(tcx: &TyCtxt<'tcx>) -> TypeTrace<'tcx> { TypeTrace { origin: TypeOrigin::Misc(codemap::DUMMY_SP), values: Types(ExpectedFound { diff --git a/src/librustc/middle/infer/region_inference/graphviz.rs b/src/librustc/middle/infer/region_inference/graphviz.rs index dafa65c5bdc..b6c9b5636d9 100644 --- a/src/librustc/middle/infer/region_inference/graphviz.rs +++ b/src/librustc/middle/infer/region_inference/graphviz.rs @@ -18,7 +18,7 @@ /// For clarity, rename the graphviz crate locally to dot. use graphviz as dot; -use middle::ty; +use middle::ty::{self, TyCtxt}; use middle::region::CodeExtent; use super::Constraint; use middle::infer::SubregionOrigin; @@ -119,7 +119,7 @@ pub fn maybe_print_constraints_for<'a, 'tcx>(region_vars: &RegionVarBindings<'a, } struct ConstraintGraph<'a, 'tcx: 'a> { - tcx: &'a ty::ctxt<'tcx>, + tcx: &'a TyCtxt<'tcx>, graph_name: String, map: &'a FnvHashMap<Constraint, SubregionOrigin<'tcx>>, node_ids: FnvHashMap<Node, usize>, @@ -139,7 +139,7 @@ enum Edge { } impl<'a, 'tcx> ConstraintGraph<'a, 'tcx> { - fn new(tcx: &'a ty::ctxt<'tcx>, + fn new(tcx: &'a TyCtxt<'tcx>, name: String, map: &'a ConstraintMap<'tcx>) -> ConstraintGraph<'a, 'tcx> { @@ -254,7 +254,7 @@ impl<'a, 'tcx> dot::GraphWalk<'a, Node, Edge> for ConstraintGraph<'a, 'tcx> { pub type ConstraintMap<'tcx> = FnvHashMap<Constraint, SubregionOrigin<'tcx>>; -fn dump_region_constraints_to<'a, 'tcx: 'a>(tcx: &'a ty::ctxt<'tcx>, +fn dump_region_constraints_to<'a, 'tcx: 'a>(tcx: &'a TyCtxt<'tcx>, map: &ConstraintMap<'tcx>, path: &str) -> io::Result<()> { diff --git a/src/librustc/middle/infer/region_inference/mod.rs b/src/librustc/middle/infer/region_inference/mod.rs index bfc770d53aa..36462b68288 100644 --- a/src/librustc/middle/infer/region_inference/mod.rs +++ b/src/librustc/middle/infer/region_inference/mod.rs @@ -23,7 +23,7 @@ use super::unify_key; use rustc_data_structures::graph::{self, Direction, NodeIndex}; use rustc_data_structures::unify::{self, UnificationTable}; use middle::free_region::FreeRegionMap; -use middle::ty::{self, Ty}; +use middle::ty::{self, Ty, TyCtxt}; use middle::ty::{BoundRegion, Region, RegionVid}; use middle::ty::{ReEmpty, ReStatic, ReFree, ReEarlyBound}; use middle::ty::{ReLateBound, ReScope, ReVar, ReSkolemized, BrFresh}; @@ -187,7 +187,7 @@ impl SameRegions { pub type CombineMap = FnvHashMap<TwoRegions, RegionVid>; pub struct RegionVarBindings<'a, 'tcx: 'a> { - tcx: &'a ty::ctxt<'tcx>, + tcx: &'a TyCtxt<'tcx>, var_origins: RefCell<Vec<RegionVariableOrigin>>, // Constraints of the form `A <= B` introduced by the region @@ -250,7 +250,7 @@ pub struct RegionSnapshot { } impl<'a, 'tcx> RegionVarBindings<'a, 'tcx> { - pub fn new(tcx: &'a ty::ctxt<'tcx>) -> RegionVarBindings<'a, 'tcx> { + pub fn new(tcx: &'a TyCtxt<'tcx>) -> RegionVarBindings<'a, 'tcx> { RegionVarBindings { tcx: tcx, var_origins: RefCell::new(Vec::new()), @@ -1358,7 +1358,7 @@ impl<'tcx> fmt::Display for GenericKind<'tcx> { } impl<'tcx> GenericKind<'tcx> { - pub fn to_ty(&self, tcx: &ty::ctxt<'tcx>) -> Ty<'tcx> { + pub fn to_ty(&self, tcx: &TyCtxt<'tcx>) -> Ty<'tcx> { match *self { GenericKind::Param(ref p) => p.to_ty(tcx), GenericKind::Projection(ref p) => tcx.mk_projection(p.trait_ref.clone(), p.item_name), @@ -1420,7 +1420,7 @@ impl VerifyBound { } fn is_met<'tcx>(&self, - tcx: &ty::ctxt<'tcx>, + tcx: &TyCtxt<'tcx>, free_regions: &FreeRegionMap, var_values: &Vec<VarValue>, min: ty::Region) diff --git a/src/librustc/middle/infer/resolve.rs b/src/librustc/middle/infer/resolve.rs index c68d0a9fa56..8c610589844 100644 --- a/src/librustc/middle/infer/resolve.rs +++ b/src/librustc/middle/infer/resolve.rs @@ -9,7 +9,7 @@ // except according to those terms. use super::{InferCtxt, FixupError, FixupResult}; -use middle::ty::{self, Ty, TypeFoldable}; +use middle::ty::{self, Ty, TyCtxt, TypeFoldable}; /////////////////////////////////////////////////////////////////////////// // OPPORTUNISTIC TYPE RESOLVER @@ -30,7 +30,7 @@ impl<'a, 'tcx> OpportunisticTypeResolver<'a, 'tcx> { } impl<'a, 'tcx> ty::fold::TypeFolder<'tcx> for OpportunisticTypeResolver<'a, 'tcx> { - fn tcx(&self) -> &ty::ctxt<'tcx> { + fn tcx(&self) -> &TyCtxt<'tcx> { self.infcx.tcx } @@ -58,7 +58,7 @@ impl<'a, 'tcx> OpportunisticTypeAndRegionResolver<'a, 'tcx> { } impl<'a, 'tcx> ty::fold::TypeFolder<'tcx> for OpportunisticTypeAndRegionResolver<'a, 'tcx> { - fn tcx(&self) -> &ty::ctxt<'tcx> { + fn tcx(&self) -> &TyCtxt<'tcx> { self.infcx.tcx } @@ -104,7 +104,7 @@ struct FullTypeResolver<'a, 'tcx:'a> { } impl<'a, 'tcx> ty::fold::TypeFolder<'tcx> for FullTypeResolver<'a, 'tcx> { - fn tcx(&self) -> &ty::ctxt<'tcx> { + fn tcx(&self) -> &TyCtxt<'tcx> { self.infcx.tcx } diff --git a/src/librustc/middle/infer/sub.rs b/src/librustc/middle/infer/sub.rs index 2cd686fde15..e13d29b8b42 100644 --- a/src/librustc/middle/infer/sub.rs +++ b/src/librustc/middle/infer/sub.rs @@ -13,7 +13,7 @@ use super::higher_ranked::HigherRankedRelations; use super::SubregionOrigin; use super::type_variable::{SubtypeOf, SupertypeOf}; -use middle::ty::{self, Ty}; +use middle::ty::{self, Ty, TyCtxt}; use middle::ty::TyVar; use middle::ty::relate::{Cause, Relate, RelateResult, TypeRelation}; use std::mem; @@ -31,7 +31,7 @@ impl<'a, 'tcx> Sub<'a, 'tcx> { impl<'a, 'tcx> TypeRelation<'a, 'tcx> for Sub<'a, 'tcx> { fn tag(&self) -> &'static str { "Sub" } - fn tcx(&self) -> &'a ty::ctxt<'tcx> { self.fields.infcx.tcx } + fn tcx(&self) -> &'a TyCtxt<'tcx> { self.fields.infcx.tcx } fn a_is_expected(&self) -> bool { self.fields.a_is_expected } fn with_cause<F,R>(&mut self, cause: Cause, f: F) -> R diff --git a/src/librustc/middle/infer/unify_key.rs b/src/librustc/middle/infer/unify_key.rs index c83231930f5..5008a92a4f5 100644 --- a/src/librustc/middle/infer/unify_key.rs +++ b/src/librustc/middle/infer/unify_key.rs @@ -9,11 +9,11 @@ // except according to those terms. use syntax::ast; -use middle::ty::{self, IntVarValue, Ty}; +use middle::ty::{self, IntVarValue, Ty, TyCtxt}; use rustc_data_structures::unify::{Combine, UnifyKey}; pub trait ToType<'tcx> { - fn to_type(&self, tcx: &ty::ctxt<'tcx>) -> Ty<'tcx>; + fn to_type(&self, tcx: &TyCtxt<'tcx>) -> Ty<'tcx>; } impl UnifyKey for ty::IntVid { @@ -51,7 +51,7 @@ impl UnifyKey for ty::RegionVid { } impl<'tcx> ToType<'tcx> for IntVarValue { - fn to_type(&self, tcx: &ty::ctxt<'tcx>) -> Ty<'tcx> { + fn to_type(&self, tcx: &TyCtxt<'tcx>) -> Ty<'tcx> { match *self { ty::IntType(i) => tcx.mk_mach_int(i), ty::UintType(i) => tcx.mk_mach_uint(i), @@ -69,7 +69,7 @@ impl UnifyKey for ty::FloatVid { } impl<'tcx> ToType<'tcx> for ast::FloatTy { - fn to_type(&self, tcx: &ty::ctxt<'tcx>) -> Ty<'tcx> { + fn to_type(&self, tcx: &TyCtxt<'tcx>) -> Ty<'tcx> { tcx.mk_mach_float(*self) } } diff --git a/src/librustc/middle/intrinsicck.rs b/src/librustc/middle/intrinsicck.rs index a763677db06..7de8904e3f2 100644 --- a/src/librustc/middle/intrinsicck.rs +++ b/src/librustc/middle/intrinsicck.rs @@ -12,7 +12,7 @@ use dep_graph::DepNode; use middle::def::Def; use middle::def_id::DefId; use middle::subst::{Subst, Substs, EnumeratedItems}; -use middle::ty::{TransmuteRestriction, ctxt, TyBareFn}; +use middle::ty::{TransmuteRestriction, TyCtxt, TyBareFn}; use middle::ty::{self, Ty, TypeFoldable}; use std::fmt; @@ -23,7 +23,7 @@ use syntax::codemap::Span; use rustc_front::intravisit::{self, Visitor, FnKind}; use rustc_front::hir; -pub fn check_crate(tcx: &ctxt) { +pub fn check_crate(tcx: &TyCtxt) { let mut visitor = IntrinsicCheckingVisitor { tcx: tcx, param_envs: Vec::new(), @@ -34,7 +34,7 @@ pub fn check_crate(tcx: &ctxt) { } struct IntrinsicCheckingVisitor<'a, 'tcx: 'a> { - tcx: &'a ctxt<'tcx>, + tcx: &'a TyCtxt<'tcx>, // As we traverse the AST, we keep a stack of the parameter // environments for each function we encounter. When we find a diff --git a/src/librustc/middle/liveness.rs b/src/librustc/middle/liveness.rs index a487ddbc2b1..81f0cb1fbb2 100644 --- a/src/librustc/middle/liveness.rs +++ b/src/librustc/middle/liveness.rs @@ -112,7 +112,7 @@ use self::VarKind::*; use dep_graph::DepNode; use middle::def::*; use middle::pat_util; -use middle::ty; +use middle::ty::{self, TyCtxt}; use lint; use util::nodemap::NodeMap; @@ -166,7 +166,7 @@ enum LiveNodeKind { ExitNode } -fn live_node_kind_to_string(lnk: LiveNodeKind, cx: &ty::ctxt) -> String { +fn live_node_kind_to_string(lnk: LiveNodeKind, cx: &TyCtxt) -> String { let cm = cx.sess.codemap(); match lnk { FreeVarNode(s) => { @@ -192,7 +192,7 @@ impl<'a, 'tcx, 'v> Visitor<'v> for IrMaps<'a, 'tcx> { fn visit_arm(&mut self, a: &hir::Arm) { visit_arm(self, a); } } -pub fn check_crate(tcx: &ty::ctxt) { +pub fn check_crate(tcx: &TyCtxt) { let _task = tcx.dep_graph.in_task(DepNode::Liveness); tcx.map.krate().visit_all_items(&mut IrMaps::new(tcx)); tcx.sess.abort_if_errors(); @@ -260,7 +260,7 @@ enum VarKind { } struct IrMaps<'a, 'tcx: 'a> { - tcx: &'a ty::ctxt<'tcx>, + tcx: &'a TyCtxt<'tcx>, num_live_nodes: usize, num_vars: usize, @@ -272,7 +272,7 @@ struct IrMaps<'a, 'tcx: 'a> { } impl<'a, 'tcx> IrMaps<'a, 'tcx> { - fn new(tcx: &'a ty::ctxt<'tcx>) -> IrMaps<'a, 'tcx> { + fn new(tcx: &'a TyCtxt<'tcx>) -> IrMaps<'a, 'tcx> { IrMaps { tcx: tcx, num_live_nodes: 0, diff --git a/src/librustc/middle/mem_categorization.rs b/src/librustc/middle/mem_categorization.rs index fef35764e1c..11ef1dbd705 100644 --- a/src/librustc/middle/mem_categorization.rs +++ b/src/librustc/middle/mem_categorization.rs @@ -77,7 +77,7 @@ use middle::infer; use middle::const_qualif::ConstQualif; use middle::def::Def; use middle::ty::adjustment; -use middle::ty::{self, Ty}; +use middle::ty::{self, Ty, TyCtxt}; use rustc_front::hir::{MutImmutable, MutMutable, PatKind}; use rustc_front::hir; @@ -302,7 +302,7 @@ impl MutabilityCategory { ret } - fn from_local(tcx: &ty::ctxt, id: ast::NodeId) -> MutabilityCategory { + fn from_local(tcx: &TyCtxt, id: ast::NodeId) -> MutabilityCategory { let ret = match tcx.map.get(id) { ast_map::NodeLocal(p) => match p.node { PatKind::Ident(bind_mode, _, _) => { @@ -363,7 +363,7 @@ impl<'t, 'a,'tcx> MemCategorizationContext<'t, 'a, 'tcx> { MemCategorizationContext { typer: typer } } - fn tcx(&self) -> &'a ty::ctxt<'tcx> { + fn tcx(&self) -> &'a TyCtxt<'tcx> { self.typer.tcx } @@ -1081,7 +1081,7 @@ impl<'t, 'a,'tcx> MemCategorizationContext<'t, 'a, 'tcx> { /// In a pattern like [a, b, ..c], normally `c` has slice type, but if you have [a, b, /// ..ref c], then the type of `ref c` will be `&&[]`, so to extract the slice details we /// have to recurse through rptrs. - fn vec_slice_info(tcx: &ty::ctxt, + fn vec_slice_info(tcx: &TyCtxt, pat: &hir::Pat, slice_ty: Ty) -> (hir::Mutability, ty::Region) { @@ -1387,7 +1387,7 @@ impl<'tcx> cmt_<'tcx> { } /// Returns `FreelyAliasable(_)` if this lvalue represents a freely aliasable pointer type. - pub fn freely_aliasable(&self, ctxt: &ty::ctxt<'tcx>) + pub fn freely_aliasable(&self, ctxt: &TyCtxt<'tcx>) -> Aliasability { // Maybe non-obvious: copied upvars can only be considered // non-aliasable in once closures, since any other kind can be @@ -1462,7 +1462,7 @@ impl<'tcx> cmt_<'tcx> { } - pub fn descriptive_string(&self, tcx: &ty::ctxt) -> String { + pub fn descriptive_string(&self, tcx: &TyCtxt) -> String { match self.cat { Categorization::StaticItem => { "static item".to_string() diff --git a/src/librustc/middle/pat_util.rs b/src/librustc/middle/pat_util.rs index a1a3c194efe..81166945115 100644 --- a/src/librustc/middle/pat_util.rs +++ b/src/librustc/middle/pat_util.rs @@ -10,7 +10,7 @@ use middle::def::*; use middle::def_id::DefId; -use middle::ty; +use middle::ty::TyCtxt; use util::nodemap::FnvHashMap; use syntax::ast; @@ -210,7 +210,7 @@ pub fn simple_name<'a>(pat: &'a hir::Pat) -> Option<ast::Name> { } } -pub fn def_to_path(tcx: &ty::ctxt, id: DefId) -> hir::Path { +pub fn def_to_path(tcx: &TyCtxt, id: DefId) -> hir::Path { tcx.with_path(id, |path| hir::Path { global: false, segments: path.last().map(|elem| hir::PathSegment { diff --git a/src/librustc/middle/reachable.rs b/src/librustc/middle/reachable.rs index 614d9be147b..601f069513d 100644 --- a/src/librustc/middle/reachable.rs +++ b/src/librustc/middle/reachable.rs @@ -19,7 +19,7 @@ use dep_graph::DepNode; use front::map as ast_map; use middle::def::Def; use middle::def_id::DefId; -use middle::ty; +use middle::ty::{self, TyCtxt}; use middle::privacy; use session::config; use util::nodemap::NodeSet; @@ -55,7 +55,7 @@ fn item_might_be_inlined(item: &hir::Item) -> bool { } } -fn method_might_be_inlined(tcx: &ty::ctxt, sig: &hir::MethodSig, +fn method_might_be_inlined(tcx: &TyCtxt, sig: &hir::MethodSig, impl_item: &hir::ImplItem, impl_src: DefId) -> bool { if attr::requests_inline(&impl_item.attrs) || @@ -77,7 +77,7 @@ fn method_might_be_inlined(tcx: &ty::ctxt, sig: &hir::MethodSig, // Information needed while computing reachability. struct ReachableContext<'a, 'tcx: 'a> { // The type context. - tcx: &'a ty::ctxt<'tcx>, + tcx: &'a TyCtxt<'tcx>, // The set of items which must be exported in the linkage sense. reachable_symbols: NodeSet, // A worklist of item IDs. Each item ID in this worklist will be inlined @@ -143,7 +143,7 @@ impl<'a, 'tcx, 'v> Visitor<'v> for ReachableContext<'a, 'tcx> { impl<'a, 'tcx> ReachableContext<'a, 'tcx> { // Creates a new reachability computation context. - fn new(tcx: &'a ty::ctxt<'tcx>) -> ReachableContext<'a, 'tcx> { + fn new(tcx: &'a TyCtxt<'tcx>) -> ReachableContext<'a, 'tcx> { let any_library = tcx.sess.crate_types.borrow().iter().any(|ty| { *ty != config::CrateTypeExecutable }); @@ -349,7 +349,7 @@ impl<'a, 'v> Visitor<'v> for CollectPrivateImplItemsVisitor<'a> { } } -pub fn find_reachable(tcx: &ty::ctxt, +pub fn find_reachable(tcx: &TyCtxt, access_levels: &privacy::AccessLevels) -> NodeSet { let _task = tcx.dep_graph.in_task(DepNode::Reachability); diff --git a/src/librustc/middle/stability.rs b/src/librustc/middle/stability.rs index c35c86ce974..2d92742ed0f 100644 --- a/src/librustc/middle/stability.rs +++ b/src/librustc/middle/stability.rs @@ -20,7 +20,7 @@ use lint; use middle::cstore::{CrateStore, LOCAL_CRATE}; use middle::def::Def; use middle::def_id::{CRATE_DEF_INDEX, DefId}; -use middle::ty; +use middle::ty::{self, TyCtxt}; use middle::privacy::AccessLevels; use syntax::parse::token::InternedString; use syntax::codemap::{Span, DUMMY_SP}; @@ -72,7 +72,7 @@ pub struct Index<'tcx> { // A private tree-walker for producing an Index. struct Annotator<'a, 'tcx: 'a> { - tcx: &'a ty::ctxt<'tcx>, + tcx: &'a TyCtxt<'tcx>, index: &'a mut Index<'tcx>, parent_stab: Option<&'tcx Stability>, parent_depr: Option<Deprecation>, @@ -279,7 +279,7 @@ impl<'a, 'tcx, 'v> Visitor<'v> for Annotator<'a, 'tcx> { impl<'tcx> Index<'tcx> { /// Construct the stability index for a crate being compiled. - pub fn build(&mut self, tcx: &ty::ctxt<'tcx>, access_levels: &AccessLevels) { + pub fn build(&mut self, tcx: &TyCtxt<'tcx>, access_levels: &AccessLevels) { let _task = tcx.dep_graph.in_task(DepNode::StabilityIndex); let krate = tcx.map.krate(); let mut annotator = Annotator { @@ -319,7 +319,7 @@ impl<'tcx> Index<'tcx> { /// Cross-references the feature names of unstable APIs with enabled /// features and possibly prints errors. Returns a list of all /// features used. -pub fn check_unstable_api_usage(tcx: &ty::ctxt) +pub fn check_unstable_api_usage(tcx: &TyCtxt) -> FnvHashMap<InternedString, StabilityLevel> { let _task = tcx.dep_graph.in_task(DepNode::StabilityCheck); let ref active_lib_features = tcx.sess.features.borrow().declared_lib_features; @@ -339,7 +339,7 @@ pub fn check_unstable_api_usage(tcx: &ty::ctxt) } struct Checker<'a, 'tcx: 'a> { - tcx: &'a ty::ctxt<'tcx>, + tcx: &'a TyCtxt<'tcx>, active_features: FnvHashSet<InternedString>, used_features: FnvHashMap<InternedString, StabilityLevel>, // Within a block where feature gate checking can be skipped. @@ -466,7 +466,7 @@ impl<'a, 'v, 'tcx> Visitor<'v> for Checker<'a, 'tcx> { } /// Helper for discovering nodes to check for stability -pub fn check_item(tcx: &ty::ctxt, item: &hir::Item, warn_about_defns: bool, +pub fn check_item(tcx: &TyCtxt, item: &hir::Item, warn_about_defns: bool, cb: &mut FnMut(DefId, Span, &Option<&Stability>, &Option<Deprecation>)) { match item.node { hir::ItemExternCrate(_) => { @@ -503,7 +503,7 @@ pub fn check_item(tcx: &ty::ctxt, item: &hir::Item, warn_about_defns: bool, } /// Helper for discovering nodes to check for stability -pub fn check_expr(tcx: &ty::ctxt, e: &hir::Expr, +pub fn check_expr(tcx: &TyCtxt, e: &hir::Expr, cb: &mut FnMut(DefId, Span, &Option<&Stability>, &Option<Deprecation>)) { let span; let id = match e.node { @@ -564,7 +564,7 @@ pub fn check_expr(tcx: &ty::ctxt, e: &hir::Expr, maybe_do_stability_check(tcx, id, span, cb); } -pub fn check_path(tcx: &ty::ctxt, path: &hir::Path, id: ast::NodeId, +pub fn check_path(tcx: &TyCtxt, path: &hir::Path, id: ast::NodeId, cb: &mut FnMut(DefId, Span, &Option<&Stability>, &Option<Deprecation>)) { match tcx.def_map.borrow().get(&id).map(|d| d.full_def()) { Some(Def::PrimTy(..)) => {} @@ -576,7 +576,7 @@ pub fn check_path(tcx: &ty::ctxt, path: &hir::Path, id: ast::NodeId, } } -pub fn check_path_list_item(tcx: &ty::ctxt, item: &hir::PathListItem, +pub fn check_path_list_item(tcx: &TyCtxt, item: &hir::PathListItem, cb: &mut FnMut(DefId, Span, &Option<&Stability>, &Option<Deprecation>)) { match tcx.def_map.borrow().get(&item.node.id()).map(|d| d.full_def()) { Some(Def::PrimTy(..)) => {} @@ -587,7 +587,7 @@ pub fn check_path_list_item(tcx: &ty::ctxt, item: &hir::PathListItem, } } -pub fn check_pat(tcx: &ty::ctxt, pat: &hir::Pat, +pub fn check_pat(tcx: &TyCtxt, pat: &hir::Pat, cb: &mut FnMut(DefId, Span, &Option<&Stability>, &Option<Deprecation>)) { debug!("check_pat(pat = {:?})", pat); if is_internal(tcx, pat.span) { return; } @@ -616,7 +616,7 @@ pub fn check_pat(tcx: &ty::ctxt, pat: &hir::Pat, } } -fn maybe_do_stability_check(tcx: &ty::ctxt, id: DefId, span: Span, +fn maybe_do_stability_check(tcx: &TyCtxt, id: DefId, span: Span, cb: &mut FnMut(DefId, Span, &Option<&Stability>, &Option<Deprecation>)) { if is_internal(tcx, span) { @@ -634,11 +634,11 @@ fn maybe_do_stability_check(tcx: &ty::ctxt, id: DefId, span: Span, cb(id, span, &stability, &deprecation); } -fn is_internal(tcx: &ty::ctxt, span: Span) -> bool { +fn is_internal(tcx: &TyCtxt, span: Span) -> bool { tcx.sess.codemap().span_allows_unstable(span) } -fn is_staged_api(tcx: &ty::ctxt, id: DefId) -> bool { +fn is_staged_api(tcx: &TyCtxt, id: DefId) -> bool { match tcx.trait_item_of_item(id) { Some(ty::MethodTraitItemId(trait_method_id)) if trait_method_id != id => { @@ -653,7 +653,7 @@ fn is_staged_api(tcx: &ty::ctxt, id: DefId) -> bool { /// Lookup the stability for a node, loading external crate /// metadata as necessary. -pub fn lookup_stability<'tcx>(tcx: &ty::ctxt<'tcx>, id: DefId) -> Option<&'tcx Stability> { +pub fn lookup_stability<'tcx>(tcx: &TyCtxt<'tcx>, id: DefId) -> Option<&'tcx Stability> { if let Some(st) = tcx.stability.borrow().stab_map.get(&id) { return *st; } @@ -663,7 +663,7 @@ pub fn lookup_stability<'tcx>(tcx: &ty::ctxt<'tcx>, id: DefId) -> Option<&'tcx S st } -pub fn lookup_deprecation<'tcx>(tcx: &ty::ctxt<'tcx>, id: DefId) -> Option<Deprecation> { +pub fn lookup_deprecation<'tcx>(tcx: &TyCtxt<'tcx>, id: DefId) -> Option<Deprecation> { if let Some(depr) = tcx.stability.borrow().depr_map.get(&id) { return depr.clone(); } @@ -673,7 +673,7 @@ pub fn lookup_deprecation<'tcx>(tcx: &ty::ctxt<'tcx>, id: DefId) -> Option<Depre depr } -fn lookup_stability_uncached<'tcx>(tcx: &ty::ctxt<'tcx>, id: DefId) -> Option<&'tcx Stability> { +fn lookup_stability_uncached<'tcx>(tcx: &TyCtxt<'tcx>, id: DefId) -> Option<&'tcx Stability> { debug!("lookup(id={:?})", id); if id.is_local() { None // The stability cache is filled partially lazily @@ -682,7 +682,7 @@ fn lookup_stability_uncached<'tcx>(tcx: &ty::ctxt<'tcx>, id: DefId) -> Option<&' } } -fn lookup_deprecation_uncached<'tcx>(tcx: &ty::ctxt<'tcx>, id: DefId) -> Option<Deprecation> { +fn lookup_deprecation_uncached<'tcx>(tcx: &TyCtxt<'tcx>, id: DefId) -> Option<Deprecation> { debug!("lookup(id={:?})", id); if id.is_local() { None // The stability cache is filled partially lazily diff --git a/src/librustc/middle/subst.rs b/src/librustc/middle/subst.rs index f8c6d3d9341..9cc94402b16 100644 --- a/src/librustc/middle/subst.rs +++ b/src/librustc/middle/subst.rs @@ -15,7 +15,7 @@ pub use self::RegionSubsts::*; use middle::cstore; use middle::def_id::DefId; -use middle::ty::{self, Ty}; +use middle::ty::{self, Ty, TyCtxt}; use middle::ty::fold::{TypeFoldable, TypeFolder}; use serialize::{Encodable, Encoder, Decodable, Decoder}; @@ -161,7 +161,7 @@ impl<'tcx> Substs<'tcx> { } /// Creates a trait-ref out of this substs, ignoring the FnSpace substs - pub fn to_trait_ref(&self, tcx: &ty::ctxt<'tcx>, trait_id: DefId) + pub fn to_trait_ref(&self, tcx: &TyCtxt<'tcx>, trait_id: DefId) -> ty::TraitRef<'tcx> { let Substs { mut types, regions } = self.clone(); types.truncate(FnSpace, 0); @@ -589,11 +589,11 @@ impl<'a,T> IntoIterator for &'a VecPerParamSpace<T> { // there is more information available (for better errors). pub trait Subst<'tcx> : Sized { - fn subst(&self, tcx: &ty::ctxt<'tcx>, substs: &Substs<'tcx>) -> Self { + fn subst(&self, tcx: &TyCtxt<'tcx>, substs: &Substs<'tcx>) -> Self { self.subst_spanned(tcx, substs, None) } - fn subst_spanned(&self, tcx: &ty::ctxt<'tcx>, + fn subst_spanned(&self, tcx: &TyCtxt<'tcx>, substs: &Substs<'tcx>, span: Option<Span>) -> Self; @@ -601,7 +601,7 @@ pub trait Subst<'tcx> : Sized { impl<'tcx, T:TypeFoldable<'tcx>> Subst<'tcx> for T { fn subst_spanned(&self, - tcx: &ty::ctxt<'tcx>, + tcx: &TyCtxt<'tcx>, substs: &Substs<'tcx>, span: Option<Span>) -> T @@ -620,7 +620,7 @@ impl<'tcx, T:TypeFoldable<'tcx>> Subst<'tcx> for T { // The actual substitution engine itself is a type folder. struct SubstFolder<'a, 'tcx: 'a> { - tcx: &'a ty::ctxt<'tcx>, + tcx: &'a TyCtxt<'tcx>, substs: &'a Substs<'tcx>, // The location for which the substitution is performed, if available. @@ -637,7 +637,7 @@ struct SubstFolder<'a, 'tcx: 'a> { } impl<'a, 'tcx> TypeFolder<'tcx> for SubstFolder<'a, 'tcx> { - fn tcx(&self) -> &ty::ctxt<'tcx> { self.tcx } + fn tcx(&self) -> &TyCtxt<'tcx> { self.tcx } fn enter_region_binder(&mut self) { self.region_binders_passed += 1; diff --git a/src/librustc/middle/traits/coherence.rs b/src/librustc/middle/traits/coherence.rs index 0f95aa74b6f..b0970457892 100644 --- a/src/librustc/middle/traits/coherence.rs +++ b/src/librustc/middle/traits/coherence.rs @@ -20,7 +20,7 @@ use super::util; use middle::cstore::LOCAL_CRATE; use middle::def_id::DefId; use middle::subst::{Subst, Substs, TypeSpace}; -use middle::ty::{self, Ty}; +use middle::ty::{self, Ty, TyCtxt}; use middle::infer::{self, InferCtxt, TypeOrigin}; use syntax::codemap::{DUMMY_SP, Span}; @@ -94,7 +94,7 @@ fn overlap<'cx, 'tcx>(selcx: &mut SelectionContext<'cx, 'tcx>, Some(selcx.infcx().resolve_type_vars_if_possible(&a_trait_ref)) } -pub fn trait_ref_is_knowable<'tcx>(tcx: &ty::ctxt<'tcx>, trait_ref: &ty::TraitRef<'tcx>) -> bool +pub fn trait_ref_is_knowable<'tcx>(tcx: &TyCtxt<'tcx>, trait_ref: &ty::TraitRef<'tcx>) -> bool { debug!("trait_ref_is_knowable(trait_ref={:?})", trait_ref); @@ -174,7 +174,7 @@ pub enum OrphanCheckErr<'tcx> { /// /// 1. All type parameters in `Self` must be "covered" by some local type constructor. /// 2. Some local type must appear in `Self`. -pub fn orphan_check<'tcx>(tcx: &ty::ctxt<'tcx>, +pub fn orphan_check<'tcx>(tcx: &TyCtxt<'tcx>, impl_def_id: DefId) -> Result<(), OrphanCheckErr<'tcx>> { @@ -195,7 +195,7 @@ pub fn orphan_check<'tcx>(tcx: &ty::ctxt<'tcx>, orphan_check_trait_ref(tcx, &trait_ref, InferIsLocal(false)) } -fn orphan_check_trait_ref<'tcx>(tcx: &ty::ctxt<'tcx>, +fn orphan_check_trait_ref<'tcx>(tcx: &TyCtxt<'tcx>, trait_ref: &ty::TraitRef<'tcx>, infer_is_local: InferIsLocal) -> Result<(), OrphanCheckErr<'tcx>> @@ -243,7 +243,7 @@ fn orphan_check_trait_ref<'tcx>(tcx: &ty::ctxt<'tcx>, return Err(OrphanCheckErr::NoLocalInputType); } -fn uncovered_tys<'tcx>(tcx: &ty::ctxt<'tcx>, +fn uncovered_tys<'tcx>(tcx: &TyCtxt<'tcx>, ty: Ty<'tcx>, infer_is_local: InferIsLocal) -> Vec<Ty<'tcx>> @@ -267,13 +267,13 @@ fn is_type_parameter<'tcx>(ty: Ty<'tcx>) -> bool { } } -fn ty_is_local<'tcx>(tcx: &ty::ctxt<'tcx>, ty: Ty<'tcx>, infer_is_local: InferIsLocal) -> bool +fn ty_is_local<'tcx>(tcx: &TyCtxt<'tcx>, ty: Ty<'tcx>, infer_is_local: InferIsLocal) -> bool { ty_is_local_constructor(tcx, ty, infer_is_local) || fundamental_ty(tcx, ty) && ty.walk_shallow().any(|t| ty_is_local(tcx, t, infer_is_local)) } -fn fundamental_ty<'tcx>(tcx: &ty::ctxt<'tcx>, ty: Ty<'tcx>) -> bool +fn fundamental_ty<'tcx>(tcx: &TyCtxt<'tcx>, ty: Ty<'tcx>) -> bool { match ty.sty { ty::TyBox(..) | ty::TyRef(..) => @@ -287,7 +287,7 @@ fn fundamental_ty<'tcx>(tcx: &ty::ctxt<'tcx>, ty: Ty<'tcx>) -> bool } } -fn ty_is_local_constructor<'tcx>(tcx: &ty::ctxt<'tcx>, +fn ty_is_local_constructor<'tcx>(tcx: &TyCtxt<'tcx>, ty: Ty<'tcx>, infer_is_local: InferIsLocal) -> bool diff --git a/src/librustc/middle/traits/error_reporting.rs b/src/librustc/middle/traits/error_reporting.rs index fac53ec140d..dd051471a4d 100644 --- a/src/librustc/middle/traits/error_reporting.rs +++ b/src/librustc/middle/traits/error_reporting.rs @@ -26,7 +26,7 @@ use super::{ use fmt_macros::{Parser, Piece, Position}; use middle::def_id::DefId; use middle::infer::InferCtxt; -use middle::ty::{self, ToPredicate, ToPolyTraitRef, TraitRef, Ty, TypeFoldable}; +use middle::ty::{self, ToPredicate, ToPolyTraitRef, TraitRef, Ty, TyCtxt, TypeFoldable}; use middle::ty::fast_reject; use util::nodemap::{FnvHashMap, FnvHashSet}; @@ -326,7 +326,7 @@ pub fn try_report_overflow_error_type_of_infinite_size<'a, 'tcx>( unreachable!(); } -pub fn recursive_type_with_infinite_size_error<'tcx>(tcx: &ty::ctxt<'tcx>, +pub fn recursive_type_with_infinite_size_error<'tcx>(tcx: &TyCtxt<'tcx>, type_def_id: DefId) -> DiagnosticBuilder<'tcx> { @@ -507,7 +507,7 @@ pub fn report_selection_error<'a, 'tcx>(infcx: &InferCtxt<'a, 'tcx>, } } -pub fn report_object_safety_error<'tcx>(tcx: &ty::ctxt<'tcx>, +pub fn report_object_safety_error<'tcx>(tcx: &TyCtxt<'tcx>, span: Span, trait_def_id: DefId, violations: Vec<ObjectSafetyViolation>) @@ -796,7 +796,7 @@ fn note_obligation_cause_code<'a, 'tcx, T>(infcx: &InferCtxt<'a, 'tcx>, } } -fn suggest_new_overflow_limit(tcx: &ty::ctxt, err:&mut DiagnosticBuilder, span: Span) { +fn suggest_new_overflow_limit(tcx: &TyCtxt, err:&mut DiagnosticBuilder, span: Span) { let current_limit = tcx.sess.recursion_limit.get(); let suggested_limit = current_limit * 2; err.fileline_note( diff --git a/src/librustc/middle/traits/fulfill.rs b/src/librustc/middle/traits/fulfill.rs index de70cdbd29a..b2371175642 100644 --- a/src/librustc/middle/traits/fulfill.rs +++ b/src/librustc/middle/traits/fulfill.rs @@ -10,7 +10,7 @@ use dep_graph::DepGraph; use middle::infer::InferCtxt; -use middle::ty::{self, Ty, TypeFoldable, ToPolyTraitRef}; +use middle::ty::{self, Ty, TyCtxt, TypeFoldable, ToPolyTraitRef}; use rustc_data_structures::obligation_forest::{Backtrace, ObligationForest, Error}; use std::iter; use syntax::ast; @@ -237,7 +237,7 @@ impl<'tcx> FulfillmentContext<'tcx> { } fn is_duplicate_or_add(&mut self, - tcx: &ty::ctxt<'tcx>, + tcx: &TyCtxt<'tcx>, predicate: &ty::Predicate<'tcx>) -> bool { // For "global" predicates -- that is, predicates that don't diff --git a/src/librustc/middle/traits/object_safety.rs b/src/librustc/middle/traits/object_safety.rs index 7ffdc3bdef2..4a0da521eef 100644 --- a/src/librustc/middle/traits/object_safety.rs +++ b/src/librustc/middle/traits/object_safety.rs @@ -23,7 +23,7 @@ use super::elaborate_predicates; use middle::def_id::DefId; use middle::subst::{self, SelfSpace, TypeSpace}; use middle::traits; -use middle::ty::{self, ToPolyTraitRef, Ty, TypeFoldable}; +use middle::ty::{self, ToPolyTraitRef, Ty, TyCtxt, TypeFoldable}; use std::rc::Rc; use syntax::ast; @@ -53,7 +53,7 @@ pub enum MethodViolationCode { Generic, } -pub fn is_object_safe<'tcx>(tcx: &ty::ctxt<'tcx>, +pub fn is_object_safe<'tcx>(tcx: &TyCtxt<'tcx>, trait_def_id: DefId) -> bool { @@ -80,7 +80,7 @@ pub fn is_object_safe<'tcx>(tcx: &ty::ctxt<'tcx>, /// astconv - currently, Self in supertraits. This is needed /// because `object_safety_violations` can't be used during /// type collection. -pub fn astconv_object_safety_violations<'tcx>(tcx: &ty::ctxt<'tcx>, +pub fn astconv_object_safety_violations<'tcx>(tcx: &TyCtxt<'tcx>, trait_def_id: DefId) -> Vec<ObjectSafetyViolation<'tcx>> { @@ -97,7 +97,7 @@ pub fn astconv_object_safety_violations<'tcx>(tcx: &ty::ctxt<'tcx>, violations } -pub fn object_safety_violations<'tcx>(tcx: &ty::ctxt<'tcx>, +pub fn object_safety_violations<'tcx>(tcx: &TyCtxt<'tcx>, trait_def_id: DefId) -> Vec<ObjectSafetyViolation<'tcx>> { @@ -106,7 +106,7 @@ pub fn object_safety_violations<'tcx>(tcx: &ty::ctxt<'tcx>, .collect() } -fn object_safety_violations_for_trait<'tcx>(tcx: &ty::ctxt<'tcx>, +fn object_safety_violations_for_trait<'tcx>(tcx: &TyCtxt<'tcx>, trait_def_id: DefId) -> Vec<ObjectSafetyViolation<'tcx>> { @@ -139,7 +139,7 @@ fn object_safety_violations_for_trait<'tcx>(tcx: &ty::ctxt<'tcx>, violations } -pub fn supertraits_reference_self<'tcx>(tcx: &ty::ctxt<'tcx>, +pub fn supertraits_reference_self<'tcx>(tcx: &TyCtxt<'tcx>, trait_def_id: DefId) -> bool { @@ -172,7 +172,7 @@ pub fn supertraits_reference_self<'tcx>(tcx: &ty::ctxt<'tcx>, }) } -fn trait_has_sized_self<'tcx>(tcx: &ty::ctxt<'tcx>, +fn trait_has_sized_self<'tcx>(tcx: &TyCtxt<'tcx>, trait_def_id: DefId) -> bool { @@ -181,7 +181,7 @@ fn trait_has_sized_self<'tcx>(tcx: &ty::ctxt<'tcx>, generics_require_sized_self(tcx, &trait_def.generics, &trait_predicates) } -fn generics_require_sized_self<'tcx>(tcx: &ty::ctxt<'tcx>, +fn generics_require_sized_self<'tcx>(tcx: &TyCtxt<'tcx>, generics: &ty::Generics<'tcx>, predicates: &ty::GenericPredicates<'tcx>) -> bool @@ -215,7 +215,7 @@ fn generics_require_sized_self<'tcx>(tcx: &ty::ctxt<'tcx>, } /// Returns `Some(_)` if this method makes the containing trait not object safe. -fn object_safety_violation_for_method<'tcx>(tcx: &ty::ctxt<'tcx>, +fn object_safety_violation_for_method<'tcx>(tcx: &TyCtxt<'tcx>, trait_def_id: DefId, method: &ty::Method<'tcx>) -> Option<MethodViolationCode> @@ -233,7 +233,7 @@ fn object_safety_violation_for_method<'tcx>(tcx: &ty::ctxt<'tcx>, /// object. Note that object-safe traits can have some /// non-vtable-safe methods, so long as they require `Self:Sized` or /// otherwise ensure that they cannot be used when `Self=Trait`. -pub fn is_vtable_safe_method<'tcx>(tcx: &ty::ctxt<'tcx>, +pub fn is_vtable_safe_method<'tcx>(tcx: &TyCtxt<'tcx>, trait_def_id: DefId, method: &ty::Method<'tcx>) -> bool @@ -245,7 +245,7 @@ pub fn is_vtable_safe_method<'tcx>(tcx: &ty::ctxt<'tcx>, /// object; this does not necessarily imply that the enclosing trait /// is not object safe, because the method might have a where clause /// `Self:Sized`. -fn virtual_call_violation_for_method<'tcx>(tcx: &ty::ctxt<'tcx>, +fn virtual_call_violation_for_method<'tcx>(tcx: &TyCtxt<'tcx>, trait_def_id: DefId, method: &ty::Method<'tcx>) -> Option<MethodViolationCode> @@ -286,7 +286,7 @@ fn virtual_call_violation_for_method<'tcx>(tcx: &ty::ctxt<'tcx>, None } -fn contains_illegal_self_type_reference<'tcx>(tcx: &ty::ctxt<'tcx>, +fn contains_illegal_self_type_reference<'tcx>(tcx: &TyCtxt<'tcx>, trait_def_id: DefId, ty: Ty<'tcx>) -> bool diff --git a/src/librustc/middle/traits/project.rs b/src/librustc/middle/traits/project.rs index c363425db85..b19771420bd 100644 --- a/src/librustc/middle/traits/project.rs +++ b/src/librustc/middle/traits/project.rs @@ -23,7 +23,7 @@ use super::util; use middle::infer::{self, TypeOrigin}; use middle::subst::Subst; -use middle::ty::{self, ToPredicate, ToPolyTraitRef, Ty}; +use middle::ty::{self, ToPredicate, ToPolyTraitRef, Ty, TyCtxt}; use middle::ty::fold::{TypeFoldable, TypeFolder}; use syntax::parse::token; use util::common::FN_OUTPUT_NAME; @@ -257,7 +257,7 @@ impl<'a,'b,'tcx> AssociatedTypeNormalizer<'a,'b,'tcx> { } impl<'a,'b,'tcx> TypeFolder<'tcx> for AssociatedTypeNormalizer<'a,'b,'tcx> { - fn tcx(&self) -> &ty::ctxt<'tcx> { + fn tcx(&self) -> &TyCtxt<'tcx> { self.selcx.tcx() } diff --git a/src/librustc/middle/traits/select.rs b/src/librustc/middle/traits/select.rs index 29355e0684d..373ec37663f 100644 --- a/src/librustc/middle/traits/select.rs +++ b/src/librustc/middle/traits/select.rs @@ -39,7 +39,7 @@ use middle::def_id::DefId; use middle::infer; use middle::infer::{InferCtxt, TypeFreshener, TypeOrigin}; use middle::subst::{Subst, Substs, TypeSpace}; -use middle::ty::{self, ToPredicate, ToPolyTraitRef, Ty, TypeFoldable}; +use middle::ty::{self, ToPredicate, ToPolyTraitRef, Ty, TyCtxt, TypeFoldable}; use middle::ty::fast_reject; use middle::ty::relate::TypeRelation; @@ -273,7 +273,7 @@ impl<'cx, 'tcx> SelectionContext<'cx, 'tcx> { self.infcx } - pub fn tcx(&self) -> &'cx ty::ctxt<'tcx> { + pub fn tcx(&self) -> &'cx TyCtxt<'tcx> { self.infcx.tcx } diff --git a/src/librustc/middle/traits/util.rs b/src/librustc/middle/traits/util.rs index c50c9e9765d..08d504143c7 100644 --- a/src/librustc/middle/traits/util.rs +++ b/src/librustc/middle/traits/util.rs @@ -11,7 +11,7 @@ use middle::def_id::DefId; use middle::infer::InferCtxt; use middle::subst::Substs; -use middle::ty::{self, Ty, ToPredicate, ToPolyTraitRef}; +use middle::ty::{self, Ty, TyCtxt, ToPredicate, ToPolyTraitRef}; use syntax::codemap::Span; use util::common::ErrorReported; use util::nodemap::FnvHashSet; @@ -19,12 +19,12 @@ use util::nodemap::FnvHashSet; use super::{Obligation, ObligationCause, PredicateObligation}; struct PredicateSet<'a,'tcx:'a> { - tcx: &'a ty::ctxt<'tcx>, + tcx: &'a TyCtxt<'tcx>, set: FnvHashSet<ty::Predicate<'tcx>>, } impl<'a,'tcx> PredicateSet<'a,'tcx> { - fn new(tcx: &'a ty::ctxt<'tcx>) -> PredicateSet<'a,'tcx> { + fn new(tcx: &'a TyCtxt<'tcx>) -> PredicateSet<'a,'tcx> { PredicateSet { tcx: tcx, set: FnvHashSet() } } @@ -77,13 +77,13 @@ impl<'a,'tcx> PredicateSet<'a,'tcx> { /// Foo : 'static`, and we know that `T : Foo`, then we know that `T : /// 'static`. pub struct Elaborator<'cx, 'tcx:'cx> { - tcx: &'cx ty::ctxt<'tcx>, + tcx: &'cx TyCtxt<'tcx>, stack: Vec<ty::Predicate<'tcx>>, visited: PredicateSet<'cx,'tcx>, } pub fn elaborate_trait_ref<'cx, 'tcx>( - tcx: &'cx ty::ctxt<'tcx>, + tcx: &'cx TyCtxt<'tcx>, trait_ref: ty::PolyTraitRef<'tcx>) -> Elaborator<'cx, 'tcx> { @@ -91,7 +91,7 @@ pub fn elaborate_trait_ref<'cx, 'tcx>( } pub fn elaborate_trait_refs<'cx, 'tcx>( - tcx: &'cx ty::ctxt<'tcx>, + tcx: &'cx TyCtxt<'tcx>, trait_refs: &[ty::PolyTraitRef<'tcx>]) -> Elaborator<'cx, 'tcx> { @@ -102,7 +102,7 @@ pub fn elaborate_trait_refs<'cx, 'tcx>( } pub fn elaborate_predicates<'cx, 'tcx>( - tcx: &'cx ty::ctxt<'tcx>, + tcx: &'cx TyCtxt<'tcx>, mut predicates: Vec<ty::Predicate<'tcx>>) -> Elaborator<'cx, 'tcx> { @@ -205,14 +205,14 @@ impl<'cx, 'tcx> Iterator for Elaborator<'cx, 'tcx> { pub type Supertraits<'cx, 'tcx> = FilterToTraits<Elaborator<'cx, 'tcx>>; -pub fn supertraits<'cx, 'tcx>(tcx: &'cx ty::ctxt<'tcx>, +pub fn supertraits<'cx, 'tcx>(tcx: &'cx TyCtxt<'tcx>, trait_ref: ty::PolyTraitRef<'tcx>) -> Supertraits<'cx, 'tcx> { elaborate_trait_ref(tcx, trait_ref).filter_to_traits() } -pub fn transitive_bounds<'cx, 'tcx>(tcx: &'cx ty::ctxt<'tcx>, +pub fn transitive_bounds<'cx, 'tcx>(tcx: &'cx TyCtxt<'tcx>, bounds: &[ty::PolyTraitRef<'tcx>]) -> Supertraits<'cx, 'tcx> { @@ -223,12 +223,12 @@ pub fn transitive_bounds<'cx, 'tcx>(tcx: &'cx ty::ctxt<'tcx>, // Iterator over def-ids of supertraits pub struct SupertraitDefIds<'cx, 'tcx:'cx> { - tcx: &'cx ty::ctxt<'tcx>, + tcx: &'cx TyCtxt<'tcx>, stack: Vec<DefId>, visited: FnvHashSet<DefId>, } -pub fn supertrait_def_ids<'cx, 'tcx>(tcx: &'cx ty::ctxt<'tcx>, +pub fn supertrait_def_ids<'cx, 'tcx>(tcx: &'cx TyCtxt<'tcx>, trait_def_id: DefId) -> SupertraitDefIds<'cx, 'tcx> { @@ -330,7 +330,7 @@ pub fn predicates_for_generics<'tcx>(cause: ObligationCause<'tcx>, } pub fn trait_ref_for_builtin_bound<'tcx>( - tcx: &ty::ctxt<'tcx>, + tcx: &TyCtxt<'tcx>, builtin_bound: ty::BuiltinBound, param_ty: Ty<'tcx>) -> Result<ty::TraitRef<'tcx>, ErrorReported> @@ -364,7 +364,7 @@ pub fn predicate_for_trait_ref<'tcx>( } pub fn predicate_for_trait_def<'tcx>( - tcx: &ty::ctxt<'tcx>, + tcx: &TyCtxt<'tcx>, cause: ObligationCause<'tcx>, trait_def_id: DefId, recursion_depth: usize, @@ -380,7 +380,7 @@ pub fn predicate_for_trait_def<'tcx>( } pub fn predicate_for_builtin_bound<'tcx>( - tcx: &ty::ctxt<'tcx>, + tcx: &TyCtxt<'tcx>, cause: ObligationCause<'tcx>, builtin_bound: ty::BuiltinBound, recursion_depth: usize, @@ -394,7 +394,7 @@ pub fn predicate_for_builtin_bound<'tcx>( /// Cast a trait reference into a reference to one of its super /// traits; returns `None` if `target_trait_def_id` is not a /// supertrait. -pub fn upcast<'tcx>(tcx: &ty::ctxt<'tcx>, +pub fn upcast<'tcx>(tcx: &TyCtxt<'tcx>, source_trait_ref: ty::PolyTraitRef<'tcx>, target_trait_def_id: DefId) -> Vec<ty::PolyTraitRef<'tcx>> @@ -411,7 +411,7 @@ pub fn upcast<'tcx>(tcx: &ty::ctxt<'tcx>, /// Given a trait `trait_ref`, returns the number of vtable entries /// that come from `trait_ref`, excluding its supertraits. Used in /// computing the vtable base for an upcast trait of a trait object. -pub fn count_own_vtable_entries<'tcx>(tcx: &ty::ctxt<'tcx>, +pub fn count_own_vtable_entries<'tcx>(tcx: &TyCtxt<'tcx>, trait_ref: ty::PolyTraitRef<'tcx>) -> usize { let mut entries = 0; @@ -428,7 +428,7 @@ pub fn count_own_vtable_entries<'tcx>(tcx: &ty::ctxt<'tcx>, /// Given an upcast trait object described by `object`, returns the /// index of the method `method_def_id` (which should be part of /// `object.upcast_trait_ref`) within the vtable for `object`. -pub fn get_vtable_index_of_object_method<'tcx>(tcx: &ty::ctxt<'tcx>, +pub fn get_vtable_index_of_object_method<'tcx>(tcx: &TyCtxt<'tcx>, object: &super::VtableObjectData<'tcx>, method_def_id: DefId) -> usize { // Count number of methods preceding the one we are selecting and @@ -457,7 +457,7 @@ pub fn get_vtable_index_of_object_method<'tcx>(tcx: &ty::ctxt<'tcx>, pub enum TupleArgumentsFlag { Yes, No } pub fn closure_trait_ref_and_return_type<'tcx>( - tcx: &ty::ctxt<'tcx>, + tcx: &TyCtxt<'tcx>, fn_trait_def_id: DefId, self_ty: Ty<'tcx>, sig: &ty::PolyFnSig<'tcx>, diff --git a/src/librustc/middle/ty/_match.rs b/src/librustc/middle/ty/_match.rs index 5a3ad9095ad..41612a68a91 100644 --- a/src/librustc/middle/ty/_match.rs +++ b/src/librustc/middle/ty/_match.rs @@ -8,7 +8,7 @@ // option. This file may not be copied, modified, or distributed // except according to those terms. -use middle::ty::{self, Ty}; +use middle::ty::{self, Ty, TyCtxt}; use middle::ty::error::TypeError; use middle::ty::relate::{self, Relate, TypeRelation, RelateResult}; @@ -29,18 +29,18 @@ use middle::ty::relate::{self, Relate, TypeRelation, RelateResult}; /// important thing about the result is Ok/Err. Also, matching never /// affects any type variables or unification state. pub struct Match<'a, 'tcx: 'a> { - tcx: &'a ty::ctxt<'tcx> + tcx: &'a TyCtxt<'tcx> } impl<'a, 'tcx> Match<'a, 'tcx> { - pub fn new(tcx: &'a ty::ctxt<'tcx>) -> Match<'a, 'tcx> { + pub fn new(tcx: &'a TyCtxt<'tcx>) -> Match<'a, 'tcx> { Match { tcx: tcx } } } impl<'a, 'tcx> TypeRelation<'a, 'tcx> for Match<'a, 'tcx> { fn tag(&self) -> &'static str { "Match" } - fn tcx(&self) -> &'a ty::ctxt<'tcx> { self.tcx } + fn tcx(&self) -> &'a TyCtxt<'tcx> { self.tcx } fn a_is_expected(&self) -> bool { true } // irrelevant fn relate_with_variance<T:Relate<'a,'tcx>>(&mut self, diff --git a/src/librustc/middle/ty/adjustment.rs b/src/librustc/middle/ty/adjustment.rs index afe177fbdcd..40581cfa1c5 100644 --- a/src/librustc/middle/ty/adjustment.rs +++ b/src/librustc/middle/ty/adjustment.rs @@ -11,7 +11,7 @@ pub use self::AutoAdjustment::*; pub use self::AutoRef::*; -use middle::ty::{self, Ty, TypeAndMut, TypeFoldable}; +use middle::ty::{self, Ty, TyCtxt, TypeAndMut, TypeFoldable}; use middle::ty::LvaluePreference::{NoPreference}; use syntax::ast; @@ -138,7 +138,7 @@ pub enum CustomCoerceUnsized { impl<'tcx> ty::TyS<'tcx> { /// See `expr_ty_adjusted` - pub fn adjust<F>(&'tcx self, cx: &ty::ctxt<'tcx>, + pub fn adjust<F>(&'tcx self, cx: &TyCtxt<'tcx>, span: Span, expr_id: ast::NodeId, adjustment: Option<&AutoAdjustment<'tcx>>, @@ -220,7 +220,7 @@ impl<'tcx> ty::TyS<'tcx> { } pub fn adjust_for_autoderef<F>(&'tcx self, - cx: &ty::ctxt<'tcx>, + cx: &TyCtxt<'tcx>, expr_id: ast::NodeId, expr_span: Span, autoderef: u32, // how many autoderefs so far? @@ -249,7 +249,7 @@ impl<'tcx> ty::TyS<'tcx> { } } - pub fn adjust_for_autoref(&'tcx self, cx: &ty::ctxt<'tcx>, + pub fn adjust_for_autoref(&'tcx self, cx: &TyCtxt<'tcx>, autoref: Option<AutoRef<'tcx>>) -> Ty<'tcx> { match autoref { diff --git a/src/librustc/middle/ty/contents.rs b/src/librustc/middle/ty/contents.rs index 3a42e8e9bfa..8dfa0262f2b 100644 --- a/src/librustc/middle/ty/contents.rs +++ b/src/librustc/middle/ty/contents.rs @@ -9,7 +9,7 @@ // except according to those terms. use middle::def_id::{DefId}; -use middle::ty::{self, Ty}; +use middle::ty::{self, Ty, TyCtxt}; use util::common::MemoizationMap; use util::nodemap::FnvHashMap; @@ -89,7 +89,7 @@ impl TypeContents { self.intersects(TC::InteriorUnsafe) } - pub fn needs_drop(&self, _: &ty::ctxt) -> bool { + pub fn needs_drop(&self, _: &TyCtxt) -> bool { self.intersects(TC::NeedsDrop) } @@ -140,10 +140,10 @@ impl fmt::Debug for TypeContents { } impl<'tcx> ty::TyS<'tcx> { - pub fn type_contents(&'tcx self, cx: &ty::ctxt<'tcx>) -> TypeContents { + pub fn type_contents(&'tcx self, cx: &TyCtxt<'tcx>) -> TypeContents { return cx.tc_cache.memoize(self, || tc_ty(cx, self, &mut FnvHashMap())); - fn tc_ty<'tcx>(cx: &ty::ctxt<'tcx>, + fn tc_ty<'tcx>(cx: &TyCtxt<'tcx>, ty: Ty<'tcx>, cache: &mut FnvHashMap<Ty<'tcx>, TypeContents>) -> TypeContents { @@ -255,7 +255,7 @@ impl<'tcx> ty::TyS<'tcx> { result } - fn apply_lang_items(cx: &ty::ctxt, did: DefId, tc: TypeContents) + fn apply_lang_items(cx: &TyCtxt, did: DefId, tc: TypeContents) -> TypeContents { if Some(did) == cx.lang_items.unsafe_cell_type() { tc | TC::InteriorUnsafe diff --git a/src/librustc/middle/ty/context.rs b/src/librustc/middle/ty/context.rs index a014c63f0a2..ffc52af19bb 100644 --- a/src/librustc/middle/ty/context.rs +++ b/src/librustc/middle/ty/context.rs @@ -10,9 +10,6 @@ //! type context book-keeping -// FIXME: (@jroesch) @eddyb should remove this when he renames ctxt -#![allow(non_camel_case_types)] - use dep_graph::{DepGraph, DepTrackingMap}; use front::map as ast_map; use session::Session; @@ -155,7 +152,7 @@ impl<'tcx> Tables<'tcx> { } pub fn closure_kind(this: &RefCell<Self>, - tcx: &ty::ctxt<'tcx>, + tcx: &TyCtxt<'tcx>, def_id: DefId) -> ty::ClosureKind { // If this is a local def-id, it should be inserted into the @@ -171,7 +168,7 @@ impl<'tcx> Tables<'tcx> { } pub fn closure_type(this: &RefCell<Self>, - tcx: &ty::ctxt<'tcx>, + tcx: &TyCtxt<'tcx>, def_id: DefId, substs: &ClosureSubsts<'tcx>) -> ty::ClosureTy<'tcx> @@ -194,7 +191,7 @@ impl<'tcx> CommonTypes<'tcx> { interner: &RefCell<FnvHashMap<InternedTy<'tcx>, Ty<'tcx>>>) -> CommonTypes<'tcx> { - let mk = |sty| ctxt::intern_ty(arena, interner, sty); + let mk = |sty| TyCtxt::intern_ty(arena, interner, sty); CommonTypes { bool: mk(TyBool), char: mk(TyChar), @@ -218,7 +215,7 @@ impl<'tcx> CommonTypes<'tcx> { /// The data structure to keep track of all the information that typechecker /// generates so that so that it can be reused and doesn't have to be redone /// later on. -pub struct ctxt<'tcx> { +pub struct TyCtxt<'tcx> { /// The arenas that types etc are allocated from. arenas: &'tcx CtxtArenas<'tcx>, @@ -417,7 +414,7 @@ pub struct ctxt<'tcx> { pub fragment_infos: RefCell<DefIdMap<Vec<ty::FragmentInfo>>>, } -impl<'tcx> ctxt<'tcx> { +impl<'tcx> TyCtxt<'tcx> { pub fn type_parameter_def(&self, node_id: NodeId) -> ty::TypeParameterDef<'tcx> @@ -498,7 +495,7 @@ impl<'tcx> ctxt<'tcx> { value.lift_to_tcx(self) } - /// Create a type context and call the closure with a `&ty::ctxt` reference + /// Create a type context and call the closure with a `&TyCtxt` reference /// to the context. The closure enforces that the type context and any interned /// value (types, substs, etc.) can only be used while `ty::tls` has a valid /// reference to the context, to allow formatting values that need it. @@ -512,13 +509,13 @@ impl<'tcx> ctxt<'tcx> { lang_items: middle::lang_items::LanguageItems, stability: stability::Index<'tcx>, f: F) -> R - where F: FnOnce(&ctxt<'tcx>) -> R + where F: FnOnce(&TyCtxt<'tcx>) -> R { let interner = RefCell::new(FnvHashMap()); let common_types = CommonTypes::new(&arenas.type_, &interner); let dep_graph = map.dep_graph.clone(); let fulfilled_predicates = traits::GlobalFulfilledPredicates::new(dep_graph.clone()); - tls::enter(ctxt { + tls::enter(TyCtxt { arenas: arenas, interner: interner, substs_interner: RefCell::new(FnvHashMap()), @@ -577,7 +574,7 @@ impl<'tcx> ctxt<'tcx> { /// A trait implemented for all X<'a> types which can be safely and /// efficiently converted to X<'tcx> as long as they are part of the -/// provided ty::ctxt<'tcx>. +/// provided TyCtxt<'tcx>. /// This can be done, for example, for Ty<'tcx> or &'tcx Substs<'tcx> /// by looking them up in their respective interners. /// None is returned if the value or one of the components is not part @@ -588,12 +585,12 @@ impl<'tcx> ctxt<'tcx> { /// e.g. `()` or `u8`, was interned in a different context. pub trait Lift<'tcx> { type Lifted; - fn lift_to_tcx(&self, tcx: &ctxt<'tcx>) -> Option<Self::Lifted>; + fn lift_to_tcx(&self, tcx: &TyCtxt<'tcx>) -> Option<Self::Lifted>; } impl<'a, 'tcx> Lift<'tcx> for Ty<'a> { type Lifted = Ty<'tcx>; - fn lift_to_tcx(&self, tcx: &ctxt<'tcx>) -> Option<Ty<'tcx>> { + fn lift_to_tcx(&self, tcx: &TyCtxt<'tcx>) -> Option<Ty<'tcx>> { if let Some(&ty) = tcx.interner.borrow().get(&self.sty) { if *self as *const _ == ty as *const _ { return Some(ty); @@ -605,7 +602,7 @@ impl<'a, 'tcx> Lift<'tcx> for Ty<'a> { impl<'a, 'tcx> Lift<'tcx> for &'a Substs<'a> { type Lifted = &'tcx Substs<'tcx>; - fn lift_to_tcx(&self, tcx: &ctxt<'tcx>) -> Option<&'tcx Substs<'tcx>> { + fn lift_to_tcx(&self, tcx: &TyCtxt<'tcx>) -> Option<&'tcx Substs<'tcx>> { if let Some(&substs) = tcx.substs_interner.borrow().get(*self) { if *self as *const _ == substs as *const _ { return Some(substs); @@ -617,7 +614,7 @@ impl<'a, 'tcx> Lift<'tcx> for &'a Substs<'a> { pub mod tls { - use middle::ty; + use middle::ty::TyCtxt; use std::cell::Cell; use std::fmt; @@ -638,7 +635,7 @@ pub mod tls { }) } - pub fn enter<'tcx, F: FnOnce(&ty::ctxt<'tcx>) -> R, R>(tcx: ty::ctxt<'tcx>, f: F) -> R { + pub fn enter<'tcx, F: FnOnce(&TyCtxt<'tcx>) -> R, R>(tcx: TyCtxt<'tcx>, f: F) -> R { codemap::SPAN_DEBUG.with(|span_dbg| { let original_span_debug = span_dbg.get(); span_dbg.set(span_debug); @@ -655,14 +652,14 @@ pub mod tls { }) } - pub fn with<F: FnOnce(&ty::ctxt) -> R, R>(f: F) -> R { + pub fn with<F: FnOnce(&TyCtxt) -> R, R>(f: F) -> R { TLS_TCX.with(|tcx| { let tcx = tcx.get().unwrap(); - f(unsafe { &*(tcx as *const ty::ctxt) }) + f(unsafe { &*(tcx as *const TyCtxt) }) }) } - pub fn with_opt<F: FnOnce(Option<&ty::ctxt>) -> R, R>(f: F) -> R { + pub fn with_opt<F: FnOnce(Option<&TyCtxt>) -> R, R>(f: F) -> R { if TLS_TCX.with(|tcx| tcx.get().is_some()) { with(|v| f(Some(v))) } else { @@ -677,7 +674,7 @@ macro_rules! sty_debug_print { // variable names. #[allow(non_snake_case)] mod inner { - use middle::ty; + use middle::ty::{self, TyCtxt}; #[derive(Copy, Clone)] struct DebugStat { total: usize, @@ -686,7 +683,7 @@ macro_rules! sty_debug_print { both_infer: usize, } - pub fn go(tcx: &ty::ctxt) { + pub fn go(tcx: &TyCtxt) { let mut total = DebugStat { total: 0, region_infer: 0, ty_infer: 0, both_infer: 0, @@ -733,7 +730,7 @@ macro_rules! sty_debug_print { }} } -impl<'tcx> ctxt<'tcx> { +impl<'tcx> TyCtxt<'tcx> { pub fn print_debug_stats(&self) { sty_debug_print!( self, @@ -780,7 +777,7 @@ fn bound_list_is_sorted(bounds: &[ty::PolyProjectionPredicate]) -> bool { |(index, bound)| bounds[index].sort_key() <= bound.sort_key()) } -impl<'tcx> ctxt<'tcx> { +impl<'tcx> TyCtxt<'tcx> { // Type constructors pub fn mk_substs(&self, substs: Substs<'tcx>) -> &'tcx Substs<'tcx> { if let Some(substs) = self.substs_interner.borrow().get(&substs) { @@ -854,7 +851,7 @@ impl<'tcx> ctxt<'tcx> { // Interns a type/name combination, stores the resulting box in cx.interner, // and returns the box as cast to an unsafe ptr (see comments for Ty above). pub fn mk_ty(&self, st: TypeVariants<'tcx>) -> Ty<'tcx> { - ctxt::intern_ty(&self.arenas.type_, &self.interner, st) + TyCtxt::intern_ty(&self.arenas.type_, &self.interner, st) } pub fn mk_mach_int(&self, tm: ast::IntTy) -> Ty<'tcx> { diff --git a/src/librustc/middle/ty/error.rs b/src/librustc/middle/ty/error.rs index ab48fd7fb86..39a5069e129 100644 --- a/src/librustc/middle/ty/error.rs +++ b/src/librustc/middle/ty/error.rs @@ -11,7 +11,7 @@ use middle::def_id::DefId; use middle::subst; use middle::infer::type_variable; -use middle::ty::{self, BoundRegion, Region, Ty}; +use middle::ty::{self, BoundRegion, Region, Ty, TyCtxt}; use std::fmt; use syntax::abi; @@ -211,7 +211,7 @@ impl<'tcx> fmt::Display for TypeError<'tcx> { } impl<'tcx> ty::TyS<'tcx> { - fn sort_string(&self, cx: &ty::ctxt) -> String { + fn sort_string(&self, cx: &TyCtxt) -> String { match self.sty { ty::TyBool | ty::TyChar | ty::TyInt(_) | ty::TyUint(_) | ty::TyFloat(_) | ty::TyStr => self.to_string(), @@ -252,7 +252,7 @@ impl<'tcx> ty::TyS<'tcx> { } } -impl<'tcx> ty::ctxt<'tcx> { +impl<'tcx> TyCtxt<'tcx> { pub fn note_and_explain_type_err(&self, db: &mut DiagnosticBuilder, err: &TypeError<'tcx>, diff --git a/src/librustc/middle/ty/fast_reject.rs b/src/librustc/middle/ty/fast_reject.rs index a06e8a72c44..a42e5fc2e85 100644 --- a/src/librustc/middle/ty/fast_reject.rs +++ b/src/librustc/middle/ty/fast_reject.rs @@ -9,7 +9,7 @@ // except according to those terms. use middle::def_id::DefId; -use middle::ty::{self, Ty}; +use middle::ty::{self, Ty, TyCtxt}; use syntax::ast; use self::SimplifiedType::*; @@ -43,7 +43,7 @@ pub enum SimplifiedType { /// then we can't say much about whether two types would unify. Put another way, /// `can_simplify_params` should be true if type parameters appear free in `ty` and `false` if they /// are to be considered bound. -pub fn simplify_type(tcx: &ty::ctxt, +pub fn simplify_type(tcx: &TyCtxt, ty: Ty, can_simplify_params: bool) -> Option<SimplifiedType> diff --git a/src/librustc/middle/ty/fold.rs b/src/librustc/middle/ty/fold.rs index da0245a8d25..162ea3a7714 100644 --- a/src/librustc/middle/ty/fold.rs +++ b/src/librustc/middle/ty/fold.rs @@ -42,7 +42,7 @@ use middle::region; use middle::subst; use middle::ty::adjustment; -use middle::ty::{self, Binder, Ty, TypeFlags}; +use middle::ty::{self, Binder, Ty, TyCtxt, TypeFlags}; use std::fmt; use util::nodemap::{FnvHashMap, FnvHashSet}; @@ -114,7 +114,7 @@ pub trait TypeFoldable<'tcx>: fmt::Debug + Clone { /// identity fold, it should invoke `foo.fold_with(self)` to fold each /// sub-item. pub trait TypeFolder<'tcx> : Sized { - fn tcx<'a>(&'a self) -> &'a ty::ctxt<'tcx>; + fn tcx<'a>(&'a self) -> &'a TyCtxt<'tcx>; /// Invoked by the `super_*` routines when we enter a region /// binding level (for example, when entering a function @@ -209,14 +209,14 @@ pub trait TypeVisitor<'tcx> : Sized { // Some sample folders pub struct BottomUpFolder<'a, 'tcx: 'a, F> where F: FnMut(Ty<'tcx>) -> Ty<'tcx> { - pub tcx: &'a ty::ctxt<'tcx>, + pub tcx: &'a TyCtxt<'tcx>, pub fldop: F, } impl<'a, 'tcx, F> TypeFolder<'tcx> for BottomUpFolder<'a, 'tcx, F> where F: FnMut(Ty<'tcx>) -> Ty<'tcx>, { - fn tcx(&self) -> &ty::ctxt<'tcx> { self.tcx } + fn tcx(&self) -> &TyCtxt<'tcx> { self.tcx } fn fold_ty(&mut self, ty: Ty<'tcx>) -> Ty<'tcx> { let t1 = ty.super_fold_with(self); @@ -227,7 +227,7 @@ impl<'a, 'tcx, F> TypeFolder<'tcx> for BottomUpFolder<'a, 'tcx, F> where /////////////////////////////////////////////////////////////////////////// // Region folder -impl<'tcx> ty::ctxt<'tcx> { +impl<'tcx> TyCtxt<'tcx> { /// Collects the free and escaping regions in `value` into `region_set`. Returns /// whether any late-bound regions were skipped pub fn collect_regions<T>(&self, @@ -267,14 +267,14 @@ impl<'tcx> ty::ctxt<'tcx> { /// visited by `fld_r`. pub struct RegionFolder<'a, 'tcx: 'a> { - tcx: &'a ty::ctxt<'tcx>, + tcx: &'a TyCtxt<'tcx>, skipped_regions: &'a mut bool, current_depth: u32, fld_r: &'a mut (FnMut(ty::Region, u32) -> ty::Region + 'a), } impl<'a, 'tcx> RegionFolder<'a, 'tcx> { - pub fn new<F>(tcx: &'a ty::ctxt<'tcx>, + pub fn new<F>(tcx: &'a TyCtxt<'tcx>, skipped_regions: &'a mut bool, fld_r: &'a mut F) -> RegionFolder<'a, 'tcx> where F : FnMut(ty::Region, u32) -> ty::Region @@ -290,7 +290,7 @@ impl<'a, 'tcx> RegionFolder<'a, 'tcx> { impl<'a, 'tcx> TypeFolder<'tcx> for RegionFolder<'a, 'tcx> { - fn tcx(&self) -> &ty::ctxt<'tcx> { self.tcx } + fn tcx(&self) -> &TyCtxt<'tcx> { self.tcx } fn enter_region_binder(&mut self) { self.current_depth += 1; @@ -323,13 +323,13 @@ impl<'a, 'tcx> TypeFolder<'tcx> for RegionFolder<'a, 'tcx> // Replaces the escaping regions in a type. struct RegionReplacer<'a, 'tcx: 'a> { - tcx: &'a ty::ctxt<'tcx>, + tcx: &'a TyCtxt<'tcx>, current_depth: u32, fld_r: &'a mut (FnMut(ty::BoundRegion) -> ty::Region + 'a), map: FnvHashMap<ty::BoundRegion, ty::Region> } -impl<'tcx> ty::ctxt<'tcx> { +impl<'tcx> TyCtxt<'tcx> { pub fn replace_late_bound_regions<T,F>(&self, value: &Binder<T>, mut f: F) @@ -418,7 +418,7 @@ impl<'tcx> ty::ctxt<'tcx> { } impl<'a, 'tcx> RegionReplacer<'a, 'tcx> { - fn new<F>(tcx: &'a ty::ctxt<'tcx>, fld_r: &'a mut F) -> RegionReplacer<'a, 'tcx> + fn new<F>(tcx: &'a TyCtxt<'tcx>, fld_r: &'a mut F) -> RegionReplacer<'a, 'tcx> where F : FnMut(ty::BoundRegion) -> ty::Region { RegionReplacer { @@ -432,7 +432,7 @@ impl<'a, 'tcx> RegionReplacer<'a, 'tcx> { impl<'a, 'tcx> TypeFolder<'tcx> for RegionReplacer<'a, 'tcx> { - fn tcx(&self) -> &ty::ctxt<'tcx> { self.tcx } + fn tcx(&self) -> &TyCtxt<'tcx> { self.tcx } fn enter_region_binder(&mut self) { self.current_depth += 1; @@ -475,7 +475,7 @@ impl<'a, 'tcx> TypeFolder<'tcx> for RegionReplacer<'a, 'tcx> /////////////////////////////////////////////////////////////////////////// // Region eraser -impl<'tcx> ty::ctxt<'tcx> { +impl<'tcx> TyCtxt<'tcx> { /// Returns an equivalent value with all free regions removed (note /// that late-bound regions remain, because they are important for /// subtyping, but they are anonymized and normalized as well).. @@ -487,10 +487,10 @@ impl<'tcx> ty::ctxt<'tcx> { value, value1); return value1; - struct RegionEraser<'a, 'tcx: 'a>(&'a ty::ctxt<'tcx>); + struct RegionEraser<'a, 'tcx: 'a>(&'a TyCtxt<'tcx>); impl<'a, 'tcx> TypeFolder<'tcx> for RegionEraser<'a, 'tcx> { - fn tcx(&self) -> &ty::ctxt<'tcx> { self.0 } + fn tcx(&self) -> &TyCtxt<'tcx> { self.0 } fn fold_ty(&mut self, ty: Ty<'tcx>) -> Ty<'tcx> { match self.tcx().normalized_cache.borrow().get(&ty).cloned() { @@ -555,7 +555,7 @@ pub fn shift_region(region: ty::Region, amount: u32) -> ty::Region { } } -pub fn shift_regions<'tcx, T:TypeFoldable<'tcx>>(tcx: &ty::ctxt<'tcx>, +pub fn shift_regions<'tcx, T:TypeFoldable<'tcx>>(tcx: &TyCtxt<'tcx>, amount: u32, value: &T) -> T { debug!("shift_regions(value={:?}, amount={})", value, amount); diff --git a/src/librustc/middle/ty/mod.rs b/src/librustc/middle/ty/mod.rs index 105e0bb7b15..85035b25001 100644 --- a/src/librustc/middle/ty/mod.rs +++ b/src/librustc/middle/ty/mod.rs @@ -75,7 +75,7 @@ pub use self::sty::BuiltinBound::Copy as BoundCopy; pub use self::sty::BuiltinBound::Sync as BoundSync; pub use self::contents::TypeContents; -pub use self::context::{ctxt, tls}; +pub use self::context::{TyCtxt, tls}; pub use self::context::{CtxtArenas, Lift, Tables}; pub use self::trait_def::{TraitDef, TraitFlags}; @@ -699,7 +699,7 @@ impl<'tcx> GenericPredicates<'tcx> { } } - pub fn instantiate(&self, tcx: &ctxt<'tcx>, substs: &Substs<'tcx>) + pub fn instantiate(&self, tcx: &TyCtxt<'tcx>, substs: &Substs<'tcx>) -> InstantiatedPredicates<'tcx> { InstantiatedPredicates { predicates: self.predicates.subst(tcx, substs), @@ -707,7 +707,7 @@ impl<'tcx> GenericPredicates<'tcx> { } pub fn instantiate_supertrait(&self, - tcx: &ctxt<'tcx>, + tcx: &TyCtxt<'tcx>, poly_trait_ref: &ty::PolyTraitRef<'tcx>) -> InstantiatedPredicates<'tcx> { @@ -751,7 +751,7 @@ impl<'tcx> Predicate<'tcx> { /// substitution in terms of what happens with bound regions. See /// lengthy comment below for details. pub fn subst_supertrait(&self, - tcx: &ctxt<'tcx>, + tcx: &TyCtxt<'tcx>, trait_ref: &ty::PolyTraitRef<'tcx>) -> ty::Predicate<'tcx> { @@ -1111,7 +1111,7 @@ impl<'tcx> TraitRef<'tcx> { /// more distinctions clearer. #[derive(Clone)] pub struct ParameterEnvironment<'a, 'tcx:'a> { - pub tcx: &'a ctxt<'tcx>, + pub tcx: &'a TyCtxt<'tcx>, /// See `construct_free_substs` for details. pub free_substs: Substs<'tcx>, @@ -1160,7 +1160,7 @@ impl<'a, 'tcx> ParameterEnvironment<'a, 'tcx> { } } - pub fn for_item(cx: &'a ctxt<'tcx>, id: NodeId) -> ParameterEnvironment<'a, 'tcx> { + pub fn for_item(cx: &'a TyCtxt<'tcx>, id: NodeId) -> ParameterEnvironment<'a, 'tcx> { match cx.map.find(id) { Some(ast_map::NodeImplItem(ref impl_item)) => { match impl_item.node { @@ -1460,7 +1460,7 @@ impl VariantKind { } impl<'tcx, 'container> AdtDefData<'tcx, 'container> { - fn new(tcx: &ctxt<'tcx>, + fn new(tcx: &TyCtxt<'tcx>, did: DefId, kind: AdtKind, variants: Vec<VariantDefData<'tcx, 'container>>) -> Self { @@ -1489,7 +1489,7 @@ impl<'tcx, 'container> AdtDefData<'tcx, 'container> { } } - fn calculate_dtorck(&'tcx self, tcx: &ctxt<'tcx>) { + fn calculate_dtorck(&'tcx self, tcx: &TyCtxt<'tcx>) { if tcx.is_adt_dtorck(self) { self.flags.set(self.flags.get() | AdtFlags::IS_DTORCK); } @@ -1510,7 +1510,7 @@ impl<'tcx, 'container> AdtDefData<'tcx, 'container> { /// true, this type being safe for destruction requires it to be /// alive; Otherwise, only the contents are required to be. #[inline] - pub fn is_dtorck(&'tcx self, tcx: &ctxt<'tcx>) -> bool { + pub fn is_dtorck(&'tcx self, tcx: &TyCtxt<'tcx>) -> bool { if !self.flags.get().intersects(AdtFlags::IS_DTORCK_VALID) { self.calculate_dtorck(tcx) } @@ -1551,12 +1551,12 @@ impl<'tcx, 'container> AdtDefData<'tcx, 'container> { } #[inline] - pub fn type_scheme(&self, tcx: &ctxt<'tcx>) -> TypeScheme<'tcx> { + pub fn type_scheme(&self, tcx: &TyCtxt<'tcx>) -> TypeScheme<'tcx> { tcx.lookup_item_type(self.did) } #[inline] - pub fn predicates(&self, tcx: &ctxt<'tcx>) -> GenericPredicates<'tcx> { + pub fn predicates(&self, tcx: &TyCtxt<'tcx>) -> GenericPredicates<'tcx> { tcx.lookup_predicates(self.did) } @@ -1674,7 +1674,7 @@ impl<'tcx, 'container> FieldDefData<'tcx, 'container> { } } - pub fn ty(&self, tcx: &ctxt<'tcx>, subst: &Substs<'tcx>) -> Ty<'tcx> { + pub fn ty(&self, tcx: &TyCtxt<'tcx>, subst: &Substs<'tcx>) -> Ty<'tcx> { self.unsubst_ty().subst(tcx, subst) } @@ -1705,7 +1705,7 @@ pub enum ClosureKind { } impl ClosureKind { - pub fn trait_did(&self, cx: &ctxt) -> DefId { + pub fn trait_did(&self, cx: &TyCtxt) -> DefId { let result = match *self { FnClosureKind => cx.lang_items.require(FnTraitLangItem), FnMutClosureKind => { @@ -1855,7 +1855,7 @@ impl BorrowKind { } } -impl<'tcx> ctxt<'tcx> { +impl<'tcx> TyCtxt<'tcx> { pub fn node_id_to_type(&self, id: NodeId) -> Ty<'tcx> { match self.node_id_to_type_opt(id) { Some(ty) => ty, @@ -2666,7 +2666,7 @@ pub type TraitMap = NodeMap<Vec<DefId>>; // imported. pub type GlobMap = HashMap<NodeId, HashSet<Name>>; -impl<'tcx> ctxt<'tcx> { +impl<'tcx> TyCtxt<'tcx> { pub fn with_freevars<T, F>(&self, fid: NodeId, f: F) -> T where F: FnOnce(&[Freevar]) -> T, { diff --git a/src/librustc/middle/ty/relate.rs b/src/librustc/middle/ty/relate.rs index 974b5c4bc6c..5d6106a6d77 100644 --- a/src/librustc/middle/ty/relate.rs +++ b/src/librustc/middle/ty/relate.rs @@ -15,7 +15,7 @@ use middle::def_id::DefId; use middle::subst::{ErasedRegions, NonerasedRegions, ParamSpace, Substs}; -use middle::ty::{self, Ty, TypeFoldable}; +use middle::ty::{self, Ty, TyCtxt, TypeFoldable}; use middle::ty::error::{ExpectedFound, TypeError}; use std::rc::Rc; use syntax::abi; @@ -29,7 +29,7 @@ pub enum Cause { } pub trait TypeRelation<'a,'tcx> : Sized { - fn tcx(&self) -> &'a ty::ctxt<'tcx>; + fn tcx(&self) -> &'a TyCtxt<'tcx>; /// Returns a static string we can use for printouts. fn tag(&self) -> &'static str; diff --git a/src/librustc/middle/ty/structural_impls.rs b/src/librustc/middle/ty/structural_impls.rs index 01b2bd36b4f..001ea02a27c 100644 --- a/src/librustc/middle/ty/structural_impls.rs +++ b/src/librustc/middle/ty/structural_impls.rs @@ -10,7 +10,7 @@ use middle::subst::{self, VecPerParamSpace}; use middle::traits; -use middle::ty::{self, Lift, TraitRef, Ty}; +use middle::ty::{self, Lift, TraitRef, Ty, TyCtxt}; use middle::ty::fold::{TypeFoldable, TypeFolder, TypeVisitor}; use std::rc::Rc; @@ -24,14 +24,14 @@ use rustc_front::hir; impl<'tcx, A: Lift<'tcx>, B: Lift<'tcx>> Lift<'tcx> for (A, B) { type Lifted = (A::Lifted, B::Lifted); - fn lift_to_tcx(&self, tcx: &ty::ctxt<'tcx>) -> Option<Self::Lifted> { + fn lift_to_tcx(&self, tcx: &TyCtxt<'tcx>) -> Option<Self::Lifted> { tcx.lift(&self.0).and_then(|a| tcx.lift(&self.1).map(|b| (a, b))) } } impl<'tcx, T: Lift<'tcx>> Lift<'tcx> for [T] { type Lifted = Vec<T::Lifted>; - fn lift_to_tcx(&self, tcx: &ty::ctxt<'tcx>) -> Option<Self::Lifted> { + fn lift_to_tcx(&self, tcx: &TyCtxt<'tcx>) -> Option<Self::Lifted> { // type annotation needed to inform `projection_must_outlive` let mut result : Vec<<T as Lift<'tcx>>::Lifted> = Vec::with_capacity(self.len()); @@ -48,14 +48,14 @@ impl<'tcx, T: Lift<'tcx>> Lift<'tcx> for [T] { impl<'tcx> Lift<'tcx> for ty::Region { type Lifted = Self; - fn lift_to_tcx(&self, _: &ty::ctxt<'tcx>) -> Option<ty::Region> { + fn lift_to_tcx(&self, _: &TyCtxt<'tcx>) -> Option<ty::Region> { Some(*self) } } impl<'a, 'tcx> Lift<'tcx> for TraitRef<'a> { type Lifted = TraitRef<'tcx>; - fn lift_to_tcx(&self, tcx: &ty::ctxt<'tcx>) -> Option<TraitRef<'tcx>> { + fn lift_to_tcx(&self, tcx: &TyCtxt<'tcx>) -> Option<TraitRef<'tcx>> { tcx.lift(&self.substs).map(|substs| TraitRef { def_id: self.def_id, substs: substs @@ -65,7 +65,7 @@ impl<'a, 'tcx> Lift<'tcx> for TraitRef<'a> { impl<'a, 'tcx> Lift<'tcx> for ty::TraitPredicate<'a> { type Lifted = ty::TraitPredicate<'tcx>; - fn lift_to_tcx(&self, tcx: &ty::ctxt<'tcx>) -> Option<ty::TraitPredicate<'tcx>> { + fn lift_to_tcx(&self, tcx: &TyCtxt<'tcx>) -> Option<ty::TraitPredicate<'tcx>> { tcx.lift(&self.trait_ref).map(|trait_ref| ty::TraitPredicate { trait_ref: trait_ref }) @@ -74,21 +74,21 @@ impl<'a, 'tcx> Lift<'tcx> for ty::TraitPredicate<'a> { impl<'a, 'tcx> Lift<'tcx> for ty::EquatePredicate<'a> { type Lifted = ty::EquatePredicate<'tcx>; - fn lift_to_tcx(&self, tcx: &ty::ctxt<'tcx>) -> Option<ty::EquatePredicate<'tcx>> { + fn lift_to_tcx(&self, tcx: &TyCtxt<'tcx>) -> Option<ty::EquatePredicate<'tcx>> { tcx.lift(&(self.0, self.1)).map(|(a, b)| ty::EquatePredicate(a, b)) } } impl<'tcx, A: Copy+Lift<'tcx>, B: Copy+Lift<'tcx>> Lift<'tcx> for ty::OutlivesPredicate<A, B> { type Lifted = ty::OutlivesPredicate<A::Lifted, B::Lifted>; - fn lift_to_tcx(&self, tcx: &ty::ctxt<'tcx>) -> Option<Self::Lifted> { + fn lift_to_tcx(&self, tcx: &TyCtxt<'tcx>) -> Option<Self::Lifted> { tcx.lift(&(self.0, self.1)).map(|(a, b)| ty::OutlivesPredicate(a, b)) } } impl<'a, 'tcx> Lift<'tcx> for ty::ProjectionPredicate<'a> { type Lifted = ty::ProjectionPredicate<'tcx>; - fn lift_to_tcx(&self, tcx: &ty::ctxt<'tcx>) -> Option<ty::ProjectionPredicate<'tcx>> { + fn lift_to_tcx(&self, tcx: &TyCtxt<'tcx>) -> Option<ty::ProjectionPredicate<'tcx>> { tcx.lift(&(self.projection_ty.trait_ref, self.ty)).map(|(trait_ref, ty)| { ty::ProjectionPredicate { projection_ty: ty::ProjectionTy { @@ -103,7 +103,7 @@ impl<'a, 'tcx> Lift<'tcx> for ty::ProjectionPredicate<'a> { impl<'tcx, T: Lift<'tcx>> Lift<'tcx> for ty::Binder<T> { type Lifted = ty::Binder<T::Lifted>; - fn lift_to_tcx(&self, tcx: &ty::ctxt<'tcx>) -> Option<Self::Lifted> { + fn lift_to_tcx(&self, tcx: &TyCtxt<'tcx>) -> Option<Self::Lifted> { tcx.lift(&self.0).map(|x| ty::Binder(x)) } } diff --git a/src/librustc/middle/ty/sty.rs b/src/librustc/middle/ty/sty.rs index 2a13c47895e..c8f8e073832 100644 --- a/src/librustc/middle/ty/sty.rs +++ b/src/librustc/middle/ty/sty.rs @@ -15,7 +15,7 @@ use middle::def_id::DefId; use middle::region; use middle::subst::{self, Substs}; use middle::traits; -use middle::ty::{self, AdtDef, ToPredicate, TypeFlags, Ty, TyS, TypeFoldable}; +use middle::ty::{self, AdtDef, ToPredicate, TypeFlags, Ty, TyCtxt, TyS, TypeFoldable}; use util::common::ErrorReported; use collections::enum_set::{self, EnumSet, CLike}; @@ -281,7 +281,7 @@ impl<'tcx> TraitTy<'tcx> { /// you must give *some* self-type. A common choice is `mk_err()` /// or some skolemized type. pub fn principal_trait_ref_with_self_ty(&self, - tcx: &ty::ctxt<'tcx>, + tcx: &TyCtxt<'tcx>, self_ty: Ty<'tcx>) -> ty::PolyTraitRef<'tcx> { @@ -295,7 +295,7 @@ impl<'tcx> TraitTy<'tcx> { } pub fn projection_bounds_with_self_ty(&self, - tcx: &ty::ctxt<'tcx>, + tcx: &TyCtxt<'tcx>, self_ty: Ty<'tcx>) -> Vec<ty::PolyProjectionPredicate<'tcx>> { @@ -540,7 +540,7 @@ impl ParamTy { ParamTy::new(def.space, def.index, def.name) } - pub fn to_ty<'tcx>(self, tcx: &ty::ctxt<'tcx>) -> Ty<'tcx> { + pub fn to_ty<'tcx>(self, tcx: &TyCtxt<'tcx>) -> Ty<'tcx> { tcx.mk_param(self.space, self.idx, self.name) } @@ -775,7 +775,7 @@ impl BuiltinBounds { } pub fn to_predicates<'tcx>(&self, - tcx: &ty::ctxt<'tcx>, + tcx: &TyCtxt<'tcx>, self_ty: Ty<'tcx>) -> Vec<ty::Predicate<'tcx>> { self.iter().filter_map(|builtin_bound| match traits::trait_ref_for_builtin_bound(tcx, builtin_bound, self_ty) { @@ -822,7 +822,7 @@ impl CLike for BuiltinBound { } } -impl<'tcx> ty::ctxt<'tcx> { +impl<'tcx> TyCtxt<'tcx> { pub fn try_add_builtin_trait(&self, trait_def_id: DefId, builtin_bounds: &mut EnumSet<BuiltinBound>) @@ -902,7 +902,7 @@ impl<'tcx> TyS<'tcx> { } } - pub fn is_empty(&self, _cx: &ty::ctxt) -> bool { + pub fn is_empty(&self, _cx: &TyCtxt) -> bool { // FIXME(#24885): be smarter here match self.sty { TyEnum(def, _) | TyStruct(def, _) => def.is_empty(), @@ -974,7 +974,7 @@ impl<'tcx> TyS<'tcx> { } } - pub fn sequence_element_type(&self, cx: &ty::ctxt<'tcx>) -> Ty<'tcx> { + pub fn sequence_element_type(&self, cx: &TyCtxt<'tcx>) -> Ty<'tcx> { match self.sty { TyArray(ty, _) | TySlice(ty) => ty, TyStr => cx.mk_mach_uint(ast::UintTy::U8), @@ -983,7 +983,7 @@ impl<'tcx> TyS<'tcx> { } } - pub fn simd_type(&self, cx: &ty::ctxt<'tcx>) -> Ty<'tcx> { + pub fn simd_type(&self, cx: &TyCtxt<'tcx>) -> Ty<'tcx> { match self.sty { TyStruct(def, substs) => { def.struct_variant().fields[0].ty(cx, substs) @@ -992,7 +992,7 @@ impl<'tcx> TyS<'tcx> { } } - pub fn simd_size(&self, _cx: &ty::ctxt) -> usize { + pub fn simd_size(&self, _cx: &TyCtxt) -> usize { match self.sty { TyStruct(def, _) => def.struct_variant().fields.len(), _ => panic!("simd_size called on invalid type") diff --git a/src/librustc/middle/ty/trait_def.rs b/src/librustc/middle/ty/trait_def.rs index db001ce2c44..5ecbbbcfbde 100644 --- a/src/librustc/middle/ty/trait_def.rs +++ b/src/librustc/middle/ty/trait_def.rs @@ -12,7 +12,7 @@ use dep_graph::DepNode; use middle::def_id::DefId; use middle::ty; use middle::ty::fast_reject; -use middle::ty::Ty; +use middle::ty::{Ty, TyCtxt}; use std::borrow::{Borrow}; use std::cell::{Cell, Ref, RefCell}; use syntax::ast::Name; @@ -106,17 +106,17 @@ impl<'tcx> TraitDef<'tcx> { ); } - fn write_trait_impls(&self, tcx: &ty::ctxt<'tcx>) { + fn write_trait_impls(&self, tcx: &TyCtxt<'tcx>) { tcx.dep_graph.write(DepNode::TraitImpls(self.trait_ref.def_id)); } - fn read_trait_impls(&self, tcx: &ty::ctxt<'tcx>) { + fn read_trait_impls(&self, tcx: &TyCtxt<'tcx>) { tcx.dep_graph.read(DepNode::TraitImpls(self.trait_ref.def_id)); } /// Records a trait-to-implementation mapping. pub fn record_impl(&self, - tcx: &ty::ctxt<'tcx>, + tcx: &TyCtxt<'tcx>, impl_def_id: DefId, impl_trait_ref: ty::TraitRef<'tcx>) { debug!("TraitDef::record_impl for {:?}, from {:?}", @@ -147,7 +147,7 @@ impl<'tcx> TraitDef<'tcx> { } } - pub fn for_each_impl<F: FnMut(DefId)>(&self, tcx: &ty::ctxt<'tcx>, mut f: F) { + pub fn for_each_impl<F: FnMut(DefId)>(&self, tcx: &TyCtxt<'tcx>, mut f: F) { self.read_trait_impls(tcx); tcx.populate_implementations_for_trait_if_necessary(self.trait_ref.def_id); @@ -166,7 +166,7 @@ impl<'tcx> TraitDef<'tcx> { /// Iterate over every impl that could possibly match the /// self-type `self_ty`. pub fn for_each_relevant_impl<F: FnMut(DefId)>(&self, - tcx: &ty::ctxt<'tcx>, + tcx: &TyCtxt<'tcx>, self_ty: Ty<'tcx>, mut f: F) { @@ -205,7 +205,7 @@ impl<'tcx> TraitDef<'tcx> { } } - pub fn borrow_impl_lists<'s>(&'s self, tcx: &ty::ctxt<'tcx>) + pub fn borrow_impl_lists<'s>(&'s self, tcx: &TyCtxt<'tcx>) -> (Ref<'s, Vec<DefId>>, Ref<'s, FnvHashMap<fast_reject::SimplifiedType, Vec<DefId>>>) { self.read_trait_impls(tcx); diff --git a/src/librustc/middle/ty/util.rs b/src/librustc/middle/ty/util.rs index 0b5c0d147cb..7c32d931fff 100644 --- a/src/librustc/middle/ty/util.rs +++ b/src/librustc/middle/ty/util.rs @@ -18,7 +18,7 @@ use middle::subst::{self, Subst, Substs}; use middle::infer; use middle::pat_util; use middle::traits; -use middle::ty::{self, Ty, TypeAndMut, TypeFlags, TypeFoldable}; +use middle::ty::{self, Ty, TyCtxt, TypeAndMut, TypeFlags, TypeFoldable}; use middle::ty::{Disr, ParameterEnvironment}; use middle::ty::TypeVariants::*; use util::num::ToPrimitive; @@ -33,7 +33,7 @@ use syntax::codemap::Span; use rustc_front::hir; pub trait IntTypeExt { - fn to_ty<'tcx>(&self, cx: &ty::ctxt<'tcx>) -> Ty<'tcx>; + fn to_ty<'tcx>(&self, cx: &TyCtxt<'tcx>) -> Ty<'tcx>; fn i64_to_disr(&self, val: i64) -> Option<Disr>; fn u64_to_disr(&self, val: u64) -> Option<Disr>; fn disr_incr(&self, val: Disr) -> Option<Disr>; @@ -42,7 +42,7 @@ pub trait IntTypeExt { } impl IntTypeExt for attr::IntType { - fn to_ty<'tcx>(&self, cx: &ty::ctxt<'tcx>) -> Ty<'tcx> { + fn to_ty<'tcx>(&self, cx: &TyCtxt<'tcx>) -> Ty<'tcx> { match *self { SignedInt(ast::IntTy::I8) => cx.types.i8, SignedInt(ast::IntTy::I16) => cx.types.i16, @@ -218,7 +218,7 @@ impl<'a, 'tcx> ParameterEnvironment<'a, 'tcx> { } } -impl<'tcx> ty::ctxt<'tcx> { +impl<'tcx> TyCtxt<'tcx> { pub fn pat_contains_ref_binding(&self, pat: &hir::Pat) -> Option<hir::Mutability> { pat_util::pat_contains_ref_binding(&self.def_map, pat) } @@ -430,7 +430,7 @@ impl<'tcx> ty::ctxt<'tcx> { helper(self, ty, svh, &mut state); return state.finish(); - fn helper<'tcx>(tcx: &ty::ctxt<'tcx>, ty: Ty<'tcx>, svh: &Svh, + fn helper<'tcx>(tcx: &TyCtxt<'tcx>, ty: Ty<'tcx>, svh: &Svh, state: &mut SipHasher) { macro_rules! byte { ($b:expr) => { ($b as u8).hash(state) } } macro_rules! hash { ($e:expr) => { $e.hash(state) } } @@ -603,7 +603,7 @@ pub struct ImplMethod<'tcx> { pub is_provided: bool } -impl<'tcx> ty::ctxt<'tcx> { +impl<'tcx> TyCtxt<'tcx> { pub fn get_impl_method(&self, impl_def_id: DefId, substs: Substs<'tcx>, @@ -742,10 +742,10 @@ impl<'tcx> ty::TyS<'tcx> { /// Check whether a type is representable. This means it cannot contain unboxed /// structural recursion. This check is needed for structs and enums. - pub fn is_representable(&'tcx self, cx: &ty::ctxt<'tcx>, sp: Span) -> Representability { + pub fn is_representable(&'tcx self, cx: &TyCtxt<'tcx>, sp: Span) -> Representability { // Iterate until something non-representable is found - fn find_nonrepresentable<'tcx, It: Iterator<Item=Ty<'tcx>>>(cx: &ty::ctxt<'tcx>, + fn find_nonrepresentable<'tcx, It: Iterator<Item=Ty<'tcx>>>(cx: &TyCtxt<'tcx>, sp: Span, seen: &mut Vec<Ty<'tcx>>, iter: It) @@ -754,7 +754,7 @@ impl<'tcx> ty::TyS<'tcx> { |r, ty| cmp::max(r, is_type_structurally_recursive(cx, sp, seen, ty))) } - fn are_inner_types_recursive<'tcx>(cx: &ty::ctxt<'tcx>, sp: Span, + fn are_inner_types_recursive<'tcx>(cx: &TyCtxt<'tcx>, sp: Span, seen: &mut Vec<Ty<'tcx>>, ty: Ty<'tcx>) -> Representability { match ty.sty { @@ -813,7 +813,7 @@ impl<'tcx> ty::TyS<'tcx> { // Does the type `ty` directly (without indirection through a pointer) // contain any types on stack `seen`? - fn is_type_structurally_recursive<'tcx>(cx: &ty::ctxt<'tcx>, + fn is_type_structurally_recursive<'tcx>(cx: &TyCtxt<'tcx>, sp: Span, seen: &mut Vec<Ty<'tcx>>, ty: Ty<'tcx>) -> Representability { diff --git a/src/librustc/middle/ty/wf.rs b/src/librustc/middle/ty/wf.rs index 5f0fc306c24..c6d1bc8d649 100644 --- a/src/librustc/middle/ty/wf.rs +++ b/src/librustc/middle/ty/wf.rs @@ -13,7 +13,7 @@ use middle::infer::InferCtxt; use middle::ty::outlives::{self, Component}; use middle::subst::Substs; use middle::traits; -use middle::ty::{self, ToPredicate, Ty, TypeFoldable}; +use middle::ty::{self, ToPredicate, Ty, TyCtxt, TypeFoldable}; use std::iter::once; use syntax::ast; use syntax::codemap::Span; @@ -487,7 +487,7 @@ impl<'a,'tcx> WfPredicates<'a,'tcx> { /// `'static` would appear in the list. The hard work is done by /// `ty::required_region_bounds`, see that for more information. pub fn object_region_bounds<'tcx>( - tcx: &ty::ctxt<'tcx>, + tcx: &TyCtxt<'tcx>, principal: &ty::PolyTraitRef<'tcx>, others: ty::BuiltinBounds) -> Vec<ty::Region> diff --git a/src/librustc/mir/mir_map.rs b/src/librustc/mir/mir_map.rs index 32e78b04676..933621b765f 100644 --- a/src/librustc/mir/mir_map.rs +++ b/src/librustc/mir/mir_map.rs @@ -12,7 +12,7 @@ use dep_graph::DepNode; use util::nodemap::NodeMap; use mir::repr::Mir; use mir::transform::MirPass; -use middle::ty; +use middle::ty::{self, TyCtxt}; use middle::infer; pub struct MirMap<'tcx> { @@ -20,7 +20,7 @@ pub struct MirMap<'tcx> { } impl<'tcx> MirMap<'tcx> { - pub fn run_passes(&mut self, passes: &mut [Box<MirPass>], tcx: &ty::ctxt<'tcx>) { + pub fn run_passes(&mut self, passes: &mut [Box<MirPass>], tcx: &TyCtxt<'tcx>) { if passes.is_empty() { return; } for (&id, mir) in &mut self.map { diff --git a/src/librustc/mir/tcx.rs b/src/librustc/mir/tcx.rs index 20e083f840f..26f6db4aa4f 100644 --- a/src/librustc/mir/tcx.rs +++ b/src/librustc/mir/tcx.rs @@ -16,7 +16,7 @@ use mir::repr::*; use middle::const_eval::ConstVal; use middle::subst::{Subst, Substs}; -use middle::ty::{self, AdtDef, Ty}; +use middle::ty::{self, AdtDef, Ty, TyCtxt}; use rustc_front::hir; #[derive(Copy, Clone, Debug)] @@ -35,7 +35,7 @@ impl<'tcx> LvalueTy<'tcx> { LvalueTy::Ty { ty: ty } } - pub fn to_ty(&self, tcx: &ty::ctxt<'tcx>) -> Ty<'tcx> { + pub fn to_ty(&self, tcx: &TyCtxt<'tcx>) -> Ty<'tcx> { match *self { LvalueTy::Ty { ty } => ty, @@ -45,7 +45,7 @@ impl<'tcx> LvalueTy<'tcx> { } pub fn projection_ty(self, - tcx: &ty::ctxt<'tcx>, + tcx: &TyCtxt<'tcx>, elem: &LvalueElem<'tcx>) -> LvalueTy<'tcx> { @@ -80,7 +80,7 @@ impl<'tcx> LvalueTy<'tcx> { impl<'tcx> Mir<'tcx> { pub fn operand_ty(&self, - tcx: &ty::ctxt<'tcx>, + tcx: &TyCtxt<'tcx>, operand: &Operand<'tcx>) -> Ty<'tcx> { @@ -91,7 +91,7 @@ impl<'tcx> Mir<'tcx> { } pub fn binop_ty(&self, - tcx: &ty::ctxt<'tcx>, + tcx: &TyCtxt<'tcx>, op: BinOp, lhs_ty: Ty<'tcx>, rhs_ty: Ty<'tcx>) @@ -116,7 +116,7 @@ impl<'tcx> Mir<'tcx> { } pub fn lvalue_ty(&self, - tcx: &ty::ctxt<'tcx>, + tcx: &TyCtxt<'tcx>, lvalue: &Lvalue<'tcx>) -> LvalueTy<'tcx> { @@ -137,7 +137,7 @@ impl<'tcx> Mir<'tcx> { } pub fn rvalue_ty(&self, - tcx: &ty::ctxt<'tcx>, + tcx: &TyCtxt<'tcx>, rvalue: &Rvalue<'tcx>) -> Option<Ty<'tcx>> { diff --git a/src/librustc/util/ppaux.rs b/src/librustc/util/ppaux.rs index 5868f233776..9c92208191e 100644 --- a/src/librustc/util/ppaux.rs +++ b/src/librustc/util/ppaux.rs @@ -17,7 +17,7 @@ use middle::ty::{TyError, TyStr, TyArray, TySlice, TyFloat, TyBareFn}; use middle::ty::{TyParam, TyRawPtr, TyRef, TyTuple}; use middle::ty::TyClosure; use middle::ty::{TyBox, TyTrait, TyInt, TyUint, TyInfer}; -use middle::ty::{self, Ty, TypeFoldable}; +use middle::ty::{self, Ty, TyCtxt, TypeFoldable}; use std::fmt; use syntax::abi::Abi; @@ -66,7 +66,7 @@ fn parameterized<GG>(f: &mut fmt::Formatter, projections: &[ty::ProjectionPredicate], get_generics: GG) -> fmt::Result - where GG: for<'tcx> FnOnce(&ty::ctxt<'tcx>) -> ty::Generics<'tcx> + where GG: for<'tcx> FnOnce(&TyCtxt<'tcx>) -> ty::Generics<'tcx> { let (fn_trait_kind, verbose) = try!(ty::tls::with(|tcx| { try!(write!(f, "{}", tcx.item_path_str(did))); @@ -189,7 +189,7 @@ fn parameterized<GG>(f: &mut fmt::Formatter, } fn in_binder<'tcx, T, U>(f: &mut fmt::Formatter, - tcx: &ty::ctxt<'tcx>, + tcx: &TyCtxt<'tcx>, original: &ty::Binder<T>, lifted: Option<ty::Binder<U>>) -> fmt::Result where T: fmt::Display, U: fmt::Display + TypeFoldable<'tcx>  | 
