Skip to content

Commit 1ecce71

Browse files
committed
---
yaml --- r: 79394 b: refs/heads/snap-stage3 c: be43625 h: refs/heads/master v: v3
1 parent f789515 commit 1ecce71

File tree

10 files changed

+27
-31
lines changed

10 files changed

+27
-31
lines changed

[refs]

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,7 @@
11
---
22
refs/heads/master: 124eb2119c78651cfaaa7a046a101fa2e20f83ca
33
refs/heads/snap-stage1: e33de59e47c5076a89eadeb38f4934f58a3618a6
4-
refs/heads/snap-stage3: d285ea791058f7db8bef828740aae95e69becc99
4+
refs/heads/snap-stage3: be43625082bf14f7ca49c9edc4b8a899fd73eddf
55
refs/heads/try: ac820906c0e53eab79a98ee64f7231f57c3887b4
66
refs/tags/release-0.1: 1f5c5126e96c79d22cb7862f75304136e204f105
77
refs/heads/ndm: f3868061cd7988080c30d6d5bf352a5a5fe2460b

branches/snap-stage3/src/libextra/ebml.rs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -410,7 +410,7 @@ pub mod reader {
410410
}
411411

412412
fn read_bool(&mut self) -> bool {
413-
doc_as_u8(self.next_doc(EsBool)) != 0
413+
doc_as_u8(self.next_doc(EsBool)) as bool
414414
}
415415

416416
fn read_f64(&mut self) -> f64 {

branches/snap-stage3/src/librustc/middle/trans/base.rs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -2219,7 +2219,7 @@ pub fn trans_item(ccx: @mut CrateContext, item: &ast::item) {
22192219
}
22202220
let v = ccx.const_values.get_copy(&item.id);
22212221
unsafe {
2222-
if !(llvm::LLVMConstIntGetZExtValue(v) != 0) {
2222+
if !(llvm::LLVMConstIntGetZExtValue(v) as bool) {
22232223
ccx.sess.span_fatal(expr.span, "static assertion failed");
22242224
}
22252225
}

branches/snap-stage3/src/librustc/middle/typeck/check/mod.rs

Lines changed: 0 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -2696,7 +2696,6 @@ pub fn check_expr_with_unifier(fcx: @mut FnCtxt,
26962696
}, t_e, None);
26972697
}
26982698

2699-
let t1 = structurally_resolved_type(fcx, e.span, t_1);
27002699
let te = structurally_resolved_type(fcx, e.span, t_e);
27012700
let t_1_is_char = type_is_char(fcx, expr.span, t_1);
27022701

@@ -2711,9 +2710,6 @@ pub fn check_expr_with_unifier(fcx: @mut FnCtxt,
27112710
fmt!("only `u8` can be cast as `char`, not `%s`", actual)
27122711
}, t_e, None);
27132712
}
2714-
} else if ty::get(t1).sty == ty::ty_bool {
2715-
fcx.tcx().sess.span_err(expr.span,
2716-
"cannot cast as `bool`, compare with zero instead");
27172713
} else if type_is_region_ptr(fcx, expr.span, t_e) &&
27182714
type_is_unsafe_ptr(fcx, expr.span, t_1) {
27192715

branches/snap-stage3/src/libstd/from_str.rs

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -19,3 +19,7 @@ pub trait FromStr {
1919
/// string is ill-formatted, the None is returned.
2020
fn from_str(s: &str) -> Option<Self>;
2121
}
22+
23+
pub fn from_str<A: FromStr>(s: &str) -> Option<A> {
24+
FromStr::from_str(s)
25+
}

branches/snap-stage3/src/libstd/prelude.rs

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -41,6 +41,7 @@ pub use result::{Result, Ok, Err};
4141
// Reexported functions
4242
pub use io::{print, println};
4343
pub use iterator::range;
44+
pub use from_str::from_str;
4445

4546
// Reexported types and traits
4647
pub use c_str::ToCStr;

branches/snap-stage3/src/libstd/str.rs

Lines changed: 3 additions & 12 deletions
Original file line numberDiff line numberDiff line change
@@ -799,8 +799,6 @@ pub fn is_utf8(v: &[u8]) -> bool {
799799
// first C2 80 last DF BF
800800
// 3-byte encoding is for codepoints \u0800 to \uffff
801801
// first E0 A0 80 last EF BF BF
802-
// excluding surrogates codepoints \ud800 to \udfff
803-
// ED A0 80 to ED BF BF
804802
// 4-byte encoding is for codepoints \u10000 to \u10ffff
805803
// first F0 90 80 80 last F4 8F BF BF
806804
//
@@ -814,6 +812,8 @@ pub fn is_utf8(v: &[u8]) -> bool {
814812
// UTF8-4 = %xF0 %x90-BF 2( UTF8-tail ) / %xF1-F3 3( UTF8-tail ) /
815813
// %xF4 %x80-8F 2( UTF8-tail )
816814
// UTF8-tail = %x80-BF
815+
// --
816+
// This code allows surrogate pairs: \uD800 to \uDFFF -> ED A0 80 to ED BF BF
817817
match w {
818818
2 => if unsafe_get(v, i + 1) & 192u8 != TAG_CONT_U8 {
819819
return false
@@ -822,9 +822,7 @@ pub fn is_utf8(v: &[u8]) -> bool {
822822
unsafe_get(v, i + 1),
823823
unsafe_get(v, i + 2) & 192u8) {
824824
(0xE0 , 0xA0 .. 0xBF, TAG_CONT_U8) => (),
825-
(0xE1 .. 0xEC, 0x80 .. 0xBF, TAG_CONT_U8) => (),
826-
(0xED , 0x80 .. 0x9F, TAG_CONT_U8) => (),
827-
(0xEE .. 0xEF, 0x80 .. 0xBF, TAG_CONT_U8) => (),
825+
(0xE1 .. 0xEF, 0x80 .. 0xBF, TAG_CONT_U8) => (),
828826
_ => return false,
829827
},
830828
_ => match (v_i,
@@ -3014,7 +3012,6 @@ mod tests {
30143012
30153013
#[test]
30163014
fn test_is_utf8() {
3017-
// deny overlong encodings
30183015
assert!(!is_utf8([0xc0, 0x80]));
30193016
assert!(!is_utf8([0xc0, 0xae]));
30203017
assert!(!is_utf8([0xe0, 0x80, 0x80]));
@@ -3023,15 +3020,9 @@ mod tests {
30233020
assert!(!is_utf8([0xf0, 0x82, 0x82, 0xac]));
30243021
assert!(!is_utf8([0xf4, 0x90, 0x80, 0x80]));
30253022
3026-
// deny surrogates
3027-
assert!(!is_utf8([0xED, 0xA0, 0x80]));
3028-
assert!(!is_utf8([0xED, 0xBF, 0xBF]));
3029-
30303023
assert!(is_utf8([0xC2, 0x80]));
30313024
assert!(is_utf8([0xDF, 0xBF]));
30323025
assert!(is_utf8([0xE0, 0xA0, 0x80]));
3033-
assert!(is_utf8([0xED, 0x9F, 0xBF]));
3034-
assert!(is_utf8([0xEE, 0x80, 0x80]));
30353026
assert!(is_utf8([0xEF, 0xBF, 0xBF]));
30363027
assert!(is_utf8([0xF0, 0x90, 0x80, 0x80]));
30373028
assert!(is_utf8([0xF4, 0x8F, 0xBF, 0xBF]));

branches/snap-stage3/src/test/compile-fail/cast-as-bool.rs

Lines changed: 0 additions & 12 deletions
This file was deleted.

branches/snap-stage3/src/test/run-pass/cast.rs

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -18,5 +18,6 @@ pub fn main() {
1818
assert_eq!(i as u8, 'Q' as u8);
1919
assert_eq!(i as u8 as i8, 'Q' as u8 as i8);
2020
assert_eq!(0x51u8 as char, 'Q');
21+
assert_eq!(true, 1 as bool);
2122
assert_eq!(0 as u32, false as u32);
2223
}

branches/snap-stage3/src/test/run-pass/supported-cast.rs

Lines changed: 15 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -26,6 +26,7 @@ pub fn main() {
2626
info!(1 as int);
2727
info!(1 as uint);
2828
info!(1 as float);
29+
info!(1 as bool);
2930
info!(1 as *libc::FILE);
3031
info!(1 as i8);
3132
info!(1 as i16);
@@ -41,6 +42,7 @@ pub fn main() {
4142
info!(1u as int);
4243
info!(1u as uint);
4344
info!(1u as float);
45+
info!(1u as bool);
4446
info!(1u as *libc::FILE);
4547
info!(1u as i8);
4648
info!(1u as i16);
@@ -56,6 +58,7 @@ pub fn main() {
5658
info!(1i8 as int);
5759
info!(1i8 as uint);
5860
info!(1i8 as float);
61+
info!(1i8 as bool);
5962
info!(1i8 as *libc::FILE);
6063
info!(1i8 as i8);
6164
info!(1i8 as i16);
@@ -71,6 +74,7 @@ pub fn main() {
7174
info!(1u8 as int);
7275
info!(1u8 as uint);
7376
info!(1u8 as float);
77+
info!(1u8 as bool);
7478
info!(1u8 as *libc::FILE);
7579
info!(1u8 as i8);
7680
info!(1u8 as i16);
@@ -86,6 +90,7 @@ pub fn main() {
8690
info!(1i16 as int);
8791
info!(1i16 as uint);
8892
info!(1i16 as float);
93+
info!(1i16 as bool);
8994
info!(1i16 as *libc::FILE);
9095
info!(1i16 as i8);
9196
info!(1i16 as i16);
@@ -101,6 +106,7 @@ pub fn main() {
101106
info!(1u16 as int);
102107
info!(1u16 as uint);
103108
info!(1u16 as float);
109+
info!(1u16 as bool);
104110
info!(1u16 as *libc::FILE);
105111
info!(1u16 as i8);
106112
info!(1u16 as i16);
@@ -116,6 +122,7 @@ pub fn main() {
116122
info!(1i32 as int);
117123
info!(1i32 as uint);
118124
info!(1i32 as float);
125+
info!(1i32 as bool);
119126
info!(1i32 as *libc::FILE);
120127
info!(1i32 as i8);
121128
info!(1i32 as i16);
@@ -131,6 +138,7 @@ pub fn main() {
131138
info!(1u32 as int);
132139
info!(1u32 as uint);
133140
info!(1u32 as float);
141+
info!(1u32 as bool);
134142
info!(1u32 as *libc::FILE);
135143
info!(1u32 as i8);
136144
info!(1u32 as i16);
@@ -146,6 +154,7 @@ pub fn main() {
146154
info!(1i64 as int);
147155
info!(1i64 as uint);
148156
info!(1i64 as float);
157+
info!(1i64 as bool);
149158
info!(1i64 as *libc::FILE);
150159
info!(1i64 as i8);
151160
info!(1i64 as i16);
@@ -161,6 +170,7 @@ pub fn main() {
161170
info!(1u64 as int);
162171
info!(1u64 as uint);
163172
info!(1u64 as float);
173+
info!(1u64 as bool);
164174
info!(1u64 as *libc::FILE);
165175
info!(1u64 as i8);
166176
info!(1u64 as i16);
@@ -176,6 +186,7 @@ pub fn main() {
176186
info!(1u64 as int);
177187
info!(1u64 as uint);
178188
info!(1u64 as float);
189+
info!(1u64 as bool);
179190
info!(1u64 as *libc::FILE);
180191
info!(1u64 as i8);
181192
info!(1u64 as i16);
@@ -191,6 +202,7 @@ pub fn main() {
191202
info!(true as int);
192203
info!(true as uint);
193204
info!(true as float);
205+
info!(true as bool);
194206
info!(true as *libc::FILE);
195207
info!(true as i8);
196208
info!(true as i16);
@@ -206,6 +218,7 @@ pub fn main() {
206218
info!(1. as int);
207219
info!(1. as uint);
208220
info!(1. as float);
221+
info!(1. as bool);
209222
info!(1. as i8);
210223
info!(1. as i16);
211224
info!(1. as i32);
@@ -220,6 +233,7 @@ pub fn main() {
220233
info!(1f32 as int);
221234
info!(1f32 as uint);
222235
info!(1f32 as float);
236+
info!(1f32 as bool);
223237
info!(1f32 as i8);
224238
info!(1f32 as i16);
225239
info!(1f32 as i32);
@@ -234,6 +248,7 @@ pub fn main() {
234248
info!(1f64 as int);
235249
info!(1f64 as uint);
236250
info!(1f64 as float);
251+
info!(1f64 as bool);
237252
info!(1f64 as i8);
238253
info!(1f64 as i16);
239254
info!(1f64 as i32);

0 commit comments

Comments
 (0)