Skip to content

Commit

Permalink
bring TyCtxt into scope
Browse files Browse the repository at this point in the history
  • Loading branch information
qmx committed Sep 15, 2017
1 parent d3bbce7 commit 2bde694
Show file tree
Hide file tree
Showing 11 changed files with 31 additions and 31 deletions.
8 changes: 4 additions & 4 deletions src/librustc/ich/hcx.rs
Original file line number Diff line number Diff line change
Expand Up @@ -13,7 +13,7 @@ use hir::def_id::DefId;
use hir::map::DefPathHash;
use ich::{self, CachingCodemapView};
use session::config::DebugInfoLevel::NoDebugInfo;
use ty;
use ty::TyCtxt;
use util::nodemap::{NodeMap, ItemLocalMap};

use std::hash as std_hash;
Expand All @@ -34,7 +34,7 @@ use rustc_data_structures::accumulate_vec::AccumulateVec;
/// a reference to the TyCtxt) and it holds a few caches for speeding up various
/// things (e.g. each DefId/DefPath is only hashed once).
pub struct StableHashingContext<'a, 'gcx: 'a+'tcx, 'tcx: 'a> {
tcx: ty::TyCtxt<'a, 'gcx, 'tcx>,
tcx: TyCtxt<'a, 'gcx, 'tcx>,
codemap: CachingCodemapView<'gcx>,
hash_spans: bool,
hash_bodies: bool,
Expand All @@ -53,7 +53,7 @@ pub enum NodeIdHashingMode {

impl<'a, 'gcx, 'tcx> StableHashingContext<'a, 'gcx, 'tcx> {

pub fn new(tcx: ty::TyCtxt<'a, 'gcx, 'tcx>) -> Self {
pub fn new(tcx: TyCtxt<'a, 'gcx, 'tcx>) -> Self {
let hash_spans_initial = tcx.sess.opts.debuginfo != NoDebugInfo;
let check_overflow_initial = tcx.sess.overflow_checks();

Expand Down Expand Up @@ -111,7 +111,7 @@ impl<'a, 'gcx, 'tcx> StableHashingContext<'a, 'gcx, 'tcx> {
}

#[inline]
pub fn tcx(&self) -> ty::TyCtxt<'a, 'gcx, 'tcx> {
pub fn tcx(&self) -> TyCtxt<'a, 'gcx, 'tcx> {
self.tcx
}

Expand Down
2 changes: 1 addition & 1 deletion src/librustc/middle/lang_items.rs
Original file line number Diff line number Diff line change
Expand Up @@ -340,7 +340,7 @@ language_item_table! {
DebugTraitLangItem, "debug_trait", debug_trait;
}

impl<'a, 'tcx, 'gcx> ty::TyCtxt<'a, 'tcx, 'gcx> {
impl<'a, 'tcx, 'gcx> TyCtxt<'a, 'tcx, 'gcx> {
pub fn require_lang_item(&self, lang_item: LangItem) -> DefId {
self.lang_items().require(lang_item).unwrap_or_else(|msg| {
self.sess.fatal(&msg)
Expand Down
6 changes: 3 additions & 3 deletions src/librustc/mir/mod.rs
Original file line number Diff line number Diff line change
Expand Up @@ -21,7 +21,7 @@ use rustc_data_structures::control_flow_graph::ControlFlowGraph;
use hir::def::CtorKind;
use hir::def_id::DefId;
use ty::subst::{Subst, Substs};
use ty::{self, AdtDef, ClosureSubsts, Region, Ty, GeneratorInterior};
use ty::{self, AdtDef, ClosureSubsts, Region, Ty, TyCtxt, GeneratorInterior};
use ty::fold::{TypeFoldable, TypeFolder, TypeVisitor};
use util::ppaux;
use rustc_back::slice;
Expand Down Expand Up @@ -644,7 +644,7 @@ impl<'tcx> Terminator<'tcx> {
}

impl<'tcx> TerminatorKind<'tcx> {
pub fn if_<'a, 'gcx>(tcx: ty::TyCtxt<'a, 'gcx, 'tcx>, cond: Operand<'tcx>,
pub fn if_<'a, 'gcx>(tcx: TyCtxt<'a, 'gcx, 'tcx>, cond: Operand<'tcx>,
t: BasicBlock, f: BasicBlock) -> TerminatorKind<'tcx> {
static BOOL_SWITCH_FALSE: &'static [ConstInt] = &[ConstInt::U8(0)];
TerminatorKind::SwitchInt {
Expand Down Expand Up @@ -1182,7 +1182,7 @@ impl<'tcx> Debug for Operand<'tcx> {

impl<'tcx> Operand<'tcx> {
pub fn function_handle<'a>(
tcx: ty::TyCtxt<'a, 'tcx, 'tcx>,
tcx: TyCtxt<'a, 'tcx, 'tcx>,
def_id: DefId,
substs: &'tcx Substs<'tcx>,
span: Span,
Expand Down
2 changes: 1 addition & 1 deletion src/librustc/ty/layout.rs
Original file line number Diff line number Diff line change
Expand Up @@ -386,7 +386,7 @@ impl Integer {
}
}

pub fn to_ty<'a, 'tcx>(&self, tcx: &ty::TyCtxt<'a, 'tcx, 'tcx>,
pub fn to_ty<'a, 'tcx>(&self, tcx: &TyCtxt<'a, 'tcx, 'tcx>,
signed: bool) -> Ty<'tcx> {
match (*self, signed) {
(I1, false) => tcx.types.u8,
Expand Down
4 changes: 2 additions & 2 deletions src/librustc_metadata/astencode.rs
Original file line number Diff line number Diff line change
Expand Up @@ -14,7 +14,7 @@ use isolated_encoder::IsolatedEncoder;
use schema::*;

use rustc::hir;
use rustc::ty;
use rustc::ty::{self, TyCtxt};

#[derive(RustcEncodable, RustcDecodable)]
pub struct Ast<'tcx> {
Expand Down Expand Up @@ -59,7 +59,7 @@ impl<'a, 'b, 'tcx> IsolatedEncoder<'a, 'b, 'tcx> {
}

struct NestedBodyCollector<'a, 'tcx: 'a> {
tcx: ty::TyCtxt<'a, 'tcx, 'tcx>,
tcx: TyCtxt<'a, 'tcx, 'tcx>,
bodies_found: Vec<&'tcx hir::Body>,
}

Expand Down
4 changes: 2 additions & 2 deletions src/librustc_mir/build/cfg.rs
Original file line number Diff line number Diff line change
Expand Up @@ -16,7 +16,7 @@
use build::CFG;
use rustc::middle::region;
use rustc::mir::*;
use rustc::ty;
use rustc::ty::TyCtxt;

impl<'tcx> CFG<'tcx> {
pub fn block_data(&self, blk: BasicBlock) -> &BasicBlockData<'tcx> {
Expand Down Expand Up @@ -46,7 +46,7 @@ impl<'tcx> CFG<'tcx> {
}

pub fn push_end_region<'a, 'gcx:'a+'tcx>(&mut self,
tcx: ty::TyCtxt<'a, 'gcx, 'tcx>,
tcx: TyCtxt<'a, 'gcx, 'tcx>,
block: BasicBlock,
source_info: SourceInfo,
region_scope: region::Scope) {
Expand Down
18 changes: 9 additions & 9 deletions src/librustc_mir/shim.rs
Original file line number Diff line number Diff line change
Expand Up @@ -14,7 +14,7 @@ use rustc::infer;
use rustc::middle::const_val::ConstVal;
use rustc::mir::*;
use rustc::mir::transform::MirSource;
use rustc::ty::{self, Ty};
use rustc::ty::{self, Ty, TyCtxt};
use rustc::ty::subst::{Kind, Subst, Substs};
use rustc::ty::maps::Providers;
use rustc_const_math::{ConstInt, ConstUsize};
Expand All @@ -36,7 +36,7 @@ pub fn provide(providers: &mut Providers) {
providers.mir_shims = make_shim;
}

fn make_shim<'a, 'tcx>(tcx: ty::TyCtxt<'a, 'tcx, 'tcx>,
fn make_shim<'a, 'tcx>(tcx: TyCtxt<'a, 'tcx, 'tcx>,
instance: ty::InstanceDef<'tcx>)
-> &'tcx Mir<'tcx>
{
Expand Down Expand Up @@ -154,7 +154,7 @@ fn local_decls_for_sig<'tcx>(sig: &ty::FnSig<'tcx>, span: Span)
.collect()
}

fn build_drop_shim<'a, 'tcx>(tcx: ty::TyCtxt<'a, 'tcx, 'tcx>,
fn build_drop_shim<'a, 'tcx>(tcx: TyCtxt<'a, 'tcx, 'tcx>,
def_id: DefId,
ty: Option<Ty<'tcx>>)
-> Mir<'tcx>
Expand Down Expand Up @@ -235,7 +235,7 @@ fn build_drop_shim<'a, 'tcx>(tcx: ty::TyCtxt<'a, 'tcx, 'tcx>,
pub struct DropShimElaborator<'a, 'tcx: 'a> {
pub mir: &'a Mir<'tcx>,
pub patch: MirPatch<'tcx>,
pub tcx: ty::TyCtxt<'a, 'tcx, 'tcx>,
pub tcx: TyCtxt<'a, 'tcx, 'tcx>,
pub param_env: ty::ParamEnv<'tcx>,
}

Expand All @@ -250,7 +250,7 @@ impl<'a, 'tcx> DropElaborator<'a, 'tcx> for DropShimElaborator<'a, 'tcx> {

fn patch(&mut self) -> &mut MirPatch<'tcx> { &mut self.patch }
fn mir(&self) -> &'a Mir<'tcx> { self.mir }
fn tcx(&self) -> ty::TyCtxt<'a, 'tcx, 'tcx> { self.tcx }
fn tcx(&self) -> TyCtxt<'a, 'tcx, 'tcx> { self.tcx }
fn param_env(&self) -> ty::ParamEnv<'tcx> { self.param_env }

fn drop_style(&self, _path: Self::Path, mode: DropFlagMode) -> DropStyle {
Expand Down Expand Up @@ -280,7 +280,7 @@ impl<'a, 'tcx> DropElaborator<'a, 'tcx> for DropShimElaborator<'a, 'tcx> {
}

/// Build a `Clone::clone` shim for `self_ty`. Here, `def_id` is `Clone::clone`.
fn build_clone_shim<'a, 'tcx>(tcx: ty::TyCtxt<'a, 'tcx, 'tcx>,
fn build_clone_shim<'a, 'tcx>(tcx: TyCtxt<'a, 'tcx, 'tcx>,
def_id: DefId,
self_ty: ty::Ty<'tcx>)
-> Mir<'tcx>
Expand All @@ -306,7 +306,7 @@ fn build_clone_shim<'a, 'tcx>(tcx: ty::TyCtxt<'a, 'tcx, 'tcx>,
}

struct CloneShimBuilder<'a, 'tcx: 'a> {
tcx: ty::TyCtxt<'a, 'tcx, 'tcx>,
tcx: TyCtxt<'a, 'tcx, 'tcx>,
def_id: DefId,
local_decls: IndexVec<Local, LocalDecl<'tcx>>,
blocks: IndexVec<BasicBlock, BasicBlockData<'tcx>>,
Expand All @@ -315,7 +315,7 @@ struct CloneShimBuilder<'a, 'tcx: 'a> {
}

impl<'a, 'tcx> CloneShimBuilder<'a, 'tcx> {
fn new(tcx: ty::TyCtxt<'a, 'tcx, 'tcx>, def_id: DefId) -> Self {
fn new(tcx: TyCtxt<'a, 'tcx, 'tcx>, def_id: DefId) -> Self {
let sig = tcx.fn_sig(def_id);
let sig = tcx.erase_late_bound_regions(&sig);
let span = tcx.def_span(def_id);
Expand Down Expand Up @@ -666,7 +666,7 @@ impl<'a, 'tcx> CloneShimBuilder<'a, 'tcx> {
///
/// If `untuple_args` is a vec of types, the second argument of the
/// function will be untupled as these types.
fn build_call_shim<'a, 'tcx>(tcx: ty::TyCtxt<'a, 'tcx, 'tcx>,
fn build_call_shim<'a, 'tcx>(tcx: TyCtxt<'a, 'tcx, 'tcx>,
def_id: DefId,
rcvr_adjustment: Adjustment,
call_kind: CallKind,
Expand Down
2 changes: 1 addition & 1 deletion src/librustc_mir/transform/elaborate_drops.rs
Original file line number Diff line number Diff line change
Expand Up @@ -192,7 +192,7 @@ impl<'a, 'b, 'tcx> DropElaborator<'a, 'tcx> for Elaborator<'a, 'b, 'tcx> {
self.ctxt.mir
}

fn tcx(&self) -> ty::TyCtxt<'a, 'tcx, 'tcx> {
fn tcx(&self) -> TyCtxt<'a, 'tcx, 'tcx> {
self.ctxt.tcx
}

Expand Down
6 changes: 3 additions & 3 deletions src/librustc_mir/util/elaborate_drops.rs
Original file line number Diff line number Diff line change
Expand Up @@ -13,7 +13,7 @@ use rustc::hir;
use rustc::mir::*;
use rustc::middle::const_val::{ConstInt, ConstVal};
use rustc::middle::lang_items;
use rustc::ty::{self, Ty};
use rustc::ty::{self, Ty, TyCtxt};
use rustc::ty::subst::{Kind, Substs};
use rustc::ty::util::IntTypeExt;
use rustc_data_structures::indexed_vec::Idx;
Expand Down Expand Up @@ -84,7 +84,7 @@ pub trait DropElaborator<'a, 'tcx: 'a> : fmt::Debug {

fn patch(&mut self) -> &mut MirPatch<'tcx>;
fn mir(&self) -> &'a Mir<'tcx>;
fn tcx(&self) -> ty::TyCtxt<'a, 'tcx, 'tcx>;
fn tcx(&self) -> TyCtxt<'a, 'tcx, 'tcx>;
fn param_env(&self) -> ty::ParamEnv<'tcx>;

fn drop_style(&self, path: Self::Path, mode: DropFlagMode) -> DropStyle;
Expand Down Expand Up @@ -133,7 +133,7 @@ impl<'l, 'b, 'tcx, D> DropCtxt<'l, 'b, 'tcx, D>
lvalue.ty(self.elaborator.mir(), self.tcx()).to_ty(self.tcx())
}

fn tcx(&self) -> ty::TyCtxt<'b, 'tcx, 'tcx> {
fn tcx(&self) -> TyCtxt<'b, 'tcx, 'tcx> {
self.elaborator.tcx()
}

Expand Down
4 changes: 2 additions & 2 deletions src/librustc_typeck/check/upvar.rs
Original file line number Diff line number Diff line change
Expand Up @@ -45,7 +45,7 @@ use super::FnCtxt;
use middle::expr_use_visitor as euv;
use middle::mem_categorization as mc;
use middle::mem_categorization::Categorization;
use rustc::ty::{self, Ty};
use rustc::ty::{self, Ty, TyCtxt};
use rustc::infer::UpvarRegion;
use syntax::ast;
use syntax_pos::Span;
Expand Down Expand Up @@ -586,7 +586,7 @@ impl<'a, 'gcx, 'tcx> euv::Delegate<'tcx> for InferBorrowKind<'a, 'gcx, 'tcx> {
}
}

fn var_name(tcx: ty::TyCtxt, var_hir_id: hir::HirId) -> ast::Name {
fn var_name(tcx: TyCtxt, var_hir_id: hir::HirId) -> ast::Name {
let var_node_id = tcx.hir.hir_to_node_id(var_hir_id);
tcx.hir.name(var_node_id)
}
6 changes: 3 additions & 3 deletions src/librustc_typeck/constrained_type_params.rs
Original file line number Diff line number Diff line change
Expand Up @@ -8,7 +8,7 @@
// option. This file may not be copied, modified, or distributed
// except according to those terms.

use rustc::ty::{self, Ty};
use rustc::ty::{self, Ty, TyCtxt};
use rustc::ty::fold::{TypeFoldable, TypeVisitor};
use rustc::util::nodemap::FxHashSet;

Expand Down Expand Up @@ -86,7 +86,7 @@ impl<'tcx> TypeVisitor<'tcx> for ParameterCollector {
}
}

pub fn identify_constrained_type_params<'tcx>(tcx: ty::TyCtxt,
pub fn identify_constrained_type_params<'tcx>(tcx: TyCtxt,
predicates: &[ty::Predicate<'tcx>],
impl_trait_ref: Option<ty::TraitRef<'tcx>>,
input_parameters: &mut FxHashSet<Parameter>)
Expand Down Expand Up @@ -136,7 +136,7 @@ pub fn identify_constrained_type_params<'tcx>(tcx: ty::TyCtxt,
/// 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::TyCtxt,
pub fn setup_constraining_predicates<'tcx>(tcx: TyCtxt,
predicates: &mut [ty::Predicate<'tcx>],
impl_trait_ref: Option<ty::TraitRef<'tcx>>,
input_parameters: &mut FxHashSet<Parameter>)
Expand Down

0 comments on commit 2bde694

Please sign in to comment.