Skip to content

Commit fa858d3

Browse files
committed
---
yaml --- r: 52053 b: refs/heads/dist-snap c: a75c0b3 h: refs/heads/master i: 52051: 19a314a v: v3
1 parent 991ee90 commit fa858d3

File tree

4 files changed

+22
-2
lines changed

4 files changed

+22
-2
lines changed

[refs]

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -7,7 +7,7 @@ refs/tags/release-0.1: 1f5c5126e96c79d22cb7862f75304136e204f105
77
refs/heads/ndm: f3868061cd7988080c30d6d5bf352a5a5fe2460b
88
refs/heads/try2: 147ecfdd8221e4a4d4e090486829a06da1e0ca3c
99
refs/heads/incoming: 44d4d6de762f3f9aae1fedcf454c66b79b3ad58d
10-
refs/heads/dist-snap: 13879d8e9f172de888db91d59ce267d0116d687d
10+
refs/heads/dist-snap: a75c0b3b3210cc842a02b2dc2a9976278ef9c427
1111
refs/tags/release-0.2: c870d2dffb391e14efb05aa27898f1f6333a9596
1212
refs/tags/release-0.3: b5f0d0f648d9a6153664837026ba1be43d3e2503
1313
refs/heads/try3: 9387340aab40a73e8424c48fd42f0c521a4875c0

branches/dist-snap/src/librustc/middle/ty.rs

Lines changed: 14 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -162,10 +162,11 @@ export kind_is_durable;
162162
export meta_kind, kind_lteq, type_kind, type_kind_ext;
163163
export operators;
164164
export type_err, terr_vstore_kind;
165-
export terr_mismatch, terr_onceness_mismatch;
165+
export terr_integer_as_char, terr_mismatch, terr_onceness_mismatch;
166166
export type_err_to_str, note_and_explain_type_err;
167167
export expected_found;
168168
export type_needs_drop;
169+
export type_is_char;
169170
export type_is_empty;
170171
export type_is_integral;
171172
export type_is_numeric;
@@ -714,6 +715,7 @@ enum type_err {
714715
terr_in_field(@type_err, ast::ident),
715716
terr_sorts(expected_found<t>),
716717
terr_self_substs,
718+
terr_integer_as_char,
717719
terr_no_integral_type,
718720
terr_no_floating_point_type,
719721
}
@@ -2541,6 +2543,13 @@ fn type_is_integral(ty: t) -> bool {
25412543
}
25422544
}
25432545
2546+
fn type_is_char(ty: t) -> bool {
2547+
match get(ty).sty {
2548+
ty_int(ty_char) => true,
2549+
_ => false
2550+
}
2551+
}
2552+
25442553
fn type_is_fp(ty: t) -> bool {
25452554
match get(ty).sty {
25462555
ty_infer(FloatVar(_)) | ty_float(_) => true,
@@ -3510,6 +3519,10 @@ fn type_err_to_str(cx: ctxt, err: &type_err) -> ~str {
35103519
~"couldn't determine an appropriate integral type for integer \
35113520
literal"
35123521
}
3522+
terr_integer_as_char => {
3523+
~"integer literals can't be inferred to char type \
3524+
(try an explicit cast)"
3525+
}
35133526
terr_no_floating_point_type => {
35143527
~"couldn't determine an appropriate floating point type for \
35153528
floating point literal"

branches/dist-snap/src/librustc/middle/typeck/infer/unify.rs

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -366,6 +366,10 @@ impl infer_ctxt {
366366
}
367367

368368
fn int_var_sub_t(a_id: ty::IntVid, b: ty::t) -> ures {
369+
if ty::type_is_char(b) {
370+
return Err(ty::terr_integer_as_char);
371+
}
372+
369373
assert ty::type_is_integral(b);
370374

371375
let vb = &self.int_var_bindings;
Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,3 @@
1+
fn main() {
2+
let _p: char = 100; //~ ERROR mismatched types: expected `char` but found
3+
}

0 commit comments

Comments
 (0)