Skip to content

Commit 9b7a621

Browse files
committed
---
yaml --- r: 79396 b: refs/heads/snap-stage3 c: 2bd628e h: refs/heads/master v: v3
1 parent df0c15b commit 9b7a621

File tree

12 files changed

+45
-28
lines changed

12 files changed

+45
-28
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: c1c5c8b725165546a5a2b158ad46888aee5df241
4+
refs/heads/snap-stage3: 2bd628eafab1225cdc59c468c32868302b5e92ed
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)) as bool
413+
doc_as_u8(self.next_doc(EsBool)) != 0
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) as bool) {
2222+
if !(llvm::LLVMConstIntGetZExtValue(v) != 0) {
22232223
ccx.sess.span_fatal(expr.span, "static assertion failed");
22242224
}
22252225
}

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

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -2696,6 +2696,7 @@ 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);
26992700
let te = structurally_resolved_type(fcx, e.span, t_e);
27002701
let t_1_is_char = type_is_char(fcx, expr.span, t_1);
27012702

@@ -2710,6 +2711,9 @@ pub fn check_expr_with_unifier(fcx: @mut FnCtxt,
27102711
fmt!("only `u8` can be cast as `char`, not `%s`", actual)
27112712
}, t_e, None);
27122713
}
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");
27132717
} else if type_is_region_ptr(fcx, expr.span, t_e) &&
27142718
type_is_unsafe_ptr(fcx, expr.span, t_1) {
27152719

branches/snap-stage3/src/libstd/fmt/parse.rs

Lines changed: 11 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -149,6 +149,7 @@ pub struct SelectArm<'self> {
149149
pub struct Parser<'self> {
150150
priv input: &'self str,
151151
priv cur: str::CharOffsetIterator<'self>,
152+
priv depth: uint,
152153
}
153154

154155
impl<'self> iterator::Iterator<Piece<'self>> for Parser<'self> {
@@ -168,6 +169,11 @@ impl<'self> iterator::Iterator<Piece<'self>> for Parser<'self> {
168169
self.escape(); // ensure it's a valid escape sequence
169170
Some(String(self.string(pos + 1))) // skip the '\' character
170171
}
172+
Some((_, '}')) if self.depth == 0 => {
173+
self.cur.next();
174+
self.err(~"unmatched `}` found");
175+
None
176+
}
171177
Some((_, '}')) | None => { None }
172178
Some((pos, _)) => {
173179
Some(String(self.string(pos)))
@@ -182,6 +188,7 @@ impl<'self> Parser<'self> {
182188
Parser {
183189
input: s,
184190
cur: s.char_offset_iter(),
191+
depth: 0,
185192
}
186193
}
187194

@@ -393,7 +400,9 @@ impl<'self> Parser<'self> {
393400
if !self.wsconsume('{') {
394401
self.err(~"selector must be followed by `{`");
395402
}
403+
self.depth += 1;
396404
let pieces = self.collect();
405+
self.depth -= 1;
397406
if !self.wsconsume('}') {
398407
self.err(~"selector case must be terminated by `}`");
399408
}
@@ -494,7 +503,9 @@ impl<'self> Parser<'self> {
494503
if !self.wsconsume('{') {
495504
self.err(~"selector must be followed by `{`");
496505
}
506+
self.depth += 1;
497507
let pieces = self.collect();
508+
self.depth -= 1;
498509
if !self.wsconsume('}') {
499510
self.err(~"selector case must be terminated by `}`");
500511
}

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

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

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

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -41,7 +41,6 @@ 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;
4544

4645
// Reexported types and traits
4746
pub use c_str::ToCStr;

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

Lines changed: 12 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -799,6 +799,8 @@ 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
802804
// 4-byte encoding is for codepoints \u10000 to \u10ffff
803805
// first F0 90 80 80 last F4 8F BF BF
804806
//
@@ -812,8 +814,6 @@ pub fn is_utf8(v: &[u8]) -> bool {
812814
// UTF8-4 = %xF0 %x90-BF 2( UTF8-tail ) / %xF1-F3 3( UTF8-tail ) /
813815
// %xF4 %x80-8F 2( UTF8-tail )
814816
// 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,7 +822,9 @@ 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 .. 0xEF, 0x80 .. 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) => (),
826828
_ => return false,
827829
},
828830
_ => match (v_i,
@@ -3012,6 +3014,7 @@ mod tests {
30123014
30133015
#[test]
30143016
fn test_is_utf8() {
3017+
// deny overlong encodings
30153018
assert!(!is_utf8([0xc0, 0x80]));
30163019
assert!(!is_utf8([0xc0, 0xae]));
30173020
assert!(!is_utf8([0xe0, 0x80, 0x80]));
@@ -3020,9 +3023,15 @@ mod tests {
30203023
assert!(!is_utf8([0xf0, 0x82, 0x82, 0xac]));
30213024
assert!(!is_utf8([0xf4, 0x90, 0x80, 0x80]));
30223025
3026+
// deny surrogates
3027+
assert!(!is_utf8([0xED, 0xA0, 0x80]));
3028+
assert!(!is_utf8([0xED, 0xBF, 0xBF]));
3029+
30233030
assert!(is_utf8([0xC2, 0x80]));
30243031
assert!(is_utf8([0xDF, 0xBF]));
30253032
assert!(is_utf8([0xE0, 0xA0, 0x80]));
3033+
assert!(is_utf8([0xED, 0x9F, 0xBF]));
3034+
assert!(is_utf8([0xEE, 0x80, 0x80]));
30263035
assert!(is_utf8([0xEF, 0xBF, 0xBF]));
30273036
assert!(is_utf8([0xF0, 0x90, 0x80, 0x80]));
30283037
assert!(is_utf8([0xF4, 0x8F, 0xBF, 0xBF]));
Lines changed: 12 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,12 @@
1+
// Copyright 2013 The Rust Project Developers. See the COPYRIGHT
2+
// file at the top-level directory of this distribution and at
3+
// http://rust-lang.org/COPYRIGHT.
4+
//
5+
// Licensed under the Apache License, Version 2.0 <LICENSE-APACHE or
6+
// http://www.apache.org/licenses/LICENSE-2.0> or the MIT license
7+
// <LICENSE-MIT or http://opensource.org/licenses/MIT>, at your
8+
// option. This file may not be copied, modified, or distributed
9+
// except according to those terms.
10+
11+
// error-pattern: cannot cast as `bool`, compare with zero instead
12+
fn main() { let u = (5 as bool); }

branches/snap-stage3/src/test/compile-fail/ifmt-bad-arg.rs

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -71,4 +71,7 @@ fn main() {
7171
format!("{0, select, other{{}}}", "a"); //~ ERROR: cannot use implicit
7272
format!("{0, plural, other{{}}}", 1); //~ ERROR: cannot use implicit
7373
format!("{0, plural, other{{1:.*d}}}", 1, 2); //~ ERROR: cannot use implicit
74+
75+
format!("foo } bar"); //~ ERROR: unmatched `}` found
76+
format!("foo }"); //~ ERROR: unmatched `}` found
7477
}

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

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -18,6 +18,5 @@ 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);
2221
assert_eq!(0 as u32, false as u32);
2322
}

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

Lines changed: 0 additions & 15 deletions
Original file line numberDiff line numberDiff line change
@@ -26,7 +26,6 @@ pub fn main() {
2626
info!(1 as int);
2727
info!(1 as uint);
2828
info!(1 as float);
29-
info!(1 as bool);
3029
info!(1 as *libc::FILE);
3130
info!(1 as i8);
3231
info!(1 as i16);
@@ -42,7 +41,6 @@ pub fn main() {
4241
info!(1u as int);
4342
info!(1u as uint);
4443
info!(1u as float);
45-
info!(1u as bool);
4644
info!(1u as *libc::FILE);
4745
info!(1u as i8);
4846
info!(1u as i16);
@@ -58,7 +56,6 @@ pub fn main() {
5856
info!(1i8 as int);
5957
info!(1i8 as uint);
6058
info!(1i8 as float);
61-
info!(1i8 as bool);
6259
info!(1i8 as *libc::FILE);
6360
info!(1i8 as i8);
6461
info!(1i8 as i16);
@@ -74,7 +71,6 @@ pub fn main() {
7471
info!(1u8 as int);
7572
info!(1u8 as uint);
7673
info!(1u8 as float);
77-
info!(1u8 as bool);
7874
info!(1u8 as *libc::FILE);
7975
info!(1u8 as i8);
8076
info!(1u8 as i16);
@@ -90,7 +86,6 @@ pub fn main() {
9086
info!(1i16 as int);
9187
info!(1i16 as uint);
9288
info!(1i16 as float);
93-
info!(1i16 as bool);
9489
info!(1i16 as *libc::FILE);
9590
info!(1i16 as i8);
9691
info!(1i16 as i16);
@@ -106,7 +101,6 @@ pub fn main() {
106101
info!(1u16 as int);
107102
info!(1u16 as uint);
108103
info!(1u16 as float);
109-
info!(1u16 as bool);
110104
info!(1u16 as *libc::FILE);
111105
info!(1u16 as i8);
112106
info!(1u16 as i16);
@@ -122,7 +116,6 @@ pub fn main() {
122116
info!(1i32 as int);
123117
info!(1i32 as uint);
124118
info!(1i32 as float);
125-
info!(1i32 as bool);
126119
info!(1i32 as *libc::FILE);
127120
info!(1i32 as i8);
128121
info!(1i32 as i16);
@@ -138,7 +131,6 @@ pub fn main() {
138131
info!(1u32 as int);
139132
info!(1u32 as uint);
140133
info!(1u32 as float);
141-
info!(1u32 as bool);
142134
info!(1u32 as *libc::FILE);
143135
info!(1u32 as i8);
144136
info!(1u32 as i16);
@@ -154,7 +146,6 @@ pub fn main() {
154146
info!(1i64 as int);
155147
info!(1i64 as uint);
156148
info!(1i64 as float);
157-
info!(1i64 as bool);
158149
info!(1i64 as *libc::FILE);
159150
info!(1i64 as i8);
160151
info!(1i64 as i16);
@@ -170,7 +161,6 @@ pub fn main() {
170161
info!(1u64 as int);
171162
info!(1u64 as uint);
172163
info!(1u64 as float);
173-
info!(1u64 as bool);
174164
info!(1u64 as *libc::FILE);
175165
info!(1u64 as i8);
176166
info!(1u64 as i16);
@@ -186,7 +176,6 @@ pub fn main() {
186176
info!(1u64 as int);
187177
info!(1u64 as uint);
188178
info!(1u64 as float);
189-
info!(1u64 as bool);
190179
info!(1u64 as *libc::FILE);
191180
info!(1u64 as i8);
192181
info!(1u64 as i16);
@@ -202,7 +191,6 @@ pub fn main() {
202191
info!(true as int);
203192
info!(true as uint);
204193
info!(true as float);
205-
info!(true as bool);
206194
info!(true as *libc::FILE);
207195
info!(true as i8);
208196
info!(true as i16);
@@ -218,7 +206,6 @@ pub fn main() {
218206
info!(1. as int);
219207
info!(1. as uint);
220208
info!(1. as float);
221-
info!(1. as bool);
222209
info!(1. as i8);
223210
info!(1. as i16);
224211
info!(1. as i32);
@@ -233,7 +220,6 @@ pub fn main() {
233220
info!(1f32 as int);
234221
info!(1f32 as uint);
235222
info!(1f32 as float);
236-
info!(1f32 as bool);
237223
info!(1f32 as i8);
238224
info!(1f32 as i16);
239225
info!(1f32 as i32);
@@ -248,7 +234,6 @@ pub fn main() {
248234
info!(1f64 as int);
249235
info!(1f64 as uint);
250236
info!(1f64 as float);
251-
info!(1f64 as bool);
252237
info!(1f64 as i8);
253238
info!(1f64 as i16);
254239
info!(1f64 as i32);

0 commit comments

Comments
 (0)