Skip to content

Commit ed3f09c

Browse files
authored
Rollup merge of rust-lang#44560 - qmx:import-TyCtxt, r=eddyb
bring TyCtxt into scope got comments both from @eddyb and @nikomatsakis (via rust-lang#44505) that we should always put `TyCtxt` in scope should I just go and import it at other places in the codebase or we just keep doing small improvements?
2 parents d2d8fc2 + 3fe4612 commit ed3f09c

File tree

30 files changed

+94
-94
lines changed

30 files changed

+94
-94
lines changed

src/librustc/ich/hcx.rs

+4-4
Original file line numberDiff line numberDiff line change
@@ -13,7 +13,7 @@ use hir::def_id::DefId;
1313
use hir::map::DefPathHash;
1414
use ich::{self, CachingCodemapView};
1515
use session::config::DebugInfoLevel::NoDebugInfo;
16-
use ty;
16+
use ty::TyCtxt;
1717
use util::nodemap::{NodeMap, ItemLocalMap};
1818

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

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

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

@@ -111,7 +111,7 @@ impl<'a, 'gcx, 'tcx> StableHashingContext<'a, 'gcx, 'tcx> {
111111
}
112112

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

src/librustc/infer/error_reporting/mod.rs

+5-5
Original file line numberDiff line numberDiff line change
@@ -66,7 +66,7 @@ use hir::map as hir_map;
6666
use hir::def_id::DefId;
6767
use middle::region;
6868
use traits::{ObligationCause, ObligationCauseCode};
69-
use ty::{self, Region, TyCtxt, TypeFoldable};
69+
use ty::{self, Region, Ty, TyCtxt, TypeFoldable};
7070
use ty::error::TypeError;
7171
use syntax::ast::DUMMY_NODE_ID;
7272
use syntax_pos::{Pos, Span};
@@ -418,7 +418,7 @@ impl<'a, 'gcx, 'tcx> InferCtxt<'a, 'gcx, 'tcx> {
418418
name: String,
419419
sub: &ty::subst::Substs<'tcx>,
420420
pos: usize,
421-
other_ty: &ty::Ty<'tcx>) {
421+
other_ty: &Ty<'tcx>) {
422422
// `value` and `other_value` hold two incomplete type representation for display.
423423
// `name` is the path of both types being compared. `sub`
424424
value.push_highlighted(name);
@@ -491,7 +491,7 @@ impl<'a, 'gcx, 'tcx> InferCtxt<'a, 'gcx, 'tcx> {
491491
path: String,
492492
sub: &ty::subst::Substs<'tcx>,
493493
other_path: String,
494-
other_ty: &ty::Ty<'tcx>) -> Option<()> {
494+
other_ty: &Ty<'tcx>) -> Option<()> {
495495
for (i, ta) in sub.types().enumerate() {
496496
if &ta == other_ty {
497497
self.highlight_outer(&mut t1_out, &mut t2_out, path, sub, i, &other_ty);
@@ -522,7 +522,7 @@ impl<'a, 'gcx, 'tcx> InferCtxt<'a, 'gcx, 'tcx> {
522522

523523
/// Compare two given types, eliding parts that are the same between them and highlighting
524524
/// relevant differences, and return two representation of those types for highlighted printing.
525-
fn cmp(&self, t1: ty::Ty<'tcx>, t2: ty::Ty<'tcx>)
525+
fn cmp(&self, t1: Ty<'tcx>, t2: Ty<'tcx>)
526526
-> (DiagnosticStyledString, DiagnosticStyledString)
527527
{
528528
match (&t1.sty, &t2.sty) {
@@ -743,7 +743,7 @@ impl<'a, 'gcx, 'tcx> InferCtxt<'a, 'gcx, 'tcx> {
743743
}
744744

745745
fn expected_found_str_ty(&self,
746-
exp_found: &ty::error::ExpectedFound<ty::Ty<'tcx>>)
746+
exp_found: &ty::error::ExpectedFound<Ty<'tcx>>)
747747
-> Option<(DiagnosticStyledString, DiagnosticStyledString)> {
748748
let exp_found = self.resolve_type_vars_if_possible(exp_found);
749749
if exp_found.references_error() {

src/librustc/infer/error_reporting/util.rs

+2-2
Original file line numberDiff line numberDiff line change
@@ -12,7 +12,7 @@
1212
//! anonymous regions.
1313
use hir;
1414
use infer::InferCtxt;
15-
use ty::{self, Region};
15+
use ty::{self, Region, Ty};
1616
use hir::def_id::DefId;
1717
use hir::map as hir_map;
1818

@@ -35,7 +35,7 @@ pub struct AnonymousArgInfo<'tcx> {
3535
// the argument corresponding to the anonymous region
3636
pub arg: &'tcx hir::Arg,
3737
// the type corresponding to the anonymopus region argument
38-
pub arg_ty: ty::Ty<'tcx>,
38+
pub arg_ty: Ty<'tcx>,
3939
// the ty::BoundRegion corresponding to the anonymous region
4040
pub bound_region: ty::BoundRegion,
4141
// corresponds to id the argument is the first parameter

src/librustc/infer/mod.rs

+1-1
Original file line numberDiff line numberDiff line change
@@ -644,7 +644,7 @@ impl<'a, 'gcx, 'tcx> InferCtxt<'a, 'gcx, 'tcx> {
644644
}
645645
}
646646

647-
pub fn unsolved_variables(&self) -> Vec<ty::Ty<'tcx>> {
647+
pub fn unsolved_variables(&self) -> Vec<Ty<'tcx>> {
648648
let mut variables = Vec::new();
649649

650650
let unbound_ty_vars = self.type_variables

src/librustc/middle/lang_items.rs

+1-1
Original file line numberDiff line numberDiff line change
@@ -315,7 +315,7 @@ language_item_table! {
315315
DebugTraitLangItem, "debug_trait", debug_trait;
316316
}
317317

318-
impl<'a, 'tcx, 'gcx> ty::TyCtxt<'a, 'tcx, 'gcx> {
318+
impl<'a, 'tcx, 'gcx> TyCtxt<'a, 'tcx, 'gcx> {
319319
pub fn require_lang_item(&self, lang_item: LangItem) -> DefId {
320320
self.lang_items().require(lang_item).unwrap_or_else(|msg| {
321321
self.sess.fatal(&msg)

src/librustc/mir/mod.rs

+3-3
Original file line numberDiff line numberDiff line change
@@ -21,7 +21,7 @@ use rustc_data_structures::control_flow_graph::ControlFlowGraph;
2121
use hir::def::CtorKind;
2222
use hir::def_id::DefId;
2323
use ty::subst::{Subst, Substs};
24-
use ty::{self, AdtDef, ClosureSubsts, Region, Ty, GeneratorInterior};
24+
use ty::{self, AdtDef, ClosureSubsts, Region, Ty, TyCtxt, GeneratorInterior};
2525
use ty::fold::{TypeFoldable, TypeFolder, TypeVisitor};
2626
use util::ppaux;
2727
use rustc_back::slice;
@@ -644,7 +644,7 @@ impl<'tcx> Terminator<'tcx> {
644644
}
645645

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

11831183
impl<'tcx> Operand<'tcx> {
11841184
pub fn function_handle<'a>(
1185-
tcx: ty::TyCtxt<'a, 'tcx, 'tcx>,
1185+
tcx: TyCtxt<'a, 'tcx, 'tcx>,
11861186
def_id: DefId,
11871187
substs: &'tcx Substs<'tcx>,
11881188
span: Span,

src/librustc/traits/mod.rs

+1-1
Original file line numberDiff line numberDiff line change
@@ -381,7 +381,7 @@ pub struct VtableObjectData<'tcx, N> {
381381

382382
#[derive(Clone, PartialEq, Eq)]
383383
pub struct VtableFnPointerData<'tcx, N> {
384-
pub fn_ty: ty::Ty<'tcx>,
384+
pub fn_ty: Ty<'tcx>,
385385
pub nested: Vec<N>
386386
}
387387

src/librustc/ty/instance.rs

+4-4
Original file line numberDiff line numberDiff line change
@@ -9,7 +9,7 @@
99
// except according to those terms.
1010

1111
use hir::def_id::DefId;
12-
use ty::{self, Ty, TypeFoldable, Substs};
12+
use ty::{self, Ty, TypeFoldable, Substs, TyCtxt};
1313
use util::ppaux;
1414

1515
use std::fmt;
@@ -57,12 +57,12 @@ impl<'tcx> InstanceDef<'tcx> {
5757
}
5858

5959
#[inline]
60-
pub fn def_ty<'a>(&self, tcx: ty::TyCtxt<'a, 'tcx, 'tcx>) -> Ty<'tcx> {
60+
pub fn def_ty<'a>(&self, tcx: TyCtxt<'a, 'tcx, 'tcx>) -> Ty<'tcx> {
6161
tcx.type_of(self.def_id())
6262
}
6363

6464
#[inline]
65-
pub fn attrs<'a>(&self, tcx: ty::TyCtxt<'a, 'tcx, 'tcx>) -> ty::Attributes<'tcx> {
65+
pub fn attrs<'a>(&self, tcx: TyCtxt<'a, 'tcx, 'tcx>) -> ty::Attributes<'tcx> {
6666
tcx.get_attrs(self.def_id())
6767
}
6868
}
@@ -103,7 +103,7 @@ impl<'a, 'b, 'tcx> Instance<'tcx> {
103103
Instance { def: InstanceDef::Item(def_id), substs: substs }
104104
}
105105

106-
pub fn mono(tcx: ty::TyCtxt<'a, 'tcx, 'b>, def_id: DefId) -> Instance<'tcx> {
106+
pub fn mono(tcx: TyCtxt<'a, 'tcx, 'b>, def_id: DefId) -> Instance<'tcx> {
107107
Instance::new(def_id, tcx.global_tcx().empty_substs_for_def_id(def_id))
108108
}
109109

src/librustc/ty/layout.rs

+1-1
Original file line numberDiff line numberDiff line change
@@ -386,7 +386,7 @@ impl Integer {
386386
}
387387
}
388388

389-
pub fn to_ty<'a, 'tcx>(&self, tcx: &ty::TyCtxt<'a, 'tcx, 'tcx>,
389+
pub fn to_ty<'a, 'tcx>(&self, tcx: &TyCtxt<'a, 'tcx, 'tcx>,
390390
signed: bool) -> Ty<'tcx> {
391391
match (*self, signed) {
392392
(I1, false) => tcx.types.u8,

src/librustc_borrowck/borrowck/mod.rs

+4-4
Original file line numberDiff line numberDiff line change
@@ -34,7 +34,7 @@ use rustc::middle::mem_categorization::Categorization;
3434
use rustc::middle::mem_categorization::ImmutabilityBlame;
3535
use rustc::middle::region;
3636
use rustc::middle::free_region::RegionRelations;
37-
use rustc::ty::{self, TyCtxt};
37+
use rustc::ty::{self, Ty, TyCtxt};
3838
use rustc::ty::maps::Providers;
3939
use rustc_mir::util::borrowck_errors::{BorrowckErrors, Origin};
4040

@@ -275,7 +275,7 @@ impl<'tcx> Loan<'tcx> {
275275
#[derive(Eq)]
276276
pub struct LoanPath<'tcx> {
277277
kind: LoanPathKind<'tcx>,
278-
ty: ty::Ty<'tcx>,
278+
ty: Ty<'tcx>,
279279
}
280280

281281
impl<'tcx> PartialEq for LoanPath<'tcx> {
@@ -299,11 +299,11 @@ pub enum LoanPathKind<'tcx> {
299299
}
300300

301301
impl<'tcx> LoanPath<'tcx> {
302-
fn new(kind: LoanPathKind<'tcx>, ty: ty::Ty<'tcx>) -> LoanPath<'tcx> {
302+
fn new(kind: LoanPathKind<'tcx>, ty: Ty<'tcx>) -> LoanPath<'tcx> {
303303
LoanPath { kind: kind, ty: ty }
304304
}
305305

306-
fn to_type(&self) -> ty::Ty<'tcx> { self.ty }
306+
fn to_type(&self) -> Ty<'tcx> { self.ty }
307307
}
308308

309309
// FIXME (pnkfelix): See discussion here

src/librustc_metadata/astencode.rs

+2-2
Original file line numberDiff line numberDiff line change
@@ -14,7 +14,7 @@ use isolated_encoder::IsolatedEncoder;
1414
use schema::*;
1515

1616
use rustc::hir;
17-
use rustc::ty;
17+
use rustc::ty::{self, TyCtxt};
1818

1919
#[derive(RustcEncodable, RustcDecodable)]
2020
pub struct Ast<'tcx> {
@@ -59,7 +59,7 @@ impl<'a, 'b, 'tcx> IsolatedEncoder<'a, 'b, 'tcx> {
5959
}
6060

6161
struct NestedBodyCollector<'a, 'tcx: 'a> {
62-
tcx: ty::TyCtxt<'a, 'tcx, 'tcx>,
62+
tcx: TyCtxt<'a, 'tcx, 'tcx>,
6363
bodies_found: Vec<&'tcx hir::Body>,
6464
}
6565

src/librustc_mir/build/cfg.rs

+2-2
Original file line numberDiff line numberDiff line change
@@ -16,7 +16,7 @@
1616
use build::CFG;
1717
use rustc::middle::region;
1818
use rustc::mir::*;
19-
use rustc::ty;
19+
use rustc::ty::TyCtxt;
2020

2121
impl<'tcx> CFG<'tcx> {
2222
pub fn block_data(&self, blk: BasicBlock) -> &BasicBlockData<'tcx> {
@@ -46,7 +46,7 @@ impl<'tcx> CFG<'tcx> {
4646
}
4747

4848
pub fn push_end_region<'a, 'gcx:'a+'tcx>(&mut self,
49-
tcx: ty::TyCtxt<'a, 'gcx, 'tcx>,
49+
tcx: TyCtxt<'a, 'gcx, 'tcx>,
5050
block: BasicBlock,
5151
source_info: SourceInfo,
5252
region_scope: region::Scope) {

src/librustc_mir/build/expr/as_rvalue.rs

+4-4
Original file line numberDiff line numberDiff line change
@@ -22,7 +22,7 @@ use hair::*;
2222
use rustc_const_math::{ConstInt, ConstIsize};
2323
use rustc::middle::const_val::ConstVal;
2424
use rustc::middle::region;
25-
use rustc::ty;
25+
use rustc::ty::{self, Ty};
2626
use rustc::mir::*;
2727
use syntax::ast;
2828
use syntax_pos::Span;
@@ -291,7 +291,7 @@ impl<'a, 'gcx, 'tcx> Builder<'a, 'gcx, 'tcx> {
291291
}
292292

293293
pub fn build_binary_op(&mut self, mut block: BasicBlock,
294-
op: BinOp, span: Span, ty: ty::Ty<'tcx>,
294+
op: BinOp, span: Span, ty: Ty<'tcx>,
295295
lhs: Operand<'tcx>, rhs: Operand<'tcx>) -> BlockAnd<Rvalue<'tcx>> {
296296
let source_info = self.source_info(span);
297297
let bool_ty = self.hir.bool_ty();
@@ -378,7 +378,7 @@ impl<'a, 'gcx, 'tcx> Builder<'a, 'gcx, 'tcx> {
378378
}
379379

380380
// Helper to get a `-1` value of the appropriate type
381-
fn neg_1_literal(&mut self, span: Span, ty: ty::Ty<'tcx>) -> Operand<'tcx> {
381+
fn neg_1_literal(&mut self, span: Span, ty: Ty<'tcx>) -> Operand<'tcx> {
382382
let literal = match ty.sty {
383383
ty::TyInt(ity) => {
384384
let val = match ity {
@@ -410,7 +410,7 @@ impl<'a, 'gcx, 'tcx> Builder<'a, 'gcx, 'tcx> {
410410
}
411411

412412
// Helper to get the minimum value of the appropriate type
413-
fn minval_literal(&mut self, span: Span, ty: ty::Ty<'tcx>) -> Operand<'tcx> {
413+
fn minval_literal(&mut self, span: Span, ty: Ty<'tcx>) -> Operand<'tcx> {
414414
let literal = match ty.sty {
415415
ty::TyInt(ity) => {
416416
let val = match ity {

src/librustc_mir/hair/mod.rs

+2-2
Original file line numberDiff line numberDiff line change
@@ -19,7 +19,7 @@ use rustc::mir::{BinOp, BorrowKind, Field, Literal, UnOp};
1919
use rustc::hir::def_id::DefId;
2020
use rustc::middle::region;
2121
use rustc::ty::subst::Substs;
22-
use rustc::ty::{self, AdtDef, ClosureSubsts, Region, Ty, GeneratorInterior};
22+
use rustc::ty::{AdtDef, ClosureSubsts, Region, Ty, GeneratorInterior};
2323
use rustc::hir;
2424
use syntax::ast;
2525
use syntax_pos::Span;
@@ -117,7 +117,7 @@ pub enum ExprKind<'tcx> {
117117
value: ExprRef<'tcx>,
118118
},
119119
Call {
120-
ty: ty::Ty<'tcx>,
120+
ty: Ty<'tcx>,
121121
fun: ExprRef<'tcx>,
122122
args: Vec<ExprRef<'tcx>>,
123123
},

0 commit comments

Comments
 (0)