diff --git a/src/librustc/dep_graph/mod.rs b/src/librustc/dep_graph/mod.rs index a4d222d24cac1..2fad161652f69 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 fb5413114b789..d492f6927039b 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 8b1bdc31beb01..e17aaaca16e04 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> { 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 701a459690889..a6fb5c02f54c3 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, @@ -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 ac84d3dec94e2..394633c59114d 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; pub type CFGEdge = graph::Edge; 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 246a4e9f28f6b..be8793bac5dbf 100644 --- a/src/librustc/middle/check_match.rs +++ b/src/librustc/middle/check_match.rs @@ -107,7 +107,7 @@ impl<'a> FromIterator> 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 { } 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 3d28f3a8a3f0c..06030c0021171 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, 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 { 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> { 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 { +pub fn const_expr_to_pat(tcx: &TyCtxt, expr: &Expr, span: Span) -> P { 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 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 { }) } -pub fn compare_lit_exprs<'tcx>(tcx: &ty::ctxt<'tcx>, +pub fn compare_lit_exprs<'tcx>(tcx: &TyCtxt<'tcx>, a: &Expr, b: &Expr) -> Option { 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 3b72685eca310..3af987df3a8c2 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; fn deprecation(&self, def: DefId) -> Option; - 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; - 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; fn extern_item_path(&self, def: DefId) -> Vec; 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; 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; fn inherent_implementations_for_type(&self, def_id: DefId) -> Vec; // trait info fn implementations_of_trait(&self, def_id: DefId) -> Vec; - fn provided_trait_methods(&self, tcx: &ty::ctxt<'tcx>, def: DefId) + fn provided_trait_methods(&self, tcx: &TyCtxt<'tcx>, def: DefId) -> Vec>>; fn trait_item_def_ids(&self, def: DefId) -> Vec; // impl info fn impl_items(&self, impl_def_id: DefId) -> Vec; - fn impl_trait_ref(&self, tcx: &ty::ctxt<'tcx>, def: DefId) + fn impl_trait_ref(&self, tcx: &TyCtxt<'tcx>, def: DefId) -> Option>; fn impl_polarity(&self, def: DefId) -> Option; fn custom_coerce_unsized_kind(&self, def: DefId) -> Option; - fn associated_consts(&self, tcx: &ty::ctxt<'tcx>, def: DefId) + fn associated_consts(&self, tcx: &TyCtxt<'tcx>, def: DefId) -> Vec>>; // 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; - 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; // 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>; 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; + fn encode_type(&self, tcx: &TyCtxt<'tcx>, ty: Ty<'tcx>) -> Vec; fn used_crates(&self, prefer: LinkagePreference) -> Vec<(ast::CrateNum, Option)>; fn used_crate_source(&self, cnum: ast::CrateNum) -> CrateSource; fn extern_mod_stmt_cnum(&self, emod_id: ast::NodeId) -> Option; fn encode_metadata(&self, - tcx: &ty::ctxt<'tcx>, + tcx: &TyCtxt<'tcx>, reexports: &def::ExportMap, item_symbols: &RefCell>, link_meta: &LinkMeta, @@ -302,33 +302,33 @@ impl<'tcx> CrateStore<'tcx> for DummyCrateStore { // item info fn stability(&self, def: DefId) -> Option { unimplemented!() } fn deprecation(&self, def: DefId) -> Option { 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 { 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 { unimplemented!() } fn extern_item_path(&self, def: DefId) -> Vec { 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 { 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 { unimplemented!() } fn inherent_implementations_for_type(&self, def_id: DefId) -> Vec { vec![] } // trait info fn implementations_of_trait(&self, def_id: DefId) -> Vec { vec![] } - fn provided_trait_methods(&self, tcx: &ty::ctxt<'tcx>, def: DefId) + fn provided_trait_methods(&self, tcx: &TyCtxt<'tcx>, def: DefId) -> Vec>> { unimplemented!() } fn trait_item_def_ids(&self, def: DefId) -> Vec { unimplemented!() } @@ -336,19 +336,19 @@ impl<'tcx> CrateStore<'tcx> for DummyCrateStore { // impl info fn impl_items(&self, impl_def_id: DefId) -> Vec { unimplemented!() } - fn impl_trait_ref(&self, tcx: &ty::ctxt<'tcx>, def: DefId) + fn impl_trait_ref(&self, tcx: &TyCtxt<'tcx>, def: DefId) -> Option> { unimplemented!() } fn impl_polarity(&self, def: DefId) -> Option { unimplemented!() } fn custom_coerce_unsized_kind(&self, def: DefId) -> Option { unimplemented!() } - fn associated_consts(&self, tcx: &ty::ctxt<'tcx>, def: DefId) + fn associated_consts(&self, tcx: &TyCtxt<'tcx>, def: DefId) -> Vec>> { 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 { 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> { 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 + fn encode_type(&self, tcx: &TyCtxt<'tcx>, ty: Ty<'tcx>) -> Vec { unimplemented!() } fn used_crates(&self, prefer: LinkagePreference) -> Vec<(ast::CrateNum, Option)> { vec![] } fn used_crate_source(&self, cnum: ast::CrateNum) -> CrateSource { unimplemented!() } fn extern_mod_stmt_cnum(&self, emod_id: ast::NodeId) -> Option { None } fn encode_metadata(&self, - tcx: &ty::ctxt<'tcx>, + tcx: &TyCtxt<'tcx>, reexports: &def::ExportMap, item_symbols: &RefCell>, 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 3fc45c575f045..c746fab3ea13b 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 eefefed5f2daa..f1b38ea8b8130 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, - tcx: &'a ty::ctxt<'tcx>, + tcx: &'a TyCtxt<'tcx>, live_symbols: Box>, 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) -> 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 { 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> { @@ -410,7 +411,7 @@ fn get_struct_ctor_id(item: &hir::Item) -> Option { } struct DeadVisitor<'a, 'tcx: 'a> { - tcx: &'a ty::ctxt<'tcx>, + tcx: &'a TyCtxt<'tcx>, live_symbols: Box>, } @@ -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 c27d029374aff..e3d05388f5218 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 93cc158cd12f2..8b042e73e796a 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 face6d629340d..cb45a3e2507c9 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 2d9432b75e719..cb6542856be24 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 faf1bdb0ce504..cd4a2eb2d93b4 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 d1dad4921ae21..a10568d1fa33a 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 8c578bcd3d2ae..2f1af4184e549 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) { 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 { @@ -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 { let mut taken = Vec::new(); diff --git a/src/librustc/middle/infer/freshen.rs b/src/librustc/middle/infer/freshen.rs index 76dd62383f1b1..b64fa688d5163 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 0035f31e8db94..82803acd393e9 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 e8f542db933cb..9b6625886a47c 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 238dad65ef0d9..2ab0b92e42a33 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 26ea5454693e1..b9a5b32b71d82 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 = Result; // "fixup result" pub struct InferCtxt<'a, 'tcx: 'a> { - pub tcx: &'a ty::ctxt<'tcx>, + pub tcx: &'a TyCtxt<'tcx>, pub tables: &'a RefCell>, @@ -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>, param_env: Option>) -> 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>) -> 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 dafa65c5bdca8..b6c9b5636d9af 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>, node_ids: FnvHashMap, @@ -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>; -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 bfc770d53aaba..36462b68288c9 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; pub struct RegionVarBindings<'a, 'tcx: 'a> { - tcx: &'a ty::ctxt<'tcx>, + tcx: &'a TyCtxt<'tcx>, var_origins: RefCell>, // 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, min: ty::Region) diff --git a/src/librustc/middle/infer/resolve.rs b/src/librustc/middle/infer/resolve.rs index c68d0a9fa5683..8c6105898446a 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 2cd686fde156e..e13d29b8b4215 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(&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 c83231930f502..5008a92a4f59d 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 a763677db0661..7de8904e3f26f 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 a487ddbc2b1c2..81f0cb1fbb2a9 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 fef35764e1cc1..11ef1dbd70556 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 a1a3c194efe07..81166945115bb 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 { } } -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 614d9be147bd8..601f069513d12 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 c35c86ce974a5..2d92742ed0f20 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, @@ -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 { 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, used_features: FnvHashMap, // 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)) { 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)) { 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)) { 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)) { 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)) { 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)) { 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 { +pub fn lookup_deprecation<'tcx>(tcx: &TyCtxt<'tcx>, id: DefId) -> Option { 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(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 { +fn lookup_deprecation_uncached<'tcx>(tcx: &TyCtxt<'tcx>, id: DefId) -> Option { 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 f8c6d3d934123..9cc94402b1651 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 { // 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) -> 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) -> 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 0f95aa74b6fd7..b0970457892bb 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> @@ -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 fac53ec140dbc..dd051471a4d1b 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) @@ -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 de70cdbd29a35..b237117564228 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 7ffdc3bdef27a..4a0da521eef30 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> { @@ -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> { @@ -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> { @@ -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 @@ -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 @@ -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 c363425db85b0..b19771420bd39 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 29355e0684d96..373ec37663f55 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 c50c9e9765d25..08d504143c7cc 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>, } 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>, 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>) -> Elaborator<'cx, 'tcx> { @@ -205,14 +205,14 @@ impl<'cx, 'tcx> Iterator for Elaborator<'cx, 'tcx> { pub type Supertraits<'cx, 'tcx> = FilterToTraits>; -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, visited: FnvHashSet, } -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, 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> @@ -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 5a3ad9095ad2c..41612a68a91ef 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>(&mut self, diff --git a/src/librustc/middle/ty/adjustment.rs b/src/librustc/middle/ty/adjustment.rs index afe177fbdcdcb..40581cfa1c54d 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(&'tcx self, cx: &ty::ctxt<'tcx>, + pub fn adjust(&'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(&'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>) -> Ty<'tcx> { match autoref { diff --git a/src/librustc/middle/ty/contents.rs b/src/librustc/middle/ty/contents.rs index 3a42e8e9bfaa6..8dfa0262f2b0d 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, 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 a014c63f0a2a9..ffc52af19bbe1 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, - 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, - 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, 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>>, } -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; + fn lift_to_tcx(&self, tcx: &TyCtxt<'tcx>) -> Option; } impl<'a, 'tcx> Lift<'tcx> for Ty<'a> { type Lifted = Ty<'tcx>; - fn lift_to_tcx(&self, tcx: &ctxt<'tcx>) -> Option> { + fn lift_to_tcx(&self, tcx: &TyCtxt<'tcx>) -> Option> { 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 R, R>(f: F) -> R { + pub fn with 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) -> R, R>(f: F) -> R { + pub fn with_opt) -> 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 ab48fd7fb8665..39a5069e12944 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 a06e8a72c44ee..a42e5fc2e85f2 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 diff --git a/src/librustc/middle/ty/fold.rs b/src/librustc/middle/ty/fold.rs index da0245a8d2520..162ea3a7714df 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(&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(tcx: &'a ty::ctxt<'tcx>, + pub fn new(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 } -impl<'tcx> ty::ctxt<'tcx> { +impl<'tcx> TyCtxt<'tcx> { pub fn replace_late_bound_regions(&self, value: &Binder, mut f: F) @@ -418,7 +418,7 @@ impl<'tcx> ty::ctxt<'tcx> { } impl<'a, 'tcx> RegionReplacer<'a, 'tcx> { - fn new(tcx: &'a ty::ctxt<'tcx>, fld_r: &'a mut F) -> RegionReplacer<'a, 'tcx> + fn new(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 105e0bb7b1589..85035b2500144 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>) -> 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>; // imported. pub type GlobMap = HashMap>; -impl<'tcx> ctxt<'tcx> { +impl<'tcx> TyCtxt<'tcx> { pub fn with_freevars(&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 974b5c4bc6c2a..5d6106a6d7747 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 01b2bd36b4f07..001ea02a27c3e 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 { + fn lift_to_tcx(&self, tcx: &TyCtxt<'tcx>) -> Option { 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; - fn lift_to_tcx(&self, tcx: &ty::ctxt<'tcx>) -> Option { + fn lift_to_tcx(&self, tcx: &TyCtxt<'tcx>) -> Option { // type annotation needed to inform `projection_must_outlive` let mut result : Vec<>::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 { + fn lift_to_tcx(&self, _: &TyCtxt<'tcx>) -> Option { Some(*self) } } impl<'a, 'tcx> Lift<'tcx> for TraitRef<'a> { type Lifted = TraitRef<'tcx>; - fn lift_to_tcx(&self, tcx: &ty::ctxt<'tcx>) -> Option> { + fn lift_to_tcx(&self, tcx: &TyCtxt<'tcx>) -> Option> { 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> { + fn lift_to_tcx(&self, tcx: &TyCtxt<'tcx>) -> Option> { 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> { + fn lift_to_tcx(&self, tcx: &TyCtxt<'tcx>) -> Option> { 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 { type Lifted = ty::OutlivesPredicate; - fn lift_to_tcx(&self, tcx: &ty::ctxt<'tcx>) -> Option { + fn lift_to_tcx(&self, tcx: &TyCtxt<'tcx>) -> Option { 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> { + fn lift_to_tcx(&self, tcx: &TyCtxt<'tcx>) -> Option> { 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 { type Lifted = ty::Binder; - fn lift_to_tcx(&self, tcx: &ty::ctxt<'tcx>) -> Option { + fn lift_to_tcx(&self, tcx: &TyCtxt<'tcx>) -> Option { 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 2a13c47895e0c..c8f8e07383275 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> { @@ -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> { 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) @@ -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 db001ce2c446c..5ecbbbcfbde6d 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(&self, tcx: &ty::ctxt<'tcx>, mut f: F) { + pub fn for_each_impl(&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(&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>, Ref<'s, FnvHashMap>>) { self.read_trait_impls(tcx); diff --git a/src/librustc/middle/ty/util.rs b/src/librustc/middle/ty/util.rs index 0b5c0d147cb57..7c32d931fffcb 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; fn u64_to_disr(&self, val: u64) -> Option; fn disr_incr(&self, val: Disr) -> Option; @@ -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 { 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>>(cx: &ty::ctxt<'tcx>, + fn find_nonrepresentable<'tcx, It: Iterator>>(cx: &TyCtxt<'tcx>, sp: Span, seen: &mut Vec>, 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: 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: Ty<'tcx>) -> Representability { diff --git a/src/librustc/middle/ty/wf.rs b/src/librustc/middle/ty/wf.rs index 5f0fc306c24f8..c6d1bc8d64958 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 diff --git a/src/librustc/mir/mir_map.rs b/src/librustc/mir/mir_map.rs index 32e78b0467639..933621b765f93 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], tcx: &ty::ctxt<'tcx>) { + pub fn run_passes(&mut self, passes: &mut [Box], 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 20e083f840f8c..26f6db4aa4fc1 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> { diff --git a/src/librustc/util/ppaux.rs b/src/librustc/util/ppaux.rs index 5868f233776c2..9c92208191e9c 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(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(f: &mut fmt::Formatter, } fn in_binder<'tcx, T, U>(f: &mut fmt::Formatter, - tcx: &ty::ctxt<'tcx>, + tcx: &TyCtxt<'tcx>, original: &ty::Binder, lifted: Option>) -> fmt::Result where T: fmt::Display, U: fmt::Display + TypeFoldable<'tcx> diff --git a/src/librustc_borrowck/borrowck/check_loans.rs b/src/librustc_borrowck/borrowck/check_loans.rs index f19a8658a057b..4a1c115e65599 100644 --- a/src/librustc_borrowck/borrowck/check_loans.rs +++ b/src/librustc_borrowck/borrowck/check_loans.rs @@ -26,7 +26,7 @@ use rustc::middle::infer; use rustc::middle::mem_categorization as mc; use rustc::middle::mem_categorization::Categorization; use rustc::middle::region; -use rustc::middle::ty; +use rustc::middle::ty::{self, TyCtxt}; use syntax::ast; use syntax::codemap::Span; use rustc_front::hir; @@ -231,7 +231,7 @@ fn compatible_borrow_kinds(borrow_kind1: ty::BorrowKind, } impl<'a, 'tcx> CheckLoanCtxt<'a, 'tcx> { - pub fn tcx(&self) -> &'a ty::ctxt<'tcx> { self.bccx.tcx } + pub fn tcx(&self) -> &'a TyCtxt<'tcx> { self.bccx.tcx } pub fn each_issued_loan(&self, node: ast::NodeId, mut op: F) -> bool where F: FnMut(&Loan<'tcx>) -> bool, diff --git a/src/librustc_borrowck/borrowck/fragments.rs b/src/librustc_borrowck/borrowck/fragments.rs index c5e2b69683b10..3d6e9c8868c92 100644 --- a/src/librustc_borrowck/borrowck/fragments.rs +++ b/src/librustc_borrowck/borrowck/fragments.rs @@ -21,7 +21,7 @@ use borrowck::LoanPathElem::{LpDeref, LpInterior}; use borrowck::move_data::InvalidMovePathIndex; use borrowck::move_data::{MoveData, MovePathIndex}; use rustc::middle::def_id::{DefId}; -use rustc::middle::ty; +use rustc::middle::ty::{self, TyCtxt}; use rustc::middle::mem_categorization as mc; use std::mem; @@ -200,7 +200,7 @@ impl FragmentSets { } pub fn instrument_move_fragments<'tcx>(this: &MoveData<'tcx>, - tcx: &ty::ctxt<'tcx>, + tcx: &TyCtxt<'tcx>, sp: Span, id: ast::NodeId) { let span_err = tcx.map.attrs(id).iter() @@ -245,7 +245,7 @@ pub fn instrument_move_fragments<'tcx>(this: &MoveData<'tcx>, /// /// Note: "left-over fragments" means paths that were not directly referenced in moves nor /// assignments, but must nonetheless be tracked as potential drop obligations. -pub fn fixup_fragment_sets<'tcx>(this: &MoveData<'tcx>, tcx: &ty::ctxt<'tcx>) { +pub fn fixup_fragment_sets<'tcx>(this: &MoveData<'tcx>, tcx: &TyCtxt<'tcx>) { let mut fragments = this.fragments.borrow_mut(); @@ -347,7 +347,7 @@ pub fn fixup_fragment_sets<'tcx>(this: &MoveData<'tcx>, tcx: &ty::ctxt<'tcx>) { /// example, if `lp` represents `s.x.j`, then adds moves paths for `s.x.i` and `s.x.k`, the /// siblings of `s.x.j`. fn add_fragment_siblings<'tcx>(this: &MoveData<'tcx>, - tcx: &ty::ctxt<'tcx>, + tcx: &TyCtxt<'tcx>, gathered_fragments: &mut Vec, lp: Rc>, origin_id: Option) { @@ -406,7 +406,7 @@ fn add_fragment_siblings<'tcx>(this: &MoveData<'tcx>, /// We have determined that `origin_lp` destructures to LpExtend(parent, original_field_name). /// Based on this, add move paths for all of the siblings of `origin_lp`. fn add_fragment_siblings_for_extension<'tcx>(this: &MoveData<'tcx>, - tcx: &ty::ctxt<'tcx>, + tcx: &TyCtxt<'tcx>, gathered_fragments: &mut Vec, parent_lp: &Rc>, mc: mc::MutabilityCategory, @@ -504,7 +504,7 @@ fn add_fragment_siblings_for_extension<'tcx>(this: &MoveData<'tcx>, /// Adds the single sibling `LpExtend(parent, new_field_name)` of `origin_lp` (the original /// loan-path). fn add_fragment_sibling_core<'tcx>(this: &MoveData<'tcx>, - tcx: &ty::ctxt<'tcx>, + tcx: &TyCtxt<'tcx>, gathered_fragments: &mut Vec, parent: Rc>, mc: mc::MutabilityCategory, diff --git a/src/librustc_borrowck/borrowck/gather_loans/mod.rs b/src/librustc_borrowck/borrowck/gather_loans/mod.rs index 38157d04a5d6d..e2543b289103a 100644 --- a/src/librustc_borrowck/borrowck/gather_loans/mod.rs +++ b/src/librustc_borrowck/borrowck/gather_loans/mod.rs @@ -23,7 +23,7 @@ use rustc::middle::infer; use rustc::middle::mem_categorization as mc; use rustc::middle::mem_categorization::Categorization; use rustc::middle::region; -use rustc::middle::ty; +use rustc::middle::ty::{self, TyCtxt}; use syntax::ast; use syntax::codemap::Span; @@ -253,7 +253,7 @@ fn check_mutability<'a, 'tcx>(bccx: &BorrowckCtxt<'a, 'tcx>, } impl<'a, 'tcx> GatherLoanCtxt<'a, 'tcx> { - pub fn tcx(&self) -> &'a ty::ctxt<'tcx> { self.bccx.tcx } + pub fn tcx(&self) -> &'a TyCtxt<'tcx> { self.bccx.tcx } /// Guarantees that `cmt` is assignable, or reports an error. fn guarantee_assignment_valid(&mut self, diff --git a/src/librustc_borrowck/borrowck/mod.rs b/src/librustc_borrowck/borrowck/mod.rs index 1fa36a98ec5d9..ceaa6625fe2d9 100644 --- a/src/librustc_borrowck/borrowck/mod.rs +++ b/src/librustc_borrowck/borrowck/mod.rs @@ -34,7 +34,7 @@ use rustc::middle::free_region::FreeRegionMap; use rustc::middle::mem_categorization as mc; use rustc::middle::mem_categorization::Categorization; use rustc::middle::region; -use rustc::middle::ty::{self, Ty}; +use rustc::middle::ty::{self, Ty, TyCtxt}; use std::fmt; use std::mem; @@ -98,7 +98,7 @@ impl<'a, 'tcx, 'v> Visitor<'v> for BorrowckCtxt<'a, 'tcx> { } } -pub fn check_crate(tcx: &ty::ctxt) { +pub fn check_crate(tcx: &TyCtxt) { let mut bccx = BorrowckCtxt { tcx: tcx, free_region_map: FreeRegionMap::new(), @@ -232,7 +232,7 @@ fn build_borrowck_dataflow_data<'a, 'tcx>(this: &mut BorrowckCtxt<'a, 'tcx>, /// Accessor for introspective clients inspecting `AnalysisData` and /// the `BorrowckCtxt` itself , e.g. the flowgraph visualizer. pub fn build_borrowck_dataflow_data_for_fn<'a, 'tcx>( - tcx: &'a ty::ctxt<'tcx>, + tcx: &'a TyCtxt<'tcx>, fn_parts: FnParts<'a>, cfg: &cfg::CFG) -> (BorrowckCtxt<'a, 'tcx>, AnalysisData<'a, 'tcx>) @@ -264,7 +264,7 @@ pub fn build_borrowck_dataflow_data_for_fn<'a, 'tcx>( // Type definitions pub struct BorrowckCtxt<'a, 'tcx: 'a> { - tcx: &'a ty::ctxt<'tcx>, + tcx: &'a TyCtxt<'tcx>, // Hacky. As we visit various fns, we have to load up the // free-region map for each one. This map is computed by during @@ -394,7 +394,7 @@ pub enum LoanPathElem { } pub fn closure_to_block(closure_id: ast::NodeId, - tcx: &ty::ctxt) -> ast::NodeId { + tcx: &TyCtxt) -> ast::NodeId { match tcx.map.get(closure_id) { hir_map::NodeExpr(expr) => match expr.node { hir::ExprClosure(_, _, ref block) => { @@ -409,7 +409,7 @@ pub fn closure_to_block(closure_id: ast::NodeId, } impl<'tcx> LoanPath<'tcx> { - pub fn kill_scope(&self, tcx: &ty::ctxt<'tcx>) -> region::CodeExtent { + pub fn kill_scope(&self, tcx: &TyCtxt<'tcx>) -> region::CodeExtent { match self.kind { LpVar(local_id) => tcx.region_maps.var_scope(local_id), LpUpvar(upvar_id) => { @@ -1157,7 +1157,7 @@ impl<'a, 'tcx> BorrowckCtxt<'a, 'tcx> { } } -fn statement_scope_span(tcx: &ty::ctxt, region: ty::Region) -> Option { +fn statement_scope_span(tcx: &TyCtxt, region: ty::Region) -> Option { match region { ty::ReScope(scope) => { match tcx.map.find(scope.node_id(&tcx.region_maps)) { diff --git a/src/librustc_borrowck/borrowck/move_data.rs b/src/librustc_borrowck/borrowck/move_data.rs index cbec32e358d81..4c645d4bb69bd 100644 --- a/src/librustc_borrowck/borrowck/move_data.rs +++ b/src/librustc_borrowck/borrowck/move_data.rs @@ -21,7 +21,7 @@ use rustc::middle::dataflow::DataFlowOperator; use rustc::middle::dataflow::KillFrom; use rustc::middle::expr_use_visitor as euv; use rustc::middle::expr_use_visitor::MutateMode; -use rustc::middle::ty; +use rustc::middle::ty::TyCtxt; use rustc::util::nodemap::{FnvHashMap, NodeSet}; use std::cell::RefCell; @@ -273,7 +273,7 @@ impl<'tcx> MoveData<'tcx> { /// Returns the existing move path index for `lp`, if any, and otherwise adds a new index for /// `lp` and any of its base paths that do not yet have an index. pub fn move_path(&self, - tcx: &ty::ctxt<'tcx>, + tcx: &TyCtxt<'tcx>, lp: Rc>) -> MovePathIndex { match self.path_map.borrow().get(&lp) { Some(&index) => { @@ -365,7 +365,7 @@ impl<'tcx> MoveData<'tcx> { /// Adds a new move entry for a move of `lp` that occurs at location `id` with kind `kind`. pub fn add_move(&self, - tcx: &ty::ctxt<'tcx>, + tcx: &TyCtxt<'tcx>, lp: Rc>, id: ast::NodeId, kind: MoveKind) { @@ -393,7 +393,7 @@ impl<'tcx> MoveData<'tcx> { /// Adds a new record for an assignment to `lp` that occurs at location `id` with the given /// `span`. pub fn add_assignment(&self, - tcx: &ty::ctxt<'tcx>, + tcx: &TyCtxt<'tcx>, lp: Rc>, assign_id: ast::NodeId, span: Span, @@ -438,7 +438,7 @@ impl<'tcx> MoveData<'tcx> { /// should be able to recover the span info from the /// `pattern_id` and the ast_map, I think.) pub fn add_variant_match(&self, - tcx: &ty::ctxt<'tcx>, + tcx: &TyCtxt<'tcx>, lp: Rc>, pattern_id: ast::NodeId, base_lp: Rc>, @@ -461,7 +461,7 @@ impl<'tcx> MoveData<'tcx> { self.variant_matches.borrow_mut().push(variant_match); } - fn fixup_fragment_sets(&self, tcx: &ty::ctxt<'tcx>) { + fn fixup_fragment_sets(&self, tcx: &TyCtxt<'tcx>) { fragments::fixup_fragment_sets(self, tcx) } @@ -471,7 +471,7 @@ impl<'tcx> MoveData<'tcx> { /// scoping. Assignments are generated by assignment to variables and /// killed by scoping. See `README.md` for more details. fn add_gen_kills(&self, - tcx: &ty::ctxt<'tcx>, + tcx: &TyCtxt<'tcx>, dfcx_moves: &mut MoveDataFlow, dfcx_assign: &mut AssignDataFlow) { for (i, the_move) in self.moves.borrow().iter().enumerate() { @@ -600,7 +600,7 @@ impl<'tcx> MoveData<'tcx> { impl<'a, 'tcx> FlowedMoveData<'a, 'tcx> { pub fn new(move_data: MoveData<'tcx>, - tcx: &'a ty::ctxt<'tcx>, + tcx: &'a TyCtxt<'tcx>, cfg: &cfg::CFG, id_range: ast_util::IdRange, decl: &hir::FnDecl, diff --git a/src/librustc_driver/driver.rs b/src/librustc_driver/driver.rs index b446dec96fbfb..9c1be4c9f2f3e 100644 --- a/src/librustc_driver/driver.rs +++ b/src/librustc_driver/driver.rs @@ -17,9 +17,9 @@ use rustc::session::{Session, CompileResult, compile_result_from_err_count}; use rustc::session::config::{self, Input, OutputFilenames, OutputType}; use rustc::session::search_paths::PathKind; use rustc::lint; -use rustc::middle::{dependency_format, stability, ty, reachable}; +use rustc::middle::{self, dependency_format, stability, ty, reachable}; use rustc::middle::privacy::AccessLevels; -use rustc::middle; +use rustc::middle::ty::TyCtxt; use rustc::util::common::time; use rustc::util::nodemap::NodeSet; use rustc_borrowck as borrowck; @@ -313,7 +313,7 @@ pub struct CompileState<'a, 'ast: 'a, 'tcx: 'a> { pub ast_map: Option<&'a hir_map::Map<'ast>>, pub mir_map: Option<&'a MirMap<'tcx>>, pub analysis: Option<&'a ty::CrateAnalysis<'a>>, - pub tcx: Option<&'a ty::ctxt<'tcx>>, + pub tcx: Option<&'a TyCtxt<'tcx>>, pub lcx: Option<&'a LoweringContext<'a>>, pub trans: Option<&'a trans::CrateTranslation>, } @@ -389,7 +389,7 @@ impl<'a, 'ast, 'tcx> CompileState<'a, 'ast, 'tcx> { hir_crate: &'a hir::Crate, analysis: &'a ty::CrateAnalysis, mir_map: Option<&'a MirMap<'tcx>>, - tcx: &'a ty::ctxt<'tcx>, + tcx: &'a TyCtxt<'tcx>, lcx: &'a LoweringContext<'a>, crate_name: &'a str) -> CompileState<'a, 'ast, 'tcx> { @@ -730,7 +730,7 @@ pub fn phase_3_run_analysis_passes<'tcx, F, R>(sess: &'tcx Session, make_glob_map: resolve::MakeGlobMap, f: F) -> Result - where F: FnOnce(&ty::ctxt<'tcx>, Option>, ty::CrateAnalysis, CompileResult) -> R + where F: FnOnce(&TyCtxt<'tcx>, Option>, ty::CrateAnalysis, CompileResult) -> R { macro_rules! try_with_f { ($e: expr, ($t: expr, $m: expr, $a: expr)) => { @@ -803,7 +803,7 @@ pub fn phase_3_run_analysis_passes<'tcx, F, R>(sess: &'tcx Session, let index = stability::Index::new(&hir_map); - ty::ctxt::create_and_enter(sess, + TyCtxt::create_and_enter(sess, arenas, def_map, named_region_map, @@ -913,7 +913,7 @@ pub fn phase_3_run_analysis_passes<'tcx, F, R>(sess: &'tcx Session, /// Run the translation phase to LLVM, after which the AST and analysis can /// be discarded. -pub fn phase_4_translate_to_llvm<'tcx>(tcx: &ty::ctxt<'tcx>, +pub fn phase_4_translate_to_llvm<'tcx>(tcx: &TyCtxt<'tcx>, mut mir_map: MirMap<'tcx>, analysis: ty::CrateAnalysis) -> trans::CrateTranslation { diff --git a/src/librustc_driver/pretty.rs b/src/librustc_driver/pretty.rs index e9db30f3cb24f..eb4668e6abb1c 100644 --- a/src/librustc_driver/pretty.rs +++ b/src/librustc_driver/pretty.rs @@ -20,7 +20,7 @@ use rustc_trans::back::link; use {driver, abort_on_err}; use rustc::dep_graph::DepGraph; -use rustc::middle::ty; +use rustc::middle::ty::{self, TyCtxt}; use rustc::middle::cfg; use rustc::middle::cfg::graphviz::LabelledCFG; use rustc::session::Session; @@ -431,7 +431,7 @@ impl<'ast> pprust::PpAnn for HygieneAnnotation<'ast> { struct TypedAnnotation<'a, 'tcx: 'a> { - tcx: &'a ty::ctxt<'tcx>, + tcx: &'a TyCtxt<'tcx>, } impl<'b, 'tcx> HirPrinterSupport<'tcx> for TypedAnnotation<'b, 'tcx> { @@ -913,7 +913,7 @@ pub fn pretty_print_input(sess: Session, } fn print_flowgraph(variants: Vec, - tcx: &ty::ctxt, + tcx: &TyCtxt, code: blocks::Code, mode: PpFlowGraphMode, mut out: W) diff --git a/src/librustc_driver/test.rs b/src/librustc_driver/test.rs index 3220295d9b88a..abeaffe80ab0b 100644 --- a/src/librustc_driver/test.rs +++ b/src/librustc_driver/test.rs @@ -22,7 +22,7 @@ use rustc_typeck::middle::resolve_lifetime; use rustc_typeck::middle::stability; use rustc_typeck::middle::subst; use rustc_typeck::middle::subst::Subst; -use rustc_typeck::middle::ty::{self, Ty, TypeFoldable}; +use rustc_typeck::middle::ty::{self, Ty, TyCtxt, TypeFoldable}; use rustc_typeck::middle::ty::relate::TypeRelation; use rustc_typeck::middle::infer::{self, TypeOrigin}; use rustc_typeck::middle::infer::lub::Lub; @@ -133,7 +133,7 @@ fn test_env(source_string: &str, let named_region_map = resolve_lifetime::krate(&sess, &ast_map, &def_map.borrow()); let region_map = region::resolve_crate(&sess, &ast_map); let index = stability::Index::new(&ast_map); - ty::ctxt::create_and_enter(&sess, + TyCtxt::create_and_enter(&sess, &arenas, def_map, named_region_map.unwrap(), @@ -153,7 +153,7 @@ fn test_env(source_string: &str, } impl<'a, 'tcx> Env<'a, 'tcx> { - pub fn tcx(&self) -> &ty::ctxt<'tcx> { + pub fn tcx(&self) -> &TyCtxt<'tcx> { self.infcx.tcx } diff --git a/src/librustc_lint/builtin.rs b/src/librustc_lint/builtin.rs index 2c96b84471de6..86ab8d45e4e1d 100644 --- a/src/librustc_lint/builtin.rs +++ b/src/librustc_lint/builtin.rs @@ -33,7 +33,7 @@ use middle::def::Def; use middle::cstore::CrateStore; use middle::def_id::DefId; use middle::subst::Substs; -use middle::ty::{self, Ty}; +use middle::ty::{self, Ty, TyCtxt}; use middle::ty::adjustment; use rustc::front::map as hir_map; use util::nodemap::{NodeSet}; @@ -774,7 +774,7 @@ impl LateLintPass for UnconditionalRecursion { // Functions for identifying if the given Expr NodeId `id` // represents a call to the function `fn_id`/method `method`. - fn expr_refers_to_this_fn(tcx: &ty::ctxt, + fn expr_refers_to_this_fn(tcx: &TyCtxt, fn_id: ast::NodeId, id: ast::NodeId) -> bool { match tcx.map.get(id) { @@ -790,7 +790,7 @@ impl LateLintPass for UnconditionalRecursion { } // Check if the expression `id` performs a call to `method`. - fn expr_refers_to_this_method(tcx: &ty::ctxt, + fn expr_refers_to_this_method(tcx: &TyCtxt, method: &ty::Method, id: ast::NodeId) -> bool { // Check for method calls and overloaded operators. @@ -838,7 +838,7 @@ impl LateLintPass for UnconditionalRecursion { // Check if the method call to the method with the ID `callee_id` // and instantiated with `callee_substs` refers to method `method`. - fn method_call_refers_to_method<'tcx>(tcx: &ty::ctxt<'tcx>, + fn method_call_refers_to_method<'tcx>(tcx: &TyCtxt<'tcx>, method: &ty::Method, callee_id: DefId, callee_substs: &Substs<'tcx>, diff --git a/src/librustc_lint/types.rs b/src/librustc_lint/types.rs index 203f6626f51d3..c7cb2d15a092f 100644 --- a/src/librustc_lint/types.rs +++ b/src/librustc_lint/types.rs @@ -13,7 +13,7 @@ use middle::{infer}; use middle::def_id::DefId; use middle::subst::Substs; -use middle::ty::{self, Ty}; +use middle::ty::{self, Ty, TyCtxt}; use middle::const_eval::{eval_const_expr_partial, ConstVal}; use middle::const_eval::EvalHint::ExprTypeChecked; use util::nodemap::{FnvHashSet}; @@ -293,7 +293,7 @@ impl LateLintPass for TypeLimits { } } - fn check_limits(tcx: &ty::ctxt, binop: hir::BinOp, + fn check_limits(tcx: &TyCtxt, binop: hir::BinOp, l: &hir::Expr, r: &hir::Expr) -> bool { let (lit, expr, swap) = match (&l.node, &r.node) { (&hir::ExprLit(_), _) => (l, r, true), @@ -374,7 +374,7 @@ enum FfiResult { /// to function pointers and references, but could be /// expanded to cover NonZero raw pointers and newtypes. /// FIXME: This duplicates code in trans. -fn is_repr_nullable_ptr<'tcx>(tcx: &ty::ctxt<'tcx>, +fn is_repr_nullable_ptr<'tcx>(tcx: &TyCtxt<'tcx>, def: ty::AdtDef<'tcx>, substs: &Substs<'tcx>) -> bool { @@ -400,7 +400,7 @@ fn is_repr_nullable_ptr<'tcx>(tcx: &ty::ctxt<'tcx>, false } -fn ast_ty_to_normalized<'tcx>(tcx: &ty::ctxt<'tcx>, +fn ast_ty_to_normalized<'tcx>(tcx: &TyCtxt<'tcx>, id: ast::NodeId) -> Ty<'tcx> { let tty = match tcx.ast_ty_to_ty_cache.borrow().get(&id) { diff --git a/src/librustc_metadata/astencode.rs b/src/librustc_metadata/astencode.rs index ff14652477eaa..d43a9f4dcda58 100644 --- a/src/librustc_metadata/astencode.rs +++ b/src/librustc_metadata/astencode.rs @@ -34,7 +34,7 @@ use middle::def::{self, Def}; use middle::def_id::DefId; use middle::region; use middle::subst; -use middle::ty::{self, Ty}; +use middle::ty::{self, Ty, TyCtxt}; use syntax::{ast, ast_util, codemap}; use syntax::ast::NodeIdAssigner; @@ -59,7 +59,7 @@ use serialize::EncoderHelpers; #[cfg(test)] use rustc_front::lowering::{lower_item, LoweringContext}; struct DecodeContext<'a, 'b, 'tcx: 'a> { - tcx: &'a ty::ctxt<'tcx>, + tcx: &'a TyCtxt<'tcx>, cdata: &'b cstore::crate_metadata, from_id_range: ast_util::IdRange, to_id_range: ast_util::IdRange, @@ -122,7 +122,7 @@ impl<'a, 'b, 'c, 'tcx> ast_map::FoldOps for &'a DecodeContext<'b, 'c, 'tcx> { /// Decodes an item from its AST in the cdata's metadata and adds it to the /// ast-map. pub fn decode_inlined_item<'tcx>(cdata: &cstore::crate_metadata, - tcx: &ty::ctxt<'tcx>, + tcx: &TyCtxt<'tcx>, parent_path: Vec, parent_def_path: ast_map::DefPath, par_doc: rbml::Doc, @@ -878,18 +878,18 @@ trait rbml_decoder_decoder_helpers<'tcx> { // Versions of the type reading functions that don't need the full // DecodeContext. fn read_ty_nodcx(&mut self, - tcx: &ty::ctxt<'tcx>, cdata: &cstore::crate_metadata) -> Ty<'tcx>; + tcx: &TyCtxt<'tcx>, cdata: &cstore::crate_metadata) -> Ty<'tcx>; fn read_tys_nodcx(&mut self, - tcx: &ty::ctxt<'tcx>, + tcx: &TyCtxt<'tcx>, cdata: &cstore::crate_metadata) -> Vec>; - fn read_substs_nodcx(&mut self, tcx: &ty::ctxt<'tcx>, + fn read_substs_nodcx(&mut self, tcx: &TyCtxt<'tcx>, cdata: &cstore::crate_metadata) -> subst::Substs<'tcx>; } impl<'a, 'tcx> rbml_decoder_decoder_helpers<'tcx> for reader::Decoder<'a> { fn read_ty_nodcx(&mut self, - tcx: &ty::ctxt<'tcx>, + tcx: &TyCtxt<'tcx>, cdata: &cstore::crate_metadata) -> Ty<'tcx> { self.read_opaque(|_, doc| { @@ -901,7 +901,7 @@ impl<'a, 'tcx> rbml_decoder_decoder_helpers<'tcx> for reader::Decoder<'a> { } fn read_tys_nodcx(&mut self, - tcx: &ty::ctxt<'tcx>, + tcx: &TyCtxt<'tcx>, cdata: &cstore::crate_metadata) -> Vec> { self.read_to_vec(|this| Ok(this.read_ty_nodcx(tcx, cdata)) ) .unwrap() @@ -910,7 +910,7 @@ impl<'a, 'tcx> rbml_decoder_decoder_helpers<'tcx> for reader::Decoder<'a> { } fn read_substs_nodcx(&mut self, - tcx: &ty::ctxt<'tcx>, + tcx: &TyCtxt<'tcx>, cdata: &cstore::crate_metadata) -> subst::Substs<'tcx> { diff --git a/src/librustc_metadata/csearch.rs b/src/librustc_metadata/csearch.rs index 9b534df075bef..63db3d3c870e6 100644 --- a/src/librustc_metadata/csearch.rs +++ b/src/librustc_metadata/csearch.rs @@ -18,7 +18,7 @@ use middle::cstore::{CrateStore, CrateSource, ChildItem, FoundAst}; use middle::cstore::{NativeLibraryKind, LinkMeta, LinkagePreference}; use middle::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 rustc::front::map as hir_map; @@ -49,14 +49,14 @@ impl<'tcx> CrateStore<'tcx> for cstore::CStore { decoder::get_deprecation(&cdata, def.index) } - fn closure_kind(&self, _tcx: &ty::ctxt<'tcx>, def_id: DefId) -> ty::ClosureKind + fn closure_kind(&self, _tcx: &TyCtxt<'tcx>, def_id: DefId) -> ty::ClosureKind { assert!(!def_id.is_local()); let cdata = self.get_crate_data(def_id.krate); decoder::closure_kind(&cdata, def_id.index) } - fn closure_ty(&self, tcx: &ty::ctxt<'tcx>, def_id: DefId) -> ty::ClosureTy<'tcx> + fn closure_ty(&self, tcx: &TyCtxt<'tcx>, def_id: DefId) -> ty::ClosureTy<'tcx> { assert!(!def_id.is_local()); let cdata = self.get_crate_data(def_id.krate); @@ -73,21 +73,21 @@ impl<'tcx> CrateStore<'tcx> for cstore::CStore { decoder::get_repr_attrs(&cdata, def.index) } - fn item_type(&self, tcx: &ty::ctxt<'tcx>, def: DefId) + fn item_type(&self, tcx: &TyCtxt<'tcx>, def: DefId) -> ty::TypeScheme<'tcx> { let cdata = self.get_crate_data(def.krate); decoder::get_type(&cdata, def.index, tcx) } - fn item_predicates(&self, tcx: &ty::ctxt<'tcx>, def: DefId) + fn item_predicates(&self, tcx: &TyCtxt<'tcx>, def: DefId) -> ty::GenericPredicates<'tcx> { let cdata = self.get_crate_data(def.krate); decoder::get_predicates(&cdata, def.index, 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> { let cdata = self.get_crate_data(def.krate); @@ -106,13 +106,13 @@ impl<'tcx> CrateStore<'tcx> for cstore::CStore { decoder::get_symbol(&cdata, def.index) } - 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> { let cdata = self.get_crate_data(def.krate); decoder::get_trait_def(&cdata, def.index, tcx) } - 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> { let cdata = self.get_crate_data(def.krate); decoder::get_adt_def(&self.intr, &cdata, def.index, tcx) @@ -173,7 +173,7 @@ impl<'tcx> CrateStore<'tcx> for cstore::CStore { result } - fn provided_trait_methods(&self, tcx: &ty::ctxt<'tcx>, def: DefId) + fn provided_trait_methods(&self, tcx: &TyCtxt<'tcx>, def: DefId) -> Vec>> { let cdata = self.get_crate_data(def.krate); @@ -199,7 +199,7 @@ impl<'tcx> CrateStore<'tcx> for cstore::CStore { decoder::get_impl_polarity(&cdata, def.index) } - fn impl_trait_ref(&self, tcx: &ty::ctxt<'tcx>, def: DefId) + fn impl_trait_ref(&self, tcx: &TyCtxt<'tcx>, def: DefId) -> Option> { let cdata = self.get_crate_data(def.krate); @@ -214,19 +214,19 @@ impl<'tcx> CrateStore<'tcx> for cstore::CStore { } // FIXME: killme - fn associated_consts(&self, tcx: &ty::ctxt<'tcx>, def: DefId) + fn associated_consts(&self, tcx: &TyCtxt<'tcx>, def: DefId) -> Vec>> { let cdata = self.get_crate_data(def.krate); decoder::get_associated_consts(self.intr.clone(), &cdata, def.index, tcx) } - fn trait_of_item(&self, tcx: &ty::ctxt<'tcx>, def_id: DefId) -> Option + fn trait_of_item(&self, tcx: &TyCtxt<'tcx>, def_id: DefId) -> Option { let cdata = self.get_crate_data(def_id.krate); decoder::get_trait_of_item(&cdata, def_id.index, tcx) } - 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> { let cdata = self.get_crate_data(def.krate); @@ -260,7 +260,7 @@ impl<'tcx> CrateStore<'tcx> for cstore::CStore { decoder::is_default_impl(&cdata, impl_did.index) } - fn is_extern_item(&self, tcx: &ty::ctxt<'tcx>, did: DefId) -> bool { + fn is_extern_item(&self, tcx: &TyCtxt<'tcx>, did: DefId) -> bool { let cdata = self.get_crate_data(did.krate); decoder::is_extern_item(&cdata, did.index, tcx) } @@ -425,7 +425,7 @@ impl<'tcx> CrateStore<'tcx> for cstore::CStore { result } - 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> { let cdata = self.get_crate_data(def.krate); @@ -433,7 +433,7 @@ impl<'tcx> CrateStore<'tcx> for cstore::CStore { decoder::maybe_get_item_ast(&cdata, tcx, def.index, decode_inlined_item) } - fn maybe_get_item_mir(&self, tcx: &ty::ctxt<'tcx>, def: DefId) + fn maybe_get_item_mir(&self, tcx: &TyCtxt<'tcx>, def: DefId) -> Option> { let cdata = self.get_crate_data(def.krate); decoder::maybe_get_item_mir(&cdata, tcx, def.index) @@ -470,7 +470,7 @@ impl<'tcx> CrateStore<'tcx> for cstore::CStore { { loader::meta_section_name(target) } - fn encode_type(&self, tcx: &ty::ctxt<'tcx>, ty: Ty<'tcx>) -> Vec + fn encode_type(&self, tcx: &TyCtxt<'tcx>, ty: Ty<'tcx>) -> Vec { encoder::encoded_ty(tcx, ty) } @@ -491,7 +491,7 @@ impl<'tcx> CrateStore<'tcx> for cstore::CStore { } fn encode_metadata(&self, - tcx: &ty::ctxt<'tcx>, + tcx: &TyCtxt<'tcx>, reexports: &def::ExportMap, item_symbols: &RefCell>, link_meta: &LinkMeta, diff --git a/src/librustc_metadata/decoder.rs b/src/librustc_metadata/decoder.rs index bce83d33f9ffe..e286e028f3330 100644 --- a/src/librustc_metadata/decoder.rs +++ b/src/librustc_metadata/decoder.rs @@ -33,7 +33,7 @@ use middle::def_id::{DefId, DefIndex}; use middle::lang_items; use middle::subst; use middle::ty::{ImplContainer, TraitContainer}; -use middle::ty::{self, Ty, TypeFoldable, VariantKind}; +use middle::ty::{self, Ty, TyCtxt, TypeFoldable, VariantKind}; use rustc::mir; use rustc::mir::visit::MutVisitor; @@ -206,14 +206,14 @@ fn variant_disr_val(d: rbml::Doc) -> Option { }) } -fn doc_type<'tcx>(doc: rbml::Doc, tcx: &ty::ctxt<'tcx>, cdata: Cmd) -> Ty<'tcx> { +fn doc_type<'tcx>(doc: rbml::Doc, tcx: &TyCtxt<'tcx>, cdata: Cmd) -> Ty<'tcx> { let tp = reader::get_doc(doc, tag_items_data_item_type); TyDecoder::with_doc(tcx, cdata.cnum, tp, &mut |did| translate_def_id(cdata, did)) .parse_ty() } -fn maybe_doc_type<'tcx>(doc: rbml::Doc, tcx: &ty::ctxt<'tcx>, cdata: Cmd) -> Option> { +fn maybe_doc_type<'tcx>(doc: rbml::Doc, tcx: &TyCtxt<'tcx>, cdata: Cmd) -> Option> { reader::maybe_get_doc(doc, tag_items_data_item_type).map(|tp| { TyDecoder::with_doc(tcx, cdata.cnum, tp, &mut |did| translate_def_id(cdata, did)) @@ -222,18 +222,18 @@ fn maybe_doc_type<'tcx>(doc: rbml::Doc, tcx: &ty::ctxt<'tcx>, cdata: Cmd) -> Opt } pub fn item_type<'tcx>(_item_id: DefId, item: rbml::Doc, - tcx: &ty::ctxt<'tcx>, cdata: Cmd) -> Ty<'tcx> { + tcx: &TyCtxt<'tcx>, cdata: Cmd) -> Ty<'tcx> { doc_type(item, tcx, cdata) } -fn doc_trait_ref<'tcx>(doc: rbml::Doc, tcx: &ty::ctxt<'tcx>, cdata: Cmd) +fn doc_trait_ref<'tcx>(doc: rbml::Doc, tcx: &TyCtxt<'tcx>, cdata: Cmd) -> ty::TraitRef<'tcx> { TyDecoder::with_doc(tcx, cdata.cnum, doc, &mut |did| translate_def_id(cdata, did)) .parse_trait_ref() } -fn item_trait_ref<'tcx>(doc: rbml::Doc, tcx: &ty::ctxt<'tcx>, cdata: Cmd) +fn item_trait_ref<'tcx>(doc: rbml::Doc, tcx: &TyCtxt<'tcx>, cdata: Cmd) -> ty::TraitRef<'tcx> { let tp = reader::get_doc(doc, tag_item_trait_ref); doc_trait_ref(tp, tcx, cdata) @@ -351,7 +351,7 @@ fn parse_associated_type_names(item_doc: rbml::Doc) -> Vec { pub fn get_trait_def<'tcx>(cdata: Cmd, item_id: DefIndex, - tcx: &ty::ctxt<'tcx>) -> ty::TraitDef<'tcx> + tcx: &TyCtxt<'tcx>) -> ty::TraitDef<'tcx> { let item_doc = cdata.lookup_item(item_id); let generics = doc_generics(item_doc, tcx, cdata, tag_item_generics); @@ -369,9 +369,9 @@ pub fn get_trait_def<'tcx>(cdata: Cmd, pub fn get_adt_def<'tcx>(intr: &IdentInterner, cdata: Cmd, item_id: DefIndex, - tcx: &ty::ctxt<'tcx>) -> ty::AdtDefMaster<'tcx> + tcx: &TyCtxt<'tcx>) -> ty::AdtDefMaster<'tcx> { - fn expect_variant_kind<'tcx>(family: Family, tcx: &ty::ctxt<'tcx>) -> ty::VariantKind { + fn expect_variant_kind<'tcx>(family: Family, tcx: &TyCtxt<'tcx>) -> ty::VariantKind { match family_to_variant_kind(family) { Some(kind) => kind, _ => tcx.sess.bug(&format!("unexpected family: {:?}", family)), @@ -380,7 +380,7 @@ pub fn get_adt_def<'tcx>(intr: &IdentInterner, fn get_enum_variants<'tcx>(intr: &IdentInterner, cdata: Cmd, doc: rbml::Doc, - tcx: &ty::ctxt<'tcx>) -> Vec> { + tcx: &TyCtxt<'tcx>) -> Vec> { let mut disr_val = 0; reader::tagged_docs(doc, tag_items_data_item_variant).map(|p| { let did = translated_def_id(cdata, p); @@ -404,7 +404,7 @@ pub fn get_adt_def<'tcx>(intr: &IdentInterner, fn get_variant_fields<'tcx>(intr: &IdentInterner, cdata: Cmd, doc: rbml::Doc, - tcx: &ty::ctxt<'tcx>) -> Vec> { + tcx: &TyCtxt<'tcx>) -> Vec> { let mut index = 0; reader::tagged_docs(doc, tag_item_field).map(|f| { let ff = item_family(f); @@ -427,7 +427,7 @@ pub fn get_adt_def<'tcx>(intr: &IdentInterner, cdata: Cmd, doc: rbml::Doc, did: DefId, - tcx: &ty::ctxt<'tcx>) -> ty::VariantDefData<'tcx, 'tcx> { + tcx: &TyCtxt<'tcx>) -> ty::VariantDefData<'tcx, 'tcx> { ty::VariantDefData { did: did, name: item_name(intr, doc), @@ -500,7 +500,7 @@ pub fn get_adt_def<'tcx>(intr: &IdentInterner, pub fn get_predicates<'tcx>(cdata: Cmd, item_id: DefIndex, - tcx: &ty::ctxt<'tcx>) + tcx: &TyCtxt<'tcx>) -> ty::GenericPredicates<'tcx> { let item_doc = cdata.lookup_item(item_id); @@ -509,14 +509,14 @@ pub fn get_predicates<'tcx>(cdata: Cmd, pub fn get_super_predicates<'tcx>(cdata: Cmd, item_id: DefIndex, - tcx: &ty::ctxt<'tcx>) + tcx: &TyCtxt<'tcx>) -> ty::GenericPredicates<'tcx> { let item_doc = cdata.lookup_item(item_id); doc_predicates(item_doc, tcx, cdata, tag_item_super_predicates) } -pub fn get_type<'tcx>(cdata: Cmd, id: DefIndex, tcx: &ty::ctxt<'tcx>) +pub fn get_type<'tcx>(cdata: Cmd, id: DefIndex, tcx: &TyCtxt<'tcx>) -> ty::TypeScheme<'tcx> { let item_doc = cdata.lookup_item(id); @@ -584,7 +584,7 @@ pub fn get_custom_coerce_unsized_kind<'tcx>( pub fn get_impl_trait<'tcx>(cdata: Cmd, id: DefIndex, - tcx: &ty::ctxt<'tcx>) + tcx: &TyCtxt<'tcx>) -> Option> { let item_doc = cdata.lookup_item(id); @@ -773,7 +773,7 @@ pub fn get_item_name(intr: &IdentInterner, cdata: Cmd, id: DefIndex) -> ast::Nam pub type DecodeInlinedItem<'a> = Box FnMut(Cmd, - &ty::ctxt<'tcx>, + &TyCtxt<'tcx>, Vec, // parent_path hir_map::DefPath, // parent_def_path rbml::Doc, @@ -782,7 +782,7 @@ pub type DecodeInlinedItem<'a> = hir_map::DefPath)> + 'a>; pub fn maybe_get_item_ast<'tcx>(cdata: Cmd, - tcx: &ty::ctxt<'tcx>, + tcx: &TyCtxt<'tcx>, id: DefIndex, mut decode_inlined_item: DecodeInlinedItem) -> FoundAst<'tcx> { @@ -840,7 +840,7 @@ pub fn is_item_mir_available<'tcx>(cdata: Cmd, id: DefIndex) -> bool { } pub fn maybe_get_item_mir<'tcx>(cdata: Cmd, - tcx: &ty::ctxt<'tcx>, + tcx: &TyCtxt<'tcx>, id: DefIndex) -> Option> { let item_doc = cdata.lookup_item(id); @@ -955,7 +955,7 @@ pub fn is_static_method(cdata: Cmd, id: DefIndex) -> bool { pub fn get_impl_or_trait_item<'tcx>(intr: Rc, cdata: Cmd, id: DefIndex, - tcx: &ty::ctxt<'tcx>) + tcx: &TyCtxt<'tcx>) -> ty::ImplOrTraitItem<'tcx> { let item_doc = cdata.lookup_item(id); @@ -1042,7 +1042,7 @@ pub fn get_item_variances(cdata: Cmd, id: DefIndex) -> ty::ItemVariances { pub fn get_provided_trait_methods<'tcx>(intr: Rc, cdata: Cmd, id: DefIndex, - tcx: &ty::ctxt<'tcx>) + tcx: &TyCtxt<'tcx>) -> Vec>> { let item = cdata.lookup_item(id); @@ -1069,7 +1069,7 @@ pub fn get_provided_trait_methods<'tcx>(intr: Rc, pub fn get_associated_consts<'tcx>(intr: Rc, cdata: Cmd, id: DefIndex, - tcx: &ty::ctxt<'tcx>) + tcx: &TyCtxt<'tcx>) -> Vec>> { let item = cdata.lookup_item(id); @@ -1436,7 +1436,7 @@ pub fn each_implementation_for_trait(cdata: Cmd, } } -pub fn get_trait_of_item(cdata: Cmd, id: DefIndex, tcx: &ty::ctxt) +pub fn get_trait_of_item(cdata: Cmd, id: DefIndex, tcx: &TyCtxt) -> Option { let item_doc = cdata.lookup_item(id); let parent_item_id = match item_parent_item(cdata, item_doc) { @@ -1571,7 +1571,7 @@ pub fn is_const_fn(cdata: Cmd, id: DefIndex) -> bool { } } -pub fn is_extern_item(cdata: Cmd, id: DefIndex, tcx: &ty::ctxt) -> bool { +pub fn is_extern_item(cdata: Cmd, id: DefIndex, tcx: &TyCtxt) -> bool { let item_doc = match cdata.get_item(id) { Some(doc) => doc, None => return false, @@ -1606,7 +1606,7 @@ pub fn is_impl(cdata: Cmd, id: DefIndex) -> bool { } fn doc_generics<'tcx>(base_doc: rbml::Doc, - tcx: &ty::ctxt<'tcx>, + tcx: &TyCtxt<'tcx>, cdata: Cmd, tag: usize) -> ty::Generics<'tcx> @@ -1655,7 +1655,7 @@ fn doc_generics<'tcx>(base_doc: rbml::Doc, fn doc_predicate<'tcx>(cdata: Cmd, doc: rbml::Doc, - tcx: &ty::ctxt<'tcx>) + tcx: &TyCtxt<'tcx>) -> ty::Predicate<'tcx> { let predicate_pos = cdata.xref_index.lookup( @@ -1667,7 +1667,7 @@ fn doc_predicate<'tcx>(cdata: Cmd, } fn doc_predicates<'tcx>(base_doc: rbml::Doc, - tcx: &ty::ctxt<'tcx>, + tcx: &TyCtxt<'tcx>, cdata: Cmd, tag: usize) -> ty::GenericPredicates<'tcx> @@ -1722,7 +1722,7 @@ pub fn closure_kind(cdata: Cmd, closure_id: DefIndex) -> ty::ClosureKind { ty::ClosureKind::decode(&mut decoder).unwrap() } -pub fn closure_ty<'tcx>(cdata: Cmd, closure_id: DefIndex, tcx: &ty::ctxt<'tcx>) +pub fn closure_ty<'tcx>(cdata: Cmd, closure_id: DefIndex, tcx: &TyCtxt<'tcx>) -> ty::ClosureTy<'tcx> { let closure_doc = cdata.lookup_item(closure_id); let closure_ty_doc = reader::get_doc(closure_doc, tag_items_closure_ty); diff --git a/src/librustc_metadata/encoder.rs b/src/librustc_metadata/encoder.rs index 8aee6a9a83a08..1d1cd38225522 100644 --- a/src/librustc_metadata/encoder.rs +++ b/src/librustc_metadata/encoder.rs @@ -25,7 +25,7 @@ use middle::def_id::{CRATE_DEF_INDEX, DefId}; use middle::dependency_format::Linkage; use middle::stability; use middle::subst; -use middle::ty::{self, Ty}; +use middle::ty::{self, Ty, TyCtxt}; use rustc::back::svh::Svh; use rustc::front::map::{LinkedPath, PathElem, PathElems}; @@ -58,7 +58,7 @@ pub type EncodeInlinedItem<'a> = pub struct EncodeParams<'a, 'tcx: 'a> { pub diag: &'a Handler, - pub tcx: &'a ty::ctxt<'tcx>, + pub tcx: &'a TyCtxt<'tcx>, pub reexports: &'a def::ExportMap, pub item_symbols: &'a RefCell>, pub link_meta: &'a LinkMeta, @@ -70,7 +70,7 @@ pub struct EncodeParams<'a, 'tcx: 'a> { pub struct EncodeContext<'a, 'tcx: 'a> { pub diag: &'a Handler, - pub tcx: &'a ty::ctxt<'tcx>, + pub tcx: &'a TyCtxt<'tcx>, pub reexports: &'a def::ExportMap, pub item_symbols: &'a RefCell>, pub link_meta: &'a LinkMeta, @@ -1766,7 +1766,7 @@ fn encode_struct_field_attrs(ecx: &EncodeContext, struct ImplVisitor<'a, 'tcx:'a> { - tcx: &'a ty::ctxt<'tcx>, + tcx: &'a TyCtxt<'tcx>, impls: FnvHashMap> } @@ -2093,7 +2093,7 @@ fn encode_metadata_inner(rbml_w: &mut Encoder, } // Get the encoded string for a type -pub fn encoded_ty<'tcx>(tcx: &ty::ctxt<'tcx>, t: Ty<'tcx>) -> Vec { +pub fn encoded_ty<'tcx>(tcx: &TyCtxt<'tcx>, t: Ty<'tcx>) -> Vec { let mut wr = Cursor::new(Vec::new()); tyencode::enc_ty(&mut wr, &tyencode::ctxt { diag: tcx.sess.diagnostic(), diff --git a/src/librustc_metadata/tls_context.rs b/src/librustc_metadata/tls_context.rs index 37e661c21e15a..f90abd9e1d961 100644 --- a/src/librustc_metadata/tls_context.rs +++ b/src/librustc_metadata/tls_context.rs @@ -16,7 +16,7 @@ use rbml::opaque::Decoder as OpaqueDecoder; use rustc::middle::cstore::tls; use rustc::middle::def_id::DefId; use rustc::middle::subst::Substs; -use rustc::middle::ty; +use rustc::middle::ty::{self, TyCtxt}; use decoder::{self, Cmd}; use encoder; @@ -25,7 +25,7 @@ use tyencode; impl<'a, 'tcx: 'a> tls::EncodingContext<'tcx> for encoder::EncodeContext<'a, 'tcx> { - fn tcx<'s>(&'s self) -> &'s ty::ctxt<'tcx> { + fn tcx<'s>(&'s self) -> &'s TyCtxt<'tcx> { &self.tcx } @@ -40,12 +40,12 @@ impl<'a, 'tcx: 'a> tls::EncodingContext<'tcx> for encoder::EncodeContext<'a, 'tc pub struct DecodingContext<'a, 'tcx: 'a> { pub crate_metadata: Cmd<'a>, - pub tcx: &'a ty::ctxt<'tcx>, + pub tcx: &'a TyCtxt<'tcx>, } impl<'a, 'tcx: 'a> tls::DecodingContext<'tcx> for DecodingContext<'a, 'tcx> { - fn tcx<'s>(&'s self) -> &'s ty::ctxt<'tcx> { + fn tcx<'s>(&'s self) -> &'s TyCtxt<'tcx> { &self.tcx } diff --git a/src/librustc_metadata/tydecode.rs b/src/librustc_metadata/tydecode.rs index 5a48d6019d699..bf5a97232fcc7 100644 --- a/src/librustc_metadata/tydecode.rs +++ b/src/librustc_metadata/tydecode.rs @@ -22,7 +22,7 @@ use middle::def_id::{DefId, DefIndex}; use middle::region; use middle::subst; use middle::subst::VecPerParamSpace; -use middle::ty::{self, ToPredicate, Ty, TypeFoldable}; +use middle::ty::{self, ToPredicate, Ty, TyCtxt, TypeFoldable}; use rbml; use rbml::leb128; @@ -41,12 +41,12 @@ pub struct TyDecoder<'a, 'tcx: 'a> { data: &'a [u8], krate: ast::CrateNum, pos: usize, - tcx: &'a ty::ctxt<'tcx>, + tcx: &'a TyCtxt<'tcx>, conv_def_id: DefIdConvert<'a>, } impl<'a,'tcx> TyDecoder<'a,'tcx> { - pub fn with_doc(tcx: &'a ty::ctxt<'tcx>, + pub fn with_doc(tcx: &'a TyCtxt<'tcx>, crate_num: ast::CrateNum, doc: rbml::Doc<'a>, conv: DefIdConvert<'a>) @@ -57,7 +57,7 @@ impl<'a,'tcx> TyDecoder<'a,'tcx> { pub fn new(data: &'a [u8], crate_num: ast::CrateNum, pos: usize, - tcx: &'a ty::ctxt<'tcx>, + tcx: &'a TyCtxt<'tcx>, conv: DefIdConvert<'a>) -> TyDecoder<'a, 'tcx> { TyDecoder { diff --git a/src/librustc_metadata/tyencode.rs b/src/librustc_metadata/tyencode.rs index b41ff5977fef1..7289cd2b5b3b8 100644 --- a/src/librustc_metadata/tyencode.rs +++ b/src/librustc_metadata/tyencode.rs @@ -22,7 +22,7 @@ use middle::region; use middle::subst; use middle::subst::VecPerParamSpace; use middle::ty::ParamTy; -use middle::ty::{self, Ty}; +use middle::ty::{self, Ty, TyCtxt}; use rustc::util::nodemap::FnvHashMap; use rustc_front::hir; @@ -39,7 +39,7 @@ pub struct ctxt<'a, 'tcx: 'a> { // Def -> str Callback: pub ds: fn(DefId) -> String, // The type context. - pub tcx: &'a ty::ctxt<'tcx>, + pub tcx: &'a TyCtxt<'tcx>, pub abbrevs: &'a abbrev_map<'tcx> } diff --git a/src/librustc_mir/build/scope.rs b/src/librustc_mir/build/scope.rs index a738663bf8cc5..6b1b3a33d3d79 100644 --- a/src/librustc_mir/build/scope.rs +++ b/src/librustc_mir/build/scope.rs @@ -90,7 +90,7 @@ use build::{BlockAnd, BlockAndExtension, Builder, CFG}; use rustc::middle::region::CodeExtent; use rustc::middle::lang_items; use rustc::middle::subst::{Substs, Subst, VecPerParamSpace}; -use rustc::middle::ty::{self, Ty}; +use rustc::middle::ty::{self, Ty, TyCtxt}; use rustc::mir::repr::*; use syntax::codemap::{Span, DUMMY_SP}; use syntax::parse::token::intern_and_get_ident; @@ -551,7 +551,7 @@ fn build_scope_drops<'tcx>(cfg: &mut CFG<'tcx>, block.unit() } -fn build_diverge_scope<'tcx>(tcx: &ty::ctxt<'tcx>, +fn build_diverge_scope<'tcx>(tcx: &TyCtxt<'tcx>, cfg: &mut CFG<'tcx>, unit_temp: Lvalue<'tcx>, scope: &mut Scope<'tcx>, @@ -625,7 +625,7 @@ fn build_diverge_scope<'tcx>(tcx: &ty::ctxt<'tcx>, } } -fn build_free<'tcx>(tcx: &ty::ctxt<'tcx>, +fn build_free<'tcx>(tcx: &TyCtxt<'tcx>, unit_temp: Lvalue<'tcx>, data: &FreeData<'tcx>, target: BasicBlock) -> Terminator<'tcx> { diff --git a/src/librustc_mir/hair/cx/mod.rs b/src/librustc_mir/hair/cx/mod.rs index 7019b40bb2521..f1b74ca1288f3 100644 --- a/src/librustc_mir/hair/cx/mod.rs +++ b/src/librustc_mir/hair/cx/mod.rs @@ -20,14 +20,14 @@ use rustc::mir::repr::*; use rustc::middle::const_eval::{self, ConstVal}; use rustc::middle::infer::InferCtxt; -use rustc::middle::ty::{self, Ty}; +use rustc::middle::ty::{self, Ty, TyCtxt}; use syntax::codemap::Span; use syntax::parse::token; use rustc_front::hir; #[derive(Copy, Clone)] pub struct Cx<'a, 'tcx: 'a> { - tcx: &'a ty::ctxt<'tcx>, + tcx: &'a TyCtxt<'tcx>, infcx: &'a InferCtxt<'a, 'tcx>, } @@ -103,7 +103,7 @@ impl<'a,'tcx:'a> Cx<'a, 'tcx> { self.tcx.sess.span_bug(span, message) } - pub fn tcx(&self) -> &'a ty::ctxt<'tcx> { + pub fn tcx(&self) -> &'a TyCtxt<'tcx> { self.tcx } } diff --git a/src/librustc_mir/mir_map.rs b/src/librustc_mir/mir_map.rs index 70c3354012135..96828628888be 100644 --- a/src/librustc_mir/mir_map.rs +++ b/src/librustc_mir/mir_map.rs @@ -33,7 +33,7 @@ use rustc::mir::transform::MirPass; use rustc::mir::mir_map::MirMap; use rustc::middle::infer; use rustc::middle::region::CodeExtentData; -use rustc::middle::ty::{self, Ty}; +use rustc::middle::ty::{self, Ty, TyCtxt}; use rustc::util::common::ErrorReported; use rustc::util::nodemap::NodeMap; use rustc_front::hir; @@ -42,7 +42,7 @@ use syntax::ast; use syntax::attr::AttrMetaMethods; use syntax::codemap::Span; -pub fn build_mir_for_crate<'tcx>(tcx: &ty::ctxt<'tcx>) -> MirMap<'tcx> { +pub fn build_mir_for_crate<'tcx>(tcx: &TyCtxt<'tcx>) -> MirMap<'tcx> { let mut map = MirMap { map: NodeMap(), }; @@ -60,7 +60,7 @@ pub fn build_mir_for_crate<'tcx>(tcx: &ty::ctxt<'tcx>) -> MirMap<'tcx> { // OuterDump -- walks a crate, looking for fn items and methods to build MIR from struct OuterDump<'a, 'tcx: 'a> { - tcx: &'a ty::ctxt<'tcx>, + tcx: &'a TyCtxt<'tcx>, map: &'a mut MirMap<'tcx>, } @@ -116,7 +116,7 @@ impl<'a, 'tcx> Visitor<'tcx> for OuterDump<'a, 'tcx> { // InnerDump -- dumps MIR for a single fn and its contained closures struct InnerDump<'a, 'm, 'tcx: 'a + 'm> { - tcx: &'a ty::ctxt<'tcx>, + tcx: &'a TyCtxt<'tcx>, map: &'m mut MirMap<'tcx>, attr: Option<&'a ast::Attribute>, } @@ -236,7 +236,7 @@ fn build_mir<'a,'tcx:'a>(cx: Cx<'a,'tcx>, body)) } -fn closure_self_ty<'a, 'tcx>(tcx: &ty::ctxt<'tcx>, +fn closure_self_ty<'a, 'tcx>(tcx: &TyCtxt<'tcx>, closure_expr_id: ast::NodeId, body_id: ast::NodeId) -> Ty<'tcx> { diff --git a/src/librustc_mir/transform/erase_regions.rs b/src/librustc_mir/transform/erase_regions.rs index a82d1fc53991f..53d88709add9d 100644 --- a/src/librustc_mir/transform/erase_regions.rs +++ b/src/librustc_mir/transform/erase_regions.rs @@ -12,23 +12,23 @@ //! We want to do this once just before trans, so trans does not have to take //! care erasing regions all over the place. -use rustc::middle::ty; +use rustc::middle::ty::{self, TyCtxt}; use rustc::mir::repr::*; use rustc::mir::visit::MutVisitor; use rustc::mir::mir_map::MirMap; -pub fn erase_regions<'tcx>(tcx: &ty::ctxt<'tcx>, mir_map: &mut MirMap<'tcx>) { +pub fn erase_regions<'tcx>(tcx: &TyCtxt<'tcx>, mir_map: &mut MirMap<'tcx>) { for (_, mir) in &mut mir_map.map { EraseRegionsVisitor::new(tcx).visit_mir(mir); } } struct EraseRegionsVisitor<'a, 'tcx: 'a> { - tcx: &'a ty::ctxt<'tcx>, + tcx: &'a TyCtxt<'tcx>, } impl<'a, 'tcx> EraseRegionsVisitor<'a, 'tcx> { - pub fn new(tcx: &'a ty::ctxt<'tcx>) -> Self { + pub fn new(tcx: &'a TyCtxt<'tcx>) -> Self { EraseRegionsVisitor { tcx: tcx } diff --git a/src/librustc_mir/transform/type_check.rs b/src/librustc_mir/transform/type_check.rs index 0e97e3629064b..bf22c7b0b8b34 100644 --- a/src/librustc_mir/transform/type_check.rs +++ b/src/librustc_mir/transform/type_check.rs @@ -13,7 +13,7 @@ use rustc::middle::infer::{self, InferCtxt}; use rustc::middle::traits; -use rustc::middle::ty::{self, Ty}; +use rustc::middle::ty::{self, Ty, TyCtxt}; use rustc::middle::ty::fold::TypeFoldable; use rustc::mir::repr::*; use rustc::mir::tcx::LvalueTy; @@ -113,7 +113,7 @@ impl<'a, 'b, 'tcx> TypeVerifier<'a, 'b, 'tcx> { } } - fn tcx(&self) -> &'a ty::ctxt<'tcx> { + fn tcx(&self) -> &'a TyCtxt<'tcx> { self.cx.infcx.tcx } @@ -346,7 +346,7 @@ impl<'a, 'tcx> TypeChecker<'a, 'tcx> { a, b) } - fn tcx(&self) -> &'a ty::ctxt<'tcx> { + fn tcx(&self) -> &'a TyCtxt<'tcx> { self.infcx.tcx } diff --git a/src/librustc_passes/consts.rs b/src/librustc_passes/consts.rs index b0d459063ef29..3703e602746c6 100644 --- a/src/librustc_passes/consts.rs +++ b/src/librustc_passes/consts.rs @@ -36,7 +36,7 @@ use rustc::middle::infer; use rustc::middle::mem_categorization as mc; use rustc::middle::mem_categorization::Categorization; use rustc::middle::traits; -use rustc::middle::ty::{self, Ty}; +use rustc::middle::ty::{self, Ty, TyCtxt}; use rustc::util::nodemap::NodeMap; use rustc::middle::const_qualif::ConstQualif; use rustc::lint::builtin::CONST_ERR; @@ -65,7 +65,7 @@ enum Mode { } struct CheckCrateVisitor<'a, 'tcx: 'a> { - tcx: &'a ty::ctxt<'tcx>, + tcx: &'a TyCtxt<'tcx>, mode: Mode, qualif: ConstQualif, rvalue_borrows: NodeMap @@ -788,7 +788,7 @@ fn check_adjustments<'a, 'tcx>(v: &mut CheckCrateVisitor<'a, 'tcx>, e: &hir::Exp } } -pub fn check_crate(tcx: &ty::ctxt) { +pub fn check_crate(tcx: &TyCtxt) { tcx.visit_all_items_in_krate(DepNode::CheckConst, &mut CheckCrateVisitor { tcx: tcx, mode: Mode::Var, diff --git a/src/librustc_passes/rvalues.rs b/src/librustc_passes/rvalues.rs index f5cc020932b63..7eef69ca50fd0 100644 --- a/src/librustc_passes/rvalues.rs +++ b/src/librustc_passes/rvalues.rs @@ -15,20 +15,20 @@ use rustc::dep_graph::DepNode; use rustc::middle::expr_use_visitor as euv; use rustc::middle::infer; use rustc::middle::mem_categorization as mc; -use rustc::middle::ty::{self, ParameterEnvironment}; +use rustc::middle::ty::{self, TyCtxt, ParameterEnvironment}; use rustc_front::hir; use rustc_front::intravisit; use syntax::ast; use syntax::codemap::Span; -pub fn check_crate(tcx: &ty::ctxt) { +pub fn check_crate(tcx: &TyCtxt) { let mut rvcx = RvalueContext { tcx: tcx }; tcx.visit_all_items_in_krate(DepNode::RvalueCheck, &mut rvcx); } struct RvalueContext<'a, 'tcx: 'a> { - tcx: &'a ty::ctxt<'tcx>, + tcx: &'a TyCtxt<'tcx>, } impl<'a, 'tcx, 'v> intravisit::Visitor<'v> for RvalueContext<'a, 'tcx> { @@ -53,7 +53,7 @@ impl<'a, 'tcx, 'v> intravisit::Visitor<'v> for RvalueContext<'a, 'tcx> { } struct RvalueContextDelegate<'a, 'tcx: 'a> { - tcx: &'a ty::ctxt<'tcx>, + tcx: &'a TyCtxt<'tcx>, param_env: &'a ty::ParameterEnvironment<'a,'tcx>, } diff --git a/src/librustc_platform_intrinsics/aarch64.rs b/src/librustc_platform_intrinsics/aarch64.rs index fda65554cd2f2..ceab0ed30e719 100644 --- a/src/librustc_platform_intrinsics/aarch64.rs +++ b/src/librustc_platform_intrinsics/aarch64.rs @@ -15,12 +15,12 @@ use {Intrinsic, i, i_, u, u_, f, v, v_, agg, p, void}; use IntrinsicDef::Named; -use rustc::middle::ty; +use rustc::middle::ty::TyCtxt; // The default inlining settings trigger a pathological behaviour in // LLVM, which causes makes compilation very slow. See #28273. #[inline(never)] -pub fn find<'tcx>(_tcx: &ty::ctxt<'tcx>, name: &str) -> Option { +pub fn find<'tcx>(_tcx: &TyCtxt<'tcx>, name: &str) -> Option { if !name.starts_with("aarch64_v") { return None } Some(match &name["aarch64_v".len()..] { "hadd_s8" => Intrinsic { diff --git a/src/librustc_platform_intrinsics/arm.rs b/src/librustc_platform_intrinsics/arm.rs index 166bf66d819c7..916f267951b50 100644 --- a/src/librustc_platform_intrinsics/arm.rs +++ b/src/librustc_platform_intrinsics/arm.rs @@ -15,12 +15,12 @@ use {Intrinsic, i, i_, u, u_, f, v, v_, agg, p, void}; use IntrinsicDef::Named; -use rustc::middle::ty; +use rustc::middle::ty::TyCtxt; // The default inlining settings trigger a pathological behaviour in // LLVM, which causes makes compilation very slow. See #28273. #[inline(never)] -pub fn find<'tcx>(_tcx: &ty::ctxt<'tcx>, name: &str) -> Option { +pub fn find<'tcx>(_tcx: &TyCtxt<'tcx>, name: &str) -> Option { if !name.starts_with("arm_v") { return None } Some(match &name["arm_v".len()..] { "hadd_s8" => Intrinsic { diff --git a/src/librustc_platform_intrinsics/lib.rs b/src/librustc_platform_intrinsics/lib.rs index 6a43ef65d6a06..41d5c1a50bc92 100644 --- a/src/librustc_platform_intrinsics/lib.rs +++ b/src/librustc_platform_intrinsics/lib.rs @@ -18,7 +18,7 @@ extern crate rustc_llvm as llvm; extern crate rustc; -use rustc::middle::ty; +use rustc::middle::ty::TyCtxt; pub struct Intrinsic { pub inputs: Vec, @@ -66,7 +66,7 @@ mod arm; mod aarch64; impl Intrinsic { - pub fn find<'tcx>(tcx: &ty::ctxt<'tcx>, name: &str) -> Option { + pub fn find<'tcx>(tcx: &TyCtxt<'tcx>, name: &str) -> Option { if name.starts_with("x86_") { x86::find(tcx, name) } else if name.starts_with("arm_") { diff --git a/src/librustc_platform_intrinsics/x86.rs b/src/librustc_platform_intrinsics/x86.rs index 144fd5f4e761b..4a9b9970caf2d 100644 --- a/src/librustc_platform_intrinsics/x86.rs +++ b/src/librustc_platform_intrinsics/x86.rs @@ -15,12 +15,12 @@ use {Intrinsic, i, i_, u, u_, f, v, v_, agg, p, void}; use IntrinsicDef::Named; -use rustc::middle::ty; +use rustc::middle::ty::TyCtxt; // The default inlining settings trigger a pathological behaviour in // LLVM, which causes makes compilation very slow. See #28273. #[inline(never)] -pub fn find<'tcx>(_tcx: &ty::ctxt<'tcx>, name: &str) -> Option { +pub fn find<'tcx>(_tcx: &TyCtxt<'tcx>, name: &str) -> Option { if !name.starts_with("x86_mm") { return None } Some(match &name["x86_mm".len()..] { "_movemask_ps" => Intrinsic { diff --git a/src/librustc_privacy/lib.rs b/src/librustc_privacy/lib.rs index 098c77a1bde2f..782ac593f4411 100644 --- a/src/librustc_privacy/lib.rs +++ b/src/librustc_privacy/lib.rs @@ -42,7 +42,7 @@ use rustc::middle::def::{self, Def}; use rustc::middle::def_id::DefId; use rustc::middle::privacy::{AccessLevel, AccessLevels}; use rustc::middle::privacy::ExternalExports; -use rustc::middle::ty; +use rustc::middle::ty::{self, TyCtxt}; use rustc::util::nodemap::{NodeMap, NodeSet}; use rustc::front::map as ast_map; @@ -63,7 +63,7 @@ type CheckResult = Option<(Span, String, Option<(Span, String)>)>; //////////////////////////////////////////////////////////////////////////////// struct ParentVisitor<'a, 'tcx:'a> { - tcx: &'a ty::ctxt<'tcx>, + tcx: &'a TyCtxt<'tcx>, parents: NodeMap, curparent: ast::NodeId, } @@ -155,7 +155,7 @@ impl<'a, 'tcx, 'v> Visitor<'v> for ParentVisitor<'a, 'tcx> { //////////////////////////////////////////////////////////////////////////////// struct EmbargoVisitor<'a, 'tcx: 'a> { - tcx: &'a ty::ctxt<'tcx>, + tcx: &'a TyCtxt<'tcx>, export_map: &'a def::ExportMap, // Accessibility levels for reachable nodes @@ -472,7 +472,7 @@ impl<'b, 'a, 'tcx: 'a, 'v> Visitor<'v> for ReachEverythingInTheInterfaceVisitor< //////////////////////////////////////////////////////////////////////////////// struct PrivacyVisitor<'a, 'tcx: 'a> { - tcx: &'a ty::ctxt<'tcx>, + tcx: &'a TyCtxt<'tcx>, curitem: ast::NodeId, in_foreign: bool, parents: NodeMap, @@ -972,7 +972,7 @@ impl<'a, 'tcx, 'v> Visitor<'v> for PrivacyVisitor<'a, 'tcx> { //////////////////////////////////////////////////////////////////////////////// struct SanePrivacyVisitor<'a, 'tcx: 'a> { - tcx: &'a ty::ctxt<'tcx>, + tcx: &'a TyCtxt<'tcx>, } impl<'a, 'tcx, 'v> Visitor<'v> for SanePrivacyVisitor<'a, 'tcx> { @@ -1043,7 +1043,7 @@ impl<'a, 'tcx> SanePrivacyVisitor<'a, 'tcx> { /////////////////////////////////////////////////////////////////////////////// struct ObsoleteVisiblePrivateTypesVisitor<'a, 'tcx: 'a> { - tcx: &'a ty::ctxt<'tcx>, + tcx: &'a TyCtxt<'tcx>, access_levels: &'a AccessLevels, in_variant: bool, // set of errors produced by this obsolete visitor @@ -1382,7 +1382,7 @@ impl<'a, 'tcx, 'v> Visitor<'v> for ObsoleteVisiblePrivateTypesVisitor<'a, 'tcx> /////////////////////////////////////////////////////////////////////////////// struct SearchInterfaceForPrivateItemsVisitor<'a, 'tcx: 'a> { - tcx: &'a ty::ctxt<'tcx>, + tcx: &'a TyCtxt<'tcx>, // Do not report an error when a private type is found is_quiet: bool, // Is private component found? @@ -1513,7 +1513,7 @@ impl<'a, 'tcx: 'a, 'v> Visitor<'v> for SearchInterfaceForPrivateItemsVisitor<'a, } struct PrivateItemsInPublicInterfacesVisitor<'a, 'tcx: 'a> { - tcx: &'a ty::ctxt<'tcx>, + tcx: &'a TyCtxt<'tcx>, old_error_set: &'a NodeSet, } @@ -1603,7 +1603,7 @@ impl<'a, 'tcx, 'v> Visitor<'v> for PrivateItemsInPublicInterfacesVisitor<'a, 'tc } } -pub fn check_crate(tcx: &ty::ctxt, +pub fn check_crate(tcx: &TyCtxt, export_map: &def::ExportMap, external_exports: ExternalExports) -> AccessLevels { diff --git a/src/librustc_trans/back/link.rs b/src/librustc_trans/back/link.rs index 76360dcc1b972..88ae6cb91abb4 100644 --- a/src/librustc_trans/back/link.rs +++ b/src/librustc_trans/back/link.rs @@ -23,7 +23,7 @@ use session::Session; use middle::cstore::{self, CrateStore, LinkMeta}; use middle::cstore::{LinkagePreference, NativeLibraryKind}; use middle::dependency_format::Linkage; -use middle::ty::{self, Ty}; +use middle::ty::{Ty, TyCtxt}; use rustc::front::map::DefPath; use trans::{CrateContext, CrateTranslation, gensym_name}; use util::common::time; @@ -202,7 +202,7 @@ fn truncated_hash_result(symbol_hasher: &mut Sha256) -> String { // This calculates STH for a symbol, as defined above -fn symbol_hash<'tcx>(tcx: &ty::ctxt<'tcx>, +fn symbol_hash<'tcx>(tcx: &TyCtxt<'tcx>, symbol_hasher: &mut Sha256, t: Ty<'tcx>, link_meta: &LinkMeta) diff --git a/src/librustc_trans/save/dump_csv.rs b/src/librustc_trans/save/dump_csv.rs index d79f284a13500..c15d5ca86d026 100644 --- a/src/librustc_trans/save/dump_csv.rs +++ b/src/librustc_trans/save/dump_csv.rs @@ -34,7 +34,7 @@ use session::Session; use middle::def::Def; use middle::def_id::DefId; -use middle::ty; +use middle::ty::{self, TyCtxt}; use std::fs::File; use std::hash::*; @@ -65,7 +65,7 @@ macro_rules! down_cast_data { pub struct DumpCsvVisitor<'l, 'tcx: 'l> { save_ctxt: SaveContext<'l, 'tcx>, sess: &'l Session, - tcx: &'l ty::ctxt<'tcx>, + tcx: &'l TyCtxt<'tcx>, analysis: &'l ty::CrateAnalysis<'l>, span: SpanUtils<'l>, @@ -83,7 +83,7 @@ pub struct DumpCsvVisitor<'l, 'tcx: 'l> { } impl <'l, 'tcx> DumpCsvVisitor<'l, 'tcx> { - pub fn new(tcx: &'l ty::ctxt<'tcx>, + pub fn new(tcx: &'l TyCtxt<'tcx>, lcx: &'l LoweringContext<'l>, analysis: &'l ty::CrateAnalysis<'l>, output_file: Box) diff --git a/src/librustc_trans/save/mod.rs b/src/librustc_trans/save/mod.rs index 9c529ccbe0067..7f9f876fad1fa 100644 --- a/src/librustc_trans/save/mod.rs +++ b/src/librustc_trans/save/mod.rs @@ -8,7 +8,7 @@ // option. This file may not be copied, modified, or distributed // except according to those terms. -use middle::ty; +use middle::ty::{self, TyCtxt}; use middle::def::Def; use middle::def_id::DefId; @@ -37,7 +37,7 @@ pub mod recorder; mod dump_csv; pub struct SaveContext<'l, 'tcx: 'l> { - tcx: &'l ty::ctxt<'tcx>, + tcx: &'l TyCtxt<'tcx>, lcx: &'l lowering::LoweringContext<'l>, span_utils: SpanUtils<'l>, } @@ -195,14 +195,14 @@ macro_rules! option_try( impl<'l, 'tcx: 'l> SaveContext<'l, 'tcx> { - pub fn new(tcx: &'l ty::ctxt<'tcx>, + pub fn new(tcx: &'l TyCtxt<'tcx>, lcx: &'l lowering::LoweringContext<'l>) -> SaveContext<'l, 'tcx> { let span_utils = SpanUtils::new(&tcx.sess); SaveContext::from_span_utils(tcx, lcx, span_utils) } - pub fn from_span_utils(tcx: &'l ty::ctxt<'tcx>, + pub fn from_span_utils(tcx: &'l TyCtxt<'tcx>, lcx: &'l lowering::LoweringContext<'l>, span_utils: SpanUtils<'l>) -> SaveContext<'l, 'tcx> { @@ -790,7 +790,7 @@ impl<'v> Visitor<'v> for PathCollector { } } -pub fn process_crate<'l, 'tcx>(tcx: &'l ty::ctxt<'tcx>, +pub fn process_crate<'l, 'tcx>(tcx: &'l TyCtxt<'tcx>, lcx: &'l lowering::LoweringContext<'l>, krate: &ast::Crate, analysis: &ty::CrateAnalysis, diff --git a/src/librustc_trans/save/recorder.rs b/src/librustc_trans/save/recorder.rs index c0083bb9480d9..7ca2cf998bd2d 100644 --- a/src/librustc_trans/save/recorder.rs +++ b/src/librustc_trans/save/recorder.rs @@ -15,7 +15,7 @@ use super::span_utils::SpanUtils; use middle::cstore::LOCAL_CRATE; use middle::def_id::{CRATE_DEF_INDEX, DefId}; -use middle::ty; +use middle::ty::TyCtxt; use std::io::Write; @@ -55,7 +55,7 @@ impl Recorder { pub struct FmtStrs<'a, 'tcx: 'a> { pub recorder: Box, span: SpanUtils<'a>, - tcx: &'a ty::ctxt<'tcx>, + tcx: &'a TyCtxt<'tcx>, } macro_rules! s { ($e:expr) => { format!("{}", $e) }} @@ -103,7 +103,7 @@ pub enum Row { impl<'a, 'tcx: 'a> FmtStrs<'a, 'tcx> { pub fn new(rec: Box, span: SpanUtils<'a>, - tcx: &'a ty::ctxt<'tcx>) + tcx: &'a TyCtxt<'tcx>) -> FmtStrs<'a, 'tcx> { FmtStrs { recorder: rec, diff --git a/src/librustc_trans/trans/_match.rs b/src/librustc_trans/trans/_match.rs index c5efc9b7e2286..d1567cc6fa543 100644 --- a/src/librustc_trans/trans/_match.rs +++ b/src/librustc_trans/trans/_match.rs @@ -216,7 +216,7 @@ use trans::monomorphize; use trans::tvec; use trans::type_of; use trans::Disr; -use middle::ty::{self, Ty}; +use middle::ty::{self, Ty, TyCtxt}; use session::config::NoDebugInfo; use util::common::indenter; use util::nodemap::FnvHashMap; @@ -237,7 +237,7 @@ use syntax::ptr::P; struct ConstantExpr<'a>(&'a hir::Expr); impl<'a> ConstantExpr<'a> { - fn eq(self, other: ConstantExpr<'a>, tcx: &ty::ctxt) -> bool { + fn eq(self, other: ConstantExpr<'a>, tcx: &TyCtxt) -> bool { match const_eval::compare_lit_exprs(tcx, self.0, other.0) { Some(result) => result == Ordering::Equal, None => panic!("compare_list_exprs: type mismatch"), @@ -258,7 +258,7 @@ enum Opt<'a, 'tcx> { } impl<'a, 'tcx> Opt<'a, 'tcx> { - fn eq(&self, other: &Opt<'a, 'tcx>, tcx: &ty::ctxt<'tcx>) -> bool { + fn eq(&self, other: &Opt<'a, 'tcx>, tcx: &TyCtxt<'tcx>) -> bool { match (self, other) { (&ConstantValue(a, _), &ConstantValue(b, _)) => a.eq(b, tcx), (&ConstantRange(a1, a2, _), &ConstantRange(b1, b2, _)) => { @@ -794,7 +794,7 @@ fn any_region_pat(m: &[Match], col: usize) -> bool { any_pat!(m, col, PatKind::Ref(..)) } -fn any_irrefutable_adt_pat(tcx: &ty::ctxt, m: &[Match], col: usize) -> bool { +fn any_irrefutable_adt_pat(tcx: &TyCtxt, m: &[Match], col: usize) -> bool { m.iter().any(|br| { let pat = br.pats[col]; match pat.node { diff --git a/src/librustc_trans/trans/adt.rs b/src/librustc_trans/trans/adt.rs index ba227d6c38b35..e8368f1bd971c 100644 --- a/src/librustc_trans/trans/adt.rs +++ b/src/librustc_trans/trans/adt.rs @@ -50,7 +50,7 @@ use std::rc::Rc; use llvm::{ValueRef, True, IntEQ, IntNE}; use back::abi::FAT_PTR_ADDR; use middle::subst; -use middle::ty::{self, Ty}; +use middle::ty::{self, Ty, TyCtxt}; use syntax::ast; use syntax::attr; use syntax::attr::IntType; @@ -241,7 +241,7 @@ fn dtor_to_init_u8(dtor: bool) -> u8 { } pub trait GetDtorType<'tcx> { fn dtor_type(&self) -> Ty<'tcx>; } -impl<'tcx> GetDtorType<'tcx> for ty::ctxt<'tcx> { +impl<'tcx> GetDtorType<'tcx> for TyCtxt<'tcx> { fn dtor_type(&self) -> Ty<'tcx> { self.types.u8 } } @@ -438,7 +438,7 @@ struct Case<'tcx> { /// This represents the (GEP) indices to follow to get to the discriminant field pub type DiscrField = Vec; -fn find_discr_field_candidate<'tcx>(tcx: &ty::ctxt<'tcx>, +fn find_discr_field_candidate<'tcx>(tcx: &TyCtxt<'tcx>, ty: Ty<'tcx>, mut path: DiscrField) -> Option { match ty.sty { @@ -540,7 +540,7 @@ impl<'tcx> Case<'tcx> { } } -fn get_cases<'tcx>(tcx: &ty::ctxt<'tcx>, +fn get_cases<'tcx>(tcx: &TyCtxt<'tcx>, adt: ty::AdtDef<'tcx>, substs: &subst::Substs<'tcx>) -> Vec> { @@ -664,7 +664,7 @@ fn bounds_usable(cx: &CrateContext, ity: IntType, bounds: &IntBounds) -> bool { } } -pub fn ty_of_inttype<'tcx>(tcx: &ty::ctxt<'tcx>, ity: IntType) -> Ty<'tcx> { +pub fn ty_of_inttype<'tcx>(tcx: &TyCtxt<'tcx>, ity: IntType) -> Ty<'tcx> { match ity { attr::SignedInt(t) => tcx.mk_mach_int(t), attr::UnsignedInt(t) => tcx.mk_mach_uint(t) diff --git a/src/librustc_trans/trans/assert_dep_graph.rs b/src/librustc_trans/trans/assert_dep_graph.rs index 6171d05fef098..a186a8ea99ce9 100644 --- a/src/librustc_trans/trans/assert_dep_graph.rs +++ b/src/librustc_trans/trans/assert_dep_graph.rs @@ -40,7 +40,7 @@ use graphviz as dot; use rustc::dep_graph::{DepGraphQuery, DepNode}; use rustc::middle::def_id::DefId; -use rustc::middle::ty; +use rustc::middle::ty::TyCtxt; use rustc_data_structures::fnv::{FnvHashMap, FnvHashSet}; use rustc_data_structures::graph::{Direction, INCOMING, OUTGOING, NodeIndex}; use rustc_front::hir; @@ -58,7 +58,7 @@ const IF_THIS_CHANGED: &'static str = "rustc_if_this_changed"; const THEN_THIS_WOULD_NEED: &'static str = "rustc_then_this_would_need"; const ID: &'static str = "id"; -pub fn assert_dep_graph(tcx: &ty::ctxt) { +pub fn assert_dep_graph(tcx: &TyCtxt) { let _ignore = tcx.dep_graph.in_ignore(); if tcx.sess.opts.dump_dep_graph { @@ -84,7 +84,7 @@ type TargetHashMap = FnvHashMap>; struct IfThisChanged<'a, 'tcx:'a> { - tcx: &'a ty::ctxt<'tcx>, + tcx: &'a TyCtxt<'tcx>, if_this_changed: SourceHashMap, then_this_would_need: TargetHashMap, } @@ -171,7 +171,7 @@ impl<'a, 'tcx> Visitor<'tcx> for IfThisChanged<'a, 'tcx> { } } -fn check_paths(tcx: &ty::ctxt, +fn check_paths(tcx: &TyCtxt, if_this_changed: &SourceHashMap, then_this_would_need: &TargetHashMap) { @@ -212,7 +212,7 @@ fn check_paths(tcx: &ty::ctxt, } } -fn dump_graph(tcx: &ty::ctxt) { +fn dump_graph(tcx: &TyCtxt) { let path: String = env::var("RUST_DEP_GRAPH").unwrap_or_else(|_| format!("dep_graph")); let query = tcx.dep_graph.query(); diff --git a/src/librustc_trans/trans/base.rs b/src/librustc_trans/trans/base.rs index 9819f3c086003..33d3d66adcd67 100644 --- a/src/librustc_trans/trans/base.rs +++ b/src/librustc_trans/trans/base.rs @@ -43,7 +43,7 @@ use middle::weak_lang_items; use middle::pat_util::simple_name; use middle::subst::{self, Substs}; use middle::traits; -use middle::ty::{self, Ty, TypeFoldable}; +use middle::ty::{self, Ty, TyCtxt, TypeFoldable}; use middle::ty::adjustment::CustomCoerceUnsized; use rustc::dep_graph::DepNode; use rustc::front::map as hir_map; @@ -1471,7 +1471,7 @@ impl<'v> Visitor<'v> for FindNestedReturn { } } -fn build_cfg(tcx: &ty::ctxt, id: ast::NodeId) -> (ast::NodeId, Option) { +fn build_cfg(tcx: &TyCtxt, id: ast::NodeId) -> (ast::NodeId, Option) { let blk = match tcx.map.find(id) { Some(hir_map::NodeItem(i)) => { match i.node { @@ -1527,7 +1527,7 @@ fn build_cfg(tcx: &ty::ctxt, id: ast::NodeId) -> (ast::NodeId, Option) // part of a larger expression that may have already partially-filled the // return slot alloca. This can cause errors related to clean-up due to // the clobbering of the existing value in the return slot. -fn has_nested_returns(tcx: &ty::ctxt, cfg: &cfg::CFG, blk_id: ast::NodeId) -> bool { +fn has_nested_returns(tcx: &TyCtxt, cfg: &cfg::CFG, blk_id: ast::NodeId) -> bool { for index in cfg.graph.depth_traverse(cfg.entry) { let n = cfg.graph.node_data(index); match tcx.map.find(n.id()) { @@ -3137,7 +3137,7 @@ pub fn filter_reachable_ids(ccx: &SharedCrateContext) -> NodeSet { }).collect() } -pub fn trans_crate<'tcx>(tcx: &ty::ctxt<'tcx>, +pub fn trans_crate<'tcx>(tcx: &TyCtxt<'tcx>, mir_map: &MirMap<'tcx>, analysis: ty::CrateAnalysis) -> CrateTranslation { diff --git a/src/librustc_trans/trans/callee.rs b/src/librustc_trans/trans/callee.rs index e8dd9840fc005..5f8e31781f199 100644 --- a/src/librustc_trans/trans/callee.rs +++ b/src/librustc_trans/trans/callee.rs @@ -51,7 +51,7 @@ use trans::monomorphize; use trans::type_::Type; use trans::type_of; use trans::Disr; -use middle::ty::{self, Ty, TypeFoldable}; +use middle::ty::{self, Ty, TyCtxt, TypeFoldable}; use middle::ty::MethodCall; use rustc_front::hir; @@ -408,7 +408,7 @@ pub fn trans_fn_ref_with_substs<'a, 'tcx>( // def_id to the local id of the inlined copy. let def_id = inline::maybe_instantiate_inline(ccx, def_id); - fn is_named_tuple_constructor(tcx: &ty::ctxt, def_id: DefId) -> bool { + fn is_named_tuple_constructor(tcx: &TyCtxt, def_id: DefId) -> bool { let node_id = match tcx.map.as_local_node_id(def_id) { Some(n) => n, None => { return false; } diff --git a/src/librustc_trans/trans/cleanup.rs b/src/librustc_trans/trans/cleanup.rs index 683d5e0ead452..416d951e4b5c5 100644 --- a/src/librustc_trans/trans/cleanup.rs +++ b/src/librustc_trans/trans/cleanup.rs @@ -129,7 +129,7 @@ use trans::debuginfo::{DebugLoc, ToDebugLoc}; use trans::glue; use middle::region; use trans::type_::Type; -use middle::ty::{self, Ty}; +use middle::ty::{Ty, TyCtxt}; use std::fmt; use syntax::ast; @@ -1180,7 +1180,7 @@ impl<'tcx> Cleanup<'tcx> for LifetimeEnd { } } -pub fn temporary_scope(tcx: &ty::ctxt, +pub fn temporary_scope(tcx: &TyCtxt, id: ast::NodeId) -> ScopeId { match tcx.region_maps.temporary_scope(id) { @@ -1196,7 +1196,7 @@ pub fn temporary_scope(tcx: &ty::ctxt, } } -pub fn var_scope(tcx: &ty::ctxt, +pub fn var_scope(tcx: &TyCtxt, id: ast::NodeId) -> ScopeId { let r = AstScope(tcx.region_maps.var_scope(id).node_id(&tcx.region_maps)); diff --git a/src/librustc_trans/trans/common.rs b/src/librustc_trans/trans/common.rs index 6997ae5cabb54..3ba27a4b78756 100644 --- a/src/librustc_trans/trans/common.rs +++ b/src/librustc_trans/trans/common.rs @@ -38,7 +38,7 @@ use trans::monomorphize; use trans::type_::Type; use trans::type_of; use middle::traits; -use middle::ty::{self, Ty}; +use middle::ty::{self, Ty, TyCtxt}; use middle::ty::fold::{TypeFolder, TypeFoldable}; use rustc_front::hir; use rustc::mir::repr::Mir; @@ -58,11 +58,11 @@ use syntax::parse::token; pub use trans::context::CrateContext; /// Is the type's representation size known at compile time? -pub fn type_is_sized<'tcx>(tcx: &ty::ctxt<'tcx>, ty: Ty<'tcx>) -> bool { +pub fn type_is_sized<'tcx>(tcx: &TyCtxt<'tcx>, ty: Ty<'tcx>) -> bool { ty.is_sized(&tcx.empty_parameter_environment(), DUMMY_SP) } -pub fn type_is_fat_ptr<'tcx>(cx: &ty::ctxt<'tcx>, ty: Ty<'tcx>) -> bool { +pub fn type_is_fat_ptr<'tcx>(cx: &TyCtxt<'tcx>, ty: Ty<'tcx>) -> bool { match ty.sty { ty::TyRawPtr(ty::TypeAndMut{ty, ..}) | ty::TyRef(_, ty::TypeAndMut{ty, ..}) | @@ -184,7 +184,7 @@ pub struct VariantInfo<'tcx> { } impl<'tcx> VariantInfo<'tcx> { - pub fn from_ty(tcx: &ty::ctxt<'tcx>, + pub fn from_ty(tcx: &TyCtxt<'tcx>, ty: Ty<'tcx>, opt_def: Option) -> Self @@ -222,7 +222,7 @@ impl<'tcx> VariantInfo<'tcx> { } /// Return the variant corresponding to a given node (e.g. expr) - pub fn of_node(tcx: &ty::ctxt<'tcx>, ty: Ty<'tcx>, id: ast::NodeId) -> Self { + pub fn of_node(tcx: &TyCtxt<'tcx>, ty: Ty<'tcx>, id: ast::NodeId) -> Self { let node_def = tcx.def_map.borrow().get(&id).map(|v| v.full_def()); Self::from_ty(tcx, ty, node_def) } @@ -621,7 +621,7 @@ impl<'blk, 'tcx> BlockS<'blk, 'tcx> { pub fn fcx(&self) -> &'blk FunctionContext<'blk, 'tcx> { self.fcx } - pub fn tcx(&self) -> &'blk ty::ctxt<'tcx> { + pub fn tcx(&self) -> &'blk TyCtxt<'tcx> { self.fcx.ccx.tcx() } pub fn sess(&self) -> &'blk Session { self.fcx.ccx.sess() } @@ -752,7 +752,7 @@ impl<'blk, 'tcx> BlockAndBuilder<'blk, 'tcx> { pub fn fcx(&self) -> &'blk FunctionContext<'blk, 'tcx> { self.bcx.fcx() } - pub fn tcx(&self) -> &'blk ty::ctxt<'tcx> { + pub fn tcx(&self) -> &'blk TyCtxt<'tcx> { self.bcx.tcx() } pub fn sess(&self) -> &'blk Session { diff --git a/src/librustc_trans/trans/context.rs b/src/librustc_trans/trans/context.rs index b2ebaac665be3..eb5ca7722fd3e 100644 --- a/src/librustc_trans/trans/context.rs +++ b/src/librustc_trans/trans/context.rs @@ -27,7 +27,7 @@ use trans::monomorphize::MonoId; use trans::collector::{TransItem, TransItemState}; use trans::type_::{Type, TypeNames}; use middle::subst::Substs; -use middle::ty::{self, Ty}; +use middle::ty::{self, Ty, TyCtxt}; use session::config::NoDebugInfo; use session::Session; use util::sha2::Sha256; @@ -70,7 +70,7 @@ pub struct SharedCrateContext<'a, 'tcx: 'a> { item_symbols: RefCell>, link_meta: LinkMeta, symbol_hasher: RefCell, - tcx: &'a ty::ctxt<'tcx>, + tcx: &'a TyCtxt<'tcx>, stats: Stats, check_overflow: bool, check_drop_flag_for_sanity: bool, @@ -271,7 +271,7 @@ unsafe fn create_context_and_module(sess: &Session, mod_name: &str) -> (ContextR impl<'b, 'tcx> SharedCrateContext<'b, 'tcx> { pub fn new(crate_name: &str, local_count: usize, - tcx: &'b ty::ctxt<'tcx>, + tcx: &'b TyCtxt<'tcx>, mir_map: &'b MirMap<'tcx>, export_map: ExportMap, symbol_hasher: Sha256, @@ -430,7 +430,7 @@ impl<'b, 'tcx> SharedCrateContext<'b, 'tcx> { &self.link_meta } - pub fn tcx<'a>(&'a self) -> &'a ty::ctxt<'tcx> { + pub fn tcx<'a>(&'a self) -> &'a TyCtxt<'tcx> { self.tcx } @@ -574,7 +574,7 @@ impl<'b, 'tcx> CrateContext<'b, 'tcx> { } - pub fn tcx<'a>(&'a self) -> &'a ty::ctxt<'tcx> { + pub fn tcx<'a>(&'a self) -> &'a TyCtxt<'tcx> { self.shared.tcx } diff --git a/src/librustc_trans/trans/expr.rs b/src/librustc_trans/trans/expr.rs index 782e38d3af2d4..591d8a9f76c97 100644 --- a/src/librustc_trans/trans/expr.rs +++ b/src/librustc_trans/trans/expr.rs @@ -73,7 +73,7 @@ use trans::Disr; use middle::ty::adjustment::{AdjustDerefRef, AdjustReifyFnPointer}; use middle::ty::adjustment::{AdjustUnsafeFnPointer, AdjustMutToConstPointer}; use middle::ty::adjustment::CustomCoerceUnsized; -use middle::ty::{self, Ty}; +use middle::ty::{self, Ty, TyCtxt}; use middle::ty::MethodCall; use middle::ty::cast::{CastKind, CastTy}; use util::common::indenter; @@ -723,7 +723,7 @@ fn trans_field<'blk, 'tcx, F>(bcx: Block<'blk, 'tcx>, base: &hir::Expr, get_idx: F) -> DatumBlock<'blk, 'tcx, Expr> where - F: FnOnce(&'blk ty::ctxt<'tcx>, &VariantInfo<'tcx>) -> usize, + F: FnOnce(&'blk TyCtxt<'tcx>, &VariantInfo<'tcx>) -> usize, { let mut bcx = bcx; let _icx = push_ctxt("trans_rec_field"); @@ -1998,7 +1998,7 @@ fn trans_overloaded_call<'a, 'blk, 'tcx>(mut bcx: Block<'blk, 'tcx>, bcx } -pub fn cast_is_noop<'tcx>(tcx: &ty::ctxt<'tcx>, +pub fn cast_is_noop<'tcx>(tcx: &TyCtxt<'tcx>, expr: &hir::Expr, t_in: Ty<'tcx>, t_out: Ty<'tcx>) @@ -2365,7 +2365,7 @@ impl OverflowOpViaIntrinsic { let name = self.to_intrinsic_name(bcx.tcx(), lhs_ty); bcx.ccx().get_intrinsic(&name) } - fn to_intrinsic_name(&self, tcx: &ty::ctxt, ty: Ty) -> &'static str { + fn to_intrinsic_name(&self, tcx: &TyCtxt, ty: Ty) -> &'static str { use syntax::ast::IntTy::*; use syntax::ast::UintTy::*; use middle::ty::{TyInt, TyUint}; @@ -2557,7 +2557,7 @@ enum ExprKind { RvalueStmt } -fn expr_kind(tcx: &ty::ctxt, expr: &hir::Expr) -> ExprKind { +fn expr_kind(tcx: &TyCtxt, expr: &hir::Expr) -> ExprKind { if tcx.is_method_call(expr.id) { // Overloaded operations are generally calls, and hence they are // generated via DPS, but there are a few exceptions: diff --git a/src/librustc_trans/trans/foreign.rs b/src/librustc_trans/trans/foreign.rs index 06a4d3f1f6411..2a2178dd63b9f 100644 --- a/src/librustc_trans/trans/foreign.rs +++ b/src/librustc_trans/trans/foreign.rs @@ -28,7 +28,7 @@ use trans::type_::Type; use trans::type_of::*; use trans::type_of; use middle::infer; -use middle::ty::{self, Ty}; +use middle::ty::{self, Ty, TyCtxt}; use middle::subst::Substs; use std::cmp; @@ -467,7 +467,7 @@ pub fn trans_native_call<'blk, 'tcx>(bcx: Block<'blk, 'tcx>, // feature gate SIMD types in FFI, since I (huonw) am not sure the // ABIs are handled at all correctly. -fn gate_simd_ffi(tcx: &ty::ctxt, decl: &hir::FnDecl, ty: &ty::BareFnTy) { +fn gate_simd_ffi(tcx: &TyCtxt, decl: &hir::FnDecl, ty: &ty::BareFnTy) { if !tcx.sess.features.borrow().simd_ffi { let check = |ast_ty: &hir::Ty, ty: ty::Ty| { if ty.is_simd() { diff --git a/src/librustc_trans/trans/glue.rs b/src/librustc_trans/trans/glue.rs index 5cb6a7344f1a1..0b2ab58a835a2 100644 --- a/src/librustc_trans/trans/glue.rs +++ b/src/librustc_trans/trans/glue.rs @@ -20,7 +20,7 @@ use llvm::{ValueRef, get_param}; use middle::lang_items::ExchangeFreeFnLangItem; use middle::subst::{Substs}; use middle::traits; -use middle::ty::{self, Ty}; +use middle::ty::{self, Ty, TyCtxt}; use trans::adt; use trans::adt::GetDtorType; // for tcx.dtor_type() use trans::base::*; @@ -89,7 +89,7 @@ pub fn trans_exchange_free_ty<'blk, 'tcx>(bcx: Block<'blk, 'tcx>, } } -pub fn type_needs_drop<'tcx>(tcx: &ty::ctxt<'tcx>, ty: Ty<'tcx>) -> bool { +pub fn type_needs_drop<'tcx>(tcx: &TyCtxt<'tcx>, ty: Ty<'tcx>) -> bool { tcx.type_needs_drop_given_env(ty, &tcx.empty_parameter_environment()) } diff --git a/src/librustc_trans/trans/meth.rs b/src/librustc_trans/trans/meth.rs index ab43861618d16..221d17e6641d5 100644 --- a/src/librustc_trans/trans/meth.rs +++ b/src/librustc_trans/trans/meth.rs @@ -33,7 +33,7 @@ use trans::machine; use trans::monomorphize; use trans::type_::Type; use trans::type_of::*; -use middle::ty::{self, Ty}; +use middle::ty::{self, Ty, TyCtxt}; use middle::ty::MethodCall; use syntax::ast; @@ -641,7 +641,7 @@ pub fn get_vtable_methods<'a, 'tcx>(ccx: &CrateContext<'a, 'tcx>, } /// Replace the self type (&Self or Box) with an opaque pointer. -fn opaque_method_ty<'tcx>(tcx: &ty::ctxt<'tcx>, method_ty: &ty::BareFnTy<'tcx>) +fn opaque_method_ty<'tcx>(tcx: &TyCtxt<'tcx>, method_ty: &ty::BareFnTy<'tcx>) -> &'tcx ty::BareFnTy<'tcx> { let mut inputs = method_ty.sig.0.inputs.clone(); inputs[0] = tcx.mk_mut_ptr(tcx.mk_mach_int(ast::IntTy::I8)); diff --git a/src/librustc_trans/trans/mir/did.rs b/src/librustc_trans/trans/mir/did.rs index 36bbbce7ec46d..3741b07d248e2 100644 --- a/src/librustc_trans/trans/mir/did.rs +++ b/src/librustc_trans/trans/mir/did.rs @@ -12,7 +12,7 @@ use syntax::codemap::DUMMY_SP; use rustc::front::map; -use rustc::middle::ty::{self, Ty, TypeFoldable}; +use rustc::middle::ty::{self, Ty, TyCtxt, TypeFoldable}; use rustc::middle::subst::Substs; use rustc::middle::const_eval; use rustc::middle::def_id::DefId; @@ -156,7 +156,7 @@ impl<'bcx, 'tcx> MirContext<'bcx, 'tcx> { } } -fn is_named_tuple_constructor(tcx: &ty::ctxt, def_id: DefId) -> bool { +fn is_named_tuple_constructor(tcx: &TyCtxt, def_id: DefId) -> bool { let node_id = match tcx.map.as_local_node_id(def_id) { Some(n) => n, None => { return false; } diff --git a/src/librustc_trans/trans/monomorphize.rs b/src/librustc_trans/trans/monomorphize.rs index 867ac9b8376fb..9edda3d2b5c9b 100644 --- a/src/librustc_trans/trans/monomorphize.rs +++ b/src/librustc_trans/trans/monomorphize.rs @@ -23,7 +23,7 @@ use trans::base; use trans::common::*; use trans::declare; use trans::foreign; -use middle::ty::{self, Ty}; +use middle::ty::{self, Ty, TyCtxt}; use trans::Disr; use rustc::front::map as hir_map; @@ -296,7 +296,7 @@ pub struct MonoId<'tcx> { /// Monomorphizes a type from the AST by first applying the in-scope /// substitutions and then normalizing any associated types. -pub fn apply_param_substs<'tcx,T>(tcx: &ty::ctxt<'tcx>, +pub fn apply_param_substs<'tcx,T>(tcx: &TyCtxt<'tcx>, param_substs: &Substs<'tcx>, value: &T) -> T @@ -308,7 +308,7 @@ pub fn apply_param_substs<'tcx,T>(tcx: &ty::ctxt<'tcx>, /// Returns the normalized type of a struct field -pub fn field_ty<'tcx>(tcx: &ty::ctxt<'tcx>, +pub fn field_ty<'tcx>(tcx: &TyCtxt<'tcx>, param_substs: &Substs<'tcx>, f: ty::FieldDef<'tcx>) -> Ty<'tcx> diff --git a/src/librustc_typeck/astconv.rs b/src/librustc_typeck/astconv.rs index 8db04c2da20a2..134da7a3bb0bb 100644 --- a/src/librustc_typeck/astconv.rs +++ b/src/librustc_typeck/astconv.rs @@ -56,7 +56,7 @@ use middle::def_id::DefId; use middle::resolve_lifetime as rl; use middle::subst::{FnSpace, TypeSpace, SelfSpace, Subst, Substs, ParamSpace}; use middle::traits; -use middle::ty::{self, Ty, ToPredicate, TypeFoldable}; +use middle::ty::{self, Ty, TyCtxt, ToPredicate, TypeFoldable}; use middle::ty::wf::object_region_bounds; use require_c_abi_if_variadic; use rscope::{self, UnelidableRscope, RegionScope, ElidableRscope, @@ -76,7 +76,7 @@ use rustc_front::hir; use rustc_back::slice; pub trait AstConv<'tcx> { - fn tcx<'a>(&'a self) -> &'a ty::ctxt<'tcx>; + fn tcx<'a>(&'a self) -> &'a TyCtxt<'tcx>; /// Identify the type scheme for an item with a type, like a type /// alias, fn, or struct. This allows you to figure out the set of @@ -153,7 +153,7 @@ pub trait AstConv<'tcx> { -> Ty<'tcx>; } -pub fn ast_region_to_region(tcx: &ty::ctxt, lifetime: &hir::Lifetime) +pub fn ast_region_to_region(tcx: &TyCtxt, lifetime: &hir::Lifetime) -> ty::Region { let r = match tcx.named_region_map.get(&lifetime.id) { None => { @@ -571,7 +571,7 @@ fn convert_angle_bracketed_parameters<'tcx>(this: &AstConv<'tcx>, /// Returns the appropriate lifetime to use for any output lifetimes /// (if one exists) and a vector of the (pattern, number of lifetimes) /// corresponding to each input type/pattern. -fn find_implied_output_region<'tcx>(tcx: &ty::ctxt<'tcx>, +fn find_implied_output_region<'tcx>(tcx: &TyCtxt<'tcx>, input_tys: &[Ty<'tcx>], input_pats: Vec) -> ElidedLifetime { @@ -1166,7 +1166,7 @@ fn make_object_type<'tcx>(this: &AstConv<'tcx>, tcx.mk_trait(object.principal, object.bounds) } -fn report_ambiguous_associated_type(tcx: &ty::ctxt, +fn report_ambiguous_associated_type(tcx: &TyCtxt, span: Span, type_str: &str, trait_str: &str, @@ -1220,7 +1220,7 @@ fn find_bound_for_assoc_item<'tcx>(this: &AstConv<'tcx>, // Checks that bounds contains exactly one element and reports appropriate // errors otherwise. -fn one_bound_for_assoc_type<'tcx>(tcx: &ty::ctxt<'tcx>, +fn one_bound_for_assoc_type<'tcx>(tcx: &TyCtxt<'tcx>, bounds: Vec>, ty_param_name: &str, assoc_name: &str, @@ -2153,7 +2153,7 @@ pub struct PartitionedBounds<'a> { /// Divides a list of bounds from the AST into three groups: builtin bounds (Copy, Sized etc), /// general trait bounds, and region bounds. -pub fn partition_bounds<'a>(tcx: &ty::ctxt, +pub fn partition_bounds<'a>(tcx: &TyCtxt, _span: Span, ast_bounds: &'a [hir::TyParamBound]) -> PartitionedBounds<'a> @@ -2202,7 +2202,7 @@ pub fn partition_bounds<'a>(tcx: &ty::ctxt, } } -fn prohibit_projections<'tcx>(tcx: &ty::ctxt<'tcx>, +fn prohibit_projections<'tcx>(tcx: &TyCtxt<'tcx>, bindings: &[ConvertedBinding<'tcx>]) { for binding in bindings.iter().take(1) { @@ -2210,7 +2210,7 @@ fn prohibit_projections<'tcx>(tcx: &ty::ctxt<'tcx>, } } -fn check_type_argument_count(tcx: &ty::ctxt, span: Span, supplied: usize, +fn check_type_argument_count(tcx: &TyCtxt, span: Span, supplied: usize, required: usize, accepted: usize) { if supplied < required { let expected = if required < accepted { @@ -2235,7 +2235,7 @@ fn check_type_argument_count(tcx: &ty::ctxt, span: Span, supplied: usize, } } -fn report_lifetime_number_error(tcx: &ty::ctxt, span: Span, number: usize, expected: usize) { +fn report_lifetime_number_error(tcx: &TyCtxt, span: Span, number: usize, expected: usize) { span_err!(tcx.sess, span, E0107, "wrong number of lifetime parameters: expected {}, found {}", expected, number); @@ -2253,7 +2253,7 @@ pub struct Bounds<'tcx> { impl<'tcx> Bounds<'tcx> { pub fn predicates(&self, - tcx: &ty::ctxt<'tcx>, + tcx: &TyCtxt<'tcx>, param_ty: Ty<'tcx>) -> Vec> { diff --git a/src/librustc_typeck/check/coercion.rs b/src/librustc_typeck/check/coercion.rs index f07464592faac..5ab3c6f983f96 100644 --- a/src/librustc_typeck/check/coercion.rs +++ b/src/librustc_typeck/check/coercion.rs @@ -68,7 +68,7 @@ use middle::traits::{predicate_for_trait_def, report_selection_error}; use middle::ty::adjustment::{AutoAdjustment, AutoDerefRef, AdjustDerefRef}; use middle::ty::adjustment::{AutoPtr, AutoUnsafe, AdjustReifyFnPointer}; use middle::ty::adjustment::{AdjustUnsafeFnPointer, AdjustMutToConstPointer}; -use middle::ty::{self, LvaluePreference, TypeAndMut, Ty}; +use middle::ty::{self, LvaluePreference, TypeAndMut, Ty, TyCtxt}; use middle::ty::fold::TypeFoldable; use middle::ty::error::TypeError; use middle::ty::relate::RelateResult; @@ -87,7 +87,7 @@ struct Coerce<'a, 'tcx: 'a> { type CoerceResult<'tcx> = RelateResult<'tcx, Option>>; impl<'f, 'tcx> Coerce<'f, 'tcx> { - fn tcx(&self) -> &ty::ctxt<'tcx> { + fn tcx(&self) -> &TyCtxt<'tcx> { self.fcx.tcx() } diff --git a/src/librustc_typeck/check/compare_method.rs b/src/librustc_typeck/check/compare_method.rs index d674fa145dc9a..2bf7d65e33147 100644 --- a/src/librustc_typeck/check/compare_method.rs +++ b/src/librustc_typeck/check/compare_method.rs @@ -11,7 +11,7 @@ use middle::free_region::FreeRegionMap; use middle::infer::{self, TypeOrigin}; use middle::traits; -use middle::ty::{self}; +use middle::ty::{self, TyCtxt}; use middle::subst::{self, Subst, Substs, VecPerParamSpace}; use syntax::ast; @@ -30,7 +30,7 @@ use super::assoc; /// - trait_m: the method in the trait /// - impl_trait_ref: the TraitRef corresponding to the trait implementation -pub fn compare_impl_method<'tcx>(tcx: &ty::ctxt<'tcx>, +pub fn compare_impl_method<'tcx>(tcx: &TyCtxt<'tcx>, impl_m: &ty::Method<'tcx>, impl_m_span: Span, impl_m_body_id: ast::NodeId, @@ -364,7 +364,7 @@ pub fn compare_impl_method<'tcx>(tcx: &ty::ctxt<'tcx>, infcx.resolve_regions_and_report_errors(&free_regions, impl_m_body_id); - fn check_region_bounds_on_impl_method<'tcx>(tcx: &ty::ctxt<'tcx>, + fn check_region_bounds_on_impl_method<'tcx>(tcx: &TyCtxt<'tcx>, span: Span, impl_m: &ty::Method<'tcx>, trait_generics: &ty::Generics<'tcx>, @@ -408,7 +408,7 @@ pub fn compare_impl_method<'tcx>(tcx: &ty::ctxt<'tcx>, } } -pub fn compare_const_impl<'tcx>(tcx: &ty::ctxt<'tcx>, +pub fn compare_const_impl<'tcx>(tcx: &TyCtxt<'tcx>, impl_c: &ty::AssociatedConst<'tcx>, impl_c_span: Span, trait_c: &ty::AssociatedConst<'tcx>, diff --git a/src/librustc_typeck/check/dropck.rs b/src/librustc_typeck/check/dropck.rs index 81dd514ca7839..78faef473ddf6 100644 --- a/src/librustc_typeck/check/dropck.rs +++ b/src/librustc_typeck/check/dropck.rs @@ -16,7 +16,7 @@ use middle::infer; use middle::region; use middle::subst::{self, Subst}; use middle::traits; -use middle::ty::{self, Ty}; +use middle::ty::{self, Ty, TyCtxt}; use util::nodemap::FnvHashSet; use syntax::ast; @@ -39,7 +39,7 @@ use syntax::codemap::{self, Span}; /// struct/enum definition for the nominal type itself (i.e. /// cannot do `struct S; impl Drop for S { ... }`). /// -pub fn check_drop_impl(tcx: &ty::ctxt, drop_impl_did: DefId) -> Result<(), ()> { +pub fn check_drop_impl(tcx: &TyCtxt, drop_impl_did: DefId) -> Result<(), ()> { let ty::TypeScheme { generics: ref dtor_generics, ty: dtor_self_type } = tcx.lookup_item_type(drop_impl_did); let dtor_predicates = tcx.lookup_predicates(drop_impl_did); @@ -70,7 +70,7 @@ pub fn check_drop_impl(tcx: &ty::ctxt, drop_impl_did: DefId) -> Result<(), ()> { } fn ensure_drop_params_and_item_params_correspond<'tcx>( - tcx: &ty::ctxt<'tcx>, + tcx: &TyCtxt<'tcx>, drop_impl_did: DefId, drop_impl_generics: &ty::Generics<'tcx>, drop_impl_ty: &ty::Ty<'tcx>, @@ -119,7 +119,7 @@ fn ensure_drop_params_and_item_params_correspond<'tcx>( /// Confirms that every predicate imposed by dtor_predicates is /// implied by assuming the predicates attached to self_type_did. fn ensure_drop_predicates_are_implied_by_item_defn<'tcx>( - tcx: &ty::ctxt<'tcx>, + tcx: &TyCtxt<'tcx>, drop_impl_did: DefId, dtor_predicates: &ty::GenericPredicates<'tcx>, self_type_did: DefId, @@ -495,7 +495,7 @@ fn iterate_over_potentially_unsafe_regions_in_type<'a, 'b, 'tcx>( } } -fn has_dtor_of_interest<'tcx>(tcx: &ty::ctxt<'tcx>, +fn has_dtor_of_interest<'tcx>(tcx: &TyCtxt<'tcx>, ty: ty::Ty<'tcx>) -> bool { match ty.sty { ty::TyEnum(def, _) | ty::TyStruct(def, _) => { diff --git a/src/librustc_typeck/check/intrinsic.rs b/src/librustc_typeck/check/intrinsic.rs index 5e1dc35870bb2..6d8fff3caca2c 100644 --- a/src/librustc_typeck/check/intrinsic.rs +++ b/src/librustc_typeck/check/intrinsic.rs @@ -15,7 +15,7 @@ use astconv::AstConv; use intrinsics; use middle::subst; use middle::ty::FnSig; -use middle::ty::{self, Ty}; +use middle::ty::{self, Ty, TyCtxt}; use middle::ty::fold::TypeFolder; use {CrateCtxt, require_same_types}; @@ -28,7 +28,7 @@ use syntax::parse::token; use rustc_front::hir; -fn equate_intrinsic_type<'a, 'tcx>(tcx: &ty::ctxt<'tcx>, it: &hir::ForeignItem, +fn equate_intrinsic_type<'a, 'tcx>(tcx: &TyCtxt<'tcx>, it: &hir::ForeignItem, n_tps: usize, abi: Abi, inputs: Vec>, @@ -412,7 +412,7 @@ pub fn check_platform_intrinsic_type(ccx: &CrateCtxt, // the same, in a kinda-structural way, i.e. `Vector`s have to be simd structs with // exactly the right element type fn match_intrinsic_type_to_type<'tcx, 'a>( - tcx: &ty::ctxt<'tcx>, + tcx: &TyCtxt<'tcx>, position: &str, span: Span, structural_to_nominal: &mut HashMap<&'a intrinsics::Type, ty::Ty<'tcx>>, diff --git a/src/librustc_typeck/check/method/confirm.rs b/src/librustc_typeck/check/method/confirm.rs index bf08989bc0a12..f2f2eb664444f 100644 --- a/src/librustc_typeck/check/method/confirm.rs +++ b/src/librustc_typeck/check/method/confirm.rs @@ -15,7 +15,7 @@ use check::UnresolvedTypeAction; use middle::def_id::DefId; use middle::subst::{self}; use middle::traits; -use middle::ty::{self, NoPreference, PreferMutLvalue, Ty}; +use middle::ty::{self, NoPreference, PreferMutLvalue, Ty, TyCtxt}; use middle::ty::adjustment::{AdjustDerefRef, AutoDerefRef, AutoPtr}; use middle::ty::fold::TypeFoldable; use middle::infer; @@ -613,7 +613,7 @@ impl<'a,'tcx> ConfirmContext<'a,'tcx> { /////////////////////////////////////////////////////////////////////////// // MISCELLANY - fn tcx(&self) -> &'a ty::ctxt<'tcx> { + fn tcx(&self) -> &'a TyCtxt<'tcx> { self.fcx.tcx() } diff --git a/src/librustc_typeck/check/method/mod.rs b/src/librustc_typeck/check/method/mod.rs index 31e2334473488..fce4468341305 100644 --- a/src/librustc_typeck/check/method/mod.rs +++ b/src/librustc_typeck/check/method/mod.rs @@ -16,7 +16,7 @@ use middle::def::Def; use middle::def_id::DefId; use middle::subst; use middle::traits; -use middle::ty::{self, ToPredicate, ToPolyTraitRef, TraitRef, TypeFoldable}; +use middle::ty::{self, TyCtxt, ToPredicate, ToPolyTraitRef, TraitRef, TypeFoldable}; use middle::ty::adjustment::{AdjustDerefRef, AutoDerefRef, AutoPtr}; use middle::infer; @@ -350,7 +350,7 @@ pub fn resolve_ufcs<'a, 'tcx>(fcx: &FnCtxt<'a, 'tcx>, /// Find item with name `item_name` defined in `trait_def_id` /// and return it, or `None`, if no such item. -fn trait_item<'tcx>(tcx: &ty::ctxt<'tcx>, +fn trait_item<'tcx>(tcx: &TyCtxt<'tcx>, trait_def_id: DefId, item_name: ast::Name) -> Option> @@ -361,7 +361,7 @@ fn trait_item<'tcx>(tcx: &ty::ctxt<'tcx>, .cloned() } -fn impl_item<'tcx>(tcx: &ty::ctxt<'tcx>, +fn impl_item<'tcx>(tcx: &TyCtxt<'tcx>, impl_def_id: DefId, item_name: ast::Name) -> Option> diff --git a/src/librustc_typeck/check/method/probe.rs b/src/librustc_typeck/check/method/probe.rs index 3cf182a0d8ff6..02f8584c55d53 100644 --- a/src/librustc_typeck/check/method/probe.rs +++ b/src/librustc_typeck/check/method/probe.rs @@ -19,7 +19,7 @@ use middle::def_id::DefId; use middle::subst; use middle::subst::Subst; use middle::traits; -use middle::ty::{self, NoPreference, Ty, ToPolyTraitRef, TraitRef, TypeFoldable}; +use middle::ty::{self, NoPreference, Ty, TyCtxt, ToPolyTraitRef, TraitRef, TypeFoldable}; use middle::infer; use middle::infer::{InferCtxt, TypeOrigin}; use syntax::ast; @@ -258,7 +258,7 @@ impl<'a,'tcx> ProbeContext<'a,'tcx> { self.static_candidates.clear(); } - fn tcx(&self) -> &'a ty::ctxt<'tcx> { + fn tcx(&self) -> &'a TyCtxt<'tcx> { self.fcx.tcx() } @@ -1278,7 +1278,7 @@ impl<'a,'tcx> ProbeContext<'a,'tcx> { } } -fn impl_item<'tcx>(tcx: &ty::ctxt<'tcx>, +fn impl_item<'tcx>(tcx: &TyCtxt<'tcx>, impl_def_id: DefId, item_name: ast::Name) -> Option> @@ -1293,7 +1293,7 @@ fn impl_item<'tcx>(tcx: &ty::ctxt<'tcx>, /// Find item with name `item_name` defined in `trait_def_id` /// and return it, or `None`, if no such item. -fn trait_item<'tcx>(tcx: &ty::ctxt<'tcx>, +fn trait_item<'tcx>(tcx: &TyCtxt<'tcx>, trait_def_id: DefId, item_name: ast::Name) -> Option> diff --git a/src/librustc_typeck/check/mod.rs b/src/librustc_typeck/check/mod.rs index 46145b2a0a45e..9be46cf4053b1 100644 --- a/src/librustc_typeck/check/mod.rs +++ b/src/librustc_typeck/check/mod.rs @@ -96,7 +96,7 @@ use middle::traits::{self, report_fulfillment_errors}; use middle::ty::{GenericPredicates, TypeScheme}; use middle::ty::{Disr, ParamTy, ParameterEnvironment}; use middle::ty::{LvaluePreference, NoPreference, PreferMutLvalue}; -use middle::ty::{self, ToPolyTraitRef, Ty}; +use middle::ty::{self, ToPolyTraitRef, Ty, TyCtxt}; use middle::ty::{MethodCall, MethodCallee}; use middle::ty::adjustment; use middle::ty::error::TypeError; @@ -300,7 +300,7 @@ pub struct FnCtxt<'a, 'tcx: 'a> { } impl<'a, 'tcx> Inherited<'a, 'tcx> { - fn new(tcx: &'a ty::ctxt<'tcx>, + fn new(tcx: &'a TyCtxt<'tcx>, tables: &'a RefCell>, param_env: ty::ParameterEnvironment<'a, 'tcx>) -> Inherited<'a, 'tcx> { @@ -1091,7 +1091,7 @@ fn report_cast_to_unsized_type<'a, 'tcx>(fcx: &FnCtxt<'a, 'tcx>, impl<'a, 'tcx> AstConv<'tcx> for FnCtxt<'a, 'tcx> { - fn tcx(&self) -> &ty::ctxt<'tcx> { self.ccx.tcx } + fn tcx(&self) -> &TyCtxt<'tcx> { self.ccx.tcx } fn get_item_type_scheme(&self, _: Span, id: DefId) -> Result, ErrorReported> @@ -1199,7 +1199,7 @@ impl<'a, 'tcx> AstConv<'tcx> for FnCtxt<'a, 'tcx> { } impl<'a, 'tcx> FnCtxt<'a, 'tcx> { - fn tcx(&self) -> &ty::ctxt<'tcx> { self.ccx.tcx } + fn tcx(&self) -> &TyCtxt<'tcx> { self.ccx.tcx } pub fn infcx(&self) -> &infer::InferCtxt<'a,'tcx> { &self.inh.infcx @@ -2582,7 +2582,7 @@ fn check_argument_types<'a, 'tcx>(fcx: &FnCtxt<'a, 'tcx>, } // FIXME(#17596) Ty<'tcx> is incorrectly invariant w.r.t 'tcx. -fn err_args<'tcx>(tcx: &ty::ctxt<'tcx>, len: usize) -> Vec> { +fn err_args<'tcx>(tcx: &TyCtxt<'tcx>, len: usize) -> Vec> { (0..len).map(|_| tcx.types.err).collect() } @@ -3832,7 +3832,7 @@ impl<'tcx> Expectation<'tcx> { /// which still is useful, because it informs integer literals and the like. /// See the test case `test/run-pass/coerce-expect-unsized.rs` and #20169 /// for examples of where this comes up,. - fn rvalue_hint(tcx: &ty::ctxt<'tcx>, ty: Ty<'tcx>) -> Expectation<'tcx> { + fn rvalue_hint(tcx: &TyCtxt<'tcx>, ty: Ty<'tcx>) -> Expectation<'tcx> { match tcx.struct_tail(ty).sty { ty::TySlice(_) | ty::TyStr | ty::TyTrait(..) => { ExpectRvalueLikeUnsized(ty) @@ -4114,7 +4114,7 @@ fn check_const_with_ty<'a, 'tcx>(fcx: &FnCtxt<'a, 'tcx>, /// Checks whether a type can be represented in memory. In particular, it /// identifies types that contain themselves without indirection through a /// pointer, which would mean their size is unbounded. -pub fn check_representable(tcx: &ty::ctxt, +pub fn check_representable(tcx: &TyCtxt, sp: Span, item_id: ast::NodeId, _designation: &str) -> bool { @@ -4136,7 +4136,7 @@ pub fn check_representable(tcx: &ty::ctxt, return true } -pub fn check_simd(tcx: &ty::ctxt, sp: Span, id: ast::NodeId) { +pub fn check_simd(tcx: &TyCtxt, sp: Span, id: ast::NodeId) { let t = tcx.node_id_to_type(id); match t.sty { ty::TyStruct(def, substs) => { @@ -4852,7 +4852,7 @@ pub fn structurally_resolved_type<'a, 'tcx>(fcx: &FnCtxt<'a, 'tcx>, } // Returns true if b contains a break that can exit from b -pub fn may_break(cx: &ty::ctxt, id: ast::NodeId, b: &hir::Block) -> bool { +pub fn may_break(cx: &TyCtxt, id: ast::NodeId, b: &hir::Block) -> bool { // First: is there an unlabeled break immediately // inside the loop? (loop_query(&b, |e| { diff --git a/src/librustc_typeck/check/regionck.rs b/src/librustc_typeck/check/regionck.rs index e399818779ecf..f6225cf6ca768 100644 --- a/src/librustc_typeck/check/regionck.rs +++ b/src/librustc_typeck/check/regionck.rs @@ -91,7 +91,7 @@ use middle::mem_categorization::Categorization; use middle::region::{self, CodeExtent}; use middle::subst::Substs; use middle::traits; -use middle::ty::{self, Ty, MethodCall, TypeFoldable}; +use middle::ty::{self, Ty, TyCtxt, MethodCall, TypeFoldable}; use middle::infer::{self, GenericKind, InferCtxt, SubregionOrigin, TypeOrigin, VerifyBound}; use middle::pat_util; use middle::ty::adjustment; @@ -208,7 +208,7 @@ impl<'a, 'tcx> Rcx<'a, 'tcx> { } } - pub fn tcx(&self) -> &'a ty::ctxt<'tcx> { + pub fn tcx(&self) -> &'a TyCtxt<'tcx> { self.fcx.ccx.tcx } diff --git a/src/librustc_typeck/check/upvar.rs b/src/librustc_typeck/check/upvar.rs index bc4ec3adbc185..fca2c8193a7b0 100644 --- a/src/librustc_typeck/check/upvar.rs +++ b/src/librustc_typeck/check/upvar.rs @@ -46,7 +46,7 @@ use check::demand; use middle::expr_use_visitor as euv; use middle::mem_categorization as mc; use middle::mem_categorization::Categorization; -use middle::ty::{self, Ty}; +use middle::ty::{self, Ty, TyCtxt}; use middle::infer::{InferCtxt, UpvarRegion}; use std::collections::HashSet; use syntax::ast; @@ -114,7 +114,7 @@ impl<'a,'tcx> SeedBorrowKind<'a,'tcx> { SeedBorrowKind { fcx: fcx, closures_with_inferred_kinds: HashSet::new() } } - fn tcx(&self) -> &'a ty::ctxt<'tcx> { + fn tcx(&self) -> &'a TyCtxt<'tcx> { self.fcx.tcx() } diff --git a/src/librustc_typeck/check/wfcheck.rs b/src/librustc_typeck/check/wfcheck.rs index b2a23176c9585..997f56bd449c6 100644 --- a/src/librustc_typeck/check/wfcheck.rs +++ b/src/librustc_typeck/check/wfcheck.rs @@ -16,7 +16,7 @@ use middle::def_id::DefId; use middle::region::{CodeExtent}; use middle::subst::{self, TypeSpace, FnSpace, ParamSpace, SelfSpace}; use middle::traits; -use middle::ty::{self, Ty}; +use middle::ty::{self, Ty, TyCtxt}; use middle::ty::fold::{TypeFolder}; use std::cell::RefCell; @@ -42,7 +42,7 @@ impl<'ccx, 'tcx> CheckTypeWellFormedVisitor<'ccx, 'tcx> { } } - fn tcx(&self) -> &ty::ctxt<'tcx> { + fn tcx(&self) -> &TyCtxt<'tcx> { self.ccx.tcx } @@ -516,7 +516,7 @@ impl<'ccx, 'tcx> CheckTypeWellFormedVisitor<'ccx, 'tcx> { } } -fn reject_shadowing_type_parameters<'tcx>(tcx: &ty::ctxt<'tcx>, +fn reject_shadowing_type_parameters<'tcx>(tcx: &TyCtxt<'tcx>, span: Span, generics: &ty::Generics<'tcx>) { let impl_params = generics.types.get_slice(subst::TypeSpace).iter() @@ -623,13 +623,13 @@ pub fn error_380<'ccx,'tcx>(ccx: &'ccx CrateCtxt<'ccx, 'tcx>, span: Span) { Trait for ..`) must have no methods or associated items") } -pub fn error_392<'tcx>(tcx: &ty::ctxt<'tcx>, span: Span, param_name: ast::Name) +pub fn error_392<'tcx>(tcx: &TyCtxt<'tcx>, span: Span, param_name: ast::Name) -> DiagnosticBuilder<'tcx> { struct_span_err!(tcx.sess, span, E0392, "parameter `{}` is never used", param_name) } -pub fn error_194<'tcx>(tcx: &ty::ctxt<'tcx>, span: Span, name: ast::Name) { +pub fn error_194<'tcx>(tcx: &TyCtxt<'tcx>, span: Span, name: ast::Name) { span_err!(tcx.sess, span, E0194, "type parameter `{}` shadows another type parameter of the same name", name); diff --git a/src/librustc_typeck/check/writeback.rs b/src/librustc_typeck/check/writeback.rs index a28944995c48c..20c86f9a17c8d 100644 --- a/src/librustc_typeck/check/writeback.rs +++ b/src/librustc_typeck/check/writeback.rs @@ -17,7 +17,7 @@ use astconv::AstConv; use check::FnCtxt; use middle::def_id::DefId; use middle::pat_util; -use middle::ty::{self, Ty, MethodCall, MethodCallee}; +use middle::ty::{self, Ty, TyCtxt, MethodCall, MethodCallee}; use middle::ty::adjustment; use middle::ty::fold::{TypeFolder,TypeFoldable}; use middle::infer; @@ -85,7 +85,7 @@ impl<'cx, 'tcx> WritebackCx<'cx, 'tcx> { WritebackCx { fcx: fcx } } - fn tcx(&self) -> &'cx ty::ctxt<'tcx> { + fn tcx(&self) -> &'cx TyCtxt<'tcx> { self.fcx.tcx() } @@ -381,7 +381,7 @@ enum ResolveReason { } impl ResolveReason { - fn span(&self, tcx: &ty::ctxt) -> Span { + fn span(&self, tcx: &TyCtxt) -> Span { match *self { ResolvingExpr(s) => s, ResolvingLocal(s) => s, @@ -411,7 +411,7 @@ impl ResolveReason { // unresolved types and so forth. struct Resolver<'cx, 'tcx: 'cx> { - tcx: &'cx ty::ctxt<'tcx>, + tcx: &'cx TyCtxt<'tcx>, infcx: &'cx infer::InferCtxt<'cx, 'tcx>, writeback_errors: &'cx Cell, reason: ResolveReason, @@ -487,7 +487,7 @@ impl<'cx, 'tcx> Resolver<'cx, 'tcx> { } impl<'cx, 'tcx> TypeFolder<'tcx> for Resolver<'cx, 'tcx> { - fn tcx<'a>(&'a self) -> &'a ty::ctxt<'tcx> { + fn tcx<'a>(&'a self) -> &'a TyCtxt<'tcx> { self.tcx } diff --git a/src/librustc_typeck/coherence/mod.rs b/src/librustc_typeck/coherence/mod.rs index 941900100bbaf..6106011433027 100644 --- a/src/librustc_typeck/coherence/mod.rs +++ b/src/librustc_typeck/coherence/mod.rs @@ -20,7 +20,7 @@ use middle::def_id::DefId; use middle::lang_items::UnsizeTraitLangItem; use middle::subst::{self, Subst}; use middle::traits; -use middle::ty::{self, TypeFoldable}; +use middle::ty::{self, TyCtxt, TypeFoldable}; use middle::ty::{ImplOrTraitItemId, ConstTraitItemId}; use middle::ty::{MethodTraitItemId, TypeTraitItemId, ParameterEnvironment}; use middle::ty::{Ty, TyBool, TyChar, TyEnum, TyError}; @@ -492,7 +492,7 @@ impl<'a, 'tcx> CoherenceChecker<'a, 'tcx> { } } -fn enforce_trait_manually_implementable(tcx: &ty::ctxt, sp: Span, trait_def_id: DefId) { +fn enforce_trait_manually_implementable(tcx: &TyCtxt, sp: Span, trait_def_id: DefId) { if tcx.sess.features.borrow().unboxed_closures { // the feature gate allows all of them return diff --git a/src/librustc_typeck/coherence/orphan.rs b/src/librustc_typeck/coherence/orphan.rs index 9e966c283a0a5..56e6d0399036d 100644 --- a/src/librustc_typeck/coherence/orphan.rs +++ b/src/librustc_typeck/coherence/orphan.rs @@ -14,20 +14,20 @@ use middle::cstore::LOCAL_CRATE; use middle::def_id::DefId; use middle::traits; -use middle::ty; +use middle::ty::{self, TyCtxt}; use syntax::ast; use syntax::codemap::Span; use rustc::dep_graph::DepNode; use rustc_front::intravisit; use rustc_front::hir; -pub fn check(tcx: &ty::ctxt) { +pub fn check(tcx: &TyCtxt) { let mut orphan = OrphanChecker { tcx: tcx }; tcx.visit_all_items_in_krate(DepNode::CoherenceOrphanCheck, &mut orphan); } struct OrphanChecker<'cx, 'tcx:'cx> { - tcx: &'cx ty::ctxt<'tcx> + tcx: &'cx TyCtxt<'tcx> } impl<'cx, 'tcx> OrphanChecker<'cx, 'tcx> { diff --git a/src/librustc_typeck/coherence/overlap.rs b/src/librustc_typeck/coherence/overlap.rs index 470e954781f8b..9ec42b6d3f859 100644 --- a/src/librustc_typeck/coherence/overlap.rs +++ b/src/librustc_typeck/coherence/overlap.rs @@ -14,7 +14,7 @@ use middle::cstore::{CrateStore, LOCAL_CRATE}; use middle::def_id::DefId; use middle::traits; -use middle::ty; +use middle::ty::{self, TyCtxt}; use middle::infer; use syntax::ast; use syntax::codemap::Span; @@ -23,7 +23,7 @@ use rustc_front::hir; use rustc_front::intravisit; use util::nodemap::{DefIdMap, DefIdSet}; -pub fn check(tcx: &ty::ctxt) { +pub fn check(tcx: &TyCtxt) { let mut overlap = OverlapChecker { tcx: tcx, traits_checked: DefIdSet(), default_impls: DefIdMap() }; @@ -34,7 +34,7 @@ pub fn check(tcx: &ty::ctxt) { } struct OverlapChecker<'cx, 'tcx:'cx> { - tcx: &'cx ty::ctxt<'tcx>, + tcx: &'cx TyCtxt<'tcx>, // The set of traits where we have checked for overlap. This is // used to avoid checking the same trait twice. diff --git a/src/librustc_typeck/coherence/unsafety.rs b/src/librustc_typeck/coherence/unsafety.rs index 936d26f920850..fbb1653b06a07 100644 --- a/src/librustc_typeck/coherence/unsafety.rs +++ b/src/librustc_typeck/coherence/unsafety.rs @@ -11,17 +11,17 @@ //! Unsafety checker: every impl either implements a trait defined in this //! crate or pertains to a type defined in this crate. -use middle::ty; +use middle::ty::TyCtxt; use rustc_front::intravisit; use rustc_front::hir; -pub fn check(tcx: &ty::ctxt) { +pub fn check(tcx: &TyCtxt) { let mut orphan = UnsafetyChecker { tcx: tcx }; tcx.map.krate().visit_all_items(&mut orphan); } struct UnsafetyChecker<'cx, 'tcx:'cx> { - tcx: &'cx ty::ctxt<'tcx> + tcx: &'cx TyCtxt<'tcx> } impl<'cx, 'tcx, 'v> UnsafetyChecker<'cx, 'tcx> { diff --git a/src/librustc_typeck/collect.rs b/src/librustc_typeck/collect.rs index 0e64f2cfc41c5..b3305fdb9a044 100644 --- a/src/librustc_typeck/collect.rs +++ b/src/librustc_typeck/collect.rs @@ -69,7 +69,7 @@ use middle::const_eval::{self, ConstVal}; use middle::const_eval::EvalHint::UncheckedExprHint; use middle::subst::{Substs, FnSpace, ParamSpace, SelfSpace, TypeSpace, VecPerParamSpace}; use middle::ty::{ToPredicate, ImplContainer, ImplOrTraitItemContainer, TraitContainer}; -use middle::ty::{self, ToPolyTraitRef, Ty, TypeScheme}; +use middle::ty::{self, ToPolyTraitRef, Ty, TyCtxt, TypeScheme}; use middle::ty::{VariantKind}; use middle::ty::fold::{TypeFolder}; use middle::ty::util::IntTypeExt; @@ -97,7 +97,7 @@ use rustc_front::print::pprust; /////////////////////////////////////////////////////////////////////////// // Main entry point -pub fn collect_item_types(tcx: &ty::ctxt) { +pub fn collect_item_types(tcx: &TyCtxt) { let ccx = &CrateCtxt { tcx: tcx, stack: RefCell::new(Vec::new()) }; let mut visitor = CollectItemTypesVisitor{ ccx: ccx }; ccx.tcx.visit_all_items_in_krate(DepNode::CollectItem, &mut visitor); @@ -106,7 +106,7 @@ pub fn collect_item_types(tcx: &ty::ctxt) { /////////////////////////////////////////////////////////////////////////// struct CrateCtxt<'a,'tcx:'a> { - tcx: &'a ty::ctxt<'tcx>, + tcx: &'a TyCtxt<'tcx>, // This stack is used to identify cycles in the user's source. // Note that these cycles can cross multiple items. @@ -304,7 +304,7 @@ impl<'a,'tcx> ItemCtxt<'a,'tcx> { } impl<'a, 'tcx> AstConv<'tcx> for ItemCtxt<'a, 'tcx> { - fn tcx(&self) -> &ty::ctxt<'tcx> { self.ccx.tcx } + fn tcx(&self) -> &TyCtxt<'tcx> { self.ccx.tcx } fn get_item_type_scheme(&self, span: Span, id: DefId) -> Result, ErrorReported> @@ -500,7 +500,7 @@ impl<'tcx> GetTypeParameterBounds<'tcx> for hir::Generics { /// parameter with id `param_id`. We use this so as to avoid running /// `ast_ty_to_ty`, because we want to avoid triggering an all-out /// conversion of the type to avoid inducing unnecessary cycles. -fn is_param<'tcx>(tcx: &ty::ctxt<'tcx>, +fn is_param<'tcx>(tcx: &TyCtxt<'tcx>, ast_ty: &hir::Ty, param_id: ast::NodeId) -> bool @@ -920,7 +920,7 @@ fn convert_item(ccx: &CrateCtxt, it: &hir::Item) { } } -fn convert_variant_ctor<'a, 'tcx>(tcx: &ty::ctxt<'tcx>, +fn convert_variant_ctor<'a, 'tcx>(tcx: &TyCtxt<'tcx>, ctor_id: ast::NodeId, variant: ty::VariantDef<'tcx>, scheme: ty::TypeScheme<'tcx>, @@ -970,7 +970,7 @@ fn convert_enum_variant_types<'a, 'tcx>(ccx: &CrateCtxt<'a, 'tcx>, } } -fn convert_struct_variant<'tcx>(tcx: &ty::ctxt<'tcx>, +fn convert_struct_variant<'tcx>(tcx: &TyCtxt<'tcx>, did: DefId, name: ast::Name, disr_val: ty::Disr, @@ -1000,7 +1000,7 @@ fn convert_struct_variant<'tcx>(tcx: &ty::ctxt<'tcx>, } } -fn convert_struct_def<'tcx>(tcx: &ty::ctxt<'tcx>, +fn convert_struct_def<'tcx>(tcx: &TyCtxt<'tcx>, it: &hir::Item, def: &hir::VariantData) -> ty::AdtDefMaster<'tcx> @@ -1019,12 +1019,12 @@ fn convert_struct_def<'tcx>(tcx: &ty::ctxt<'tcx>, ) } -fn convert_enum_def<'tcx>(tcx: &ty::ctxt<'tcx>, +fn convert_enum_def<'tcx>(tcx: &TyCtxt<'tcx>, it: &hir::Item, def: &hir::EnumDef) -> ty::AdtDefMaster<'tcx> { - fn evaluate_disr_expr<'tcx>(tcx: &ty::ctxt<'tcx>, + fn evaluate_disr_expr<'tcx>(tcx: &TyCtxt<'tcx>, repr_ty: Ty<'tcx>, e: &hir::Expr) -> Option { debug!("disr expr, checking {}", pprust::expr_to_string(e)); @@ -1057,7 +1057,7 @@ fn convert_enum_def<'tcx>(tcx: &ty::ctxt<'tcx>, } } - fn report_discrim_overflow(tcx: &ty::ctxt, + fn report_discrim_overflow(tcx: &TyCtxt, variant_span: Span, variant_name: &str, repr_type: attr::IntType, @@ -1072,7 +1072,7 @@ fn convert_enum_def<'tcx>(tcx: &ty::ctxt<'tcx>, prev_val, repr_type, variant_name, computed_value); } - fn next_disr(tcx: &ty::ctxt, + fn next_disr(tcx: &TyCtxt, v: &hir::Variant, repr_type: attr::IntType, prev_disr_val: Option) -> Option { @@ -1087,7 +1087,7 @@ fn convert_enum_def<'tcx>(tcx: &ty::ctxt<'tcx>, Some(ty::INITIAL_DISCRIMINANT_VALUE) } } - fn convert_enum_variant<'tcx>(tcx: &ty::ctxt<'tcx>, + fn convert_enum_variant<'tcx>(tcx: &TyCtxt<'tcx>, v: &hir::Variant, disr: ty::Disr) -> ty::VariantDefData<'tcx, 'tcx> @@ -2171,7 +2171,7 @@ fn mk_item_substs<'a, 'tcx>(ccx: &CrateCtxt<'a, 'tcx>, } /// Checks that all the type parameters on an impl -fn enforce_impl_params_are_constrained<'tcx>(tcx: &ty::ctxt<'tcx>, +fn enforce_impl_params_are_constrained<'tcx>(tcx: &TyCtxt<'tcx>, ast_generics: &hir::Generics, impl_predicates: &mut ty::GenericPredicates<'tcx>, impl_def_id: DefId) @@ -2206,7 +2206,7 @@ fn enforce_impl_params_are_constrained<'tcx>(tcx: &ty::ctxt<'tcx>, } } -fn enforce_impl_lifetimes_are_constrained<'tcx>(tcx: &ty::ctxt<'tcx>, +fn enforce_impl_lifetimes_are_constrained<'tcx>(tcx: &TyCtxt<'tcx>, ast_generics: &hir::Generics, impl_def_id: DefId, impl_items: &[hir::ImplItem]) @@ -2271,7 +2271,7 @@ fn enforce_impl_lifetimes_are_constrained<'tcx>(tcx: &ty::ctxt<'tcx>, // used elsewhere are not projected back out. } -fn report_unused_parameter(tcx: &ty::ctxt, +fn report_unused_parameter(tcx: &TyCtxt, span: Span, kind: &str, name: &str) diff --git a/src/librustc_typeck/constrained_type_params.rs b/src/librustc_typeck/constrained_type_params.rs index 9abe101e2d9d6..336bff26e2c7f 100644 --- a/src/librustc_typeck/constrained_type_params.rs +++ b/src/librustc_typeck/constrained_type_params.rs @@ -9,7 +9,7 @@ // except according to those terms. use middle::subst; -use middle::ty::{self, Ty}; +use middle::ty::{self, Ty, TyCtxt}; use std::collections::HashSet; @@ -93,7 +93,7 @@ fn parameters_for_region(region: &ty::Region) -> Option { } } -pub fn identify_constrained_type_params<'tcx>(_tcx: &ty::ctxt<'tcx>, +pub fn identify_constrained_type_params<'tcx>(_tcx: &TyCtxt<'tcx>, predicates: &[ty::Predicate<'tcx>], impl_trait_ref: Option>, input_parameters: &mut HashSet) @@ -143,7 +143,7 @@ pub fn identify_constrained_type_params<'tcx>(_tcx: &ty::ctxt<'tcx>, /// which is determined by 1, which requires `U`, that is determined /// by 0. I should probably pick a less tangled example, but I can't /// think of any. -pub fn setup_constraining_predicates<'tcx>(_tcx: &ty::ctxt<'tcx>, +pub fn setup_constraining_predicates<'tcx>(_tcx: &TyCtxt<'tcx>, predicates: &mut [ty::Predicate<'tcx>], impl_trait_ref: Option>, input_parameters: &mut HashSet) diff --git a/src/librustc_typeck/lib.rs b/src/librustc_typeck/lib.rs index 0835762c4e5c5..a103cbc928b49 100644 --- a/src/librustc_typeck/lib.rs +++ b/src/librustc_typeck/lib.rs @@ -104,7 +104,7 @@ use front::map as hir_map; use middle::def::Def; use middle::infer::{self, TypeOrigin}; use middle::subst; -use middle::ty::{self, Ty, TypeFoldable}; +use middle::ty::{self, Ty, TyCtxt, TypeFoldable}; use session::{config, CompileResult}; use util::common::time; use rustc_front::hir; @@ -140,17 +140,17 @@ pub struct CrateCtxt<'a, 'tcx: 'a> { /// error reporting, and so is lazily initialised and generally /// shouldn't taint the common path (hence the RefCell). pub all_traits: RefCell>, - pub tcx: &'a ty::ctxt<'tcx>, + pub tcx: &'a TyCtxt<'tcx>, } // Functions that write types into the node type table -fn write_ty_to_tcx<'tcx>(tcx: &ty::ctxt<'tcx>, node_id: ast::NodeId, ty: Ty<'tcx>) { +fn write_ty_to_tcx<'tcx>(tcx: &TyCtxt<'tcx>, node_id: ast::NodeId, ty: Ty<'tcx>) { debug!("write_ty_to_tcx({}, {:?})", node_id, ty); assert!(!ty.needs_infer()); tcx.node_type_insert(node_id, ty); } -fn write_substs_to_tcx<'tcx>(tcx: &ty::ctxt<'tcx>, +fn write_substs_to_tcx<'tcx>(tcx: &TyCtxt<'tcx>, node_id: ast::NodeId, item_substs: ty::ItemSubsts<'tcx>) { if !item_substs.is_noop() { @@ -164,7 +164,7 @@ fn write_substs_to_tcx<'tcx>(tcx: &ty::ctxt<'tcx>, } } -fn lookup_full_def(tcx: &ty::ctxt, sp: Span, id: ast::NodeId) -> Def { +fn lookup_full_def(tcx: &TyCtxt, sp: Span, id: ast::NodeId) -> Def { match tcx.def_map.borrow().get(&id) { Some(x) => x.full_def(), None => { @@ -173,7 +173,7 @@ fn lookup_full_def(tcx: &ty::ctxt, sp: Span, id: ast::NodeId) -> Def { } } -fn require_c_abi_if_variadic(tcx: &ty::ctxt, +fn require_c_abi_if_variadic(tcx: &TyCtxt, decl: &hir::FnDecl, abi: Abi, span: Span) { @@ -183,7 +183,7 @@ fn require_c_abi_if_variadic(tcx: &ty::ctxt, } } -fn require_same_types<'a, 'tcx, M>(tcx: &ty::ctxt<'tcx>, +fn require_same_types<'a, 'tcx, M>(tcx: &TyCtxt<'tcx>, maybe_infcx: Option<&infer::InferCtxt<'a, 'tcx>>, t1_is_expected: bool, span: Span, @@ -325,7 +325,7 @@ fn check_for_entry_fn(ccx: &CrateCtxt) { } } -pub fn check_crate(tcx: &ty::ctxt, trait_map: ty::TraitMap) -> CompileResult { +pub fn check_crate(tcx: &TyCtxt, trait_map: ty::TraitMap) -> CompileResult { let time_passes = tcx.sess.time_passes(); let ccx = CrateCtxt { trait_map: trait_map, diff --git a/src/librustc_typeck/variance/constraints.rs b/src/librustc_typeck/variance/constraints.rs index 2f243d0fd0f80..0c9fa9fd0ab4f 100644 --- a/src/librustc_typeck/variance/constraints.rs +++ b/src/librustc_typeck/variance/constraints.rs @@ -18,7 +18,7 @@ use middle::def_id::DefId; use middle::resolve_lifetime as rl; use middle::subst; use middle::subst::ParamSpace; -use middle::ty::{self, Ty}; +use middle::ty::{self, Ty, TyCtxt}; use middle::ty::maps::ItemVariances; use rustc::front::map as hir_map; use syntax::ast; @@ -127,7 +127,7 @@ fn is_lifetime(map: &hir_map::Map, param_id: ast::NodeId) -> bool { } impl<'a, 'tcx> ConstraintContext<'a, 'tcx> { - fn tcx(&self) -> &'a ty::ctxt<'tcx> { + fn tcx(&self) -> &'a TyCtxt<'tcx> { self.terms_cx.tcx } diff --git a/src/librustc_typeck/variance/mod.rs b/src/librustc_typeck/variance/mod.rs index 3ce3a868f0477..ab37ef952c9a9 100644 --- a/src/librustc_typeck/variance/mod.rs +++ b/src/librustc_typeck/variance/mod.rs @@ -12,7 +12,7 @@ //! parameters. See README.md for details. use arena; -use middle::ty; +use middle::ty::TyCtxt; /// Defines the `TermsContext` basically houses an arena where we can /// allocate terms. @@ -27,7 +27,7 @@ mod solve; /// Code for transforming variances. mod xform; -pub fn infer_variance(tcx: &ty::ctxt) { +pub fn infer_variance(tcx: &TyCtxt) { let mut arena = arena::TypedArena::new(); let terms_cx = terms::determine_parameters_to_be_inferred(tcx, &mut arena); let constraints_cx = constraints::add_constraints_from_crate(terms_cx); diff --git a/src/librustc_typeck/variance/terms.rs b/src/librustc_typeck/variance/terms.rs index aa1e93c3d6b7d..ff55aefb20ff3 100644 --- a/src/librustc_typeck/variance/terms.rs +++ b/src/librustc_typeck/variance/terms.rs @@ -22,7 +22,7 @@ use arena::TypedArena; use dep_graph::DepTrackingMapConfig; use middle::subst::{ParamSpace, FnSpace, TypeSpace, SelfSpace, VecPerParamSpace}; -use middle::ty; +use middle::ty::{self, TyCtxt}; use middle::ty::maps::ItemVariances; use std::fmt; use std::rc::Rc; @@ -59,7 +59,7 @@ impl<'a> fmt::Debug for VarianceTerm<'a> { // The first pass over the crate simply builds up the set of inferreds. pub struct TermsContext<'a, 'tcx: 'a> { - pub tcx: &'a ty::ctxt<'tcx>, + pub tcx: &'a TyCtxt<'tcx>, pub arena: &'a TypedArena>, pub empty_variances: Rc, @@ -98,7 +98,7 @@ pub struct InferredInfo<'a> { } pub fn determine_parameters_to_be_inferred<'a, 'tcx>( - tcx: &'a ty::ctxt<'tcx>, + tcx: &'a TyCtxt<'tcx>, arena: &'a mut TypedArena>) -> TermsContext<'a, 'tcx> { @@ -125,7 +125,7 @@ pub fn determine_parameters_to_be_inferred<'a, 'tcx>( terms_cx } -fn lang_items(tcx: &ty::ctxt) -> Vec<(ast::NodeId,Vec)> { +fn lang_items(tcx: &TyCtxt) -> Vec<(ast::NodeId,Vec)> { let all = vec![ (tcx.lang_items.phantom_data(), vec![ty::Covariant]), (tcx.lang_items.unsafe_cell_type(), vec![ty::Invariant]), diff --git a/src/librustdoc/clean/inline.rs b/src/librustdoc/clean/inline.rs index 3a2e1ca0ccf93..02ea83615a372 100644 --- a/src/librustdoc/clean/inline.rs +++ b/src/librustdoc/clean/inline.rs @@ -19,7 +19,7 @@ use rustc_front::hir; use rustc::middle::cstore::{self, CrateStore}; use rustc::middle::def::Def; use rustc::middle::def_id::DefId; -use rustc::middle::ty; +use rustc::middle::ty::{self, TyCtxt}; use rustc::middle::subst; use rustc::middle::stability; use rustc::middle::const_eval; @@ -67,7 +67,7 @@ pub fn try_inline(cx: &DocContext, id: ast::NodeId, into: Option) }) } -fn try_inline_def(cx: &DocContext, tcx: &ty::ctxt, +fn try_inline_def(cx: &DocContext, tcx: &TyCtxt, def: Def) -> Option> { let mut ret = Vec::new(); let did = def.def_id(); @@ -128,7 +128,7 @@ fn try_inline_def(cx: &DocContext, tcx: &ty::ctxt, Some(ret) } -pub fn load_attrs(cx: &DocContext, tcx: &ty::ctxt, +pub fn load_attrs(cx: &DocContext, tcx: &TyCtxt, did: DefId) -> Vec { tcx.get_attrs(did).iter().map(|a| a.clean(cx)).collect() } @@ -148,7 +148,7 @@ pub fn record_extern_fqn(cx: &DocContext, did: DefId, kind: clean::TypeKind) { } } -pub fn build_external_trait(cx: &DocContext, tcx: &ty::ctxt, +pub fn build_external_trait(cx: &DocContext, tcx: &TyCtxt, did: DefId) -> clean::Trait { let def = tcx.lookup_trait_def(did); let trait_items = tcx.trait_items(did).clean(cx); @@ -164,7 +164,7 @@ pub fn build_external_trait(cx: &DocContext, tcx: &ty::ctxt, } } -fn build_external_function(cx: &DocContext, tcx: &ty::ctxt, did: DefId) -> clean::Function { +fn build_external_function(cx: &DocContext, tcx: &TyCtxt, did: DefId) -> clean::Function { let t = tcx.lookup_item_type(did); let (decl, style, abi) = match t.ty.sty { ty::TyBareFn(_, ref f) => ((did, &f.sig).clean(cx), f.unsafety, f.abi), @@ -187,7 +187,7 @@ fn build_external_function(cx: &DocContext, tcx: &ty::ctxt, did: DefId) -> clean } } -fn build_struct(cx: &DocContext, tcx: &ty::ctxt, did: DefId) -> clean::Struct { +fn build_struct(cx: &DocContext, tcx: &TyCtxt, did: DefId) -> clean::Struct { let t = tcx.lookup_item_type(did); let predicates = tcx.lookup_predicates(did); let variant = tcx.lookup_adt_def(did).struct_variant(); @@ -205,7 +205,7 @@ fn build_struct(cx: &DocContext, tcx: &ty::ctxt, did: DefId) -> clean::Struct { } } -fn build_type(cx: &DocContext, tcx: &ty::ctxt, did: DefId) -> clean::ItemEnum { +fn build_type(cx: &DocContext, tcx: &TyCtxt, did: DefId) -> clean::ItemEnum { let t = tcx.lookup_item_type(did); let predicates = tcx.lookup_predicates(did); match t.ty.sty { @@ -225,7 +225,7 @@ fn build_type(cx: &DocContext, tcx: &ty::ctxt, did: DefId) -> clean::ItemEnum { }, false) } -pub fn build_impls(cx: &DocContext, tcx: &ty::ctxt, +pub fn build_impls(cx: &DocContext, tcx: &TyCtxt, did: DefId) -> Vec { tcx.populate_inherent_implementations_for_type_if_necessary(did); let mut impls = Vec::new(); @@ -252,7 +252,7 @@ pub fn build_impls(cx: &DocContext, tcx: &ty::ctxt, populate_impls(cx, tcx, item.def, &mut impls); } - fn populate_impls(cx: &DocContext, tcx: &ty::ctxt, + fn populate_impls(cx: &DocContext, tcx: &TyCtxt, def: cstore::DefLike, impls: &mut Vec) { match def { @@ -276,7 +276,7 @@ pub fn build_impls(cx: &DocContext, tcx: &ty::ctxt, } pub fn build_impl(cx: &DocContext, - tcx: &ty::ctxt, + tcx: &TyCtxt, did: DefId, ret: &mut Vec) { if !cx.inlined.borrow_mut().as_mut().unwrap().insert(did) { @@ -442,7 +442,7 @@ fn is_doc_hidden(a: &clean::Attribute) -> bool { } } -fn build_module(cx: &DocContext, tcx: &ty::ctxt, +fn build_module(cx: &DocContext, tcx: &TyCtxt, did: DefId) -> clean::Module { let mut items = Vec::new(); fill_in(cx, tcx, did, &mut items); @@ -451,7 +451,7 @@ fn build_module(cx: &DocContext, tcx: &ty::ctxt, is_crate: false, }; - fn fill_in(cx: &DocContext, tcx: &ty::ctxt, did: DefId, + fn fill_in(cx: &DocContext, tcx: &TyCtxt, did: DefId, items: &mut Vec) { // If we're reexporting a reexport it may actually reexport something in // two namespaces, so the target may be listed twice. Make sure we only @@ -478,7 +478,7 @@ fn build_module(cx: &DocContext, tcx: &ty::ctxt, } } -fn build_const(cx: &DocContext, tcx: &ty::ctxt, +fn build_const(cx: &DocContext, tcx: &TyCtxt, did: DefId) -> clean::Constant { use rustc::middle::const_eval; use rustc_front::print::pprust; @@ -496,7 +496,7 @@ fn build_const(cx: &DocContext, tcx: &ty::ctxt, } } -fn build_static(cx: &DocContext, tcx: &ty::ctxt, +fn build_static(cx: &DocContext, tcx: &TyCtxt, did: DefId, mutable: bool) -> clean::Static { clean::Static { diff --git a/src/librustdoc/clean/mod.rs b/src/librustdoc/clean/mod.rs index af8fee561dd3a..b6da5b0ef20e8 100644 --- a/src/librustdoc/clean/mod.rs +++ b/src/librustdoc/clean/mod.rs @@ -1408,7 +1408,7 @@ pub struct PolyTrait { } /// A representation of a Type suitable for hyperlinking purposes. Ideally one can get the original -/// type out of the AST/ty::ctxt given one of these, if more information is needed. Most importantly +/// type out of the AST/TyCtxt given one of these, if more information is needed. Most importantly /// it does not preserve mutability or boxes. #[derive(Clone, RustcEncodable, RustcDecodable, PartialEq, Debug)] pub enum Type { diff --git a/src/librustdoc/core.rs b/src/librustdoc/core.rs index 6b8f34ac73f64..345b84e0cac81 100644 --- a/src/librustdoc/core.rs +++ b/src/librustdoc/core.rs @@ -15,7 +15,7 @@ use rustc::dep_graph::DepGraph; use rustc::session::{self, config}; use rustc::middle::def_id::DefId; use rustc::middle::privacy::AccessLevels; -use rustc::middle::ty; +use rustc::middle::ty::{self, TyCtxt}; use rustc::front::map as hir_map; use rustc::lint; use rustc_trans::back::link; @@ -41,7 +41,7 @@ pub use rustc::session::search_paths::SearchPaths; /// Are we generating documentation (`Typed`) or tests (`NotTyped`)? pub enum MaybeTyped<'a, 'tcx: 'a> { - Typed(&'a ty::ctxt<'tcx>), + Typed(&'a TyCtxt<'tcx>), NotTyped(&'a session::Session) } @@ -68,14 +68,14 @@ impl<'b, 'tcx> DocContext<'b, 'tcx> { } } - pub fn tcx_opt<'a>(&'a self) -> Option<&'a ty::ctxt<'tcx>> { + pub fn tcx_opt<'a>(&'a self) -> Option<&'a TyCtxt<'tcx>> { match self.maybe_typed { Typed(tcx) => Some(tcx), NotTyped(_) => None } } - pub fn tcx<'a>(&'a self) -> &'a ty::ctxt<'tcx> { + pub fn tcx<'a>(&'a self) -> &'a TyCtxt<'tcx> { let tcx_opt = self.tcx_opt(); tcx_opt.expect("tcx not present") }