@@ -57,7 +57,7 @@ export lookup_item_type;
57
57
export lookup_public_fields;
58
58
export method;
59
59
export method_idx;
60
- export mk_class;
60
+ export mk_class, mk_err ;
61
61
export mk_ctxt;
62
62
export mk_with_id, type_def_id;
63
63
export mt;
@@ -87,6 +87,7 @@ export ty_fn_proto, ty_fn_purity, ty_fn_ret, ty_fn_ret_style, tys_in_fn_ty;
87
87
export ty_int, mk_int, mk_mach_int, mk_char;
88
88
export mk_i8, mk_u8, mk_i16, mk_u16, mk_i32, mk_u32, mk_i64, mk_u64;
89
89
export mk_f32, mk_f64;
90
+ export ty_err;
90
91
export ty_estr, mk_estr, type_is_str;
91
92
export ty_evec, mk_evec, type_is_vec;
92
93
export ty_unboxed_vec, mk_unboxed_vec, mk_mut_unboxed_vec;
@@ -127,7 +128,7 @@ export kind_is_owned;
127
128
export meta_kind, kind_lteq, type_kind;
128
129
export operators;
129
130
export type_err, terr_vstore_kind;
130
- export terr_onceness_mismatch;
131
+ export terr_mismatch , terr_onceness_mismatch;
131
132
export type_err_to_str, note_and_explain_type_err;
132
133
export expected_found;
133
134
export type_needs_drop;
@@ -673,6 +674,9 @@ enum sty {
673
674
ty_self, // special, implicit `self` type parameter
674
675
675
676
ty_infer( InferTy ) , // soething used only during inference/typeck
677
+ ty_err, // Also only used during inference/typeck, to represent
678
+ // the type of an erroneous expression (helps cut down
679
+ // on non-useful type error messages)
676
680
677
681
// "Fake" types, used for trans purposes
678
682
ty_type, // type_desc*
@@ -1062,7 +1066,7 @@ fn mk_t_with_id(cx: ctxt, +st: sty, o_def_id: Option<ast::def_id>) -> t {
1062
1066
}
1063
1067
ty_nil | ty_bot | ty_bool | ty_int( _) | ty_float( _) | ty_uint( _) |
1064
1068
ty_estr( _) | ty_type | ty_opaque_closure_ptr( _) |
1065
- ty_opaque_box => ( ) ,
1069
+ ty_opaque_box | ty_err => ( ) ,
1066
1070
ty_param( _) => flags |= has_params as uint ,
1067
1071
ty_infer( _) => flags |= needs_infer as uint ,
1068
1072
ty_self => flags |= has_self as uint ,
@@ -1094,6 +1098,8 @@ fn mk_t_with_id(cx: ctxt, +st: sty, o_def_id: Option<ast::def_id>) -> t {
1094
1098
1095
1099
fn mk_nil ( cx : ctxt ) -> t { mk_t ( cx, ty_nil) }
1096
1100
1101
+ fn mk_err ( cx : ctxt ) -> t { mk_t ( cx, ty_err) }
1102
+
1097
1103
fn mk_bot ( cx : ctxt ) -> t { mk_t ( cx, ty_bot) }
1098
1104
1099
1105
fn mk_bool ( cx : ctxt ) -> t { mk_t ( cx, ty_bool) }
@@ -1301,7 +1307,7 @@ fn maybe_walk_ty(ty: t, f: fn(t) -> bool) {
1301
1307
match get ( ty) . sty {
1302
1308
ty_nil | ty_bot | ty_bool | ty_int( _) | ty_uint( _) | ty_float( _) |
1303
1309
ty_estr( _) | ty_type | ty_opaque_box | ty_self |
1304
- ty_opaque_closure_ptr( _) | ty_infer( _) | ty_param( _) => {
1310
+ ty_opaque_closure_ptr( _) | ty_infer( _) | ty_param( _) | ty_err => {
1305
1311
}
1306
1312
ty_box( tm) | ty_evec( tm, _) | ty_unboxed_vec( tm) |
1307
1313
ty_ptr( tm) | ty_rptr( _, tm) => {
@@ -1386,7 +1392,7 @@ fn fold_sty(sty: &sty, fldop: fn(t) -> t) -> sty {
1386
1392
ty_class ( did, fold_substs ( substs, fldop) )
1387
1393
}
1388
1394
ty_nil | ty_bot | ty_bool | ty_int( _) | ty_uint( _) | ty_float( _) |
1389
- ty_estr( _) | ty_type | ty_opaque_closure_ptr( _) |
1395
+ ty_estr( _) | ty_type | ty_opaque_closure_ptr( _) | ty_err |
1390
1396
ty_opaque_box | ty_infer( _) | ty_param( * ) | ty_self => {
1391
1397
* sty
1392
1398
}
@@ -1794,7 +1800,7 @@ fn type_needs_drop(cx: ctxt, ty: t) -> bool {
1794
1800
ty_trait(_, _, vstore_fixed(_)) |
1795
1801
ty_trait(_, _, vstore_slice(_)) => false,
1796
1802
1797
- ty_param(*) | ty_infer(*) => true,
1803
+ ty_param(*) | ty_infer(*) | ty_err => true,
1798
1804
1799
1805
ty_evec(mt, vstore_fixed(_)) => type_needs_drop(cx, mt.ty),
1800
1806
ty_unboxed_vec(mt) => type_needs_drop(cx, mt.ty),
@@ -2270,7 +2276,7 @@ fn type_kind(cx: ctxt, ty: t) -> Kind {
2270
2276
cx.sess.bug(~" Asked to compute kind of a type variable");
2271
2277
}
2272
2278
ty_type | ty_opaque_closure_ptr(_)
2273
- | ty_opaque_box | ty_unboxed_vec(_) => {
2279
+ | ty_opaque_box | ty_unboxed_vec(_) | ty_err => {
2274
2280
cx.sess.bug(~" Asked to compute kind of fictitious type ");
2275
2281
}
2276
2282
};
@@ -2341,7 +2347,7 @@ fn type_size(cx: ctxt, ty: t) -> uint {
2341
2347
cx.sess.bug(~" Asked to compute kind of a type variable");
2342
2348
}
2343
2349
ty_type | ty_opaque_closure_ptr(_)
2344
- | ty_opaque_box | ty_unboxed_vec(_) => {
2350
+ | ty_opaque_box | ty_unboxed_vec(_) | ty_err => {
2345
2351
cx.sess.bug(~" Asked to compute kind of fictitious type ");
2346
2352
}
2347
2353
}
@@ -2384,6 +2390,7 @@ fn is_instantiable(cx: ctxt, r_ty: t) -> bool {
2384
2390
ty_estr(_) |
2385
2391
ty_fn(_) |
2386
2392
ty_infer(_) |
2393
+ ty_err |
2387
2394
ty_param(_) |
2388
2395
ty_self |
2389
2396
ty_type |
@@ -2589,7 +2596,7 @@ fn type_is_pod(cx: ctxt, ty: t) -> bool {
2589
2596
result = false;
2590
2597
}
2591
2598
2592
- ty_infer(*) | ty_self(*) => {
2599
+ ty_infer(*) | ty_self(*) | ty_err => {
2593
2600
cx.sess.bug(~" non concrete type in type_is_pod");
2594
2601
}
2595
2602
}
@@ -2862,6 +2869,8 @@ impl sty : to_bytes::IterBytes {
2862
2869
2863
2870
ty_rptr(ref r, ref mt) =>
2864
2871
to_bytes::iter_bytes_3(&24u8, r, mt, lsb0, f),
2872
+
2873
+ ty_err => 25u8.iter_bytes(lsb0, f)
2865
2874
}
2866
2875
}
2867
2876
}
@@ -3357,7 +3366,8 @@ fn ty_sort_str(cx: ctxt, t: t) -> ~str {
3357
3366
ty_infer( IntVar ( _) ) => ~"integral variable",
3358
3367
ty_infer( FloatVar ( _) ) => ~"floating-point variable",
3359
3368
ty_param( _) => ~"type parameter",
3360
- ty_self => ~"self "
3369
+ ty_self => ~"self ",
3370
+ ty_err => ~"type error"
3361
3371
}
3362
3372
}
3363
3373
@@ -4787,6 +4797,12 @@ impl sty : cmp::Eq {
4787
4797
_ => false
4788
4798
}
4789
4799
}
4800
+ ty_err => {
4801
+ match ( * other) {
4802
+ ty_err => true ,
4803
+ _ => false
4804
+ }
4805
+ }
4790
4806
ty_param( e0a) => {
4791
4807
match ( * other) {
4792
4808
ty_param( e0b) => e0a == e0b,
@@ -4944,6 +4960,12 @@ impl sty : cmp::Eq {
4944
4960
_ => false
4945
4961
}
4946
4962
}
4963
+ ty_err => {
4964
+ match ( * other) {
4965
+ ty_err => true ,
4966
+ _ => false
4967
+ }
4968
+ }
4947
4969
ty_param( e0a) => {
4948
4970
match ( * other) {
4949
4971
ty_param( e0b) => e0a == e0b,
0 commit comments