From 255193cc1af5e07753906ad18bae077b45b5c3f0 Mon Sep 17 00:00:00 2001 From: Alex Crichton Date: Mon, 8 Apr 2013 16:50:34 -0400 Subject: Removing no longer needed unsafe blocks --- src/libsyntax/codemap.rs | 16 +++++++--------- src/libsyntax/parse/lexer.rs | 10 ++++------ 2 files changed, 11 insertions(+), 15 deletions(-) (limited to 'src/libsyntax') diff --git a/src/libsyntax/codemap.rs b/src/libsyntax/codemap.rs index 7a8aff121a8..fc08073686d 100644 --- a/src/libsyntax/codemap.rs +++ b/src/libsyntax/codemap.rs @@ -252,15 +252,13 @@ pub impl FileMap { // get a line from the list of pre-computed line-beginnings pub fn get_line(&self, line: int) -> ~str { - unsafe { - let begin: BytePos = self.lines[line] - self.start_pos; - let begin = begin.to_uint(); - let end = match str::find_char_from(*self.src, '\n', begin) { - Some(e) => e, - None => str::len(*self.src) - }; - str::slice(*self.src, begin, end).to_owned() - } + let begin: BytePos = self.lines[line] - self.start_pos; + let begin = begin.to_uint(); + let end = match str::find_char_from(*self.src, '\n', begin) { + Some(e) => e, + None => str::len(*self.src) + }; + str::slice(*self.src, begin, end).to_owned() } pub fn record_multibyte_char(&self, pos: BytePos, bytes: uint) { diff --git a/src/libsyntax/parse/lexer.rs b/src/libsyntax/parse/lexer.rs index 5e06ecf6090..de3d97de177 100644 --- a/src/libsyntax/parse/lexer.rs +++ b/src/libsyntax/parse/lexer.rs @@ -175,12 +175,10 @@ fn byte_offset(rdr: @mut StringReader) -> BytePos { } pub fn get_str_from(rdr: @mut StringReader, start: BytePos) -> ~str { - unsafe { - // I'm pretty skeptical about this subtraction. What if there's a - // multi-byte character before the mark? - return str::slice(*rdr.src, start.to_uint() - 1u, - byte_offset(rdr).to_uint() - 1u).to_owned(); - } + // I'm pretty skeptical about this subtraction. What if there's a + // multi-byte character before the mark? + return str::slice(*rdr.src, start.to_uint() - 1u, + byte_offset(rdr).to_uint() - 1u).to_owned(); } // EFFECT: advance the StringReader by one character. If a newline is -- cgit 1.4.1-3-g733a5