diff options
| author | Brian Anderson <banderson@mozilla.com> | 2014-06-19 18:22:33 -0700 |
|---|---|---|
| committer | Brian Anderson <banderson@mozilla.com> | 2014-07-01 19:12:29 -0700 |
| commit | d21336ee0a3982bdc35f17cdc32b41f6de5603d4 (patch) | |
| tree | 3f048e797533182728deab7c40618ce2635b9bdc /src/libsyntax | |
| parent | 44ec28cfac9fa3f738e0e77ccca1d804125fd1dd (diff) | |
| download | rust-d21336ee0a3982bdc35f17cdc32b41f6de5603d4.tar.gz rust-d21336ee0a3982bdc35f17cdc32b41f6de5603d4.zip | |
rustc: Remove `&str` indexing from the language.
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]
Diffstat (limited to 'src/libsyntax')
| -rw-r--r-- | src/libsyntax/diagnostic.rs | 2 | ||||
| -rw-r--r-- | src/libsyntax/parse/lexer/mod.rs | 4 |
2 files changed, 3 insertions, 3 deletions
diff --git a/src/libsyntax/diagnostic.rs b/src/libsyntax/diagnostic.rs index 90569bfc132..dfaa9fb5fcb 100644 --- a/src/libsyntax/diagnostic.rs +++ b/src/libsyntax/diagnostic.rs @@ -415,7 +415,7 @@ fn highlight_lines(err: &mut EmitterWriter, } let orig = fm.get_line(*lines.lines.get(0) as int); for pos in range(0u, left-skip) { - let cur_char = orig.as_slice()[pos] as char; + let cur_char = orig.as_bytes()[pos] as char; // Whenever a tab occurs on the previous line, we insert one on // the error-point-squiggly-line as well (instead of a space). // That way the squiggly line will usually appear in the correct 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; } |
