Skip to content

Commit ddf47b6

Browse files
committed
---
yaml --- r: 77661 b: refs/heads/master c: ebfbbe2 h: refs/heads/master i: 77659: af003f3 v: v3
1 parent 9af75ce commit ddf47b6

File tree

76 files changed

+265
-24
lines changed

Some content is hidden

Large Commits have some content hidden by default. Use the searchbox below for content that may be hidden.

76 files changed

+265
-24
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: 7f79b52ad94e20534df415e463f577b8a9794217
2+
refs/heads/master: ebfbbe294e87f08516ab060633f6af028943ead0
33
refs/heads/snap-stage1: e33de59e47c5076a89eadeb38f4934f58a3618a6
44
refs/heads/snap-stage3: 60fba4d7d677ec098e6a43014132fe99f7547363
55
refs/heads/try: ebfe63cd1c0b5d23f7ea60c69b4fde2e30cfd42a

trunk/src/compiletest/runtest.rs

Lines changed: 1 addition & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -282,9 +282,7 @@ fn run_debuginfo_test(config: &config, props: &TestProps, testfile: &Path) {
282282
}
283283
284284
// write debugger script
285-
let script_str = [~"set charset UTF-8",
286-
cmds,
287-
~"quit\n"].connect("\n");
285+
let script_str = cmds.append("\nquit\n");
288286
debug!("script_str = %s", script_str);
289287
dump_output_file(config, testfile, script_str, "debugger.script");
290288

trunk/src/librustc/metadata/creader.rs

Lines changed: 15 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -25,7 +25,7 @@ use syntax::codemap::{span, dummy_sp};
2525
use syntax::diagnostic::span_handler;
2626
use syntax::parse::token;
2727
use syntax::parse::token::ident_interner;
28-
use syntax::oldvisit;
28+
use syntax::visit;
2929

3030
// Traverses an AST, reading all the information about use'd crates and extern
3131
// libraries necessary for later resolving, typechecking, linking, etc.
@@ -46,17 +46,25 @@ pub fn read_crates(diag: @mut span_handler,
4646
next_crate_num: 1,
4747
intr: intr
4848
};
49-
let v =
50-
oldvisit::mk_simple_visitor(@oldvisit::SimpleVisitor {
51-
visit_view_item: |a| visit_view_item(e, a),
52-
visit_item: |a| visit_item(e, a),
53-
.. *oldvisit::default_simple_visitor()});
49+
let mut v = ReadCrateVisitor{ e:e };
5450
visit_crate(e, crate);
55-
oldvisit::visit_crate(crate, ((), v));
51+
visit::walk_crate(&mut v, crate, ());
5652
dump_crates(*e.crate_cache);
5753
warn_if_multiple_versions(e, diag, *e.crate_cache);
5854
}
5955

56+
struct ReadCrateVisitor { e:@mut Env }
57+
impl visit::Visitor<()> for ReadCrateVisitor {
58+
fn visit_view_item(&mut self, a:&ast::view_item, _:()) {
59+
visit_view_item(self.e, a);
60+
visit::walk_view_item(self, a, ());
61+
}
62+
fn visit_item(&mut self, a:@ast::item, _:()) {
63+
visit_item(self.e, a);
64+
visit::walk_item(self, a, ());
65+
}
66+
}
67+
6068
#[deriving(Clone)]
6169
struct cache_entry {
6270
cnum: int,

trunk/src/libstd/str.rs

Lines changed: 108 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -56,12 +56,23 @@ Section: Creating a string
5656
pub fn from_bytes(vv: &[u8]) -> ~str {
5757
use str::not_utf8::cond;
5858

59-
if !is_utf8(vv) {
60-
let first_bad_byte = *vv.iter().find(|&b| !is_utf8([*b])).unwrap();
61-
cond.raise(fmt!("from_bytes: input is not UTF-8; first bad byte is %u",
62-
first_bad_byte as uint))
59+
match from_bytes_opt(vv) {
60+
None => {
61+
let first_bad_byte = *vv.iter().find(|&b| !is_utf8([*b])).unwrap();
62+
cond.raise(fmt!("from_bytes: input is not UTF-8; first bad byte is %u",
63+
first_bad_byte as uint))
64+
}
65+
Some(s) => s
66+
}
67+
}
68+
69+
/// Convert a vector of bytes to a new UTF-8 string, if possible.
70+
/// Returns None if the vector contains invalid UTF-8.
71+
pub fn from_bytes_opt(vv: &[u8]) -> Option<~str> {
72+
if is_utf8(vv) {
73+
Some(unsafe { raw::from_bytes(vv) })
6374
} else {
64-
return unsafe { raw::from_bytes(vv) }
75+
None
6576
}
6677
}
6778

@@ -78,7 +89,17 @@ pub fn from_bytes_owned(vv: ~[u8]) -> ~str {
7889
cond.raise(fmt!("from_bytes: input is not UTF-8; first bad byte is %u",
7990
first_bad_byte as uint))
8091
} else {
81-
return unsafe { raw::from_bytes_owned(vv) }
92+
unsafe { raw::from_bytes_owned(vv) }
93+
}
94+
}
95+
96+
/// Consumes a vector of bytes to create a new utf-8 string.
97+
/// Returns None if the vector contains invalid UTF-8.
98+
pub fn from_bytes_owned_opt(vv: ~[u8]) -> Option<~str> {
99+
if is_utf8(vv) {
100+
Some(unsafe { raw::from_bytes_owned(vv) })
101+
} else {
102+
None
82103
}
83104
}
84105

@@ -91,8 +112,16 @@ pub fn from_bytes_owned(vv: ~[u8]) -> ~str {
91112
///
92113
/// Fails if invalid UTF-8
93114
pub fn from_bytes_slice<'a>(v: &'a [u8]) -> &'a str {
94-
assert!(is_utf8(v));
95-
unsafe { cast::transmute(v) }
115+
from_bytes_slice_opt(v).expect("from_bytes_slice: not utf-8")
116+
}
117+
118+
/// Converts a vector to a string slice without performing any allocations.
119+
///
120+
/// Returns None if the slice is not utf-8.
121+
pub fn from_bytes_slice_opt<'a>(v: &'a [u8]) -> Option<&'a str> {
122+
if is_utf8(v) {
123+
Some(unsafe { cast::transmute(v) })
124+
} else { None }
96125
}
97126

98127
impl ToStr for ~str {
@@ -2358,7 +2387,7 @@ impl Zero for @str {
23582387
#[cfg(test)]
23592388
mod tests {
23602389
use container::Container;
2361-
use option::Some;
2390+
use option::{None, Some};
23622391
use libc::c_char;
23632392
use libc;
23642393
use ptr;
@@ -3539,6 +3568,76 @@ mod tests {
35393568
let mut s = ~"\u00FC"; // ü
35403569
s.truncate(1);
35413570
}
3571+
3572+
#[test]
3573+
fn test_str_from_bytes_slice() {
3574+
let xs = bytes!("hello");
3575+
assert_eq!(from_bytes_slice(xs), "hello");
3576+
3577+
let xs = bytes!("ศไทย中华Việt Nam");
3578+
assert_eq!(from_bytes_slice(xs), "ศไทย中华Việt Nam");
3579+
}
3580+
3581+
#[test]
3582+
#[should_fail]
3583+
fn test_str_from_bytes_slice_invalid() {
3584+
let xs = bytes!("hello", 0xff);
3585+
let _ = from_bytes_slice(xs);
3586+
}
3587+
3588+
#[test]
3589+
fn test_str_from_bytes_slice_opt() {
3590+
let xs = bytes!("hello");
3591+
assert_eq!(from_bytes_slice_opt(xs), Some("hello"));
3592+
3593+
let xs = bytes!("ศไทย中华Việt Nam");
3594+
assert_eq!(from_bytes_slice_opt(xs), Some("ศไทย中华Việt Nam"));
3595+
3596+
let xs = bytes!("hello", 0xff);
3597+
assert_eq!(from_bytes_slice_opt(xs), None);
3598+
}
3599+
3600+
#[test]
3601+
fn test_str_from_bytes() {
3602+
let xs = bytes!("hello");
3603+
assert_eq!(from_bytes(xs), ~"hello");
3604+
3605+
let xs = bytes!("ศไทย中华Việt Nam");
3606+
assert_eq!(from_bytes(xs), ~"ศไทย中华Việt Nam");
3607+
}
3608+
3609+
#[test]
3610+
fn test_str_from_bytes_opt() {
3611+
let xs = bytes!("hello").to_owned();
3612+
assert_eq!(from_bytes_opt(xs), Some(~"hello"));
3613+
3614+
let xs = bytes!("ศไทย中华Việt Nam");
3615+
assert_eq!(from_bytes_opt(xs), Some(~"ศไทย中华Việt Nam"));
3616+
3617+
let xs = bytes!("hello", 0xff);
3618+
assert_eq!(from_bytes_opt(xs), None);
3619+
}
3620+
3621+
#[test]
3622+
fn test_str_from_bytes_owned() {
3623+
let xs = bytes!("hello").to_owned();
3624+
assert_eq!(from_bytes_owned(xs), ~"hello");
3625+
3626+
let xs = bytes!("ศไทย中华Việt Nam").to_owned();
3627+
assert_eq!(from_bytes_owned(xs), ~"ศไทย中华Việt Nam");
3628+
}
3629+
3630+
#[test]
3631+
fn test_str_from_bytes_owned_opt() {
3632+
let xs = bytes!("hello").to_owned();
3633+
assert_eq!(from_bytes_owned_opt(xs), Some(~"hello"));
3634+
3635+
let xs = bytes!("ศไทย中华Việt Nam").to_owned();
3636+
assert_eq!(from_bytes_owned_opt(xs), Some(~"ศไทย中华Việt Nam"));
3637+
3638+
let xs = bytes!("hello", 0xff).to_owned();
3639+
assert_eq!(from_bytes_owned_opt(xs), None);
3640+
}
35423641
}
35433642
35443643
#[cfg(test)]

trunk/src/test/debug-info/basic-types.rs

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -8,6 +8,8 @@
88
// option. This file may not be copied, modified, or distributed
99
// except according to those terms.
1010

11+
// xfail-win32 Broken because of LLVM bug: http://llvm.org/bugs/show_bug.cgi?id=16249
12+
1113
// Caveats - gdb prints any 8-bit value (meaning rust i8 and u8 values)
1214
// as its numerical value along with its associated ASCII char, there
1315
// doesn't seem to be any way around this. Also, gdb doesn't know

trunk/src/test/debug-info/borrowed-basic.rs

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -8,6 +8,8 @@
88
// option. This file may not be copied, modified, or distributed
99
// except according to those terms.
1010

11+
// xfail-win32 Broken because of LLVM bug: http://llvm.org/bugs/show_bug.cgi?id=16249
12+
1113
// Gdb doesn't know about UTF-32 character encoding and will print a rust char as only
1214
// its numerical value.
1315

trunk/src/test/debug-info/borrowed-c-style-enum.rs

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -8,6 +8,8 @@
88
// option. This file may not be copied, modified, or distributed
99
// except according to those terms.
1010

11+
// xfail-win32 Broken because of LLVM bug: http://llvm.org/bugs/show_bug.cgi?id=16249
12+
1113
// compile-flags:-Z extra-debug-info
1214
// debugger:break zzz
1315
// debugger:run

trunk/src/test/debug-info/borrowed-enum.rs

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -8,6 +8,8 @@
88
// option. This file may not be copied, modified, or distributed
99
// except according to those terms.
1010

11+
// xfail-win32 Broken because of LLVM bug: http://llvm.org/bugs/show_bug.cgi?id=16249
12+
1113
// compile-flags:-Z extra-debug-info
1214
// debugger:break zzz
1315
// debugger:run

trunk/src/test/debug-info/borrowed-managed-basic.rs

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -8,6 +8,8 @@
88
// option. This file may not be copied, modified, or distributed
99
// except according to those terms.
1010

11+
// xfail-win32 Broken because of LLVM bug: http://llvm.org/bugs/show_bug.cgi?id=16249
12+
1113
// Gdb doesn't know about UTF-32 character encoding and will print a rust char as only
1214
// its numerical value.
1315

trunk/src/test/debug-info/borrowed-struct.rs

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -8,6 +8,8 @@
88
// option. This file may not be copied, modified, or distributed
99
// except according to those terms.
1010

11+
// xfail-win32 Broken because of LLVM bug: http://llvm.org/bugs/show_bug.cgi?id=16249
12+
1113
// compile-flags:-Z extra-debug-info
1214
// debugger:break zzz
1315
// debugger:run

trunk/src/test/debug-info/borrowed-tuple.rs

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -8,6 +8,8 @@
88
// option. This file may not be copied, modified, or distributed
99
// except according to those terms.
1010

11+
// xfail-win32 Broken because of LLVM bug: http://llvm.org/bugs/show_bug.cgi?id=16249
12+
1113
// compile-flags:-Z extra-debug-info
1214
// debugger:break zzz
1315
// debugger:run

trunk/src/test/debug-info/borrowed-unique-basic.rs

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -8,6 +8,8 @@
88
// option. This file may not be copied, modified, or distributed
99
// except according to those terms.
1010

11+
// xfail-win32 Broken because of LLVM bug: http://llvm.org/bugs/show_bug.cgi?id=16249
12+
1113
// Gdb doesn't know about UTF-32 character encoding and will print a rust char as only
1214
// its numerical value.
1315

trunk/src/test/debug-info/box.rs

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -8,6 +8,8 @@
88
// option. This file may not be copied, modified, or distributed
99
// except according to those terms.
1010

11+
// xfail-win32 Broken because of LLVM bug: http://llvm.org/bugs/show_bug.cgi?id=16249
12+
1113
// compile-flags:-Z extra-debug-info
1214
// debugger:set print pretty off
1315
// debugger:break _zzz

trunk/src/test/debug-info/boxed-struct.rs

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -8,6 +8,8 @@
88
// option. This file may not be copied, modified, or distributed
99
// except according to those terms.
1010

11+
// xfail-win32 Broken because of LLVM bug: http://llvm.org/bugs/show_bug.cgi?id=16249
12+
1113
// compile-flags:-Z extra-debug-info
1214
// debugger:break zzz
1315
// debugger:run

trunk/src/test/debug-info/boxed-vec.rs

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -8,6 +8,8 @@
88
// option. This file may not be copied, modified, or distributed
99
// except according to those terms.
1010

11+
// xfail-win32 Broken because of LLVM bug: http://llvm.org/bugs/show_bug.cgi?id=16249
12+
1113
// compile-flags:-Z extra-debug-info
1214
// debugger:break zzz
1315
// debugger:run

trunk/src/test/debug-info/c-style-enum-in-composite.rs

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -8,6 +8,8 @@
88
// option. This file may not be copied, modified, or distributed
99
// except according to those terms.
1010

11+
// xfail-win32 Broken because of LLVM bug: http://llvm.org/bugs/show_bug.cgi?id=16249
12+
1113
// compile-flags:-Z extra-debug-info
1214
// debugger:break zzz
1315
// debugger:run

trunk/src/test/debug-info/c-style-enum.rs

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -8,6 +8,8 @@
88
// option. This file may not be copied, modified, or distributed
99
// except according to those terms.
1010

11+
// xfail-win32 Broken because of LLVM bug: http://llvm.org/bugs/show_bug.cgi?id=16249
12+
1113
// compile-flags:-Z extra-debug-info
1214
// debugger:break zzz
1315
// debugger:run

trunk/src/test/debug-info/closure-in-generic-function.rs

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -8,6 +8,8 @@
88
// option. This file may not be copied, modified, or distributed
99
// except according to those terms.
1010

11+
// xfail-win32 Broken because of LLVM bug: http://llvm.org/bugs/show_bug.cgi?id=16249
12+
1113
// compile-flags:-Z extra-debug-info
1214
// debugger:break zzz
1315
// debugger:run

trunk/src/test/debug-info/destructured-fn-argument.rs

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -8,6 +8,8 @@
88
// option. This file may not be copied, modified, or distributed
99
// except according to those terms.
1010

11+
// xfail-win32 Broken because of LLVM bug: http://llvm.org/bugs/show_bug.cgi?id=16249
12+
1113
// compile-flags:-Z extra-debug-info
1214
// debugger:break zzz
1315
// debugger:run

trunk/src/test/debug-info/destructured-local.rs

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -8,6 +8,8 @@
88
// option. This file may not be copied, modified, or distributed
99
// except according to those terms.
1010

11+
// xfail-win32 Broken because of LLVM bug: http://llvm.org/bugs/show_bug.cgi?id=16249
12+
1113
// compile-flags:-Z extra-debug-info
1214
// debugger:break zzz
1315
// debugger:run

trunk/src/test/debug-info/evec-in-struct.rs

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -8,6 +8,8 @@
88
// option. This file may not be copied, modified, or distributed
99
// except according to those terms.
1010

11+
// xfail-win32 Broken because of LLVM bug: http://llvm.org/bugs/show_bug.cgi?id=16249
12+
1113
// compile-flags:-Z extra-debug-info
1214
// debugger:set print pretty off
1315
// debugger:break zzz

trunk/src/test/debug-info/function-arguments.rs

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -8,6 +8,8 @@
88
// option. This file may not be copied, modified, or distributed
99
// except according to those terms.
1010

11+
// xfail-win32 Broken because of LLVM bug: http://llvm.org/bugs/show_bug.cgi?id=16249
12+
1113
// compile-flags:-Z extra-debug-info
1214
// debugger:break zzz
1315
// debugger:run

trunk/src/test/debug-info/generic-function.rs

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -8,6 +8,8 @@
88
// option. This file may not be copied, modified, or distributed
99
// except according to those terms.
1010

11+
// xfail-win32 Broken because of LLVM bug: http://llvm.org/bugs/show_bug.cgi?id=16249
12+
1113
// compile-flags:-Z extra-debug-info
1214
// debugger:break zzz
1315
// debugger:run

trunk/src/test/debug-info/generic-functions-nested.rs

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -8,6 +8,8 @@
88
// option. This file may not be copied, modified, or distributed
99
// except according to those terms.
1010

11+
// xfail-win32 Broken because of LLVM bug: http://llvm.org/bugs/show_bug.cgi?id=16249
12+
1113
// compile-flags:-Z extra-debug-info
1214
// debugger:break zzz
1315
// debugger:run

0 commit comments

Comments
 (0)