Skip to content

Commit 99ff5a2

Browse files
committed
---
yaml --- r: 109870 b: refs/heads/master c: 39f839d h: refs/heads/master v: v3
1 parent f584b9d commit 99ff5a2

File tree

2 files changed

+5
-210
lines changed

2 files changed

+5
-210
lines changed

[refs]

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,5 @@
11
---
2-
refs/heads/master: b4653941d6a960691249218205b58b5576ce21c7
2+
refs/heads/master: 39f839d9ee2cbef25de4f3a4fca514f5ed8a313d
33
refs/heads/snap-stage1: e33de59e47c5076a89eadeb38f4934f58a3618a6
44
refs/heads/snap-stage3: c7fac4471201977fdb1c0c0a26c87287e12dc644
55
refs/heads/try: f64fdf524a434f0e5cd0bc91d09c144723f3c90d

trunk/src/librustc/middle/ty.rs

Lines changed: 4 additions & 209 deletions
Original file line numberDiff line numberDiff line change
@@ -411,9 +411,6 @@ pub fn type_has_self(t: t) -> bool { tbox_has_flag(get(t), has_self) }
411411
pub fn type_needs_infer(t: t) -> bool {
412412
tbox_has_flag(get(t), needs_infer)
413413
}
414-
pub fn type_has_regions(t: t) -> bool {
415-
tbox_has_flag(get(t), has_regions)
416-
}
417414
pub fn type_id(t: t) -> uint { get(t).id }
418415

419416
#[deriving(Clone, Eq, TotalEq, Hash)]
@@ -1506,10 +1503,6 @@ pub fn walk_regions_and_ty(cx: &ctxt, ty: t, fldr: |r: Region|, fldt: |t: t|)
15061503
|t| { fldt(t); t }).fold_ty(ty)
15071504
}
15081505

1509-
pub fn fold_regions(cx: &ctxt, ty: t, fldr: |r: Region| -> Region) -> t {
1510-
ty_fold::RegionFolder::regions(cx, fldr).fold_ty(ty)
1511-
}
1512-
15131506
// Substitute *only* type parameters. Used in trans where regions are erased.
15141507
pub fn subst_tps(tcx: &ctxt, tps: &[t], self_ty_opt: Option<t>, typ: t) -> t {
15151508
let mut subst = TpsSubst { tcx: tcx, self_ty_opt: self_ty_opt, tps: tps };
@@ -1623,27 +1616,13 @@ pub fn type_is_structural(ty: t) -> bool {
16231616
}
16241617
}
16251618

1626-
pub fn type_is_sequence(ty: t) -> bool {
1627-
match get(ty).sty {
1628-
ty_str(_) | ty_vec(_, _) => true,
1629-
_ => false
1630-
}
1631-
}
1632-
16331619
pub fn type_is_simd(cx: &ctxt, ty: t) -> bool {
16341620
match get(ty).sty {
16351621
ty_struct(did, _) => lookup_simd(cx, did),
16361622
_ => false
16371623
}
16381624
}
16391625

1640-
pub fn type_is_str(ty: t) -> bool {
1641-
match get(ty).sty {
1642-
ty_str(_) => true,
1643-
_ => false
1644-
}
1645-
}
1646-
16471626
pub fn sequence_element_type(cx: &ctxt, ty: t) -> t {
16481627
match get(ty).sty {
16491628
ty_str(_) => return mk_mach_uint(ast::TyU8),
@@ -1672,20 +1651,6 @@ pub fn simd_size(cx: &ctxt, ty: t) -> uint {
16721651
}
16731652
}
16741653

1675-
pub fn get_element_type(ty: t, i: uint) -> t {
1676-
match get(ty).sty {
1677-
ty_tup(ref ts) => return *ts.get(i),
1678-
_ => fail!("get_element_type called on invalid type")
1679-
}
1680-
}
1681-
1682-
pub fn type_is_box(ty: t) -> bool {
1683-
match get(ty).sty {
1684-
ty_box(_) => return true,
1685-
_ => return false
1686-
}
1687-
}
1688-
16891654
pub fn type_is_boxed(ty: t) -> bool {
16901655
match get(ty).sty {
16911656
ty_box(_) => true,
@@ -1700,35 +1665,13 @@ pub fn type_is_region_ptr(ty: t) -> bool {
17001665
}
17011666
}
17021667

1703-
pub fn type_is_slice(ty: t) -> bool {
1704-
match get(ty).sty {
1705-
ty_vec(_, vstore_slice(_)) | ty_str(vstore_slice(_)) => true,
1706-
_ => return false
1707-
}
1708-
}
1709-
1710-
pub fn type_is_unique_box(ty: t) -> bool {
1711-
match get(ty).sty {
1712-
ty_uniq(_) => return true,
1713-
_ => return false
1714-
}
1715-
}
1716-
17171668
pub fn type_is_unsafe_ptr(ty: t) -> bool {
17181669
match get(ty).sty {
17191670
ty_ptr(_) => return true,
17201671
_ => return false
17211672
}
17221673
}
17231674

1724-
pub fn type_is_vec(ty: t) -> bool {
1725-
return match get(ty).sty {
1726-
ty_vec(_, _) | ty_unboxed_vec(_) => true,
1727-
ty_str(_) => true,
1728-
_ => false
1729-
};
1730-
}
1731-
17321675
pub fn type_is_unique(ty: t) -> bool {
17331676
match get(ty).sty {
17341677
ty_uniq(_) | ty_vec(_, vstore_uniq) | ty_str(vstore_uniq) => true,
@@ -1920,10 +1863,6 @@ def_type_content_sets!(
19201863
)
19211864

19221865
impl TypeContents {
1923-
pub fn meets_bounds(&self, cx: &ctxt, bbs: BuiltinBounds) -> bool {
1924-
bbs.iter().all(|bb| self.meets_bound(cx, bb))
1925-
}
1926-
19271866
pub fn meets_bound(&self, cx: &ctxt, bb: BuiltinBound) -> bool {
19281867
match bb {
19291868
BoundStatic => self.is_static(cx),
@@ -2021,10 +1960,6 @@ impl TypeContents {
20211960
v.iter().fold(TC::None, |tc, t| tc | f(t))
20221961
}
20231962

2024-
pub fn inverse(&self) -> TypeContents {
2025-
TypeContents { bits: !self.bits }
2026-
}
2027-
20281963
pub fn has_dtor(&self) -> bool {
20291964
self.intersects(TC::OwnsDtor)
20301965
}
@@ -2054,10 +1989,6 @@ impl fmt::Show for TypeContents {
20541989
}
20551990
}
20561991

2057-
pub fn type_has_dtor(cx: &ctxt, t: ty::t) -> bool {
2058-
type_contents(cx, t).has_dtor()
2059-
}
2060-
20611992
pub fn type_is_static(cx: &ctxt, t: ty::t) -> bool {
20621993
type_contents(cx, t).is_static(cx)
20631994
}
@@ -2642,14 +2573,8 @@ pub fn type_is_machine(ty: t) -> bool {
26422573
}
26432574
}
26442575

2645-
pub fn type_is_enum(ty: t) -> bool {
2646-
match get(ty).sty {
2647-
ty_enum(_, _) => return true,
2648-
_ => return false
2649-
}
2650-
}
2651-
26522576
// Is the type's representation size known at compile time?
2577+
#[allow(dead_code)] // leaving in for DST
26532578
pub fn type_is_sized(cx: &ctxt, ty: ty::t) -> bool {
26542579
match get(ty).sty {
26552580
// FIXME(#6308) add trait, vec, str, etc here.
@@ -2681,14 +2606,6 @@ pub fn type_is_c_like_enum(cx: &ctxt, ty: t) -> bool {
26812606
}
26822607
}
26832608

2684-
pub fn type_param(ty: t) -> Option<uint> {
2685-
match get(ty).sty {
2686-
ty_param(p) => return Some(p.idx),
2687-
_ => {/* fall through */ }
2688-
}
2689-
return None;
2690-
}
2691-
26922609
// Returns the type and mutability of *t.
26932610
//
26942611
// The parameter `explicit` indicates if this is an *explicit* dereference.
@@ -2751,10 +2668,6 @@ pub fn node_id_to_type_params(cx: &ctxt, id: ast::NodeId) -> Vec<t> {
27512668
}
27522669
}
27532670

2754-
fn node_id_has_type_params(cx: &ctxt, id: ast::NodeId) -> bool {
2755-
cx.node_type_substs.borrow().contains_key(&id)
2756-
}
2757-
27582671
pub fn fn_is_variadic(fty: t) -> bool {
27592672
match get(fty).sty {
27602673
ty_bare_fn(ref f) => f.sig.variadic,
@@ -2795,16 +2708,6 @@ pub fn ty_closure_sigil(fty: t) -> Sigil {
27952708
}
27962709
}
27972710

2798-
pub fn ty_fn_purity(fty: t) -> ast::Purity {
2799-
match get(fty).sty {
2800-
ty_bare_fn(ref f) => f.purity,
2801-
ty_closure(ref f) => f.purity,
2802-
ref s => {
2803-
fail!("ty_fn_purity() called on non-fn type: {:?}", s)
2804-
}
2805-
}
2806-
}
2807-
28082711
pub fn ty_fn_ret(fty: t) -> t {
28092712
match get(fty).sty {
28102713
ty_bare_fn(ref f) => f.sig.output,
@@ -2823,14 +2726,6 @@ pub fn is_fn_ty(fty: t) -> bool {
28232726
}
28242727
}
28252728

2826-
pub fn ty_vstore(ty: t) -> vstore {
2827-
match get(ty).sty {
2828-
ty_vec(_, vstore) => vstore,
2829-
ty_str(vstore) => vstore,
2830-
ref s => fail!("ty_vstore() called on invalid sty: {:?}", s)
2831-
}
2832-
}
2833-
28342729
pub fn ty_region(tcx: &ctxt,
28352730
span: Span,
28362731
ty: t) -> Region {
@@ -2846,49 +2741,6 @@ pub fn ty_region(tcx: &ctxt,
28462741
}
28472742
}
28482743

2849-
pub fn replace_fn_sig(cx: &ctxt, fsty: &sty, new_sig: FnSig) -> t {
2850-
match *fsty {
2851-
ty_bare_fn(ref f) => mk_bare_fn(cx, BareFnTy {sig: new_sig, ..*f}),
2852-
ty_closure(ref f) => mk_closure(cx, ClosureTy {sig: new_sig, ..**f}),
2853-
ref s => {
2854-
cx.sess.bug(
2855-
format!("ty_fn_sig() called on non-fn type: {:?}", s));
2856-
}
2857-
}
2858-
}
2859-
2860-
pub fn replace_closure_return_type(tcx: &ctxt, fn_type: t, ret_type: t) -> t {
2861-
/*!
2862-
*
2863-
* Returns a new function type based on `fn_type` but returning a value of
2864-
* type `ret_type` instead. */
2865-
2866-
match ty::get(fn_type).sty {
2867-
ty::ty_closure(ref fty) => {
2868-
ty::mk_closure(tcx, ClosureTy {
2869-
sig: FnSig {output: ret_type, ..fty.sig.clone()},
2870-
..(**fty).clone()
2871-
})
2872-
}
2873-
_ => {
2874-
tcx.sess.bug(format!(
2875-
"replace_fn_ret() invoked with non-fn-type: {}",
2876-
ty_to_str(tcx, fn_type)));
2877-
}
2878-
}
2879-
}
2880-
2881-
// Returns a vec of all the input and output types of fty.
2882-
pub fn tys_in_fn_sig(sig: &FnSig) -> Vec<t> {
2883-
sig.inputs.iter().map(|a| *a).collect::<Vec<_>>().append_one(sig.output)
2884-
}
2885-
2886-
// Type accessors for AST nodes
2887-
pub fn block_ty(cx: &ctxt, b: &ast::Block) -> t {
2888-
return node_id_to_type(cx, b.id);
2889-
}
2890-
2891-
28922744
// Returns the type of a pattern as a monotype. Like @expr_ty, this function
28932745
// doesn't provide type parameter substitutions.
28942746
pub fn pat_ty(cx: &ctxt, pat: &ast::Pat) -> t {
@@ -3180,6 +3032,7 @@ pub struct ParamsTy {
31803032
pub ty: t
31813033
}
31823034

3035+
#[allow(dead_code)] // this may be useful?
31833036
pub fn expr_ty_params_and_ty(cx: &ctxt,
31843037
expr: &ast::Expr)
31853038
-> ParamsTy {
@@ -3189,10 +3042,6 @@ pub fn expr_ty_params_and_ty(cx: &ctxt,
31893042
}
31903043
}
31913044

3192-
pub fn expr_has_ty_params(cx: &ctxt, expr: &ast::Expr) -> bool {
3193-
return node_id_has_type_params(cx, expr.id);
3194-
}
3195-
31963045
pub fn method_call_type_param_defs(tcx: &ctxt, origin: typeck::MethodOrigin)
31973046
-> Rc<Vec<TypeParameterDef>> {
31983047
match origin {
@@ -3416,12 +3265,6 @@ pub fn stmt_node_id(s: &ast::Stmt) -> ast::NodeId {
34163265
}
34173266
}
34183267

3419-
pub fn field_idx(name: ast::Name, fields: &[field]) -> Option<uint> {
3420-
let mut i = 0u;
3421-
for f in fields.iter() { if f.ident.name == name { return Some(i); } i += 1u; }
3422-
return None;
3423-
}
3424-
34253268
pub fn field_idx_strict(tcx: &ctxt, name: ast::Name, fields: &[field])
34263269
-> uint {
34273270
let mut i = 0u;
@@ -3657,14 +3500,6 @@ pub fn note_and_explain_type_err(cx: &ctxt, err: &type_err) {
36573500
}
36583501
}
36593502

3660-
pub fn def_has_ty_params(def: ast::Def) -> bool {
3661-
match def {
3662-
ast::DefFn(_, _) | ast::DefVariant(_, _, _) | ast::DefStruct(_)
3663-
=> true,
3664-
_ => false
3665-
}
3666-
}
3667-
36683503
pub fn provided_source(cx: &ctxt, id: ast::DefId) -> Option<ast::DefId> {
36693504
cx.provided_method_sources.borrow().find(&id).map(|x| *x)
36703505
}
@@ -3843,8 +3678,8 @@ pub fn try_add_builtin_trait(tcx: &ctxt,
38433678

38443679
pub fn ty_to_def_id(ty: t) -> Option<ast::DefId> {
38453680
match get(ty).sty {
3846-
ty_trait(~TyTrait { def_id: id, .. }) | ty_struct(id, _) | ty_enum(id, _) => Some(id),
3847-
_ => None
3681+
ty_trait(~TyTrait { def_id: id, .. }) | ty_struct(id, _) | ty_enum(id, _) => Some(id),
3682+
_ => None
38483683
}
38493684
}
38503685

@@ -4240,18 +4075,6 @@ pub fn lookup_struct_fields(cx: &ctxt, did: ast::DefId) -> Vec<field_ty> {
42404075
}
42414076
}
42424077

4243-
pub fn lookup_struct_field(cx: &ctxt,
4244-
parent: ast::DefId,
4245-
field_id: ast::DefId)
4246-
-> field_ty {
4247-
let r = lookup_struct_fields(cx, parent);
4248-
match r.iter().find(
4249-
|f| f.id.node == field_id.node) {
4250-
Some(t) => *t,
4251-
None => cx.sess.bug("struct ID not found in parent's fields")
4252-
}
4253-
}
4254-
42554078
fn struct_field_tys(fields: &[StructField]) -> Vec<field_ty> {
42564079
fields.iter().map(|field| {
42574080
match field.node.kind {
@@ -4361,13 +4184,6 @@ pub fn is_binopable(cx: &ctxt, ty: t, op: ast::BinOp) -> bool {
43614184
return tbl[tycat(cx, ty)][opcat(op)];
43624185
}
43634186

4364-
pub fn ty_params_to_tys(tcx: &ctxt, generics: &ast::Generics) -> Vec<t> {
4365-
Vec::from_fn(generics.ty_params.len(), |i| {
4366-
let id = generics.ty_params.get(i).id;
4367-
ty::mk_param(tcx, i, ast_util::local_def(id))
4368-
})
4369-
}
4370-
43714187
/// Returns an equivalent type with all the typedefs and self regions removed.
43724188
pub fn normalize_ty(cx: &ctxt, t: t) -> t {
43734189
let u = TypeNormalizer(cx).fold_ty(t);
@@ -4547,19 +4363,6 @@ pub fn each_bound_trait_and_supertraits(tcx: &ctxt,
45474363
return true;
45484364
}
45494365

4550-
pub fn count_traits_and_supertraits(tcx: &ctxt,
4551-
type_param_defs: &[TypeParameterDef]) -> uint {
4552-
let mut total = 0;
4553-
for type_param_def in type_param_defs.iter() {
4554-
each_bound_trait_and_supertraits(
4555-
tcx, type_param_def.bounds.trait_bounds.as_slice(), |_| {
4556-
total += 1;
4557-
true
4558-
});
4559-
}
4560-
return total;
4561-
}
4562-
45634366
pub fn get_tydesc_ty(tcx: &ctxt) -> Result<t, ~str> {
45644367
tcx.lang_items.require(TyDescStructLangItem).map(|tydesc_lang_item| {
45654368
tcx.intrinsic_defs.borrow().find_copy(&tydesc_lang_item)
@@ -5043,12 +4846,4 @@ impl BorrowKind {
50434846
UniqueImmBorrow => "uniquely immutable",
50444847
}
50454848
}
5046-
5047-
pub fn to_short_str(&self) -> &'static str {
5048-
match *self {
5049-
MutBorrow => "mut",
5050-
ImmBorrow => "imm",
5051-
UniqueImmBorrow => "own",
5052-
}
5053-
}
50544849
}

0 commit comments

Comments
 (0)