about summary refs log tree commit diff
path: root/src/libsyntax/parse
diff options
context:
space:
mode:
authorbors <bors@rust-lang.org>2014-07-02 05:41:30 +0000
committerbors <bors@rust-lang.org>2014-07-02 05:41:30 +0000
commit89259b34c04aff7052dd122552fac3070c830f4f (patch)
treed07053ae6f1c059a6a706dd80211795748cd9450 /src/libsyntax/parse
parentbd893d19223ae6979c180291be6b2a3b9311148a (diff)
parentd21336ee0a3982bdc35f17cdc32b41f6de5603d4 (diff)
downloadrust-89259b34c04aff7052dd122552fac3070c830f4f.tar.gz
rust-89259b34c04aff7052dd122552fac3070c830f4f.zip
auto merge of #15085 : brson/rust/stridx, r=alexcrichton
Being able to index into the bytes of a string encourages
poor UTF-8 hygiene. To get a view of `&[u8]` from either
a `String` or `&str` slice, use the `as_bytes()` method.

Closes #12710.

[breaking-change]

If the diffstat is any indication this shouldn't have a huge impact but it will have some. Most changes in the `str` and `path` module. A lot of the existing usages were in tests where ascii is expected. There are a number of other legit uses where the characters are known to be ascii.
Diffstat (limited to 'src/libsyntax/parse')
-rw-r--r--src/libsyntax/parse/lexer/mod.rs4
1 files changed, 2 insertions, 2 deletions
diff --git a/src/libsyntax/parse/lexer/mod.rs b/src/libsyntax/parse/lexer/mod.rs
index ac570c88837..0f188fdf18a 100644
--- a/src/libsyntax/parse/lexer/mod.rs
+++ b/src/libsyntax/parse/lexer/mod.rs
@@ -1203,8 +1203,8 @@ impl<'a> StringReader<'a> {
 
     fn read_one_line_comment(&mut self) -> String {
         let val = self.read_to_eol();
-        assert!((val.as_slice()[0] == '/' as u8 && val.as_slice()[1] == '/' as u8)
-             || (val.as_slice()[0] == '#' as u8 && val.as_slice()[1] == '!' as u8));
+        assert!((val.as_bytes()[0] == '/' as u8 && val.as_bytes()[1] == '/' as u8)
+             || (val.as_bytes()[0] == '#' as u8 && val.as_bytes()[1] == '!' as u8));
         return val;
     }