Skip to content
14 changes: 8 additions & 6 deletions src/cargo/cargo.rs
Original file line number Diff line number Diff line change
Expand Up @@ -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))
}
}

Expand Down Expand Up @@ -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 <pkg>
if vec::len(argv) < 3u {
cmd_usage();
Expand All @@ -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);
Expand All @@ -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);
Expand Down
4 changes: 2 additions & 2 deletions src/comp/back/link.rs
Original file line number Diff line number Diff line change
Expand Up @@ -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; }
};
Expand Down
4 changes: 2 additions & 2 deletions src/comp/middle/debuginfo.rs
Original file line number Diff line number Diff line change
Expand Up @@ -157,7 +157,7 @@ fn cached_metadata<T: copy>(cache: metadata_cache, mdtag: int,
}

fn create_compile_unit(cx: @crate_ctxt, full_path: str)
-> @metadata<compile_unit_md> {
-> @metadata<compile_unit_md> unsafe {
let cache = get_cache(cx);
let tg = CompileUnitTag;
alt cached_metadata::<@metadata<compile_unit_md>>(cache, tg,
Expand All @@ -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
Expand Down
6 changes: 3 additions & 3 deletions src/comp/syntax/codemap.rs
Original file line number Diff line number Diff line change
Expand Up @@ -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 {
Expand All @@ -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 {
Expand Down
9 changes: 5 additions & 4 deletions src/comp/syntax/parse/lexer.rs
Original file line number Diff line number Diff line change
Expand Up @@ -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 {
Expand Down Expand Up @@ -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);
Expand Down
6 changes: 3 additions & 3 deletions src/compiletest/errors.rs
Original file line number Diff line number Diff line change
Expand Up @@ -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 []; }
Expand All @@ -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);

Expand Down
4 changes: 2 additions & 2 deletions src/compiletest/header.rs
Original file line number Diff line number Diff line change
Expand Up @@ -104,12 +104,12 @@ fn parse_name_directive(line: str, directive: str) -> bool {
}

fn parse_name_value_directive(line: str,
directive: str) -> option<str> {
directive: str) -> option<str> 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)
Expand Down
4 changes: 2 additions & 2 deletions src/fuzzer/fuzzer.rs
Original file line number Diff line number Diff line change
Expand Up @@ -283,10 +283,10 @@ fn check_variants_T<T: copy>(
}
}

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), }
Expand Down
Loading