Skip to content

Commit 6db5126

Browse files
committed
rustc: make ty::mk_* constructors into methods on ty::ctxt.
1 parent 2332765 commit 6db5126

Some content is hidden

Large Commits have some content hidden by default. Use the searchbox below for content that may be hidden.

48 files changed

+481
-526
lines changed

src/librustc/metadata/tydecode.rs

+17-17
Original file line numberDiff line numberDiff line change
@@ -471,14 +471,14 @@ fn parse_ty_<'a, 'tcx, F>(st: &mut PState<'a, 'tcx>, conv: &mut F) -> Ty<'tcx> w
471471
let def = parse_def_(st, NominalType, conv);
472472
let substs = parse_substs_(st, conv);
473473
assert_eq!(next(st), ']');
474-
return ty::mk_enum(tcx, def, st.tcx.mk_substs(substs));
474+
return tcx.mk_enum(def, st.tcx.mk_substs(substs));
475475
}
476476
'x' => {
477477
assert_eq!(next(st), '[');
478478
let trait_ref = ty::Binder(parse_trait_ref_(st, conv));
479479
let bounds = parse_existential_bounds_(st, conv);
480480
assert_eq!(next(st), ']');
481-
return ty::mk_trait(tcx, trait_ref, bounds);
481+
return tcx.mk_trait(trait_ref, bounds);
482482
}
483483
'p' => {
484484
assert_eq!(next(st), '[');
@@ -487,38 +487,38 @@ fn parse_ty_<'a, 'tcx, F>(st: &mut PState<'a, 'tcx>, conv: &mut F) -> Ty<'tcx> w
487487
let space = parse_param_space(st);
488488
assert_eq!(next(st), '|');
489489
let name = token::intern(&parse_str(st, ']'));
490-
return ty::mk_param(tcx, space, index, name);
490+
return tcx.mk_param(space, index, name);
491491
}
492-
'~' => return ty::mk_uniq(tcx, parse_ty_(st, conv)),
493-
'*' => return ty::mk_ptr(tcx, parse_mt_(st, conv)),
492+
'~' => return tcx.mk_box(parse_ty_(st, conv)),
493+
'*' => return tcx.mk_ptr(parse_mt_(st, conv)),
494494
'&' => {
495495
let r = parse_region_(st, conv);
496496
let mt = parse_mt_(st, conv);
497-
return ty::mk_rptr(tcx, tcx.mk_region(r), mt);
497+
return tcx.mk_ref(tcx.mk_region(r), mt);
498498
}
499499
'V' => {
500500
let t = parse_ty_(st, conv);
501-
let sz = parse_size(st);
502-
return ty::mk_vec(tcx, t, sz);
501+
return match parse_size(st) {
502+
Some(n) => tcx.mk_array(t, n),
503+
None => tcx.mk_slice(t)
504+
};
503505
}
504506
'v' => {
505-
return ty::mk_str(tcx);
507+
return tcx.mk_str();
506508
}
507509
'T' => {
508510
assert_eq!(next(st), '[');
509511
let mut params = Vec::new();
510512
while peek(st) != ']' { params.push(parse_ty_(st, conv)); }
511513
st.pos = st.pos + 1;
512-
return ty::mk_tup(tcx, params);
514+
return tcx.mk_tup(params);
513515
}
514516
'F' => {
515517
let def_id = parse_def_(st, NominalType, conv);
516-
return ty::mk_bare_fn(tcx, Some(def_id),
517-
tcx.mk_bare_fn(parse_bare_fn_ty_(st, conv)));
518+
return tcx.mk_fn(Some(def_id), tcx.mk_bare_fn(parse_bare_fn_ty_(st, conv)));
518519
}
519520
'G' => {
520-
return ty::mk_bare_fn(tcx, None,
521-
tcx.mk_bare_fn(parse_bare_fn_ty_(st, conv)));
521+
return tcx.mk_fn(None, tcx.mk_bare_fn(parse_bare_fn_ty_(st, conv)));
522522
}
523523
'#' => {
524524
let pos = parse_hex(st);
@@ -558,20 +558,20 @@ fn parse_ty_<'a, 'tcx, F>(st: &mut PState<'a, 'tcx>, conv: &mut F) -> Ty<'tcx> w
558558
let did = parse_def_(st, NominalType, conv);
559559
let substs = parse_substs_(st, conv);
560560
assert_eq!(next(st), ']');
561-
return ty::mk_struct(st.tcx, did, st.tcx.mk_substs(substs));
561+
return st.tcx.mk_struct(did, st.tcx.mk_substs(substs));
562562
}
563563
'k' => {
564564
assert_eq!(next(st), '[');
565565
let did = parse_def_(st, ClosureSource, conv);
566566
let substs = parse_substs_(st, conv);
567567
assert_eq!(next(st), ']');
568-
return ty::mk_closure(st.tcx, did, st.tcx.mk_substs(substs));
568+
return st.tcx.mk_closure(did, st.tcx.mk_substs(substs));
569569
}
570570
'P' => {
571571
assert_eq!(next(st), '[');
572572
let trait_ref = parse_trait_ref_(st, conv);
573573
let name = token::intern(&parse_str(st, ']'));
574-
return ty::mk_projection(tcx, trait_ref, name);
574+
return tcx.mk_projection(trait_ref, name);
575575
}
576576
'e' => {
577577
return tcx.types.err;

src/librustc/middle/astconv_util.rs

+4-4
Original file line numberDiff line numberDiff line change
@@ -49,10 +49,10 @@ pub fn prim_ty_to_ty<'tcx>(tcx: &ty::ctxt<'tcx>,
4949
match nty {
5050
ast::TyBool => tcx.types.bool,
5151
ast::TyChar => tcx.types.char,
52-
ast::TyInt(it) => ty::mk_mach_int(tcx, it),
53-
ast::TyUint(uit) => ty::mk_mach_uint(tcx, uit),
54-
ast::TyFloat(ft) => ty::mk_mach_float(tcx, ft),
55-
ast::TyStr => ty::mk_str(tcx)
52+
ast::TyInt(it) => tcx.mk_mach_int(it),
53+
ast::TyUint(uit) => tcx.mk_mach_uint(uit),
54+
ast::TyFloat(ft) => tcx.mk_mach_float(ft),
55+
ast::TyStr => tcx.mk_str()
5656
}
5757
}
5858

src/librustc/middle/check_match.rs

+1-1
Original file line numberDiff line numberDiff line change
@@ -651,7 +651,7 @@ fn is_useful(cx: &MatchCheckCtxt,
651651
None => v[0]
652652
};
653653
let left_ty = if real_pat.id == DUMMY_NODE_ID {
654-
ty::mk_nil(cx.tcx)
654+
cx.tcx.mk_nil()
655655
} else {
656656
let left_ty = ty::pat_ty(cx.tcx, &*real_pat);
657657

src/librustc/middle/implicator.rs

+2-2
Original file line numberDiff line numberDiff line change
@@ -334,7 +334,7 @@ impl<'a, 'tcx> Implicator<'a, 'tcx> {
334334
let assoc_type_projections: Vec<_> =
335335
trait_def.associated_type_names
336336
.iter()
337-
.map(|&name| ty::mk_projection(self.tcx(), trait_ref.clone(), name))
337+
.map(|&name| self.tcx().mk_projection(trait_ref.clone(), name))
338338
.collect();
339339
debug!("accumulate_from_assoc_types: assoc_type_projections={:?}",
340340
assoc_type_projections);
@@ -437,7 +437,7 @@ pub fn object_region_bounds<'tcx>(
437437
// Since we don't actually *know* the self type for an object,
438438
// this "open(err)" serves as a kind of dummy standin -- basically
439439
// a skolemized type.
440-
let open_ty = ty::mk_infer(tcx, ty::FreshTy(0));
440+
let open_ty = tcx.mk_infer(ty::FreshTy(0));
441441

442442
// Note that we preserve the overall binding levels here.
443443
assert!(!open_ty.has_escaping_regions());

src/librustc/middle/infer/combine.rs

+3-3
Original file line numberDiff line numberDiff line change
@@ -129,8 +129,8 @@ fn unify_integral_variable<'a,'tcx>(infcx: &InferCtxt<'a,'tcx>,
129129
.unify_var_value(vid, val)
130130
.map_err(|e| int_unification_error(vid_is_expected, e)));
131131
match val {
132-
IntType(v) => Ok(ty::mk_mach_int(infcx.tcx, v)),
133-
UintType(v) => Ok(ty::mk_mach_uint(infcx.tcx, v)),
132+
IntType(v) => Ok(infcx.tcx.mk_mach_int(v)),
133+
UintType(v) => Ok(infcx.tcx.mk_mach_uint(v)),
134134
}
135135
}
136136

@@ -145,7 +145,7 @@ fn unify_float_variable<'a,'tcx>(infcx: &InferCtxt<'a,'tcx>,
145145
.borrow_mut()
146146
.unify_var_value(vid, val)
147147
.map_err(|e| float_unification_error(vid_is_expected, e)));
148-
Ok(ty::mk_mach_float(infcx.tcx, val))
148+
Ok(infcx.tcx.mk_mach_float(val))
149149
}
150150

151151
impl<'a, 'tcx> CombineFields<'a, 'tcx> {

src/librustc/middle/infer/freshen.rs

+1-1
Original file line numberDiff line numberDiff line change
@@ -71,7 +71,7 @@ impl<'a, 'tcx> TypeFreshener<'a, 'tcx> {
7171
Entry::Vacant(entry) => {
7272
let index = self.freshen_count;
7373
self.freshen_count += 1;
74-
let t = ty::mk_infer(self.infcx.tcx, freshener(index));
74+
let t = self.infcx.tcx.mk_infer(freshener(index));
7575
entry.insert(t);
7676
t
7777
}

src/librustc/middle/infer/higher_ranked/mod.rs

+1-1
Original file line numberDiff line numberDiff line change
@@ -507,7 +507,7 @@ pub fn construct_skolemized_substs<'a,'tcx>(infcx: &InferCtxt<'a,'tcx>,
507507
types: &mut subst::VecPerParamSpace<ty::Ty<'tcx>>,
508508
defs: &[ty::TypeParameterDef<'tcx>]) {
509509
for def in defs {
510-
let ty = ty::mk_param_from_def(tcx, def);
510+
let ty = tcx.mk_param_from_def(def);
511511
types.push(def.space, ty);
512512
}
513513
}

src/librustc/middle/infer/mod.rs

+2-2
Original file line numberDiff line numberDiff line change
@@ -772,11 +772,11 @@ impl<'a, 'tcx> InferCtxt<'a, 'tcx> {
772772
}
773773

774774
pub fn next_ty_var(&self) -> Ty<'tcx> {
775-
ty::mk_var(self.tcx, self.next_ty_var_id(false))
775+
self.tcx.mk_var(self.next_ty_var_id(false))
776776
}
777777

778778
pub fn next_diverging_ty_var(&self) -> Ty<'tcx> {
779-
ty::mk_var(self.tcx, self.next_ty_var_id(true))
779+
self.tcx.mk_var(self.next_ty_var_id(true))
780780
}
781781

782782
pub fn next_ty_vars(&self, n: usize) -> Vec<Ty<'tcx>> {

src/librustc/middle/infer/region_inference/mod.rs

+1-1
Original file line numberDiff line numberDiff line change
@@ -1672,7 +1672,7 @@ impl<'tcx> GenericKind<'tcx> {
16721672
GenericKind::Param(ref p) =>
16731673
p.to_ty(tcx),
16741674
GenericKind::Projection(ref p) =>
1675-
ty::mk_projection(tcx, p.trait_ref.clone(), p.item_name),
1675+
tcx.mk_projection(p.trait_ref.clone(), p.item_name),
16761676
}
16771677
}
16781678
}

src/librustc/middle/infer/unify_key.rs

+3-3
Original file line numberDiff line numberDiff line change
@@ -26,8 +26,8 @@ impl UnifyKey for ty::IntVid {
2626
impl<'tcx> ToType<'tcx> for IntVarValue {
2727
fn to_type(&self, tcx: &ty::ctxt<'tcx>) -> Ty<'tcx> {
2828
match *self {
29-
ty::IntType(i) => ty::mk_mach_int(tcx, i),
30-
ty::UintType(i) => ty::mk_mach_uint(tcx, i),
29+
ty::IntType(i) => tcx.mk_mach_int(i),
30+
ty::UintType(i) => tcx.mk_mach_uint(i),
3131
}
3232
}
3333
}
@@ -43,6 +43,6 @@ impl UnifyKey for ty::FloatVid {
4343

4444
impl<'tcx> ToType<'tcx> for ast::FloatTy {
4545
fn to_type(&self, tcx: &ty::ctxt<'tcx>) -> Ty<'tcx> {
46-
ty::mk_mach_float(tcx, *self)
46+
tcx.mk_mach_float(*self)
4747
}
4848
}

src/librustc/middle/intrinsicck.rs

+1-1
Original file line numberDiff line numberDiff line change
@@ -30,7 +30,7 @@ pub fn check_crate(tcx: &ctxt) {
3030
tcx: tcx,
3131
param_envs: Vec::new(),
3232
dummy_sized_ty: tcx.types.isize,
33-
dummy_unsized_ty: ty::mk_vec(tcx, tcx.types.isize, None),
33+
dummy_unsized_ty: tcx.mk_slice(tcx.types.isize),
3434
};
3535
visit::walk_crate(&mut visitor, tcx.map.krate());
3636
}

src/librustc/middle/traits/project.rs

+3-3
Original file line numberDiff line numberDiff line change
@@ -524,9 +524,9 @@ fn project_type<'cx,'tcx>(
524524
Ok(ProjectedTy::Progress(ty, obligations))
525525
}
526526
None => {
527-
Ok(ProjectedTy::NoProgress(ty::mk_projection(selcx.tcx(),
528-
obligation.predicate.trait_ref.clone(),
529-
obligation.predicate.item_name)))
527+
Ok(ProjectedTy::NoProgress(selcx.tcx().mk_projection(
528+
obligation.predicate.trait_ref.clone(),
529+
obligation.predicate.item_name)))
530530
}
531531
}
532532
}

src/librustc/middle/traits/select.rs

+2-2
Original file line numberDiff line numberDiff line change
@@ -2451,7 +2451,7 @@ impl<'cx, 'tcx> SelectionContext<'cx, 'tcx> {
24512451
projection_bounds: data_a.bounds.projection_bounds.clone(),
24522452
};
24532453

2454-
let new_trait = ty::mk_trait(tcx, data_a.principal.clone(), bounds);
2454+
let new_trait = tcx.mk_trait(data_a.principal.clone(), bounds);
24552455
let origin = infer::Misc(obligation.cause.span);
24562456
if self.infcx.sub_types(false, origin, new_trait, target).is_err() {
24572457
return Err(Unimplemented);
@@ -2573,7 +2573,7 @@ impl<'cx, 'tcx> SelectionContext<'cx, 'tcx> {
25732573
let param_b = *substs_b.types.get(TypeSpace, i);
25742574
new_substs.types.get_mut_slice(TypeSpace)[i] = param_b;
25752575
}
2576-
let new_struct = ty::mk_struct(tcx, def_id, tcx.mk_substs(new_substs));
2576+
let new_struct = tcx.mk_struct(def_id, tcx.mk_substs(new_substs));
25772577
let origin = infer::Misc(obligation.cause.span);
25782578
if self.infcx.sub_types(false, origin, new_struct, target).is_err() {
25792579
return Err(Unimplemented);

src/librustc/middle/traits/util.rs

+2-2
Original file line numberDiff line numberDiff line change
@@ -456,14 +456,14 @@ pub fn closure_trait_ref_and_return_type<'tcx>(
456456
{
457457
let arguments_tuple = match tuple_arguments {
458458
TupleArgumentsFlag::No => sig.0.inputs[0],
459-
TupleArgumentsFlag::Yes => ty::mk_tup(tcx, sig.0.inputs.to_vec()),
459+
TupleArgumentsFlag::Yes => tcx.mk_tup(sig.0.inputs.to_vec()),
460460
};
461461
let trait_substs = Substs::new_trait(vec![arguments_tuple], vec![], self_ty);
462462
let trait_ref = ty::TraitRef {
463463
def_id: fn_trait_def_id,
464464
substs: tcx.mk_substs(trait_substs),
465465
};
466-
ty::Binder((trait_ref, sig.0.output.unwrap_or(ty::mk_nil(tcx))))
466+
ty::Binder((trait_ref, sig.0.output.unwrap_or(tcx.mk_nil())))
467467
}
468468

469469
impl<'tcx,O:fmt::Debug> fmt::Debug for super::Obligation<'tcx, O> {

0 commit comments

Comments
 (0)