diff --git a/src/cargo/cargo.rs b/src/cargo/cargo.rs index fd39797b29fc0..0acd3e4f1c8e5 100644 --- a/src/cargo/cargo.rs +++ b/src/cargo/cargo.rs @@ -162,7 +162,7 @@ fn rest(s: str, start: uint) -> str { if (start >= str::char_len(s)) { "" } else { - str::char_slice(s, start, str::char_len(s)) + str::slice(s, start, str::char_len(s)) } } @@ -573,7 +573,7 @@ fn install_named_specific(c: cargo, wd: str, src: str, name: str) { error("Can't find package " + src + "/" + name); } -fn cmd_install(c: cargo, argv: [str]) { +fn cmd_install(c: cargo, argv: [str]) unsafe { // cargo install if vec::len(argv) < 3u { cmd_usage(); @@ -596,8 +596,9 @@ fn cmd_install(c: cargo, argv: [str]) { let uuid = rest(target, 5u); let idx = str::index(uuid, '/' as u8); if idx != -1 { - let source = str::slice(uuid, 0u, idx as uint); - uuid = str::slice(uuid, idx as uint + 1u, str::byte_len(uuid)); + let source = str::unsafe::slice_bytes(uuid, 0u, idx as uint); + uuid = str::unsafe::slice_bytes(uuid, idx as uint + 1u, + str::byte_len(uuid)); install_uuid_specific(c, wd, source, uuid); } else { install_uuid(c, wd, uuid); @@ -606,8 +607,9 @@ fn cmd_install(c: cargo, argv: [str]) { let name = target; let idx = str::index(name, '/' as u8); if idx != -1 { - let source = str::slice(name, 0u, idx as uint); - name = str::slice(name, idx as uint + 1u, str::byte_len(name)); + let source = str::unsafe::slice_bytes(name, 0u, idx as uint); + name = str::unsafe::slice_bytes(name, idx as uint + 1u, + str::byte_len(name)); install_named_specific(c, wd, source, name); } else { install_named(c, wd, name); diff --git a/src/comp/back/link.rs b/src/comp/back/link.rs index b7a16d7e863b8..f545b43e9ffbd 100644 --- a/src/comp/back/link.rs +++ b/src/comp/back/link.rs @@ -567,13 +567,13 @@ fn link_binary(sess: session, out_filename: str, lm: link_meta) { // Converts a library file name into a gcc -l argument - fn unlib(config: @session::config, filename: str) -> str { + fn unlib(config: @session::config, filename: str) -> str unsafe { let rmlib = fn@(filename: str) -> str { if config.os == session::os_macos || (config.os == session::os_linux || config.os == session::os_freebsd) && str::find(filename, "lib") == 0 { - ret str::slice(filename, 3u, + ret str::unsafe::slice_bytes(filename, 3u, str::byte_len(filename)); } else { ret filename; } }; diff --git a/src/comp/middle/debuginfo.rs b/src/comp/middle/debuginfo.rs index 177bbef06eac3..cebcd245b2f99 100644 --- a/src/comp/middle/debuginfo.rs +++ b/src/comp/middle/debuginfo.rs @@ -157,7 +157,7 @@ fn cached_metadata(cache: metadata_cache, mdtag: int, } fn create_compile_unit(cx: @crate_ctxt, full_path: str) - -> @metadata { + -> @metadata unsafe { let cache = get_cache(cx); let tg = CompileUnitTag; alt cached_metadata::<@metadata>(cache, tg, @@ -168,7 +168,7 @@ fn create_compile_unit(cx: @crate_ctxt, full_path: str) let work_dir = cx.sess.working_dir; let file_path = if str::starts_with(full_path, work_dir) { - str::slice(full_path, str::byte_len(work_dir), + str::unsafe::slice_bytes(full_path, str::byte_len(work_dir), str::byte_len(full_path)) } else { full_path diff --git a/src/comp/syntax/codemap.rs b/src/comp/syntax/codemap.rs index 0b893376bdbfa..eb6d1fd1d9d95 100644 --- a/src/comp/syntax/codemap.rs +++ b/src/comp/syntax/codemap.rs @@ -108,7 +108,7 @@ fn span_to_lines(sp: span, cm: codemap::codemap) -> @file_lines { ret @{name: lo.filename, lines: lines}; } -fn get_line(fm: filemap, line: int) -> str { +fn get_line(fm: filemap, line: int) -> str unsafe { let begin: uint = fm.lines[line].byte - fm.start_pos.byte; let end: uint; if line as uint < vec::len(fm.lines) - 1u { @@ -118,11 +118,11 @@ fn get_line(fm: filemap, line: int) -> str { // parsed. If we just slice the rest of the string, we'll print out // the remainder of the file, which is undesirable. end = str::byte_len(*fm.src); - let rest = str::slice(*fm.src, begin, end); + let rest = str::unsafe::slice_bytes(*fm.src, begin, end); let newline = str::index(rest, '\n' as u8); if newline != -1 { end = begin + (newline as uint); } } - ret str::slice(*fm.src, begin, end); + ret str::unsafe::slice_bytes(*fm.src, begin, end); } fn get_filemap(cm: codemap, filename: str) -> filemap { diff --git a/src/comp/syntax/parse/lexer.rs b/src/comp/syntax/parse/lexer.rs index 03fc401710619..4d7ee27eb9d10 100644 --- a/src/comp/syntax/parse/lexer.rs +++ b/src/comp/syntax/parse/lexer.rs @@ -24,10 +24,10 @@ type reader = @{ impl reader for reader { fn is_eof() -> bool { self.curr == -1 as char } - fn get_str_from(start: uint) -> str { + fn get_str_from(start: uint) -> str unsafe { // I'm pretty skeptical about this subtraction. What if there's a // multi-byte character before the mark? - ret str::slice(*self.src, start - 1u, self.pos - 1u); + ret str::unsafe::slice_bytes(*self.src, start - 1u, self.pos - 1u); } fn next() -> char { if self.pos < self.len { @@ -579,11 +579,12 @@ fn all_whitespace(s: str, begin: uint, end: uint) -> bool { ret true; } -fn trim_whitespace_prefix_and_push_line(&lines: [str], s: str, col: uint) { +fn trim_whitespace_prefix_and_push_line(&lines: [str], + s: str, col: uint) unsafe { let s1; if all_whitespace(s, 0u, col) { if col < str::byte_len(s) { - s1 = str::slice(s, col, str::byte_len(s)); + s1 = str::unsafe::slice_bytes(s, col, str::byte_len(s)); } else { s1 = ""; } } else { s1 = s; } log(debug, "pushing line: " + s1); diff --git a/src/compiletest/errors.rs b/src/compiletest/errors.rs index e0c4bf6b654c7..3703badf52793 100644 --- a/src/compiletest/errors.rs +++ b/src/compiletest/errors.rs @@ -22,7 +22,7 @@ fn load_errors(testfile: str) -> [expected_error] { ret error_patterns; } -fn parse_expected(line_num: uint, line: str) -> [expected_error] { +fn parse_expected(line_num: uint, line: str) -> [expected_error] unsafe { let error_tag = "//!"; let idx0 = str::find(line, error_tag); if idx0 < 0 { ret []; } @@ -41,11 +41,11 @@ fn parse_expected(line_num: uint, line: str) -> [expected_error] { while idx < len && line[idx] == (' ' as u8) { idx += 1u; } let start_kind = idx; while idx < len && line[idx] != (' ' as u8) { idx += 1u; } - let kind = str::to_lower(str::slice(line, start_kind, idx)); + let kind = str::to_lower(str::unsafe::slice_bytes(line, start_kind, idx)); // Extract msg: while idx < len && line[idx] == (' ' as u8) { idx += 1u; } - let msg = str::slice(line, idx, len); + let msg = str::unsafe::slice_bytes(line, idx, len); #debug("line=%u kind=%s msg=%s", line_num - adjust_line, kind, msg); diff --git a/src/compiletest/header.rs b/src/compiletest/header.rs index ec881caebbcf1..e09861141c4af 100644 --- a/src/compiletest/header.rs +++ b/src/compiletest/header.rs @@ -104,12 +104,12 @@ fn parse_name_directive(line: str, directive: str) -> bool { } fn parse_name_value_directive(line: str, - directive: str) -> option { + directive: str) -> option unsafe { let keycolon = directive + ":"; if str::find(line, keycolon) >= 0 { let colon = str::find(line, keycolon) as uint; let value = - str::slice(line, colon + str::byte_len(keycolon), + str::unsafe::slice_bytes(line, colon + str::byte_len(keycolon), str::byte_len(line)); #debug("%s: %s", directive, value); option::some(value) diff --git a/src/fuzzer/fuzzer.rs b/src/fuzzer/fuzzer.rs index 7d5156a95a005..a5cfb8db3f7cf 100644 --- a/src/fuzzer/fuzzer.rs +++ b/src/fuzzer/fuzzer.rs @@ -283,10 +283,10 @@ fn check_variants_T( } } -fn last_part(filename: str) -> str { +fn last_part(filename: str) -> str unsafe { let ix = str::rindex(filename, 47u8 /* '/' */); assert ix >= 0; - str::slice(filename, ix as uint + 1u, str::byte_len(filename) - 3u) + str::unsafe::slice_bytes(filename, ix as uint + 1u, str::byte_len(filename) - 3u) } enum happiness { passed, cleanly_rejected(str), known_bug(str), failed(str), } diff --git a/src/libcore/str.rs b/src/libcore/str.rs index 9f40dd5c3a48c..dd16e5887f229 100644 --- a/src/libcore/str.rs +++ b/src/libcore/str.rs @@ -37,9 +37,7 @@ export bytes, chars, substr, - char_slice, slice, - safe_slice, split, splitn, split_str, @@ -98,7 +96,9 @@ export escape_char, as_buf, //buf, - sbuf; + sbuf, + + unsafe; @@ -422,12 +422,12 @@ Failure: If `begin` + `len` is is greater than the byte length of the string */ -fn substr(s: str, begin: uint, len: uint) -> str { - ret slice(s, begin, begin + len); +fn substr(s: str, begin: uint, len: uint) -> str unsafe { + ret unsafe::slice_bytes(s, begin, begin + len); } /* -Function: char_slice +Function: slice Unicode-safe slice. Returns a slice of the given string containing the characters in the range [`begin`..`end`). `begin` and `end` are @@ -438,54 +438,12 @@ Failure: - If begin is greater than end - If end is greater than the character length of the string -FIXME: rename to slice(), make faster by avoiding char conversion +FIXME: make faster by avoiding char conversion */ -fn char_slice(s: str, begin: uint, end: uint) -> str { +fn slice(s: str, begin: uint, end: uint) -> str { from_chars(vec::slice(chars(s), begin, end)) } -/* -Function: slice - -Takes a bytewise slice from a string. Returns the substring from -[`begin`..`end`). - -This function is not unicode-safe. - -Failure: - -- If begin is greater than end. -- If end is greater than the length of the string. - -FIXME: rename to slice_byte or slice_byte_unsafe -*/ -fn slice(s: str, begin: uint, end: uint) -> str unsafe { - // FIXME: Typestate precondition - assert (begin <= end); - assert (end <= byte_len(s)); - - let v: [u8] = ::unsafe::reinterpret_cast(s); - let v2 = vec::slice(v, begin, end); - ::unsafe::leak(v); - v2 += [0u8]; - let s2: str = ::unsafe::reinterpret_cast(v2); - ::unsafe::leak(v2); - ret s2; -} - -/* -Function: safe_slice - -FIXME: make sure char_slice / slice / byte_slice - have these preconditions and assertions -FIXME: this shouldn't be mistaken for a UTF-8 safe slice -*/ -fn safe_slice(s: str, begin: uint, end: uint) : uint::le(begin, end) -> str { - // would need some magic to make this a precondition - assert (end <= byte_len(s)); - ret slice(s, begin, end); -} - /* Function: split @@ -662,7 +620,7 @@ fn windowed(nn: uint, ss: str) -> [str] { let ii = 0u; while ii+nn <= len { - let w = char_slice( ss, ii, ii+nn ); + let w = slice( ss, ii, ii+nn ); vec::push(ww,w); ii += 1u; } @@ -704,20 +662,21 @@ Returns: The original string with all occurances of `from` replaced with `to` */ -fn replace(s: str, from: str, to: str) : is_not_empty(from) -> str { +fn replace(s: str, from: str, to: str) : is_not_empty(from) -> str unsafe { // FIXME (694): Shouldn't have to check this check (is_not_empty(from)); if byte_len(s) == 0u { ret ""; } else if starts_with(s, from) { - ret to + replace(slice(s, byte_len(from), byte_len(s)), from, to); + ret to + replace(unsafe::slice_bytes(s, byte_len(from), byte_len(s)), + from, to); } else { let idx = find(s, from); if idx == -1 { ret s; } - ret char_slice(s, 0u, idx as uint) + to + - replace(char_slice(s, idx as uint + char_len(from), char_len(s)), + ret slice(s, 0u, idx as uint) + to + + replace(slice(s, idx as uint + char_len(from), char_len(s)), from, to); } } @@ -882,6 +841,8 @@ Function: index Returns the index of the first matching byte. Returns -1 if no match is found. + +FIXME: UTF-8 */ fn index(s: str, c: u8) -> int { let i: int = 0; @@ -894,6 +855,8 @@ Function: rindex Returns the index of the last matching byte. Returns -1 if no match is found. + +FIXME: UTF-8 */ fn rindex(s: str, c: u8) -> int { let n: int = byte_len(s) as int; @@ -915,6 +878,8 @@ needle - The string to look for Returns: The index of the first occurance of `needle`, or -1 if not found. + +FIXME: UTF-8? */ fn find(haystack: str, needle: str) -> int { let haystack_len: int = byte_len(haystack) as int; @@ -1344,7 +1309,9 @@ mod unsafe { export // UNSAFE from_bytes, - from_byte; + from_byte, + slice_bytes, + slice_bytes_safe_range; // Function: unsafe::from_bytes // @@ -1362,6 +1329,44 @@ mod unsafe { // Converts a byte to a string. Does not verify that the byte is // valid UTF-8. unsafe fn from_byte(u: u8) -> str { unsafe::from_bytes([u]) } + + /* + Function: slice + + Takes a bytewise (not UTF-8) slice from a string. + Returns the substring from [`begin`..`end`). + + Failure: + + - If begin is greater than end. + - If end is greater than the length of the string. + */ + unsafe fn slice_bytes(s: str, begin: uint, end: uint) -> str unsafe { + // FIXME: Typestate precondition + assert (begin <= end); + assert (end <= byte_len(s)); + + let v: [u8] = ::unsafe::reinterpret_cast(s); + let v2 = vec::slice(v, begin, end); + ::unsafe::leak(v); + v2 += [0u8]; + let s2: str = ::unsafe::reinterpret_cast(v2); + ::unsafe::leak(v2); + ret s2; + } + + /* + Function: slice_bytes_safe_range + + Like slice_bytes, with a precondition + */ + unsafe fn slice_bytes_safe_range(s: str, begin: uint, end: uint) + : uint::le(begin, end) -> str { + // would need some magic to make this a precondition + assert (end <= byte_len(s)); + ret slice_bytes(s, begin, end); + } + } @@ -1589,10 +1594,10 @@ mod tests { } #[test] - fn test_slice() { - assert (eq("ab", slice("abc", 0u, 2u))); - assert (eq("bc", slice("abc", 1u, 3u))); - assert (eq("", slice("abc", 1u, 1u))); + fn test_unsafe_slice() unsafe { + assert (eq("ab", unsafe::slice_bytes("abc", 0u, 2u))); + assert (eq("bc", unsafe::slice_bytes("abc", 1u, 3u))); + assert (eq("", unsafe::slice_bytes("abc", 1u, 1u))); fn a_million_letter_a() -> str { let i = 0; let rs = ""; @@ -1606,7 +1611,7 @@ mod tests { ret rs; } assert (eq(half_a_million_letter_a(), - slice(a_million_letter_a(), 0u, 500000u))); + unsafe::slice_bytes(a_million_letter_a(), 0u, 500000u))); } #[test] @@ -1653,17 +1658,17 @@ mod tests { } #[test] - fn test_char_slice() { - assert (eq("ab", char_slice("abc", 0u, 2u))); - assert (eq("bc", char_slice("abc", 1u, 3u))); - assert (eq("", char_slice("abc", 1u, 1u))); - assert (eq("\u65e5", char_slice("\u65e5\u672c", 0u, 1u))); + fn test_slice() { + assert (eq("ab", slice("abc", 0u, 2u))); + assert (eq("bc", slice("abc", 1u, 3u))); + assert (eq("", slice("abc", 1u, 1u))); + assert (eq("\u65e5", slice("\u65e5\u672c", 0u, 1u))); let data = "ประเทศไทย中华"; - assert (eq("ป", char_slice(data, 0u, 1u))); - assert (eq("ร", char_slice(data, 1u, 2u))); - assert (eq("华", char_slice(data, 10u, 11u))); - assert (eq("", char_slice(data, 1u, 1u))); + assert (eq("ป", slice(data, 0u, 1u))); + assert (eq("ร", slice(data, 1u, 2u))); + assert (eq("华", slice(data, 10u, 11u))); + assert (eq("", slice(data, 1u, 1u))); fn a_million_letter_X() -> str { let i = 0; @@ -1678,7 +1683,7 @@ mod tests { ret rs; } assert (eq(half_a_million_letter_X(), - char_slice(a_million_letter_X(), 0u, 500000u))); + slice(a_million_letter_X(), 0u, 500000u))); } #[test] diff --git a/src/libstd/fs.rs b/src/libstd/fs.rs index cbfca163c1838..1e5c9657d1e0f 100644 --- a/src/libstd/fs.rs +++ b/src/libstd/fs.rs @@ -63,7 +63,7 @@ path separators in the path then the returned path is identical to the provided path. If an empty path is provided or the path ends with a path separator then an empty path is returned. */ -fn basename(p: path) -> path { +fn basename(p: path) -> path unsafe { let i: int = str::rindex(p, os_fs::path_sep as u8); if i == -1 { i = str::rindex(p, os_fs::alt_path_sep as u8); @@ -71,7 +71,7 @@ fn basename(p: path) -> path { } let len = str::byte_len(p); if i + 1 as uint >= len { ret p; } - ret str::slice(p, i + 1 as uint, len); + ret str::unsafe::slice_bytes(p, i + 1 as uint, len); } diff --git a/src/libstd/getopts.rs b/src/libstd/getopts.rs index 585ea48725f94..bc96cb65efa68 100644 --- a/src/libstd/getopts.rs +++ b/src/libstd/getopts.rs @@ -209,7 +209,7 @@ ok(match) - On success. Use functions such as , etc. to interrogate results. err(fail_) - On failure. Use to get an error message. */ -fn getopts(args: [str], opts: [opt]) -> result { +fn getopts(args: [str], opts: [opt]) -> result unsafe { let n_opts = vec::len::(opts); fn f(_x: uint) -> [optval] { ret []; } let vals = vec::init_fn_mut::<[optval]>(n_opts, f); @@ -229,14 +229,15 @@ fn getopts(args: [str], opts: [opt]) -> result { let names; let i_arg = option::none::; if cur[1] == '-' as u8 { - let tail = str::slice(cur, 2u, curlen); + let tail = str::unsafe::slice_bytes(cur, 2u, curlen); let eq = str::index(tail, '=' as u8); if eq == -1 { names = [long(tail)]; } else { - names = [long(str::slice(tail, 0u, eq as uint))]; + names = + [long(str::unsafe::slice_bytes(tail,0u,eq as uint))]; i_arg = - option::some::(str::slice(tail, + option::some::(str::unsafe::slice_bytes(tail, (eq as uint) + 1u, curlen - 2u)); } diff --git a/src/libstd/json.rs b/src/libstd/json.rs index 306bcf6e16a21..bb1d0fb64b6b2 100644 --- a/src/libstd/json.rs +++ b/src/libstd/json.rs @@ -71,7 +71,7 @@ fn to_str(j: json) -> str { fn rest(s: str) -> str { assert(str::char_len(s) >= 1u); - str::char_slice(s, 1u, str::char_len(s)) + str::slice(s, 1u, str::char_len(s)) } fn from_str_str(s: str) -> (option, str) { @@ -99,7 +99,7 @@ fn from_str_str(s: str) -> (option, str) { cont; } else if (c == '"') { ret (some(string(res)), - str::char_slice(s, pos, str::char_len(s))); + str::slice(s, pos, str::char_len(s))); } res = res + str::from_char(c); } @@ -200,12 +200,12 @@ fn from_str_float(s: str) -> (option, str) { } '.' { break; } _ { ret (some(num(neg * res)), - str::char_slice(s, opos, str::char_len(s))); } + str::slice(s, opos, str::char_len(s))); } } } if pos == len { - ret (some(num(neg * res)), str::char_slice(s, pos, str::char_len(s))); + ret (some(num(neg * res)), str::slice(s, pos, str::char_len(s))); } let dec = 1f; @@ -220,17 +220,17 @@ fn from_str_float(s: str) -> (option, str) { res += (((c as int) - ('0' as int)) as float) * dec; } _ { ret (some(num(neg * res)), - str::char_slice(s, opos, str::char_len(s))); } + str::slice(s, opos, str::char_len(s))); } } } - ret (some(num(neg * res)), str::char_slice(s, pos, str::char_len(s))); + ret (some(num(neg * res)), str::slice(s, pos, str::char_len(s))); } fn from_str_bool(s: str) -> (option, str) { if (str::starts_with(s, "true")) { - (some(boolean(true)), str::slice(s, 4u, str::byte_len(s))) + (some(boolean(true)), str::slice(s, 4u, str::char_len(s))) } else if (str::starts_with(s, "false")) { - (some(boolean(false)), str::slice(s, 5u, str::byte_len(s))) + (some(boolean(false)), str::slice(s, 5u, str::char_len(s))) } else { (none, s) } @@ -238,7 +238,7 @@ fn from_str_bool(s: str) -> (option, str) { fn from_str_null(s: str) -> (option, str) { if (str::starts_with(s, "null")) { - (some(null), str::slice(s, 4u, str::byte_len(s))) + (some(null), str::slice(s, 4u, str::char_len(s))) } else { (none, s) } diff --git a/src/rustdoc/unindent_pass.rs b/src/rustdoc/unindent_pass.rs index 8d6aec7330039..9c43ce4486414 100644 --- a/src/rustdoc/unindent_pass.rs +++ b/src/rustdoc/unindent_pass.rs @@ -68,7 +68,7 @@ fn unindent(s: str) -> str { line } else { assert str::byte_len(line) >= min_indent; - str::char_slice(line, min_indent, str::char_len(line)) + str::slice(line, min_indent, str::char_len(line)) } }; str::connect(unindented, "\n") diff --git a/src/test/compile-fail/fn-constraint.rs b/src/test/compile-fail/fn-constraint.rs index aadbecc40a7c1..b8a4a164c7eec 100644 --- a/src/test/compile-fail/fn-constraint.rs +++ b/src/test/compile-fail/fn-constraint.rs @@ -2,8 +2,8 @@ use std; import str::*; -fn main() { +fn main() unsafe { let a: uint = 4u; let b: uint = 1u; - log(error, safe_slice("kitties", a, b)); + log(error, str::unsafe::slice_bytes_safe_range("kitties", a, b)); } diff --git a/src/test/compile-fail/no-constraint-prop.rs b/src/test/compile-fail/no-constraint-prop.rs index 2a03395f1c161..ae5a024863b7d 100644 --- a/src/test/compile-fail/no-constraint-prop.rs +++ b/src/test/compile-fail/no-constraint-prop.rs @@ -3,7 +3,7 @@ use std; import str::*; import uint::*; -fn main() { +fn main() unsafe { let a: uint = 1u; let b: uint = 4u; let c: uint = 5u; @@ -16,5 +16,5 @@ fn main() { // the next statement, since it's not true in the // prestate. let d <- a; - log(debug, safe_slice("kitties", b, d)); + log(debug, str::unsafe::slice_bytes_safe_range("kitties", b, d)); } diff --git a/src/test/run-fail/fn-constraint.rs b/src/test/run-fail/fn-constraint.rs index 40e259a0446a0..5277b1bc6e131 100644 --- a/src/test/run-fail/fn-constraint.rs +++ b/src/test/run-fail/fn-constraint.rs @@ -3,9 +3,9 @@ use std; import str::*; import uint::le; -fn main() { +fn main() unsafe { let a: uint = 4u; let b: uint = 1u; check (le(a, b)); - log(error, safe_slice("kitties", a, b)); + log(error, str::unsafe::slice_bytes_safe_range("kitties", a, b)); } diff --git a/src/test/run-pass/constraint-prop-expr-move.rs b/src/test/run-pass/constraint-prop-expr-move.rs index 7848d9b9bd539..1f8e6f69b2730 100644 --- a/src/test/run-pass/constraint-prop-expr-move.rs +++ b/src/test/run-pass/constraint-prop-expr-move.rs @@ -2,11 +2,11 @@ use std; import str::*; import uint::*; -fn main() { +fn main() unsafe { let a: uint = 1u; let b: uint = 4u; let c: uint = 17u; check (le(a, b)); c <- a; - log(debug, safe_slice("kitties", c, b)); + log(debug, str::unsafe::slice_bytes_safe_range("kitties", c, b)); } diff --git a/src/test/run-pass/constraint-prop-move.rs b/src/test/run-pass/constraint-prop-move.rs index 347ea13f0051d..12124e8801f21 100644 --- a/src/test/run-pass/constraint-prop-move.rs +++ b/src/test/run-pass/constraint-prop-move.rs @@ -2,10 +2,10 @@ use std; import str::*; import uint::*; -fn main() { +fn main() unsafe { let a: uint = 1u; let b: uint = 4u; check (le(a, b)); let c <- a; - log(debug, safe_slice("kitties", c, b)); + log(debug, str::unsafe::slice_bytes_safe_range("kitties", c, b)); } diff --git a/src/test/run-pass/constraint-prop-swap.rs b/src/test/run-pass/constraint-prop-swap.rs index 748044893ed5f..6c9af246dbda6 100644 --- a/src/test/run-pass/constraint-prop-swap.rs +++ b/src/test/run-pass/constraint-prop-swap.rs @@ -2,10 +2,10 @@ use std; import str::*; import uint::*; -fn main() { +fn main() unsafe { let a: uint = 4u; let b: uint = 1u; check (le(b, a)); b <-> a; - log(debug, safe_slice("kitties", a, b)); + log(debug, str::unsafe::slice_bytes_safe_range("kitties", a, b)); } diff --git a/src/test/run-pass/constraint-prop.rs b/src/test/run-pass/constraint-prop.rs index f15c0f4121d77..62cee45c9581e 100644 --- a/src/test/run-pass/constraint-prop.rs +++ b/src/test/run-pass/constraint-prop.rs @@ -2,10 +2,10 @@ use std; import str::*; import uint::*; -fn main() { +fn main() unsafe { let a: uint = 1u; let b: uint = 4u; check (le(a, b)); let c = b; - log(debug, safe_slice("kitties", a, c)); + log(debug, str::unsafe::slice_bytes_safe_range("kitties", a, c)); } diff --git a/src/test/run-pass/fn-constraint.rs b/src/test/run-pass/fn-constraint.rs index 68106f298617f..2d5e28f209ca4 100644 --- a/src/test/run-pass/fn-constraint.rs +++ b/src/test/run-pass/fn-constraint.rs @@ -2,9 +2,9 @@ use std; import str::*; import uint::*; -fn main() { +fn main() unsafe { let a: uint = 1u; let b: uint = 4u; check (le(a, b)); - log(debug, safe_slice("kitties", a, b)); + log(debug, str::unsafe::slice_bytes_safe_range("kitties", a, b)); }