mirror of https://github.com/rust-lang/rust.git
Replace full slice notation with index calls
This commit is contained in:
parent
918255ef8c
commit
f7ff37e4c5
|
@ -676,7 +676,7 @@ fn run_debuginfo_lldb_test(config: &Config, props: &TestProps, testfile: &Path)
|
|||
.unwrap()
|
||||
.to_string();
|
||||
|
||||
script_str.push_str(format!("command script import {}\n", rust_pp_module_abs_path[])[]);
|
||||
script_str.push_str(format!("command script import {}\n", rust_pp_module_abs_path.index(&FullRange))[]);
|
||||
script_str.push_str("type summary add --no-value ");
|
||||
script_str.push_str("--python-function lldb_rust_formatters.print_val ");
|
||||
script_str.push_str("-x \".*\" --category Rust\n");
|
||||
|
@ -910,7 +910,7 @@ fn check_error_patterns(props: &TestProps,
|
|||
if done { return; }
|
||||
|
||||
let missing_patterns =
|
||||
props.error_patterns[next_err_idx..];
|
||||
props.error_patterns.index(&(next_err_idx..));
|
||||
if missing_patterns.len() == 1u {
|
||||
fatal_proc_rec(format!("error pattern '{}' not found!",
|
||||
missing_patterns[0]).as_slice(),
|
||||
|
|
|
@ -330,7 +330,7 @@ impl Bitv {
|
|||
|
||||
if extra_bytes > 0 {
|
||||
let mut last_word = 0u32;
|
||||
for (i, &byte) in bytes[complete_words*4..].iter().enumerate() {
|
||||
for (i, &byte) in bytes.index(&((complete_words*4)..)).iter().enumerate() {
|
||||
last_word |= (reverse_bits(byte) as u32) << (i * 8);
|
||||
}
|
||||
bitv.storage.push(last_word);
|
||||
|
|
|
@ -556,7 +556,7 @@ impl<T> RingBuf<T> {
|
|||
let buf = self.buffer_as_slice();
|
||||
if contiguous {
|
||||
let (empty, buf) = buf.split_at(0);
|
||||
(buf[self.tail..self.head], empty)
|
||||
(buf.index(&(self.tail..self.head)), empty)
|
||||
} else {
|
||||
let (mid, right) = buf.split_at(self.tail);
|
||||
let (left, _) = mid.split_at(self.head);
|
||||
|
|
|
@ -55,7 +55,7 @@
|
|||
//! #![feature(slicing_syntax)]
|
||||
//! fn main() {
|
||||
//! let numbers = [0i, 1i, 2i];
|
||||
//! let last_numbers = numbers[1..3];
|
||||
//! let last_numbers = numbers.index(&(1..3));
|
||||
//! // last_numbers is now &[1i, 2i]
|
||||
//! }
|
||||
//! ```
|
||||
|
@ -98,7 +98,7 @@ use core::iter::{range, range_step, MultiplicativeIterator};
|
|||
use core::kinds::Sized;
|
||||
use core::mem::size_of;
|
||||
use core::mem;
|
||||
use core::ops::{FnMut, SliceMut};
|
||||
use core::ops::{FnMut, FullRange, Index, IndexMut};
|
||||
use core::option::Option::{self, Some, None};
|
||||
use core::ptr::PtrExt;
|
||||
use core::ptr;
|
||||
|
@ -1065,12 +1065,12 @@ impl ElementSwaps {
|
|||
|
||||
#[unstable = "trait is unstable"]
|
||||
impl<T> BorrowFrom<Vec<T>> for [T] {
|
||||
fn borrow_from(owned: &Vec<T>) -> &[T] { owned[] }
|
||||
fn borrow_from(owned: &Vec<T>) -> &[T] { owned.index(&FullRange) }
|
||||
}
|
||||
|
||||
#[unstable = "trait is unstable"]
|
||||
impl<T> BorrowFromMut<Vec<T>> for [T] {
|
||||
fn borrow_from_mut(owned: &mut Vec<T>) -> &mut [T] { owned.as_mut_slice_() }
|
||||
fn borrow_from_mut(owned: &mut Vec<T>) -> &mut [T] { owned.index_mut(&FullRange) }
|
||||
}
|
||||
|
||||
#[unstable = "trait is unstable"]
|
||||
|
@ -1606,7 +1606,7 @@ mod tests {
|
|||
|
||||
// Test on stack.
|
||||
let vec_stack: &[_] = &[1i, 2, 3];
|
||||
let v_b = vec_stack[1u..3u].to_vec();
|
||||
let v_b = vec_stack.index(&(1u..3u)).to_vec();
|
||||
assert_eq!(v_b.len(), 2u);
|
||||
let v_b = v_b.as_slice();
|
||||
assert_eq!(v_b[0], 2);
|
||||
|
@ -1614,7 +1614,7 @@ mod tests {
|
|||
|
||||
// Test `Box<[T]>`
|
||||
let vec_unique = vec![1i, 2, 3, 4, 5, 6];
|
||||
let v_d = vec_unique[1u..6u].to_vec();
|
||||
let v_d = vec_unique.index(&(1u..6u)).to_vec();
|
||||
assert_eq!(v_d.len(), 5u);
|
||||
let v_d = v_d.as_slice();
|
||||
assert_eq!(v_d[0], 2);
|
||||
|
@ -1627,21 +1627,21 @@ mod tests {
|
|||
#[test]
|
||||
fn test_slice_from() {
|
||||
let vec: &[int] = &[1, 2, 3, 4];
|
||||
assert_eq!(vec[0..], vec);
|
||||
assert_eq!(vec.index(&(0..)), vec);
|
||||
let b: &[int] = &[3, 4];
|
||||
assert_eq!(vec[2..], b);
|
||||
assert_eq!(vec.index(&(2..)), b);
|
||||
let b: &[int] = &[];
|
||||
assert_eq!(vec[4..], b);
|
||||
assert_eq!(vec.index(&(4..)), b);
|
||||
}
|
||||
|
||||
#[test]
|
||||
fn test_slice_to() {
|
||||
let vec: &[int] = &[1, 2, 3, 4];
|
||||
assert_eq!(vec[..4], vec);
|
||||
assert_eq!(vec.index(&(0..4)), vec);
|
||||
let b: &[int] = &[1, 2];
|
||||
assert_eq!(vec[..2], b);
|
||||
assert_eq!(vec.index(&(0..2)), b);
|
||||
let b: &[int] = &[];
|
||||
assert_eq!(vec[..0], b);
|
||||
assert_eq!(vec.index(&(0..0)), b);
|
||||
}
|
||||
|
||||
|
||||
|
@ -2567,7 +2567,7 @@ mod tests {
|
|||
}
|
||||
assert_eq!(cnt, 3);
|
||||
|
||||
for f in v[1..3].iter() {
|
||||
for f in v.index(&(1..3)).iter() {
|
||||
assert!(*f == Foo);
|
||||
cnt += 1;
|
||||
}
|
||||
|
|
|
@ -60,7 +60,7 @@ use core::char::CharExt;
|
|||
use core::clone::Clone;
|
||||
use core::iter::AdditiveIterator;
|
||||
use core::iter::{range, Iterator, IteratorExt};
|
||||
use core::ops;
|
||||
use core::ops::{self, llRange, Index};
|
||||
use core::option::Option::{self, Some, None};
|
||||
use core::slice::AsSlice;
|
||||
use core::str as core_str;
|
||||
|
@ -386,7 +386,7 @@ macro_rules! utf8_acc_cont_byte {
|
|||
|
||||
#[unstable = "trait is unstable"]
|
||||
impl BorrowFrom<String> for str {
|
||||
fn borrow_from(owned: &String) -> &str { owned[] }
|
||||
fn borrow_from(owned: &String) -> &str { owned.index(&FullRange) }
|
||||
}
|
||||
|
||||
#[unstable = "trait is unstable"]
|
||||
|
@ -408,7 +408,7 @@ Section: Trait implementations
|
|||
|
||||
/// Any string that can be represented as a slice.
|
||||
#[stable]
|
||||
pub trait StrExt: ops::Slice<uint, str> {
|
||||
pub trait StrExt: Index<FullRange, str> {
|
||||
/// Escapes each char in `s` with `char::escape_default`.
|
||||
#[unstable = "return type may change to be an iterator"]
|
||||
fn escape_default(&self) -> String {
|
||||
|
@ -464,7 +464,7 @@ pub trait StrExt: ops::Slice<uint, str> {
|
|||
#[unstable = "this functionality may be moved to libunicode"]
|
||||
fn nfd_chars<'a>(&'a self) -> Decompositions<'a> {
|
||||
Decompositions {
|
||||
iter: self[].chars(),
|
||||
iter: self.index(&FullRange).chars(),
|
||||
buffer: Vec::new(),
|
||||
sorted: false,
|
||||
kind: Canonical
|
||||
|
@ -477,7 +477,7 @@ pub trait StrExt: ops::Slice<uint, str> {
|
|||
#[unstable = "this functionality may be moved to libunicode"]
|
||||
fn nfkd_chars<'a>(&'a self) -> Decompositions<'a> {
|
||||
Decompositions {
|
||||
iter: self[].chars(),
|
||||
iter: self.index(&FullRange).chars(),
|
||||
buffer: Vec::new(),
|
||||
sorted: false,
|
||||
kind: Compatible
|
||||
|
@ -525,7 +525,7 @@ pub trait StrExt: ops::Slice<uint, str> {
|
|||
/// ```
|
||||
#[stable]
|
||||
fn contains(&self, pat: &str) -> bool {
|
||||
core_str::StrExt::contains(self[], pat)
|
||||
core_str::StrExt::contains(self.index(&FullRange), pat)
|
||||
}
|
||||
|
||||
/// Returns true if a string contains a char pattern.
|
||||
|
@ -541,7 +541,7 @@ pub trait StrExt: ops::Slice<uint, str> {
|
|||
/// ```
|
||||
#[unstable = "might get removed in favour of a more generic contains()"]
|
||||
fn contains_char<P: CharEq>(&self, pat: P) -> bool {
|
||||
core_str::StrExt::contains_char(self[], pat)
|
||||
core_str::StrExt::contains_char(self.index(&FullRange), pat)
|
||||
}
|
||||
|
||||
/// An iterator over the characters of `self`. Note, this iterates
|
||||
|
@ -555,7 +555,7 @@ pub trait StrExt: ops::Slice<uint, str> {
|
|||
/// ```
|
||||
#[stable]
|
||||
fn chars(&self) -> Chars {
|
||||
core_str::StrExt::chars(self[])
|
||||
core_str::StrExt::chars(self.index(&FullRange))
|
||||
}
|
||||
|
||||
/// An iterator over the bytes of `self`
|
||||
|
@ -568,13 +568,13 @@ pub trait StrExt: ops::Slice<uint, str> {
|
|||
/// ```
|
||||
#[stable]
|
||||
fn bytes(&self) -> Bytes {
|
||||
core_str::StrExt::bytes(self[])
|
||||
core_str::StrExt::bytes(self.index(&FullRange))
|
||||
}
|
||||
|
||||
/// An iterator over the characters of `self` and their byte offsets.
|
||||
#[stable]
|
||||
fn char_indices(&self) -> CharIndices {
|
||||
core_str::StrExt::char_indices(self[])
|
||||
core_str::StrExt::char_indices(self.index(&FullRange))
|
||||
}
|
||||
|
||||
/// An iterator over substrings of `self`, separated by characters
|
||||
|
@ -597,7 +597,7 @@ pub trait StrExt: ops::Slice<uint, str> {
|
|||
/// ```
|
||||
#[stable]
|
||||
fn split<P: CharEq>(&self, pat: P) -> Split<P> {
|
||||
core_str::StrExt::split(self[], pat)
|
||||
core_str::StrExt::split(self.index(&FullRange), pat)
|
||||
}
|
||||
|
||||
/// An iterator over substrings of `self`, separated by characters
|
||||
|
@ -624,7 +624,7 @@ pub trait StrExt: ops::Slice<uint, str> {
|
|||
/// ```
|
||||
#[stable]
|
||||
fn splitn<P: CharEq>(&self, count: uint, pat: P) -> SplitN<P> {
|
||||
core_str::StrExt::splitn(self[], count, pat)
|
||||
core_str::StrExt::splitn(self.index(&FullRange), count, pat)
|
||||
}
|
||||
|
||||
/// An iterator over substrings of `self`, separated by characters
|
||||
|
@ -653,7 +653,7 @@ pub trait StrExt: ops::Slice<uint, str> {
|
|||
/// ```
|
||||
#[unstable = "might get removed"]
|
||||
fn split_terminator<P: CharEq>(&self, pat: P) -> SplitTerminator<P> {
|
||||
core_str::StrExt::split_terminator(self[], pat)
|
||||
core_str::StrExt::split_terminator(self.index(&FullRange), pat)
|
||||
}
|
||||
|
||||
/// An iterator over substrings of `self`, separated by characters
|
||||
|
@ -674,7 +674,7 @@ pub trait StrExt: ops::Slice<uint, str> {
|
|||
/// ```
|
||||
#[stable]
|
||||
fn rsplitn<P: CharEq>(&self, count: uint, pat: P) -> RSplitN<P> {
|
||||
core_str::StrExt::rsplitn(self[], count, pat)
|
||||
core_str::StrExt::rsplitn(self.index(&FullRange), count, pat)
|
||||
}
|
||||
|
||||
/// An iterator over the start and end indices of the disjoint
|
||||
|
@ -699,7 +699,7 @@ pub trait StrExt: ops::Slice<uint, str> {
|
|||
/// ```
|
||||
#[unstable = "might have its iterator type changed"]
|
||||
fn match_indices<'a>(&'a self, pat: &'a str) -> MatchIndices<'a> {
|
||||
core_str::StrExt::match_indices(self[], pat)
|
||||
core_str::StrExt::match_indices(self.index(&FullRange), pat)
|
||||
}
|
||||
|
||||
/// An iterator over the substrings of `self` separated by the pattern `sep`.
|
||||
|
@ -715,7 +715,7 @@ pub trait StrExt: ops::Slice<uint, str> {
|
|||
/// ```
|
||||
#[unstable = "might get removed in the future in favor of a more generic split()"]
|
||||
fn split_str<'a>(&'a self, pat: &'a str) -> SplitStr<'a> {
|
||||
core_str::StrExt::split_str(self[], pat)
|
||||
core_str::StrExt::split_str(self.index(&FullRange), pat)
|
||||
}
|
||||
|
||||
/// An iterator over the lines of a string (subsequences separated
|
||||
|
@ -731,7 +731,7 @@ pub trait StrExt: ops::Slice<uint, str> {
|
|||
/// ```
|
||||
#[stable]
|
||||
fn lines(&self) -> Lines {
|
||||
core_str::StrExt::lines(self[])
|
||||
core_str::StrExt::lines(self.index(&FullRange))
|
||||
}
|
||||
|
||||
/// An iterator over the lines of a string, separated by either
|
||||
|
@ -747,7 +747,7 @@ pub trait StrExt: ops::Slice<uint, str> {
|
|||
/// ```
|
||||
#[stable]
|
||||
fn lines_any(&self) -> LinesAny {
|
||||
core_str::StrExt::lines_any(self[])
|
||||
core_str::StrExt::lines_any(self.index(&FullRange))
|
||||
}
|
||||
|
||||
/// Returns a slice of the given string from the byte range
|
||||
|
@ -782,7 +782,7 @@ pub trait StrExt: ops::Slice<uint, str> {
|
|||
/// ```
|
||||
#[unstable = "use slice notation [a..b] instead"]
|
||||
fn slice(&self, begin: uint, end: uint) -> &str {
|
||||
core_str::StrExt::slice(self[], begin, end)
|
||||
core_str::StrExt::slice(self.index(&FullRange), begin, end)
|
||||
}
|
||||
|
||||
/// Returns a slice of the string from `begin` to its end.
|
||||
|
@ -795,7 +795,7 @@ pub trait StrExt: ops::Slice<uint, str> {
|
|||
/// See also `slice`, `slice_to` and `slice_chars`.
|
||||
#[unstable = "use slice notation [a..] instead"]
|
||||
fn slice_from(&self, begin: uint) -> &str {
|
||||
core_str::StrExt::slice_from(self[], begin)
|
||||
core_str::StrExt::slice_from(self.index(&FullRange), begin)
|
||||
}
|
||||
|
||||
/// Returns a slice of the string from the beginning to byte
|
||||
|
@ -809,7 +809,7 @@ pub trait StrExt: ops::Slice<uint, str> {
|
|||
/// See also `slice`, `slice_from` and `slice_chars`.
|
||||
#[unstable = "use slice notation [0..a] instead"]
|
||||
fn slice_to(&self, end: uint) -> &str {
|
||||
core_str::StrExt::slice_to(self[], end)
|
||||
core_str::StrExt::slice_to(self.index(&FullRange), end)
|
||||
}
|
||||
|
||||
/// Returns a slice of the string from the character range
|
||||
|
@ -837,7 +837,7 @@ pub trait StrExt: ops::Slice<uint, str> {
|
|||
/// ```
|
||||
#[unstable = "may have yet to prove its worth"]
|
||||
fn slice_chars(&self, begin: uint, end: uint) -> &str {
|
||||
core_str::StrExt::slice_chars(self[], begin, end)
|
||||
core_str::StrExt::slice_chars(self.index(&FullRange), begin, end)
|
||||
}
|
||||
|
||||
/// Takes a bytewise (not UTF-8) slice from a string.
|
||||
|
@ -848,7 +848,7 @@ pub trait StrExt: ops::Slice<uint, str> {
|
|||
/// the entire slice as well.
|
||||
#[stable]
|
||||
unsafe fn slice_unchecked(&self, begin: uint, end: uint) -> &str {
|
||||
core_str::StrExt::slice_unchecked(self[], begin, end)
|
||||
core_str::StrExt::slice_unchecked(self.index(&FullRange), begin, end)
|
||||
}
|
||||
|
||||
/// Returns true if the pattern `pat` is a prefix of the string.
|
||||
|
@ -860,7 +860,7 @@ pub trait StrExt: ops::Slice<uint, str> {
|
|||
/// ```
|
||||
#[stable]
|
||||
fn starts_with(&self, pat: &str) -> bool {
|
||||
core_str::StrExt::starts_with(self[], pat)
|
||||
core_str::StrExt::starts_with(self.index(&FullRange), pat)
|
||||
}
|
||||
|
||||
/// Returns true if the pattern `pat` is a suffix of the string.
|
||||
|
@ -872,7 +872,7 @@ pub trait StrExt: ops::Slice<uint, str> {
|
|||
/// ```
|
||||
#[stable]
|
||||
fn ends_with(&self, pat: &str) -> bool {
|
||||
core_str::StrExt::ends_with(self[], pat)
|
||||
core_str::StrExt::ends_with(self.index(&FullRange), pat)
|
||||
}
|
||||
|
||||
/// Returns a string with all pre- and suffixes that match
|
||||
|
@ -892,7 +892,7 @@ pub trait StrExt: ops::Slice<uint, str> {
|
|||
/// ```
|
||||
#[stable]
|
||||
fn trim_matches<P: CharEq>(&self, pat: P) -> &str {
|
||||
core_str::StrExt::trim_matches(self[], pat)
|
||||
core_str::StrExt::trim_matches(self.index(&FullRange), pat)
|
||||
}
|
||||
|
||||
/// Returns a string with all prefixes that match
|
||||
|
@ -912,7 +912,7 @@ pub trait StrExt: ops::Slice<uint, str> {
|
|||
/// ```
|
||||
#[stable]
|
||||
fn trim_left_matches<P: CharEq>(&self, pat: P) -> &str {
|
||||
core_str::StrExt::trim_left_matches(self[], pat)
|
||||
core_str::StrExt::trim_left_matches(self.index(&FullRange), pat)
|
||||
}
|
||||
|
||||
/// Returns a string with all suffixes that match
|
||||
|
@ -932,7 +932,7 @@ pub trait StrExt: ops::Slice<uint, str> {
|
|||
/// ```
|
||||
#[stable]
|
||||
fn trim_right_matches<P: CharEq>(&self, pat: P) -> &str {
|
||||
core_str::StrExt::trim_right_matches(self[], pat)
|
||||
core_str::StrExt::trim_right_matches(self.index(&FullRange), pat)
|
||||
}
|
||||
|
||||
/// Check that `index`-th byte lies at the start and/or end of a
|
||||
|
@ -960,7 +960,7 @@ pub trait StrExt: ops::Slice<uint, str> {
|
|||
/// ```
|
||||
#[unstable = "naming is uncertain with container conventions"]
|
||||
fn is_char_boundary(&self, index: uint) -> bool {
|
||||
core_str::StrExt::is_char_boundary(self[], index)
|
||||
core_str::StrExt::is_char_boundary(self.index(&FullRange), index)
|
||||
}
|
||||
|
||||
/// Pluck a character out of a string and return the index of the next
|
||||
|
@ -1018,7 +1018,7 @@ pub trait StrExt: ops::Slice<uint, str> {
|
|||
/// If `i` is not the index of the beginning of a valid UTF-8 character.
|
||||
#[unstable = "naming is uncertain with container conventions"]
|
||||
fn char_range_at(&self, start: uint) -> CharRange {
|
||||
core_str::StrExt::char_range_at(self[], start)
|
||||
core_str::StrExt::char_range_at(self.index(&FullRange), start)
|
||||
}
|
||||
|
||||
/// Given a byte position and a str, return the previous char and its position.
|
||||
|
@ -1033,7 +1033,7 @@ pub trait StrExt: ops::Slice<uint, str> {
|
|||
/// If `i` is not an index following a valid UTF-8 character.
|
||||
#[unstable = "naming is uncertain with container conventions"]
|
||||
fn char_range_at_reverse(&self, start: uint) -> CharRange {
|
||||
core_str::StrExt::char_range_at_reverse(self[], start)
|
||||
core_str::StrExt::char_range_at_reverse(self.index(&FullRange), start)
|
||||
}
|
||||
|
||||
/// Plucks the character starting at the `i`th byte of a string.
|
||||
|
@ -1053,7 +1053,7 @@ pub trait StrExt: ops::Slice<uint, str> {
|
|||
/// If `i` is not the index of the beginning of a valid UTF-8 character.
|
||||
#[unstable = "naming is uncertain with container conventions"]
|
||||
fn char_at(&self, i: uint) -> char {
|
||||
core_str::StrExt::char_at(self[], i)
|
||||
core_str::StrExt::char_at(self.index(&FullRange), i)
|
||||
}
|
||||
|
||||
/// Plucks the character ending at the `i`th byte of a string.
|
||||
|
@ -1064,7 +1064,7 @@ pub trait StrExt: ops::Slice<uint, str> {
|
|||
/// If `i` is not an index following a valid UTF-8 character.
|
||||
#[unstable = "naming is uncertain with container conventions"]
|
||||
fn char_at_reverse(&self, i: uint) -> char {
|
||||
core_str::StrExt::char_at_reverse(self[], i)
|
||||
core_str::StrExt::char_at_reverse(self.index(&FullRange), i)
|
||||
}
|
||||
|
||||
/// Work with the byte buffer of a string as a byte slice.
|
||||
|
@ -1076,7 +1076,7 @@ pub trait StrExt: ops::Slice<uint, str> {
|
|||
/// ```
|
||||
#[stable]
|
||||
fn as_bytes(&self) -> &[u8] {
|
||||
core_str::StrExt::as_bytes(self[])
|
||||
core_str::StrExt::as_bytes(self.index(&FullRange))
|
||||
}
|
||||
|
||||
/// Returns the byte index of the first character of `self` that
|
||||
|
@ -1104,7 +1104,7 @@ pub trait StrExt: ops::Slice<uint, str> {
|
|||
/// ```
|
||||
#[stable]
|
||||
fn find<P: CharEq>(&self, pat: P) -> Option<uint> {
|
||||
core_str::StrExt::find(self[], pat)
|
||||
core_str::StrExt::find(self.index(&FullRange), pat)
|
||||
}
|
||||
|
||||
/// Returns the byte index of the last character of `self` that
|
||||
|
@ -1132,7 +1132,7 @@ pub trait StrExt: ops::Slice<uint, str> {
|
|||
/// ```
|
||||
#[stable]
|
||||
fn rfind<P: CharEq>(&self, pat: P) -> Option<uint> {
|
||||
core_str::StrExt::rfind(self[], pat)
|
||||
core_str::StrExt::rfind(self.index(&FullRange), pat)
|
||||
}
|
||||
|
||||
/// Returns the byte index of the first matching substring
|
||||
|
@ -1156,7 +1156,7 @@ pub trait StrExt: ops::Slice<uint, str> {
|
|||
/// ```
|
||||
#[unstable = "might get removed in favor of a more generic find in the future"]
|
||||
fn find_str(&self, needle: &str) -> Option<uint> {
|
||||
core_str::StrExt::find_str(self[], needle)
|
||||
core_str::StrExt::find_str(self.index(&FullRange), needle)
|
||||
}
|
||||
|
||||
/// Retrieves the first character from a string slice and returns
|
||||
|
@ -1179,7 +1179,7 @@ pub trait StrExt: ops::Slice<uint, str> {
|
|||
/// ```
|
||||
#[unstable = "awaiting conventions about shifting and slices"]
|
||||
fn slice_shift_char(&self) -> Option<(char, &str)> {
|
||||
core_str::StrExt::slice_shift_char(self[])
|
||||
core_str::StrExt::slice_shift_char(self.index(&FullRange))
|
||||
}
|
||||
|
||||
/// Returns the byte offset of an inner slice relative to an enclosing outer slice.
|
||||
|
@ -1198,7 +1198,7 @@ pub trait StrExt: ops::Slice<uint, str> {
|
|||
/// ```
|
||||
#[unstable = "awaiting convention about comparability of arbitrary slices"]
|
||||
fn subslice_offset(&self, inner: &str) -> uint {
|
||||
core_str::StrExt::subslice_offset(self[], inner)
|
||||
core_str::StrExt::subslice_offset(self.index(&FullRange), inner)
|
||||
}
|
||||
|
||||
/// Return an unsafe pointer to the strings buffer.
|
||||
|
@ -1209,13 +1209,13 @@ pub trait StrExt: ops::Slice<uint, str> {
|
|||
#[stable]
|
||||
#[inline]
|
||||
fn as_ptr(&self) -> *const u8 {
|
||||
core_str::StrExt::as_ptr(self[])
|
||||
core_str::StrExt::as_ptr(self.index(&FullRange))
|
||||
}
|
||||
|
||||
/// Return an iterator of `u16` over the string encoded as UTF-16.
|
||||
#[unstable = "this functionality may only be provided by libunicode"]
|
||||
fn utf16_units(&self) -> Utf16Units {
|
||||
Utf16Units { encoder: Utf16Encoder::new(self[].chars()) }
|
||||
Utf16Units { encoder: Utf16Encoder::new(self.index(&FullRange).chars()) }
|
||||
}
|
||||
|
||||
/// Return the number of bytes in this string
|
||||
|
@ -1229,7 +1229,7 @@ pub trait StrExt: ops::Slice<uint, str> {
|
|||
#[stable]
|
||||
#[inline]
|
||||
fn len(&self) -> uint {
|
||||
core_str::StrExt::len(self[])
|
||||
core_str::StrExt::len(self.index(&FullRange))
|
||||
}
|
||||
|
||||
/// Returns true if this slice contains no bytes
|
||||
|
@ -1242,7 +1242,7 @@ pub trait StrExt: ops::Slice<uint, str> {
|
|||
#[inline]
|
||||
#[stable]
|
||||
fn is_empty(&self) -> bool {
|
||||
core_str::StrExt::is_empty(self[])
|
||||
core_str::StrExt::is_empty(self.index(&FullRange))
|
||||
}
|
||||
|
||||
/// Parse this string into the specified type.
|
||||
|
@ -1256,7 +1256,7 @@ pub trait StrExt: ops::Slice<uint, str> {
|
|||
#[inline]
|
||||
#[unstable = "this method was just created"]
|
||||
fn parse<F: FromStr>(&self) -> Option<F> {
|
||||
core_str::StrExt::parse(self[])
|
||||
core_str::StrExt::parse(self.index(&FullRange))
|
||||
}
|
||||
|
||||
/// Returns an iterator over the
|
||||
|
@ -1280,7 +1280,7 @@ pub trait StrExt: ops::Slice<uint, str> {
|
|||
/// ```
|
||||
#[unstable = "this functionality may only be provided by libunicode"]
|
||||
fn graphemes(&self, is_extended: bool) -> Graphemes {
|
||||
UnicodeStr::graphemes(self[], is_extended)
|
||||
UnicodeStr::graphemes(self.index(&FullRange), is_extended)
|
||||
}
|
||||
|
||||
/// Returns an iterator over the grapheme clusters of self and their byte offsets.
|
||||
|
@ -1295,7 +1295,7 @@ pub trait StrExt: ops::Slice<uint, str> {
|
|||
/// ```
|
||||
#[unstable = "this functionality may only be provided by libunicode"]
|
||||
fn grapheme_indices(&self, is_extended: bool) -> GraphemeIndices {
|
||||
UnicodeStr::grapheme_indices(self[], is_extended)
|
||||
UnicodeStr::grapheme_indices(self.index(&FullRange), is_extended)
|
||||
}
|
||||
|
||||
/// An iterator over the words of a string (subsequences separated
|
||||
|
@ -1311,7 +1311,7 @@ pub trait StrExt: ops::Slice<uint, str> {
|
|||
/// ```
|
||||
#[stable]
|
||||
fn words(&self) -> Words {
|
||||
UnicodeStr::words(self[])
|
||||
UnicodeStr::words(self.index(&FullRange))
|
||||
}
|
||||
|
||||
/// Returns a string's displayed width in columns, treating control
|
||||
|
@ -1325,25 +1325,25 @@ pub trait StrExt: ops::Slice<uint, str> {
|
|||
/// `is_cjk` = `false`) if the locale is unknown.
|
||||
#[unstable = "this functionality may only be provided by libunicode"]
|
||||
fn width(&self, is_cjk: bool) -> uint {
|
||||
UnicodeStr::width(self[], is_cjk)
|
||||
UnicodeStr::width(self.index(&FullRange), is_cjk)
|
||||
}
|
||||
|
||||
/// Returns a string with leading and trailing whitespace removed.
|
||||
#[stable]
|
||||
fn trim(&self) -> &str {
|
||||
UnicodeStr::trim(self[])
|
||||
UnicodeStr::trim(self.index(&FullRange))
|
||||
}
|
||||
|
||||
/// Returns a string with leading whitespace removed.
|
||||
#[stable]
|
||||
fn trim_left(&self) -> &str {
|
||||
UnicodeStr::trim_left(self[])
|
||||
UnicodeStr::trim_left(self.index(&FullRange))
|
||||
}
|
||||
|
||||
/// Returns a string with trailing whitespace removed.
|
||||
#[stable]
|
||||
fn trim_right(&self) -> &str {
|
||||
UnicodeStr::trim_right(self[])
|
||||
UnicodeStr::trim_right(self.index(&FullRange))
|
||||
}
|
||||
}
|
||||
|
||||
|
@ -2133,7 +2133,7 @@ mod tests {
|
|||
let mut bytes = [0u8; 4];
|
||||
for c in range(0u32, 0x110000).filter_map(|c| ::core::char::from_u32(c)) {
|
||||
let len = c.encode_utf8(&mut bytes).unwrap_or(0);
|
||||
let s = ::core::str::from_utf8(bytes[..len]).unwrap();
|
||||
let s = ::core::str::from_utf8(bytes.index(&(0..len))).unwrap();
|
||||
if Some(c) != s.chars().next() {
|
||||
panic!("character {:x}={} does not decode correctly", c as u32, c);
|
||||
}
|
||||
|
@ -2145,7 +2145,7 @@ mod tests {
|
|||
let mut bytes = [0u8; 4];
|
||||
for c in range(0u32, 0x110000).filter_map(|c| ::core::char::from_u32(c)) {
|
||||
let len = c.encode_utf8(&mut bytes).unwrap_or(0);
|
||||
let s = ::core::str::from_utf8(bytes[..len]).unwrap();
|
||||
let s = ::core::str::from_utf8(bytes.index(&(0..len))).unwrap();
|
||||
if Some(c) != s.chars().rev().next() {
|
||||
panic!("character {:x}={} does not decode correctly", c as u32, c);
|
||||
}
|
||||
|
|
|
@ -168,7 +168,7 @@ impl String {
|
|||
|
||||
if i > 0 {
|
||||
unsafe {
|
||||
res.as_mut_vec().push_all(v[..i])
|
||||
res.as_mut_vec().push_all(v.index(&(0..i)))
|
||||
};
|
||||
}
|
||||
|
||||
|
@ -185,7 +185,7 @@ impl String {
|
|||
macro_rules! error { () => ({
|
||||
unsafe {
|
||||
if subseqidx != i_ {
|
||||
res.as_mut_vec().push_all(v[subseqidx..i_]);
|
||||
res.as_mut_vec().push_all(v.index(&(subseqidx..i_)));
|
||||
}
|
||||
subseqidx = i;
|
||||
res.as_mut_vec().push_all(REPLACEMENT);
|
||||
|
@ -254,7 +254,7 @@ impl String {
|
|||
}
|
||||
if subseqidx < total {
|
||||
unsafe {
|
||||
res.as_mut_vec().push_all(v[subseqidx..total])
|
||||
res.as_mut_vec().push_all(v.index(&(subseqidx..total)))
|
||||
};
|
||||
}
|
||||
Cow::Owned(res)
|
||||
|
@ -818,30 +818,30 @@ impl<'a> Add<&'a str> for String {
|
|||
}
|
||||
}
|
||||
|
||||
impl<T> ops::Index<ops::Range<uint>, str> for String {
|
||||
impl ops::Index<ops::Range<uint>, str> for String {
|
||||
#[inline]
|
||||
fn index(&self, &index: &ops::Range<uint>) -> &str {
|
||||
self[][*index]
|
||||
fn index(&self, index: &ops::Range<uint>) -> &str {
|
||||
&self.index(&FullRange)[*index]
|
||||
}
|
||||
}
|
||||
|
||||
impl<T> ops::Index<ops::RangeTo<uint>, str> for String {
|
||||
impl ops::Index<ops::RangeTo<uint>, str> for String {
|
||||
#[inline]
|
||||
fn index(&self, &index: &ops::RangeTo<uint>) -> &str {
|
||||
self[][*index]
|
||||
fn index(&self, index: &ops::RangeTo<uint>) -> &str {
|
||||
&self.index(&FullRange)[*index]
|
||||
}
|
||||
}
|
||||
|
||||
impl<T> ops::Index<ops::RangeFrom<uint>, str> for String {
|
||||
impl ops::Index<ops::RangeFrom<uint>, str> for String {
|
||||
#[inline]
|
||||
fn index(&self, &index: &ops::RangeFrom<uint>) -> &str {
|
||||
self[][*index]
|
||||
fn index(&self, index: &ops::RangeFrom<uint>) -> &str {
|
||||
&self.index(&FullRange)[*index]
|
||||
}
|
||||
}
|
||||
|
||||
impl<T> ops::Index<ops::FullRange<uint>, str> for String {
|
||||
impl ops::Index<ops::FullRange, str> for String {
|
||||
#[inline]
|
||||
fn index(&self, &index: &ops::FullRange<uint>) -> &str {
|
||||
fn index(&self, _index: &ops::FullRange) -> &str {
|
||||
unsafe { mem::transmute(self.vec.as_slice()) }
|
||||
}
|
||||
}
|
||||
|
@ -851,7 +851,7 @@ impl ops::Deref for String {
|
|||
type Target = str;
|
||||
|
||||
fn deref<'a>(&'a self) -> &'a str {
|
||||
unsafe { mem::transmute(self.vec[]) }
|
||||
unsafe { mem::transmute(self.vec.index(&FullRange)) }
|
||||
}
|
||||
}
|
||||
|
||||
|
@ -1230,10 +1230,10 @@ mod tests {
|
|||
#[test]
|
||||
fn test_slicing() {
|
||||
let s = "foobar".to_string();
|
||||
assert_eq!("foobar", s[]);
|
||||
assert_eq!("foo", s[..3]);
|
||||
assert_eq!("bar", s[3..]);
|
||||
assert_eq!("oob", s[1..4]);
|
||||
assert_eq!("foobar", s.index(&FullRange));
|
||||
assert_eq!("foo", s.index(&(0..3)));
|
||||
assert_eq!("bar", s.index(&(3..)));
|
||||
assert_eq!("oob", s.index(&(1..4)));
|
||||
}
|
||||
|
||||
#[test]
|
||||
|
|
|
@ -1178,7 +1178,7 @@ impl<T:Clone> Clone for Vec<T> {
|
|||
|
||||
// self.len <= other.len due to the truncate above, so the
|
||||
// slice here is always in-bounds.
|
||||
let slice = other[self.len()..];
|
||||
let slice = other.index(&(self.len()..));
|
||||
self.push_all(slice);
|
||||
}
|
||||
}
|
||||
|
@ -1209,65 +1209,58 @@ impl<T> IndexMut<uint> for Vec<T> {
|
|||
}
|
||||
}
|
||||
|
||||
impl<T> ops::Slice<uint, [T]> for Vec<T> {
|
||||
#[inline]
|
||||
fn index_mut<'a>(&'a mut self, index: &uint) -> &'a mut T {
|
||||
&mut self.as_mut_slice()[*index]
|
||||
}
|
||||
}
|
||||
|
||||
impl<T> ops::Index<ops::Range<uint>, [T]> for Vec<T> {
|
||||
#[inline]
|
||||
fn index(&self, &index: &ops::Range<uint>) -> &[T] {
|
||||
fn index(&self, index: &ops::Range<uint>) -> &[T] {
|
||||
self.as_slice().index(index)
|
||||
}
|
||||
}
|
||||
|
||||
impl<T> ops::Index<ops::RangeTo<uint>, [T]> for Vec<T> {
|
||||
#[inline]
|
||||
fn index(&self, &index: &ops::RangeTo<uint>) -> &[T] {
|
||||
fn index(&self, index: &ops::RangeTo<uint>) -> &[T] {
|
||||
self.as_slice().index(index)
|
||||
}
|
||||
}
|
||||
|
||||
impl<T> ops::Index<ops::RangeFrom<uint>, [T]> for Vec<T> {
|
||||
#[inline]
|
||||
fn index(&self, &index: &ops::RangeFrom<uint>) -> &[T] {
|
||||
fn index(&self, index: &ops::RangeFrom<uint>) -> &[T] {
|
||||
self.as_slice().index(index)
|
||||
}
|
||||
}
|
||||
|
||||
impl<T> ops::Index<ops::FullRange<uint>, [T]> for Vec<T> {
|
||||
impl<T> ops::Index<ops::FullRange, [T]> for Vec<T> {
|
||||
#[inline]
|
||||
fn index(&self, &index: &ops::FullRange<uint>) -> &[T] {
|
||||
fn index(&self, _index: &ops::FullRange) -> &[T] {
|
||||
self.as_slice()
|
||||
}
|
||||
}
|
||||
|
||||
impl<T> ops::IndexMut<ops::Range<uint>, [T]> for Vec<T> {
|
||||
#[inline]
|
||||
fn index_mut(&mut self, &index: &ops::Range<uint>) -> &mut [T] {
|
||||
fn index_mut(&mut self, index: &ops::Range<uint>) -> &mut [T] {
|
||||
self.as_mut_slice().index_mut(index)
|
||||
}
|
||||
}
|
||||
|
||||
impl<T> ops::IndexMut<ops::RangeTo<uint>, [T]> for Vec<T> {
|
||||
#[inline]
|
||||
fn index_mut(&mut self, &index: &ops::RangeTo<uint>) -> &mut [T] {
|
||||
fn index_mut(&mut self, index: &ops::RangeTo<uint>) -> &mut [T] {
|
||||
self.as_mut_slice().index_mut(index)
|
||||
}
|
||||
}
|
||||
|
||||
impl<T> ops::IndexMut<ops::RangeFrom<uint>, [T]> for Vec<T> {
|
||||
#[inline]
|
||||
fn index_mut(&mut self, &index: &ops::RangeFrom<uint>) -> &mut [T] {
|
||||
fn index_mut(&mut self, index: &ops::RangeFrom<uint>) -> &mut [T] {
|
||||
self.as_mut_slice().index_mut(index)
|
||||
}
|
||||
}
|
||||
|
||||
impl<T> ops::IndexMut<ops::FullRange<uint>, [T]> for Vec<T> {
|
||||
impl<T> ops::IndexMut<ops::FullRange, [T]> for Vec<T> {
|
||||
#[inline]
|
||||
fn index_mut(&mut self, &index: &ops::FullRange<uint>) -> &mut [T] {
|
||||
fn index_mut(&mut self, _index: &ops::FullRange) -> &mut [T] {
|
||||
self.as_mut_slice()
|
||||
}
|
||||
}
|
||||
|
@ -2125,7 +2118,7 @@ mod tests {
|
|||
#[should_fail]
|
||||
fn test_slice_out_of_bounds_2() {
|
||||
let x: Vec<int> = vec![1, 2, 3, 4, 5];
|
||||
x[..6];
|
||||
x.index(&(0..6));
|
||||
}
|
||||
|
||||
#[test]
|
||||
|
@ -2139,14 +2132,14 @@ mod tests {
|
|||
#[should_fail]
|
||||
fn test_slice_out_of_bounds_4() {
|
||||
let x: Vec<int> = vec![1, 2, 3, 4, 5];
|
||||
x[1..6];
|
||||
x.index(&(1..6));
|
||||
}
|
||||
|
||||
#[test]
|
||||
#[should_fail]
|
||||
fn test_slice_out_of_bounds_5() {
|
||||
let x: Vec<int> = vec![1, 2, 3, 4, 5];
|
||||
x[3..2];
|
||||
x.index(&(3..2));
|
||||
}
|
||||
|
||||
#[test]
|
||||
|
|
|
@ -455,7 +455,8 @@ impl<V> VecMap<V> {
|
|||
if *key >= self.v.len() {
|
||||
return None;
|
||||
}
|
||||
self.v[*key].take()
|
||||
let result = &mut self.v[*key];
|
||||
result.take()
|
||||
}
|
||||
}
|
||||
|
||||
|
|
|
@ -18,7 +18,7 @@ use clone::Clone;
|
|||
use cmp::{PartialEq, Eq, PartialOrd, Ord, Ordering};
|
||||
use fmt;
|
||||
use kinds::Copy;
|
||||
use ops::Deref;
|
||||
use ops::{Deref, FullRange, Index};
|
||||
use option::Option;
|
||||
|
||||
// macro for implementing n-ary tuple functions and operations
|
||||
|
@ -35,7 +35,7 @@ macro_rules! array_impls {
|
|||
#[unstable = "waiting for Show to stabilize"]
|
||||
impl<T:fmt::Show> fmt::Show for [T; $N] {
|
||||
fn fmt(&self, f: &mut fmt::Formatter) -> fmt::Result {
|
||||
fmt::Show::fmt(&self[], f)
|
||||
fmt::Show::fmt(&self.index(&FullRange), f)
|
||||
}
|
||||
}
|
||||
|
||||
|
@ -43,11 +43,11 @@ macro_rules! array_impls {
|
|||
impl<A, B> PartialEq<[B; $N]> for [A; $N] where A: PartialEq<B> {
|
||||
#[inline]
|
||||
fn eq(&self, other: &[B; $N]) -> bool {
|
||||
self[] == other[]
|
||||
self.index(&FullRange) == other.index(&FullRange)
|
||||
}
|
||||
#[inline]
|
||||
fn ne(&self, other: &[B; $N]) -> bool {
|
||||
self[] != other[]
|
||||
self.index(&FullRange) != other.index(&FullRange)
|
||||
}
|
||||
}
|
||||
|
||||
|
@ -57,9 +57,9 @@ macro_rules! array_impls {
|
|||
Rhs: Deref<Target=[B]>,
|
||||
{
|
||||
#[inline(always)]
|
||||
fn eq(&self, other: &Rhs) -> bool { PartialEq::eq(self[], &**other) }
|
||||
fn eq(&self, other: &Rhs) -> bool { PartialEq::eq(self.index(&FullRange), &**other) }
|
||||
#[inline(always)]
|
||||
fn ne(&self, other: &Rhs) -> bool { PartialEq::ne(self[], &**other) }
|
||||
fn ne(&self, other: &Rhs) -> bool { PartialEq::ne(self.index(&FullRange), &**other) }
|
||||
}
|
||||
|
||||
#[stable]
|
||||
|
@ -68,9 +68,9 @@ macro_rules! array_impls {
|
|||
Lhs: Deref<Target=[A]>
|
||||
{
|
||||
#[inline(always)]
|
||||
fn eq(&self, other: &[B; $N]) -> bool { PartialEq::eq(&**self, other[]) }
|
||||
fn eq(&self, other: &[B; $N]) -> bool { PartialEq::eq(&**self, other.index(&FullRange)) }
|
||||
#[inline(always)]
|
||||
fn ne(&self, other: &[B; $N]) -> bool { PartialEq::ne(&**self, other[]) }
|
||||
fn ne(&self, other: &[B; $N]) -> bool { PartialEq::ne(&**self, other.index(&FullRange)) }
|
||||
}
|
||||
|
||||
#[stable]
|
||||
|
@ -80,23 +80,23 @@ macro_rules! array_impls {
|
|||
impl<T:PartialOrd> PartialOrd for [T; $N] {
|
||||
#[inline]
|
||||
fn partial_cmp(&self, other: &[T; $N]) -> Option<Ordering> {
|
||||
PartialOrd::partial_cmp(&self[], &other[])
|
||||
PartialOrd::partial_cmp(&self.index(&FullRange), &other.index(&FullRange))
|
||||
}
|
||||
#[inline]
|
||||
fn lt(&self, other: &[T; $N]) -> bool {
|
||||
PartialOrd::lt(&self[], &other[])
|
||||
PartialOrd::lt(&self.index(&FullRange), &other.index(&FullRange))
|
||||
}
|
||||
#[inline]
|
||||
fn le(&self, other: &[T; $N]) -> bool {
|
||||
PartialOrd::le(&self[], &other[])
|
||||
PartialOrd::le(&self.index(&FullRange), &other.index(&FullRange))
|
||||
}
|
||||
#[inline]
|
||||
fn ge(&self, other: &[T; $N]) -> bool {
|
||||
PartialOrd::ge(&self[], &other[])
|
||||
PartialOrd::ge(&self.index(&FullRange), &other.index(&FullRange))
|
||||
}
|
||||
#[inline]
|
||||
fn gt(&self, other: &[T; $N]) -> bool {
|
||||
PartialOrd::gt(&self[], &other[])
|
||||
PartialOrd::gt(&self.index(&FullRange), &other.index(&FullRange))
|
||||
}
|
||||
}
|
||||
|
||||
|
@ -104,7 +104,7 @@ macro_rules! array_impls {
|
|||
impl<T:Ord> Ord for [T; $N] {
|
||||
#[inline]
|
||||
fn cmp(&self, other: &[T; $N]) -> Ordering {
|
||||
Ord::cmp(&self[], &other[])
|
||||
Ord::cmp(&self.index(&FullRange), &other.index(&FullRange))
|
||||
}
|
||||
}
|
||||
)+
|
||||
|
|
|
@ -20,7 +20,7 @@ use fmt;
|
|||
use iter::{IteratorExt, range};
|
||||
use num::{cast, Float, ToPrimitive};
|
||||
use num::FpCategory as Fp;
|
||||
use ops::FnOnce;
|
||||
use ops::{FnOnce, Index};
|
||||
use result::Result::Ok;
|
||||
use slice::{self, SliceExt};
|
||||
use str::{self, StrExt};
|
||||
|
@ -332,5 +332,5 @@ pub fn float_to_str_bytes_common<T: Float, U, F>(
|
|||
}
|
||||
}
|
||||
|
||||
f(unsafe { str::from_utf8_unchecked(buf[..end]) })
|
||||
f(unsafe { str::from_utf8_unchecked(buf.index(&(0..end))) })
|
||||
}
|
||||
|
|
|
@ -19,8 +19,8 @@ use kinds::{Copy, Sized};
|
|||
use mem;
|
||||
use option::Option;
|
||||
use option::Option::{Some, None};
|
||||
use ops::{Deref, FnOnce};
|
||||
use result::Result::Ok;
|
||||
use ops::{Deref, FnOnce, Index};
|
||||
use result;
|
||||
use slice::SliceExt;
|
||||
use slice;
|
||||
|
@ -413,7 +413,7 @@ impl<'a> Formatter<'a> {
|
|||
for c in sign.into_iter() {
|
||||
let mut b = [0; 4];
|
||||
let n = c.encode_utf8(&mut b).unwrap_or(0);
|
||||
let b = unsafe { str::from_utf8_unchecked(b[0..n]) };
|
||||
let b = unsafe { str::from_utf8_unchecked(b.index(&(0..n))) };
|
||||
try!(f.buf.write_str(b));
|
||||
}
|
||||
if prefixed { f.buf.write_str(prefix) }
|
||||
|
@ -620,7 +620,7 @@ impl Show for char {
|
|||
|
||||
let mut utf8 = [0u8; 4];
|
||||
let amt = self.encode_utf8(&mut utf8).unwrap_or(0);
|
||||
let s: &str = unsafe { mem::transmute(utf8[..amt]) };
|
||||
let s: &str = unsafe { mem::transmute(utf8.index(&(0..amt))) };
|
||||
Show::fmt(s, f)
|
||||
}
|
||||
}
|
||||
|
|
|
@ -16,6 +16,7 @@
|
|||
|
||||
use fmt;
|
||||
use iter::IteratorExt;
|
||||
use ops::Index;
|
||||
use num::{Int, cast};
|
||||
use slice::SliceExt;
|
||||
use str;
|
||||
|
@ -61,7 +62,7 @@ trait GenericRadix {
|
|||
if x == zero { break }; // No more digits left to accumulate.
|
||||
}
|
||||
}
|
||||
let buf = unsafe { str::from_utf8_unchecked(buf[curr..]) };
|
||||
let buf = unsafe { str::from_utf8_unchecked(buf.index(&(curr..))) };
|
||||
f.pad_integral(is_positive, self.prefix(), buf)
|
||||
}
|
||||
}
|
||||
|
|
|
@ -24,7 +24,7 @@ use iter::IteratorExt;
|
|||
use kinds::Copy;
|
||||
use mem::size_of;
|
||||
use ops::{Add, Sub, Mul, Div, Rem, Neg};
|
||||
use ops::{Not, BitAnd, BitOr, BitXor, Shl, Shr};
|
||||
use ops::{Not, BitAnd, BitOr, BitXor, Shl, Shr, Index};
|
||||
use option::Option;
|
||||
use option::Option::{Some, None};
|
||||
use str::{FromStr, StrExt};
|
||||
|
@ -1577,7 +1577,7 @@ macro_rules! from_str_radix_float_impl {
|
|||
};
|
||||
|
||||
// Parse the exponent as decimal integer
|
||||
let src = src[offset..];
|
||||
let src = src.index(&(offset..));
|
||||
let (is_positive, exp) = match src.slice_shift_char() {
|
||||
Some(('-', src)) => (false, src.parse::<uint>()),
|
||||
Some(('+', src)) => (true, src.parse::<uint>()),
|
||||
|
|
|
@ -43,7 +43,7 @@ use default::Default;
|
|||
use iter::*;
|
||||
use kinds::Copy;
|
||||
use num::Int;
|
||||
use ops::{FnMut, self};
|
||||
use ops::{FnMut, self, Index};
|
||||
use option::Option;
|
||||
use option::Option::{None, Some};
|
||||
use result::Result;
|
||||
|
@ -159,7 +159,7 @@ impl<T> SliceExt for [T] {
|
|||
|
||||
#[inline]
|
||||
fn split_at(&self, mid: uint) -> (&[T], &[T]) {
|
||||
(self[..mid], self[mid..])
|
||||
(self.index(&(0..mid)), self.index(&(mid..)))
|
||||
}
|
||||
|
||||
#[inline]
|
||||
|
@ -236,11 +236,11 @@ impl<T> SliceExt for [T] {
|
|||
}
|
||||
|
||||
#[inline]
|
||||
fn tail(&self) -> &[T] { self[1..] }
|
||||
fn tail(&self) -> &[T] { self.index(&(1..)) }
|
||||
|
||||
#[inline]
|
||||
fn init(&self) -> &[T] {
|
||||
self[..self.len() - 1]
|
||||
self.index(&(0..(self.len() - 1)))
|
||||
}
|
||||
|
||||
#[inline]
|
||||
|
@ -443,13 +443,13 @@ impl<T> SliceExt for [T] {
|
|||
#[inline]
|
||||
fn starts_with(&self, needle: &[T]) -> bool where T: PartialEq {
|
||||
let n = needle.len();
|
||||
self.len() >= n && needle == self[..n]
|
||||
self.len() >= n && needle == self.index(&(0..n))
|
||||
}
|
||||
|
||||
#[inline]
|
||||
fn ends_with(&self, needle: &[T]) -> bool where T: PartialEq {
|
||||
let (m, n) = (self.len(), needle.len());
|
||||
m >= n && needle == self[m-n..]
|
||||
m >= n && needle == self.index(&((m-n)..))
|
||||
}
|
||||
|
||||
#[unstable]
|
||||
|
@ -622,6 +622,20 @@ impl<T> ops::IndexMut<ops::FullRange, [T]> for [T] {
|
|||
}
|
||||
}
|
||||
|
||||
impl<T> ops::Index<ops::Range<uint>, [T]> for [T] {
|
||||
#[inline]
|
||||
fn index(&self, index: &ops::Range<uint>) -> &[T] {
|
||||
assert!(index.start <= index.end);
|
||||
assert!(index.end <= self.len());
|
||||
unsafe {
|
||||
transmute(RawSlice {
|
||||
data: self.as_ptr().offset(index.start as int),
|
||||
len: index.end - index.start
|
||||
})
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
////////////////////////////////////////////////////////////////////////////////
|
||||
// Common traits
|
||||
|
@ -779,7 +793,7 @@ impl<'a, T> ops::Index<ops::RangeFrom<uint>, [T]> for Iter<'a, T> {
|
|||
#[experimental]
|
||||
impl<'a, T> ops::Index<ops::FullRange, [T]> for Iter<'a, T> {
|
||||
#[inline]
|
||||
fn index(&self, index: &ops::FullRange) -> &[T] {
|
||||
fn index(&self, _index: &ops::FullRange) -> &[T] {
|
||||
self.as_slice()
|
||||
}
|
||||
}
|
||||
|
@ -868,7 +882,7 @@ impl<'a, T> ops::Index<ops::RangeFrom<uint>, [T]> for IterMut<'a, T> {
|
|||
#[experimental]
|
||||
impl<'a, T> ops::Index<ops::FullRange, [T]> for IterMut<'a, T> {
|
||||
#[inline]
|
||||
fn index(&self, index: &ops::FullRange) -> &[T] {
|
||||
fn index(&self, _index: &ops::FullRange) -> &[T] {
|
||||
make_slice!(T -> &[T]: self.ptr, self.end)
|
||||
}
|
||||
}
|
||||
|
@ -900,7 +914,7 @@ impl<'a, T> ops::IndexMut<ops::RangeFrom<uint>, [T]> for IterMut<'a, T> {
|
|||
#[experimental]
|
||||
impl<'a, T> ops::IndexMut<ops::FullRange, [T]> for IterMut<'a, T> {
|
||||
#[inline]
|
||||
fn index_mut(&mut self, index: &ops::FullRange) -> &mut [T] {
|
||||
fn index_mut(&mut self, _index: &ops::FullRange) -> &mut [T] {
|
||||
make_slice!(T -> &mut [T]: self.ptr, self.end)
|
||||
}
|
||||
}
|
||||
|
@ -964,8 +978,8 @@ impl<'a, T, P> Iterator for Split<'a, T, P> where P: FnMut(&T) -> bool {
|
|||
match self.v.iter().position(|x| (self.pred)(x)) {
|
||||
None => self.finish(),
|
||||
Some(idx) => {
|
||||
let ret = Some(self.v[..idx]);
|
||||
self.v = self.v[idx + 1..];
|
||||
let ret = Some(self.v.index(&(0..idx)));
|
||||
self.v = self.v.index(&((idx + 1)..));
|
||||
ret
|
||||
}
|
||||
}
|
||||
|
@ -990,8 +1004,8 @@ impl<'a, T, P> DoubleEndedIterator for Split<'a, T, P> where P: FnMut(&T) -> boo
|
|||
match self.v.iter().rposition(|x| (self.pred)(x)) {
|
||||
None => self.finish(),
|
||||
Some(idx) => {
|
||||
let ret = Some(self.v[idx + 1..]);
|
||||
self.v = self.v[..idx];
|
||||
let ret = Some(self.v.index(&((idx + 1)..)));
|
||||
self.v = self.v.index(&(0..idx));
|
||||
ret
|
||||
}
|
||||
}
|
||||
|
@ -1187,8 +1201,8 @@ impl<'a, T> Iterator for Windows<'a, T> {
|
|||
if self.size > self.v.len() {
|
||||
None
|
||||
} else {
|
||||
let ret = Some(self.v[..self.size]);
|
||||
self.v = self.v[1..];
|
||||
let ret = Some(self.v.index(&(0..self.size)));
|
||||
self.v = self.v.index(&(1..));
|
||||
ret
|
||||
}
|
||||
}
|
||||
|
@ -1275,7 +1289,7 @@ impl<'a, T> RandomAccessIterator for Chunks<'a, T> {
|
|||
let mut hi = lo + self.size;
|
||||
if hi < lo || hi > self.v.len() { hi = self.v.len(); }
|
||||
|
||||
Some(self.v[lo..hi])
|
||||
Some(self.v.index(&(lo..hi)))
|
||||
} else {
|
||||
None
|
||||
}
|
||||
|
|
|
@ -26,7 +26,7 @@ use iter::{Map, Iterator, IteratorExt, DoubleEndedIterator};
|
|||
use kinds::Sized;
|
||||
use mem;
|
||||
use num::Int;
|
||||
use ops::{Fn, FnMut};
|
||||
use ops::{Fn, FnMut, Index};
|
||||
use option::Option::{self, None, Some};
|
||||
use ptr::PtrExt;
|
||||
use raw::{Repr, Slice};
|
||||
|
@ -581,7 +581,7 @@ impl NaiveSearcher {
|
|||
|
||||
fn next(&mut self, haystack: &[u8], needle: &[u8]) -> Option<(uint, uint)> {
|
||||
while self.position + needle.len() <= haystack.len() {
|
||||
if haystack[self.position .. self.position + needle.len()] == needle {
|
||||
if haystack.index(&(self.position .. self.position + needle.len())) == needle {
|
||||
let match_pos = self.position;
|
||||
self.position += needle.len(); // add 1 for all matches
|
||||
return Some((match_pos, match_pos + needle.len()));
|
||||
|
@ -702,10 +702,10 @@ impl TwoWaySearcher {
|
|||
//
|
||||
// What's going on is we have some critical factorization (u, v) of the
|
||||
// needle, and we want to determine whether u is a suffix of
|
||||
// v[..period]. If it is, we use "Algorithm CP1". Otherwise we use
|
||||
// v.index(&(0..period)). If it is, we use "Algorithm CP1". Otherwise we use
|
||||
// "Algorithm CP2", which is optimized for when the period of the needle
|
||||
// is large.
|
||||
if needle[..crit_pos] == needle[period.. period + crit_pos] {
|
||||
if needle.index(&(0..crit_pos)) == needle.index(&(period.. period + crit_pos)) {
|
||||
TwoWaySearcher {
|
||||
crit_pos: crit_pos,
|
||||
period: period,
|
||||
|
@ -1121,28 +1121,28 @@ mod traits {
|
|||
|
||||
impl ops::Index<ops::Range<uint>, str> for str {
|
||||
#[inline]
|
||||
fn index(&self, &index: &ops::Range<uint>) -> &str {
|
||||
fn index(&self, index: &ops::Range<uint>) -> &str {
|
||||
self.slice(index.start, index.end)
|
||||
}
|
||||
}
|
||||
|
||||
impl ops::Index<ops::RangeTo<uint>, str> for str {
|
||||
#[inline]
|
||||
fn index(&self, &index: &ops::RangeTo<uint>) -> &str {
|
||||
fn index(&self, index: &ops::RangeTo<uint>) -> &str {
|
||||
self.slice_to(index.end)
|
||||
}
|
||||
}
|
||||
|
||||
impl ops::Index<ops::RangeFrom<uint>, str> for str {
|
||||
#[inline]
|
||||
fn index(&self, &index: &ops::RangeFrom<uint>) -> &str {
|
||||
fn index(&self, index: &ops::RangeFrom<uint>) -> &str {
|
||||
self.slice_from(index.start)
|
||||
}
|
||||
}
|
||||
|
||||
impl ops::Index<ops::FullRange, str> for str {
|
||||
#[inline]
|
||||
fn index(&self, &index: &ops::FullRange) -> &str {
|
||||
fn index(&self, _index: &ops::FullRange) -> &str {
|
||||
self
|
||||
}
|
||||
}
|
||||
|
@ -1412,13 +1412,13 @@ impl StrExt for str {
|
|||
#[inline]
|
||||
fn starts_with(&self, needle: &str) -> bool {
|
||||
let n = needle.len();
|
||||
self.len() >= n && needle.as_bytes() == self.as_bytes()[..n]
|
||||
self.len() >= n && needle.as_bytes() == self.as_bytes().index(&(0..n))
|
||||
}
|
||||
|
||||
#[inline]
|
||||
fn ends_with(&self, needle: &str) -> bool {
|
||||
let (m, n) = (self.len(), needle.len());
|
||||
m >= n && needle.as_bytes() == self.as_bytes()[m-n..]
|
||||
m >= n && needle.as_bytes() == self.as_bytes().index(&((m-n)..))
|
||||
}
|
||||
|
||||
#[inline]
|
||||
|
|
|
@ -167,7 +167,7 @@ fn test_encode_utf8() {
|
|||
fn check(input: char, expect: &[u8]) {
|
||||
let mut buf = [0u8; 4];
|
||||
let n = input.encode_utf8(buf.as_mut_slice()).unwrap_or(0);
|
||||
assert_eq!(buf[..n], expect);
|
||||
assert_eq!(buf.index(&(0..n)), expect);
|
||||
}
|
||||
|
||||
check('x', &[0x78]);
|
||||
|
@ -181,7 +181,7 @@ fn test_encode_utf16() {
|
|||
fn check(input: char, expect: &[u16]) {
|
||||
let mut buf = [0u16; 2];
|
||||
let n = input.encode_utf16(buf.as_mut_slice()).unwrap_or(0);
|
||||
assert_eq!(buf[..n], expect);
|
||||
assert_eq!(buf.index(&(0..n)), expect);
|
||||
}
|
||||
|
||||
check('x', &[0x0078]);
|
||||
|
|
|
@ -230,7 +230,7 @@ fn test_inspect() {
|
|||
.collect::<Vec<uint>>();
|
||||
|
||||
assert_eq!(n, xs.len());
|
||||
assert_eq!(xs[], ys[]);
|
||||
assert_eq!(xs.index(&FullRange), ys.index(&FullRange));
|
||||
}
|
||||
|
||||
#[test]
|
||||
|
@ -281,47 +281,47 @@ fn test_iterator_nth() {
|
|||
fn test_iterator_last() {
|
||||
let v: &[_] = &[0i, 1, 2, 3, 4];
|
||||
assert_eq!(v.iter().last().unwrap(), &4);
|
||||
assert_eq!(v[0..1].iter().last().unwrap(), &0);
|
||||
assert_eq!(v.index(&(0..1)).iter().last().unwrap(), &0);
|
||||
}
|
||||
|
||||
#[test]
|
||||
fn test_iterator_len() {
|
||||
let v: &[_] = &[0i, 1, 2, 3, 4, 5, 6, 7, 8, 9, 10];
|
||||
assert_eq!(v[0..4].iter().count(), 4);
|
||||
assert_eq!(v[0..10].iter().count(), 10);
|
||||
assert_eq!(v[0..0].iter().count(), 0);
|
||||
assert_eq!(v.index(&(0..4)).iter().count(), 4);
|
||||
assert_eq!(v.index(&(0..10)).iter().count(), 10);
|
||||
assert_eq!(v.index(&(0..0)).iter().count(), 0);
|
||||
}
|
||||
|
||||
#[test]
|
||||
fn test_iterator_sum() {
|
||||
let v: &[_] = &[0i, 1, 2, 3, 4, 5, 6, 7, 8, 9, 10];
|
||||
assert_eq!(v[0..4].iter().map(|&x| x).sum(), 6);
|
||||
assert_eq!(v.index(&(0..4)).iter().map(|&x| x).sum(), 6);
|
||||
assert_eq!(v.iter().map(|&x| x).sum(), 55);
|
||||
assert_eq!(v[0..0].iter().map(|&x| x).sum(), 0);
|
||||
assert_eq!(v.index(&(0..0)).iter().map(|&x| x).sum(), 0);
|
||||
}
|
||||
|
||||
#[test]
|
||||
fn test_iterator_product() {
|
||||
let v: &[_] = &[0i, 1, 2, 3, 4, 5, 6, 7, 8, 9, 10];
|
||||
assert_eq!(v[0..4].iter().map(|&x| x).product(), 0);
|
||||
assert_eq!(v[1..5].iter().map(|&x| x).product(), 24);
|
||||
assert_eq!(v[0..0].iter().map(|&x| x).product(), 1);
|
||||
assert_eq!(v.index(&(0..4)).iter().map(|&x| x).product(), 0);
|
||||
assert_eq!(v.index(&(1..5)).iter().map(|&x| x).product(), 24);
|
||||
assert_eq!(v.index(&(0..0)).iter().map(|&x| x).product(), 1);
|
||||
}
|
||||
|
||||
#[test]
|
||||
fn test_iterator_max() {
|
||||
let v: &[_] = &[0i, 1, 2, 3, 4, 5, 6, 7, 8, 9, 10];
|
||||
assert_eq!(v[0..4].iter().map(|&x| x).max(), Some(3));
|
||||
assert_eq!(v.index(&(0..4)).iter().map(|&x| x).max(), Some(3));
|
||||
assert_eq!(v.iter().map(|&x| x).max(), Some(10));
|
||||
assert_eq!(v[0..0].iter().map(|&x| x).max(), None);
|
||||
assert_eq!(v.index(&(0..0)).iter().map(|&x| x).max(), None);
|
||||
}
|
||||
|
||||
#[test]
|
||||
fn test_iterator_min() {
|
||||
let v: &[_] = &[0i, 1, 2, 3, 4, 5, 6, 7, 8, 9, 10];
|
||||
assert_eq!(v[0..4].iter().map(|&x| x).min(), Some(0));
|
||||
assert_eq!(v.index(&(0..4)).iter().map(|&x| x).min(), Some(0));
|
||||
assert_eq!(v.iter().map(|&x| x).min(), Some(0));
|
||||
assert_eq!(v[0..0].iter().map(|&x| x).min(), None);
|
||||
assert_eq!(v.index(&(0..0)).iter().map(|&x| x).min(), None);
|
||||
}
|
||||
|
||||
#[test]
|
||||
|
|
|
@ -43,31 +43,31 @@ fn iterator_to_slice() {
|
|||
|
||||
{
|
||||
let mut iter = data.iter();
|
||||
assert_eq!(iter[], other_data[]);
|
||||
assert_eq!(iter.index(&FullRange), other_data.index(&FullRange));
|
||||
|
||||
iter.next();
|
||||
assert_eq!(iter[], other_data[1..]);
|
||||
assert_eq!(iter.index(&FullRange), other_data.index(&(1..)));
|
||||
|
||||
iter.next_back();
|
||||
assert_eq!(iter[], other_data[1..2]);
|
||||
assert_eq!(iter.index(&FullRange), other_data.index(&(1..2)));
|
||||
|
||||
let s = iter.as_slice();
|
||||
iter.next();
|
||||
assert_eq!(s, other_data[1..2]);
|
||||
assert_eq!(s, other_data.index(&(1..2)));
|
||||
}
|
||||
{
|
||||
let mut iter = data.iter_mut();
|
||||
assert_eq!(iter[], other_data[]);
|
||||
assert_eq!(iter.index(&FullRange), other_data.index(&FullRange));
|
||||
// mutability:
|
||||
assert!(iter[mut] == other_data);
|
||||
|
||||
iter.next();
|
||||
assert_eq!(iter[], other_data[1..]);
|
||||
assert_eq!(iter.index(&FullRange), other_data.index(&(1..)));
|
||||
assert!(iter[mut] == other_data[mut 1..]);
|
||||
|
||||
iter.next_back();
|
||||
|
||||
assert_eq!(iter[], other_data[1..2]);
|
||||
assert_eq!(iter.index(&FullRange), other_data.index(&(1..2)));
|
||||
assert!(iter[mut] == other_data[mut 1..2]);
|
||||
|
||||
let s = iter.into_slice();
|
||||
|
|
|
@ -212,11 +212,11 @@ impl<'a> Parser<'a> {
|
|||
self.cur.next();
|
||||
}
|
||||
Some((_, other)) => {
|
||||
self.err(format!("expected `{}`, found `{}`", c, other)[]);
|
||||
self.err(format!("expected `{}`, found `{}`", c, other).index(&FullRange));
|
||||
}
|
||||
None => {
|
||||
self.err(format!("expected `{}` but string was terminated",
|
||||
c)[]);
|
||||
c).index(&FullRange));
|
||||
}
|
||||
}
|
||||
}
|
||||
|
@ -239,12 +239,12 @@ impl<'a> Parser<'a> {
|
|||
// we may not consume the character, so clone the iterator
|
||||
match self.cur.clone().next() {
|
||||
Some((pos, '}')) | Some((pos, '{')) => {
|
||||
return self.input[start..pos];
|
||||
return self.input.index(&(start..pos));
|
||||
}
|
||||
Some(..) => { self.cur.next(); }
|
||||
None => {
|
||||
self.cur.next();
|
||||
return self.input[start..self.input.len()];
|
||||
return self.input.index(&(start..self.input.len()));
|
||||
}
|
||||
}
|
||||
}
|
||||
|
@ -284,7 +284,7 @@ impl<'a> Parser<'a> {
|
|||
flags: 0,
|
||||
precision: CountImplied,
|
||||
width: CountImplied,
|
||||
ty: self.input[0..0],
|
||||
ty: self.input.index(&(0..0)),
|
||||
};
|
||||
if !self.consume(':') { return spec }
|
||||
|
||||
|
@ -393,7 +393,7 @@ impl<'a> Parser<'a> {
|
|||
self.cur.next();
|
||||
pos
|
||||
}
|
||||
Some(..) | None => { return self.input[0..0]; }
|
||||
Some(..) | None => { return self.input.index(&(0..0)); }
|
||||
};
|
||||
let mut end;
|
||||
loop {
|
||||
|
@ -405,7 +405,7 @@ impl<'a> Parser<'a> {
|
|||
None => { end = self.input.len(); break }
|
||||
}
|
||||
}
|
||||
self.input[start..end]
|
||||
self.input.index(&(start..end))
|
||||
}
|
||||
|
||||
/// Optionally parses an integer at the current position. This doesn't deal
|
||||
|
|
|
@ -281,7 +281,7 @@ impl OptGroup {
|
|||
|
||||
impl Matches {
|
||||
fn opt_vals(&self, nm: &str) -> Vec<Optval> {
|
||||
match find_opt(self.opts[], Name::from_str(nm)) {
|
||||
match find_opt(self.opts.index(&FullRange), Name::from_str(nm)) {
|
||||
Some(id) => self.vals[id].clone(),
|
||||
None => panic!("No option '{}' defined", nm)
|
||||
}
|
||||
|
@ -309,7 +309,7 @@ impl Matches {
|
|||
/// Returns true if any of several options were matched.
|
||||
pub fn opts_present(&self, names: &[String]) -> bool {
|
||||
for nm in names.iter() {
|
||||
match find_opt(self.opts.as_slice(), Name::from_str(nm[])) {
|
||||
match find_opt(self.opts.as_slice(), Name::from_str(nm.index(&FullRange))) {
|
||||
Some(id) if !self.vals[id].is_empty() => return true,
|
||||
_ => (),
|
||||
};
|
||||
|
@ -320,7 +320,7 @@ impl Matches {
|
|||
/// Returns the string argument supplied to one of several matching options or `None`.
|
||||
pub fn opts_str(&self, names: &[String]) -> Option<String> {
|
||||
for nm in names.iter() {
|
||||
match self.opt_val(nm[]) {
|
||||
match self.opt_val(nm.index(&FullRange)) {
|
||||
Some(Val(ref s)) => return Some(s.clone()),
|
||||
_ => ()
|
||||
}
|
||||
|
@ -585,7 +585,7 @@ pub fn getopts(args: &[String], optgrps: &[OptGroup]) -> Result {
|
|||
while i < l {
|
||||
let cur = args[i].clone();
|
||||
let curlen = cur.len();
|
||||
if !is_arg(cur[]) {
|
||||
if !is_arg(cur.index(&FullRange)) {
|
||||
free.push(cur);
|
||||
} else if cur == "--" {
|
||||
let mut j = i + 1;
|
||||
|
@ -595,7 +595,7 @@ pub fn getopts(args: &[String], optgrps: &[OptGroup]) -> Result {
|
|||
let mut names;
|
||||
let mut i_arg = None;
|
||||
if cur.as_bytes()[1] == b'-' {
|
||||
let tail = cur[2..curlen];
|
||||
let tail = cur.index(&(2..curlen));
|
||||
let tail_eq: Vec<&str> = tail.split('=').collect();
|
||||
if tail_eq.len() <= 1 {
|
||||
names = vec!(Long(tail.to_string()));
|
||||
|
@ -631,7 +631,7 @@ pub fn getopts(args: &[String], optgrps: &[OptGroup]) -> Result {
|
|||
};
|
||||
|
||||
if arg_follows && range.next < curlen {
|
||||
i_arg = Some(cur[range.next..curlen].to_string());
|
||||
i_arg = Some(cur.index(&(range.next..curlen)).to_string());
|
||||
break;
|
||||
}
|
||||
|
||||
|
@ -650,29 +650,34 @@ pub fn getopts(args: &[String], optgrps: &[OptGroup]) -> Result {
|
|||
if name_pos == names.len() && !i_arg.is_none() {
|
||||
return Err(UnexpectedArgument(nm.to_string()));
|
||||
}
|
||||
vals[optid].push(Given);
|
||||
let v = &mut vals[optid];
|
||||
v.push(Given);
|
||||
}
|
||||
Maybe => {
|
||||
if !i_arg.is_none() {
|
||||
vals[optid]
|
||||
.push(Val((i_arg.clone())
|
||||
let v = &mut vals[optid];
|
||||
v.push(Val((i_arg.clone())
|
||||
.unwrap()));
|
||||
} else if name_pos < names.len() || i + 1 == l ||
|
||||
is_arg(args[i + 1][]) {
|
||||
vals[optid].push(Given);
|
||||
is_arg(args[i + 1].index(&FullRange)) {
|
||||
let v = &mut vals[optid];
|
||||
v.push(Given);
|
||||
} else {
|
||||
i += 1;
|
||||
vals[optid].push(Val(args[i].clone()));
|
||||
let v = &mut vals[optid];
|
||||
v.push(Val(args[i].clone()));
|
||||
}
|
||||
}
|
||||
Yes => {
|
||||
if !i_arg.is_none() {
|
||||
vals[optid].push(Val(i_arg.clone().unwrap()));
|
||||
let v = &mut vals[optid];
|
||||
v.push(Val(i_arg.clone().unwrap()));
|
||||
} else if i + 1 == l {
|
||||
return Err(ArgumentMissing(nm.to_string()));
|
||||
} else {
|
||||
i += 1;
|
||||
vals[optid].push(Val(args[i].clone()));
|
||||
let v = &mut vals[optid];
|
||||
v.push(Val(args[i].clone()));
|
||||
}
|
||||
}
|
||||
}
|
||||
|
@ -717,7 +722,7 @@ pub fn usage(brief: &str, opts: &[OptGroup]) -> String {
|
|||
0 => {}
|
||||
1 => {
|
||||
row.push('-');
|
||||
row.push_str(short_name[]);
|
||||
row.push_str(short_name.index(&FullRange));
|
||||
row.push(' ');
|
||||
}
|
||||
_ => panic!("the short name should only be 1 ascii char long"),
|
||||
|
@ -728,7 +733,7 @@ pub fn usage(brief: &str, opts: &[OptGroup]) -> String {
|
|||
0 => {}
|
||||
_ => {
|
||||
row.push_str("--");
|
||||
row.push_str(long_name[]);
|
||||
row.push_str(long_name.index(&FullRange));
|
||||
row.push(' ');
|
||||
}
|
||||
}
|
||||
|
@ -736,10 +741,10 @@ pub fn usage(brief: &str, opts: &[OptGroup]) -> String {
|
|||
// arg
|
||||
match hasarg {
|
||||
No => {}
|
||||
Yes => row.push_str(hint[]),
|
||||
Yes => row.push_str(hint.index(&FullRange)),
|
||||
Maybe => {
|
||||
row.push('[');
|
||||
row.push_str(hint[]);
|
||||
row.push_str(hint.index(&FullRange));
|
||||
row.push(']');
|
||||
}
|
||||
}
|
||||
|
@ -752,7 +757,7 @@ pub fn usage(brief: &str, opts: &[OptGroup]) -> String {
|
|||
row.push(' ');
|
||||
}
|
||||
} else {
|
||||
row.push_str(desc_sep[]);
|
||||
row.push_str(desc_sep.index(&FullRange));
|
||||
}
|
||||
|
||||
// Normalize desc to contain words separated by one space character
|
||||
|
@ -764,14 +769,14 @@ pub fn usage(brief: &str, opts: &[OptGroup]) -> String {
|
|||
|
||||
// FIXME: #5516 should be graphemes not codepoints
|
||||
let mut desc_rows = Vec::new();
|
||||
each_split_within(desc_normalized_whitespace[], 54, |substr| {
|
||||
each_split_within(desc_normalized_whitespace.index(&FullRange), 54, |substr| {
|
||||
desc_rows.push(substr.to_string());
|
||||
true
|
||||
});
|
||||
|
||||
// FIXME: #5516 should be graphemes not codepoints
|
||||
// wrapped description
|
||||
row.push_str(desc_rows.connect(desc_sep[])[]);
|
||||
row.push_str(desc_rows.connect(desc_sep.index(&FullRange)).index(&FullRange));
|
||||
|
||||
row
|
||||
});
|
||||
|
@ -790,10 +795,10 @@ fn format_option(opt: &OptGroup) -> String {
|
|||
// Use short_name is possible, but fallback to long_name.
|
||||
if opt.short_name.len() > 0 {
|
||||
line.push('-');
|
||||
line.push_str(opt.short_name[]);
|
||||
line.push_str(opt.short_name.index(&FullRange));
|
||||
} else {
|
||||
line.push_str("--");
|
||||
line.push_str(opt.long_name[]);
|
||||
line.push_str(opt.long_name.index(&FullRange));
|
||||
}
|
||||
|
||||
if opt.hasarg != No {
|
||||
|
@ -801,7 +806,7 @@ fn format_option(opt: &OptGroup) -> String {
|
|||
if opt.hasarg == Maybe {
|
||||
line.push('[');
|
||||
}
|
||||
line.push_str(opt.hint[]);
|
||||
line.push_str(opt.hint.index(&FullRange));
|
||||
if opt.hasarg == Maybe {
|
||||
line.push(']');
|
||||
}
|
||||
|
@ -823,7 +828,7 @@ pub fn short_usage(program_name: &str, opts: &[OptGroup]) -> String {
|
|||
line.push_str(opts.iter()
|
||||
.map(format_option)
|
||||
.collect::<Vec<String>>()
|
||||
.connect(" ")[]);
|
||||
.connect(" ").index(&FullRange));
|
||||
line
|
||||
}
|
||||
|
||||
|
@ -886,9 +891,9 @@ fn each_split_within<F>(ss: &str, lim: uint, mut it: F) -> bool where
|
|||
(B, Cr, UnderLim) => { B }
|
||||
(B, Cr, OverLim) if (i - last_start + 1) > lim
|
||||
=> panic!("word starting with {} longer than limit!",
|
||||
ss[last_start..i + 1]),
|
||||
ss.index(&(last_start..(i + 1)))),
|
||||
(B, Cr, OverLim) => {
|
||||
*cont = it(ss[slice_start..last_end]);
|
||||
*cont = it(ss.index(&(slice_start..last_end)));
|
||||
slice_start = last_start;
|
||||
B
|
||||
}
|
||||
|
@ -898,7 +903,7 @@ fn each_split_within<F>(ss: &str, lim: uint, mut it: F) -> bool where
|
|||
}
|
||||
(B, Ws, OverLim) => {
|
||||
last_end = i;
|
||||
*cont = it(ss[slice_start..last_end]);
|
||||
*cont = it(ss.index(&(slice_start..last_end)));
|
||||
A
|
||||
}
|
||||
|
||||
|
@ -907,14 +912,14 @@ fn each_split_within<F>(ss: &str, lim: uint, mut it: F) -> bool where
|
|||
B
|
||||
}
|
||||
(C, Cr, OverLim) => {
|
||||
*cont = it(ss[slice_start..last_end]);
|
||||
*cont = it(ss.index(&(slice_start..last_end)));
|
||||
slice_start = i;
|
||||
last_start = i;
|
||||
last_end = i;
|
||||
B
|
||||
}
|
||||
(C, Ws, OverLim) => {
|
||||
*cont = it(ss[slice_start..last_end]);
|
||||
*cont = it(ss.index(&(slice_start..last_end)));
|
||||
A
|
||||
}
|
||||
(C, Ws, UnderLim) => {
|
||||
|
@ -1408,7 +1413,7 @@ mod tests {
|
|||
assert!(matches_single.opts_present(&["e".to_string(), "encrypt".to_string()]));
|
||||
assert!(!matches_single.opts_present(&["encrypt".to_string()]));
|
||||
assert!(!matches_single.opts_present(&["thing".to_string()]));
|
||||
assert!(!matches_single.opts_present(&[]));
|
||||
assert!(!matches_single.opts_present(&.index(&FullRange)));
|
||||
|
||||
assert_eq!(matches_single.opts_str(&["e".to_string()]).unwrap(), "foo");
|
||||
assert_eq!(matches_single.opts_str(&["e".to_string(), "encrypt".to_string()]).unwrap(),
|
||||
|
@ -1429,7 +1434,7 @@ mod tests {
|
|||
assert!(matches_both.opts_present(&["e".to_string(), "encrypt".to_string()]));
|
||||
assert!(!matches_both.opts_present(&["f".to_string()]));
|
||||
assert!(!matches_both.opts_present(&["thing".to_string()]));
|
||||
assert!(!matches_both.opts_present(&[]));
|
||||
assert!(!matches_both.opts_present(&.index(&FullRange)));
|
||||
|
||||
assert_eq!(matches_both.opts_str(&["e".to_string()]).unwrap(), "foo");
|
||||
assert_eq!(matches_both.opts_str(&["encrypt".to_string()]).unwrap(), "foo");
|
||||
|
|
|
@ -453,7 +453,7 @@ impl<'a> LabelText<'a> {
|
|||
pub fn escape(&self) -> String {
|
||||
match self {
|
||||
&LabelStr(ref s) => s.escape_default(),
|
||||
&EscStr(ref s) => LabelText::escape_str(s[]),
|
||||
&EscStr(ref s) => LabelText::escape_str(s.index(&FullRange)),
|
||||
}
|
||||
}
|
||||
|
||||
|
@ -482,7 +482,7 @@ impl<'a> LabelText<'a> {
|
|||
let mut prefix = self.pre_escaped_content().into_owned();
|
||||
let suffix = suffix.pre_escaped_content();
|
||||
prefix.push_str(r"\n\n");
|
||||
prefix.push_str(suffix[]);
|
||||
prefix.push_str(suffix.index(&FullRange));
|
||||
EscStr(prefix.into_cow())
|
||||
}
|
||||
}
|
||||
|
@ -676,7 +676,7 @@ mod tests {
|
|||
|
||||
impl<'a> Labeller<'a, Node, &'a Edge> for LabelledGraph {
|
||||
fn graph_id(&'a self) -> Id<'a> {
|
||||
Id::new(self.name[]).unwrap()
|
||||
Id::new(self.name.index(&FullRange)).unwrap()
|
||||
}
|
||||
fn node_id(&'a self, n: &Node) -> Id<'a> {
|
||||
id_name(n)
|
||||
|
|
|
@ -282,7 +282,7 @@ pub fn log(level: u32, loc: &'static LogLocation, args: fmt::Arguments) {
|
|||
// Test the literal string from args against the current filter, if there
|
||||
// is one.
|
||||
match unsafe { FILTER.as_ref() } {
|
||||
Some(filter) if !filter.is_match(args.to_string()[]) => return,
|
||||
Some(filter) if !filter.is_match(args.to_string().index(&FullRange)) => return,
|
||||
_ => {}
|
||||
}
|
||||
|
||||
|
@ -377,7 +377,7 @@ fn enabled(level: u32,
|
|||
// Search for the longest match, the vector is assumed to be pre-sorted.
|
||||
for directive in iter.rev() {
|
||||
match directive.name {
|
||||
Some(ref name) if !module.starts_with(name[]) => {},
|
||||
Some(ref name) if !module.starts_with(name.index(&FullRange)) => {},
|
||||
Some(..) | None => {
|
||||
return level <= directive.level
|
||||
}
|
||||
|
@ -392,7 +392,7 @@ fn enabled(level: u32,
|
|||
/// `Once` primitive (and this function is called from that primitive).
|
||||
fn init() {
|
||||
let (mut directives, filter) = match os::getenv("RUST_LOG") {
|
||||
Some(spec) => directive::parse_logging_spec(spec[]),
|
||||
Some(spec) => directive::parse_logging_spec(spec.index(&FullRange)),
|
||||
None => (Vec::new(), None),
|
||||
};
|
||||
|
||||
|
|
|
@ -24,7 +24,7 @@ use core::num::{Float, Int};
|
|||
|
||||
use {Rng, Rand};
|
||||
|
||||
pub use self::range::Range;
|
||||
pub use self::range::Range as RandRange;
|
||||
pub use self::gamma::{Gamma, ChiSquared, FisherF, StudentT};
|
||||
pub use self::normal::{Normal, LogNormal};
|
||||
pub use self::exponential::Exp;
|
||||
|
@ -104,7 +104,7 @@ pub struct Weighted<T> {
|
|||
/// ```
|
||||
pub struct WeightedChoice<'a, T:'a> {
|
||||
items: &'a mut [Weighted<T>],
|
||||
weight_range: Range<uint>
|
||||
weight_range: RandRange<uint>
|
||||
}
|
||||
|
||||
impl<'a, T: Clone> WeightedChoice<'a, T> {
|
||||
|
@ -138,7 +138,7 @@ impl<'a, T: Clone> WeightedChoice<'a, T> {
|
|||
items: items,
|
||||
// we're likely to be generating numbers in this range
|
||||
// relatively often, so might as well cache it
|
||||
weight_range: Range::new(0, running_total)
|
||||
weight_range: RandRange::new(0, running_total)
|
||||
}
|
||||
}
|
||||
}
|
||||
|
|
|
@ -12,7 +12,7 @@
|
|||
|
||||
// this is surprisingly complicated to be both generic & correct
|
||||
|
||||
use core::prelude::*;
|
||||
use core::prelude::{PartialOrd};
|
||||
use core::num::Int;
|
||||
|
||||
use Rng;
|
||||
|
|
|
@ -58,7 +58,7 @@ use core::prelude::*;
|
|||
pub use isaac::{IsaacRng, Isaac64Rng};
|
||||
pub use chacha::ChaChaRng;
|
||||
|
||||
use distributions::{Range, IndependentSample};
|
||||
use distributions::{RandRange, IndependentSample};
|
||||
use distributions::range::SampleRange;
|
||||
|
||||
#[cfg(test)]
|
||||
|
@ -247,7 +247,7 @@ pub trait Rng : Sized {
|
|||
/// ```
|
||||
fn gen_range<T: PartialOrd + SampleRange>(&mut self, low: T, high: T) -> T {
|
||||
assert!(low < high, "Rng.gen_range called with low >= high");
|
||||
Range::new(low, high).ind_sample(self)
|
||||
RandRange::new(low, high).ind_sample(self)
|
||||
}
|
||||
|
||||
/// Return a bool with a 1 in n chance of true
|
||||
|
@ -291,7 +291,7 @@ pub trait Rng : Sized {
|
|||
/// let mut rng = thread_rng();
|
||||
/// println!("{}", rng.choose(&choices));
|
||||
/// # // replace with slicing syntax when it's stable!
|
||||
/// assert_eq!(rng.choose(choices.slice_to(0)), None);
|
||||
/// assert_eq!(rng.choose(choices.index(&(0..0))), None);
|
||||
/// ```
|
||||
fn choose<'a, T>(&mut self, values: &'a [T]) -> Option<&'a T> {
|
||||
if values.is_empty() {
|
||||
|
|
|
@ -95,7 +95,7 @@ impl Writer for SeekableMemWriter {
|
|||
// there (left), and what will be appended on the end (right)
|
||||
let cap = self.buf.len() - self.pos;
|
||||
let (left, right) = if cap <= buf.len() {
|
||||
(buf[..cap], buf[cap..])
|
||||
(buf.index(&(0..cap)), buf.index(&(cap..)))
|
||||
} else {
|
||||
let result: (_, &[_]) = (buf, &[]);
|
||||
result
|
||||
|
|
|
@ -65,7 +65,7 @@ impl<'doc> Doc<'doc> {
|
|||
}
|
||||
|
||||
pub fn as_str_slice<'a>(&'a self) -> &'a str {
|
||||
str::from_utf8(self.data[self.start..self.end]).unwrap()
|
||||
str::from_utf8(self.data.index(&(self.start..self.end))).unwrap()
|
||||
}
|
||||
|
||||
pub fn as_str(&self) -> String {
|
||||
|
@ -300,7 +300,7 @@ pub mod reader {
|
|||
pub fn with_doc_data<T, F>(d: Doc, f: F) -> T where
|
||||
F: FnOnce(&[u8]) -> T,
|
||||
{
|
||||
f(d.data[d.start..d.end])
|
||||
f(d.data.index(&(d.start..d.end)))
|
||||
}
|
||||
|
||||
|
||||
|
|
|
@ -105,7 +105,7 @@ impl Program {
|
|||
// This is a bit hacky since we have to skip over the initial
|
||||
// 'Save' instruction.
|
||||
let mut pre = String::with_capacity(5);
|
||||
for inst in c.insts[1..].iter() {
|
||||
for inst in c.insts.index(&(1..)).iter() {
|
||||
match *inst {
|
||||
OneChar(c, FLAG_EMPTY) => pre.push(c),
|
||||
_ => break
|
||||
|
|
|
@ -18,6 +18,7 @@ use std::cmp;
|
|||
use std::fmt;
|
||||
use std::iter;
|
||||
use std::num;
|
||||
use std::ops::Index;
|
||||
|
||||
/// Static data containing Unicode ranges for general categories and scripts.
|
||||
use unicode::regex::{UNICODE_CLASSES, PERLD, PERLS, PERLW};
|
||||
|
@ -285,7 +286,7 @@ impl<'a> Parser<'a> {
|
|||
true => Ok(()),
|
||||
false => {
|
||||
self.err(format!("Expected {} but got EOF.",
|
||||
expected)[])
|
||||
expected).index(&FullRange))
|
||||
}
|
||||
}
|
||||
}
|
||||
|
@ -294,10 +295,10 @@ impl<'a> Parser<'a> {
|
|||
match self.next_char() {
|
||||
true if self.cur() == expected => Ok(()),
|
||||
true => self.err(format!("Expected '{}' but got '{}'.",
|
||||
expected, self.cur())[]),
|
||||
expected, self.cur()).index(&FullRange)),
|
||||
false => {
|
||||
self.err(format!("Expected '{}' but got EOF.",
|
||||
expected)[])
|
||||
expected).index(&FullRange))
|
||||
}
|
||||
}
|
||||
}
|
||||
|
@ -443,14 +444,14 @@ impl<'a> Parser<'a> {
|
|||
Literal(c3, _) => c2 = c3, // allow literal escapes below
|
||||
ast =>
|
||||
return self.err(format!("Expected a literal, but got {}.",
|
||||
ast)[]),
|
||||
ast).index(&FullRange)),
|
||||
}
|
||||
}
|
||||
if c2 < c {
|
||||
return self.err(format!("Invalid character class \
|
||||
range '{}-{}'",
|
||||
c,
|
||||
c2)[])
|
||||
c2).index(&FullRange))
|
||||
}
|
||||
ranges.push((c, self.cur()))
|
||||
} else {
|
||||
|
@ -488,7 +489,7 @@ impl<'a> Parser<'a> {
|
|||
FLAG_EMPTY
|
||||
};
|
||||
let name = self.slice(name_start, closer - 1);
|
||||
match find_class(ASCII_CLASSES, name[]) {
|
||||
match find_class(ASCII_CLASSES, name.index(&FullRange)) {
|
||||
None => None,
|
||||
Some(ranges) => {
|
||||
self.chari = closer;
|
||||
|
@ -513,18 +514,18 @@ impl<'a> Parser<'a> {
|
|||
return self.err(format!("No closing brace for counted \
|
||||
repetition starting at position \
|
||||
{}.",
|
||||
start)[])
|
||||
start).index(&FullRange))
|
||||
}
|
||||
};
|
||||
self.chari = closer;
|
||||
let greed = try!(self.get_next_greedy());
|
||||
let inner = self.chars[start+1..closer].iter().cloned()
|
||||
let inner = self.chars.index(&((start+1)..closer)).iter().cloned()
|
||||
.collect::<String>();
|
||||
|
||||
// Parse the min and max values from the regex.
|
||||
let (mut min, mut max): (uint, Option<uint>);
|
||||
if !inner.contains(",") {
|
||||
min = try!(self.parse_uint(inner[]));
|
||||
min = try!(self.parse_uint(inner.index(&FullRange)));
|
||||
max = Some(min);
|
||||
} else {
|
||||
let pieces: Vec<&str> = inner.splitn(1, ',').collect();
|
||||
|
@ -546,19 +547,19 @@ impl<'a> Parser<'a> {
|
|||
if min > MAX_REPEAT {
|
||||
return self.err(format!(
|
||||
"{} exceeds maximum allowed repetitions ({})",
|
||||
min, MAX_REPEAT)[]);
|
||||
min, MAX_REPEAT).index(&FullRange));
|
||||
}
|
||||
if max.is_some() {
|
||||
let m = max.unwrap();
|
||||
if m > MAX_REPEAT {
|
||||
return self.err(format!(
|
||||
"{} exceeds maximum allowed repetitions ({})",
|
||||
m, MAX_REPEAT)[]);
|
||||
m, MAX_REPEAT).index(&FullRange));
|
||||
}
|
||||
if m < min {
|
||||
return self.err(format!(
|
||||
"Max repetitions ({}) cannot be smaller than min \
|
||||
repetitions ({}).", m, min)[]);
|
||||
repetitions ({}).", m, min).index(&FullRange));
|
||||
}
|
||||
}
|
||||
|
||||
|
@ -622,7 +623,7 @@ impl<'a> Parser<'a> {
|
|||
Ok(AstClass(ranges, flags))
|
||||
}
|
||||
_ => {
|
||||
self.err(format!("Invalid escape sequence '\\\\{}'", c)[])
|
||||
self.err(format!("Invalid escape sequence '\\\\{}'", c).index(&FullRange))
|
||||
}
|
||||
}
|
||||
}
|
||||
|
@ -642,7 +643,7 @@ impl<'a> Parser<'a> {
|
|||
Some(i) => i,
|
||||
None => return self.err(format!(
|
||||
"Missing '}}' for unclosed '{{' at position {}",
|
||||
self.chari)[]),
|
||||
self.chari).index(&FullRange)),
|
||||
};
|
||||
if closer - self.chari + 1 == 0 {
|
||||
return self.err("No Unicode class name found.")
|
||||
|
@ -656,10 +657,10 @@ impl<'a> Parser<'a> {
|
|||
name = self.slice(self.chari + 1, self.chari + 2);
|
||||
self.chari += 1;
|
||||
}
|
||||
match find_class(UNICODE_CLASSES, name[]) {
|
||||
match find_class(UNICODE_CLASSES, name.index(&FullRange)) {
|
||||
None => {
|
||||
return self.err(format!("Could not find Unicode class '{}'",
|
||||
name)[])
|
||||
name).index(&FullRange))
|
||||
}
|
||||
Some(ranges) => {
|
||||
Ok(AstClass(ranges, negated | (self.flags & FLAG_NOCASE)))
|
||||
|
@ -682,11 +683,11 @@ impl<'a> Parser<'a> {
|
|||
}
|
||||
}
|
||||
let s = self.slice(start, end);
|
||||
match num::from_str_radix::<u32>(s[], 8) {
|
||||
match num::from_str_radix::<u32>(s.index(&FullRange), 8) {
|
||||
Some(n) => Ok(Literal(try!(self.char_from_u32(n)), FLAG_EMPTY)),
|
||||
None => {
|
||||
self.err(format!("Could not parse '{}' as octal number.",
|
||||
s)[])
|
||||
s).index(&FullRange))
|
||||
}
|
||||
}
|
||||
}
|
||||
|
@ -704,12 +705,12 @@ impl<'a> Parser<'a> {
|
|||
None => {
|
||||
return self.err(format!("Missing '}}' for unclosed \
|
||||
'{{' at position {}",
|
||||
start)[])
|
||||
start).index(&FullRange))
|
||||
}
|
||||
Some(i) => i,
|
||||
};
|
||||
self.chari = closer;
|
||||
self.parse_hex_digits(self.slice(start, closer)[])
|
||||
self.parse_hex_digits(self.slice(start, closer).index(&FullRange))
|
||||
}
|
||||
|
||||
// Parses a two-digit hex number.
|
||||
|
@ -729,7 +730,7 @@ impl<'a> Parser<'a> {
|
|||
match num::from_str_radix::<u32>(s, 16) {
|
||||
Some(n) => Ok(Literal(try!(self.char_from_u32(n)), FLAG_EMPTY)),
|
||||
None => {
|
||||
self.err(format!("Could not parse '{}' as hex number.", s)[])
|
||||
self.err(format!("Could not parse '{}' as hex number.", s).index(&FullRange))
|
||||
}
|
||||
}
|
||||
}
|
||||
|
@ -755,7 +756,7 @@ impl<'a> Parser<'a> {
|
|||
}
|
||||
if self.names.contains(&name) {
|
||||
return self.err(format!("Duplicate capture group name '{}'.",
|
||||
name)[])
|
||||
name).index(&FullRange))
|
||||
}
|
||||
self.names.push(name.clone());
|
||||
self.chari = closer;
|
||||
|
@ -789,7 +790,7 @@ impl<'a> Parser<'a> {
|
|||
if sign < 0 {
|
||||
return self.err(format!(
|
||||
"Cannot negate flags twice in '{}'.",
|
||||
self.slice(start, self.chari + 1))[])
|
||||
self.slice(start, self.chari + 1)).index(&FullRange))
|
||||
}
|
||||
sign = -1;
|
||||
saw_flag = false;
|
||||
|
@ -800,7 +801,7 @@ impl<'a> Parser<'a> {
|
|||
if !saw_flag {
|
||||
return self.err(format!(
|
||||
"A valid flag does not follow negation in '{}'",
|
||||
self.slice(start, self.chari + 1))[])
|
||||
self.slice(start, self.chari + 1)).index(&FullRange))
|
||||
}
|
||||
flags = flags ^ flags;
|
||||
}
|
||||
|
@ -812,7 +813,7 @@ impl<'a> Parser<'a> {
|
|||
return Ok(())
|
||||
}
|
||||
_ => return self.err(format!(
|
||||
"Unrecognized flag '{}'.", self.cur())[]),
|
||||
"Unrecognized flag '{}'.", self.cur()).index(&FullRange)),
|
||||
}
|
||||
}
|
||||
}
|
||||
|
@ -910,7 +911,7 @@ impl<'a> Parser<'a> {
|
|||
Some(i) => Ok(i),
|
||||
None => {
|
||||
self.err(format!("Expected an unsigned integer but got '{}'.",
|
||||
s)[])
|
||||
s).index(&FullRange))
|
||||
}
|
||||
}
|
||||
}
|
||||
|
@ -920,7 +921,7 @@ impl<'a> Parser<'a> {
|
|||
Some(c) => Ok(c),
|
||||
None => {
|
||||
self.err(format!("Could not decode '{}' to unicode \
|
||||
character.", n)[])
|
||||
character.", n).index(&FullRange))
|
||||
}
|
||||
}
|
||||
}
|
||||
|
@ -953,7 +954,7 @@ impl<'a> Parser<'a> {
|
|||
}
|
||||
|
||||
fn slice(&self, start: uint, end: uint) -> String {
|
||||
self.chars[start..end].iter().cloned().collect()
|
||||
self.chars.index(&(start..end)).iter().cloned().collect()
|
||||
}
|
||||
}
|
||||
|
||||
|
|
|
@ -238,19 +238,19 @@ impl Regex {
|
|||
}
|
||||
|
||||
let (s, e) = cap.pos(0).unwrap(); // captures only reports matches
|
||||
new.push_str(text[last_match..s]);
|
||||
new.push_str(rep.reg_replace(&cap)[]);
|
||||
new.push_str(text.index(&(last_match..s)));
|
||||
new.push_str(rep.reg_replace(&cap).index(&FullRange));
|
||||
last_match = e;
|
||||
}
|
||||
new.push_str(text[last_match..text.len()]);
|
||||
new.push_str(text.index(&(last_match..text.len())));
|
||||
return new;
|
||||
}
|
||||
|
||||
/// Returns the original string of this regex.
|
||||
pub fn as_str<'a>(&'a self) -> &'a str {
|
||||
match *self {
|
||||
Dynamic(ExDynamic { ref original, .. }) => original[],
|
||||
Native(ExNative { ref original, .. }) => original[],
|
||||
Dynamic(ExDynamic { ref original, .. }) => original.index(&FullRange),
|
||||
Native(ExNative { ref original, .. }) => original.index(&FullRange),
|
||||
}
|
||||
}
|
||||
|
||||
|
@ -347,13 +347,13 @@ impl<'r, 't> Iterator for RegexSplits<'r, 't> {
|
|||
if self.last >= text.len() {
|
||||
None
|
||||
} else {
|
||||
let s = text[self.last..text.len()];
|
||||
let s = text.index(&(self.last..text.len()));
|
||||
self.last = text.len();
|
||||
Some(s)
|
||||
}
|
||||
}
|
||||
Some((s, e)) => {
|
||||
let matched = text[self.last..s];
|
||||
let matched = text.index(&(self.last..s));
|
||||
self.last = e;
|
||||
Some(matched)
|
||||
}
|
||||
|
@ -384,7 +384,7 @@ impl<'r, 't> Iterator for RegexSplitsN<'r, 't> {
|
|||
} else {
|
||||
self.cur += 1;
|
||||
if self.cur >= self.limit {
|
||||
Some(text[self.splits.last..text.len()])
|
||||
Some(text.index(&(self.splits.last..text.len())))
|
||||
} else {
|
||||
self.splits.next()
|
||||
}
|
||||
|
@ -517,7 +517,7 @@ impl<'t> Captures<'t> {
|
|||
})
|
||||
});
|
||||
let re = Regex::new(r"\$\$").unwrap();
|
||||
re.replace_all(text[], NoExpand("$"))
|
||||
re.replace_all(text.index(&FullRange), NoExpand("$"))
|
||||
}
|
||||
|
||||
/// Returns the number of captured groups.
|
||||
|
|
|
@ -121,7 +121,7 @@ mat!{match_basic_110, r"a[b-d]", r"aac", Some((1, 3))}
|
|||
mat!{match_basic_111, r"a[-b]", r"a-", Some((0, 2))}
|
||||
mat!{match_basic_112, r"a[b-]", r"a-", Some((0, 2))}
|
||||
mat!{match_basic_113, r"a]", r"a]", Some((0, 2))}
|
||||
mat!{match_basic_114, r"a[]]b", r"a]b", Some((0, 3))}
|
||||
mat!{match_basic_114, r"a.index(&FullRange)]b", r"a]b", Some((0, 3))}
|
||||
mat!{match_basic_115, r"a[^bc]d", r"aed", Some((0, 3))}
|
||||
mat!{match_basic_116, r"a[^-b]c", r"adc", Some((0, 3))}
|
||||
mat!{match_basic_117, r"a[^]b]c", r"adc", Some((0, 3))}
|
||||
|
|
|
@ -152,7 +152,7 @@ impl<'r, 't> Nfa<'r, 't> {
|
|||
// out early.
|
||||
if self.prog.prefix.len() > 0 && clist.size == 0 {
|
||||
let needle = self.prog.prefix.as_bytes();
|
||||
let haystack = self.input.as_bytes()[self.ic..];
|
||||
let haystack = self.input.as_bytes().index(&(self.ic..));
|
||||
match find_prefix(needle, haystack) {
|
||||
None => break,
|
||||
Some(i) => {
|
||||
|
@ -503,7 +503,8 @@ impl Threads {
|
|||
|
||||
#[inline]
|
||||
fn groups<'r>(&'r mut self, i: uint) -> &'r mut [Option<uint>] {
|
||||
self.queue[i].groups.as_mut_slice()
|
||||
let q = &mut self.queue[i];
|
||||
q.groups.as_mut_slice()
|
||||
}
|
||||
}
|
||||
|
||||
|
|
|
@ -506,7 +506,7 @@ impl BoxPointers {
|
|||
if n_uniq > 0 {
|
||||
let s = ty_to_string(cx.tcx, ty);
|
||||
let m = format!("type uses owned (Box type) pointers: {}", s);
|
||||
cx.span_lint(BOX_POINTERS, span, m[]);
|
||||
cx.span_lint(BOX_POINTERS, span, m.index(&FullRange));
|
||||
}
|
||||
}
|
||||
}
|
||||
|
@ -586,7 +586,7 @@ impl LintPass for RawPointerDerive {
|
|||
}
|
||||
|
||||
fn check_item(&mut self, cx: &Context, item: &ast::Item) {
|
||||
if !attr::contains_name(item.attrs[], "automatically_derived") {
|
||||
if !attr::contains_name(item.attrs.index(&FullRange), "automatically_derived") {
|
||||
return
|
||||
}
|
||||
let did = match item.node {
|
||||
|
@ -769,11 +769,11 @@ impl LintPass for UnusedResults {
|
|||
ty::ty_enum(did, _) => {
|
||||
if ast_util::is_local(did) {
|
||||
if let ast_map::NodeItem(it) = cx.tcx.map.get(did.node) {
|
||||
warned |= check_must_use(cx, it.attrs[], s.span);
|
||||
warned |= check_must_use(cx, it.attrs.index(&FullRange), s.span);
|
||||
}
|
||||
} else {
|
||||
csearch::get_item_attrs(&cx.sess().cstore, did, |attrs| {
|
||||
warned |= check_must_use(cx, attrs[], s.span);
|
||||
warned |= check_must_use(cx, attrs.index(&FullRange), s.span);
|
||||
});
|
||||
}
|
||||
}
|
||||
|
@ -795,7 +795,7 @@ impl LintPass for UnusedResults {
|
|||
msg.push_str(s.get());
|
||||
}
|
||||
}
|
||||
cx.span_lint(UNUSED_MUST_USE, sp, msg[]);
|
||||
cx.span_lint(UNUSED_MUST_USE, sp, msg.index(&FullRange));
|
||||
return true;
|
||||
}
|
||||
}
|
||||
|
@ -841,7 +841,7 @@ impl NonCamelCaseTypes {
|
|||
} else {
|
||||
format!("{} `{}` should have a camel case name such as `{}`", sort, s, c)
|
||||
};
|
||||
cx.span_lint(NON_CAMEL_CASE_TYPES, span, m[]);
|
||||
cx.span_lint(NON_CAMEL_CASE_TYPES, span, m.index(&FullRange));
|
||||
}
|
||||
}
|
||||
}
|
||||
|
@ -981,7 +981,7 @@ impl NonSnakeCase {
|
|||
if !is_snake_case(ident) {
|
||||
cx.span_lint(NON_SNAKE_CASE, span,
|
||||
format!("{} `{}` should have a snake case name such as `{}`",
|
||||
sort, s, to_snake_case(s.get()))[]);
|
||||
sort, s, to_snake_case(s.get())).index(&FullRange));
|
||||
}
|
||||
}
|
||||
}
|
||||
|
@ -1068,7 +1068,7 @@ impl LintPass for NonUpperCaseGlobals {
|
|||
format!("static constant `{}` should have an uppercase name \
|
||||
such as `{}`",
|
||||
s.get(), s.get().chars().map(|c| c.to_uppercase())
|
||||
.collect::<String>()[])[]);
|
||||
.collect::<String>().index(&FullRange)).index(&FullRange));
|
||||
}
|
||||
}
|
||||
_ => {}
|
||||
|
@ -1085,7 +1085,7 @@ impl LintPass for NonUpperCaseGlobals {
|
|||
format!("static constant in pattern `{}` should have an uppercase \
|
||||
name such as `{}`",
|
||||
s.get(), s.get().chars().map(|c| c.to_uppercase())
|
||||
.collect::<String>()[])[]);
|
||||
.collect::<String>().index(&FullRange)).index(&FullRange));
|
||||
}
|
||||
}
|
||||
_ => {}
|
||||
|
@ -1110,7 +1110,7 @@ impl UnusedParens {
|
|||
if !necessary {
|
||||
cx.span_lint(UNUSED_PARENS, value.span,
|
||||
format!("unnecessary parentheses around {}",
|
||||
msg)[])
|
||||
msg).index(&FullRange))
|
||||
}
|
||||
}
|
||||
|
||||
|
@ -1212,7 +1212,7 @@ impl LintPass for UnusedImportBraces {
|
|||
let m = format!("braces around {} is unnecessary",
|
||||
token::get_ident(*name).get());
|
||||
cx.span_lint(UNUSED_IMPORT_BRACES, view_item.span,
|
||||
m[]);
|
||||
m.index(&FullRange));
|
||||
},
|
||||
_ => ()
|
||||
}
|
||||
|
@ -1251,7 +1251,7 @@ impl LintPass for NonShorthandFieldPatterns {
|
|||
if ident.node.as_str() == fieldpat.node.ident.as_str() {
|
||||
cx.span_lint(NON_SHORTHAND_FIELD_PATTERNS, fieldpat.span,
|
||||
format!("the `{}:` in this pattern is redundant and can \
|
||||
be removed", ident.node.as_str())[])
|
||||
be removed", ident.node.as_str()).index(&FullRange))
|
||||
}
|
||||
}
|
||||
}
|
||||
|
@ -1355,7 +1355,7 @@ impl LintPass for UnusedMut {
|
|||
fn check_expr(&mut self, cx: &Context, e: &ast::Expr) {
|
||||
if let ast::ExprMatch(_, ref arms, _) = e.node {
|
||||
for a in arms.iter() {
|
||||
self.check_unused_mut_pat(cx, a.pats[])
|
||||
self.check_unused_mut_pat(cx, a.pats.index(&FullRange))
|
||||
}
|
||||
}
|
||||
}
|
||||
|
@ -1476,7 +1476,7 @@ impl MissingDoc {
|
|||
});
|
||||
if !has_doc {
|
||||
cx.span_lint(MISSING_DOCS, sp,
|
||||
format!("missing documentation for {}", desc)[]);
|
||||
format!("missing documentation for {}", desc).index(&FullRange));
|
||||
}
|
||||
}
|
||||
}
|
||||
|
@ -1490,7 +1490,7 @@ impl LintPass for MissingDoc {
|
|||
let doc_hidden = self.doc_hidden() || attrs.iter().any(|attr| {
|
||||
attr.check_name("doc") && match attr.meta_item_list() {
|
||||
None => false,
|
||||
Some(l) => attr::contains_name(l[], "hidden"),
|
||||
Some(l) => attr::contains_name(l.index(&FullRange), "hidden"),
|
||||
}
|
||||
});
|
||||
self.doc_hidden_stack.push(doc_hidden);
|
||||
|
@ -1512,7 +1512,7 @@ impl LintPass for MissingDoc {
|
|||
}
|
||||
|
||||
fn check_crate(&mut self, cx: &Context, krate: &ast::Crate) {
|
||||
self.check_missing_docs_attrs(cx, None, krate.attrs[],
|
||||
self.check_missing_docs_attrs(cx, None, krate.attrs.index(&FullRange),
|
||||
krate.span, "crate");
|
||||
}
|
||||
|
||||
|
@ -1526,7 +1526,7 @@ impl LintPass for MissingDoc {
|
|||
ast::ItemTy(..) => "a type alias",
|
||||
_ => return
|
||||
};
|
||||
self.check_missing_docs_attrs(cx, Some(it.id), it.attrs[],
|
||||
self.check_missing_docs_attrs(cx, Some(it.id), it.attrs.index(&FullRange),
|
||||
it.span, desc);
|
||||
}
|
||||
|
||||
|
@ -1539,13 +1539,13 @@ impl LintPass for MissingDoc {
|
|||
|
||||
// Otherwise, doc according to privacy. This will also check
|
||||
// doc for default methods defined on traits.
|
||||
self.check_missing_docs_attrs(cx, Some(m.id), m.attrs[],
|
||||
self.check_missing_docs_attrs(cx, Some(m.id), m.attrs.index(&FullRange),
|
||||
m.span, "a method");
|
||||
}
|
||||
}
|
||||
|
||||
fn check_ty_method(&mut self, cx: &Context, tm: &ast::TypeMethod) {
|
||||
self.check_missing_docs_attrs(cx, Some(tm.id), tm.attrs[],
|
||||
self.check_missing_docs_attrs(cx, Some(tm.id), tm.attrs.index(&FullRange),
|
||||
tm.span, "a type method");
|
||||
}
|
||||
|
||||
|
@ -1555,14 +1555,14 @@ impl LintPass for MissingDoc {
|
|||
let cur_struct_def = *self.struct_def_stack.last()
|
||||
.expect("empty struct_def_stack");
|
||||
self.check_missing_docs_attrs(cx, Some(cur_struct_def),
|
||||
sf.node.attrs[], sf.span,
|
||||
sf.node.attrs.index(&FullRange), sf.span,
|
||||
"a struct field")
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
fn check_variant(&mut self, cx: &Context, v: &ast::Variant, _: &ast::Generics) {
|
||||
self.check_missing_docs_attrs(cx, Some(v.node.id), v.node.attrs[],
|
||||
self.check_missing_docs_attrs(cx, Some(v.node.id), v.node.attrs.index(&FullRange),
|
||||
v.span, "a variant");
|
||||
assert!(!self.in_variant);
|
||||
self.in_variant = true;
|
||||
|
@ -1674,7 +1674,7 @@ impl Stability {
|
|||
_ => format!("use of {} item", label)
|
||||
};
|
||||
|
||||
cx.span_lint(lint, span, msg[]);
|
||||
cx.span_lint(lint, span, msg.index(&FullRange));
|
||||
}
|
||||
|
||||
fn is_internal(&self, cx: &Context, span: Span) -> bool {
|
||||
|
|
|
@ -104,7 +104,7 @@ impl LintStore {
|
|||
}
|
||||
|
||||
pub fn get_lints<'t>(&'t self) -> &'t [(&'static Lint, bool)] {
|
||||
self.lints[]
|
||||
self.lints.index(&FullRange)
|
||||
}
|
||||
|
||||
pub fn get_lint_groups<'t>(&'t self) -> Vec<(&'static str, Vec<LintId>, bool)> {
|
||||
|
@ -124,11 +124,11 @@ impl LintStore {
|
|||
match (sess, from_plugin) {
|
||||
// We load builtin lints first, so a duplicate is a compiler bug.
|
||||
// Use early_error when handling -W help with no crate.
|
||||
(None, _) => early_error(msg[]),
|
||||
(Some(sess), false) => sess.bug(msg[]),
|
||||
(None, _) => early_error(msg.index(&FullRange)),
|
||||
(Some(sess), false) => sess.bug(msg.index(&FullRange)),
|
||||
|
||||
// A duplicate name from a plugin is a user error.
|
||||
(Some(sess), true) => sess.err(msg[]),
|
||||
(Some(sess), true) => sess.err(msg.index(&FullRange)),
|
||||
}
|
||||
}
|
||||
|
||||
|
@ -149,11 +149,11 @@ impl LintStore {
|
|||
match (sess, from_plugin) {
|
||||
// We load builtin lints first, so a duplicate is a compiler bug.
|
||||
// Use early_error when handling -W help with no crate.
|
||||
(None, _) => early_error(msg[]),
|
||||
(Some(sess), false) => sess.bug(msg[]),
|
||||
(None, _) => early_error(msg.index(&FullRange)),
|
||||
(Some(sess), false) => sess.bug(msg.index(&FullRange)),
|
||||
|
||||
// A duplicate name from a plugin is a user error.
|
||||
(Some(sess), true) => sess.err(msg[]),
|
||||
(Some(sess), true) => sess.err(msg.index(&FullRange)),
|
||||
}
|
||||
}
|
||||
}
|
||||
|
@ -267,8 +267,8 @@ impl LintStore {
|
|||
let warning = format!("lint {} has been renamed to {}",
|
||||
lint_name, new_name);
|
||||
match span {
|
||||
Some(span) => sess.span_warn(span, warning[]),
|
||||
None => sess.warn(warning[]),
|
||||
Some(span) => sess.span_warn(span, warning.index(&FullRange)),
|
||||
None => sess.warn(warning.index(&FullRange)),
|
||||
};
|
||||
Some(lint_id)
|
||||
}
|
||||
|
@ -278,13 +278,13 @@ impl LintStore {
|
|||
|
||||
pub fn process_command_line(&mut self, sess: &Session) {
|
||||
for &(ref lint_name, level) in sess.opts.lint_opts.iter() {
|
||||
match self.find_lint(lint_name[], sess, None) {
|
||||
match self.find_lint(lint_name.index(&FullRange), sess, None) {
|
||||
Some(lint_id) => self.set_level(lint_id, (level, CommandLine)),
|
||||
None => {
|
||||
match self.lint_groups.iter().map(|(&x, pair)| (x, pair.0.clone()))
|
||||
.collect::<FnvHashMap<&'static str,
|
||||
Vec<LintId>>>()
|
||||
.get(lint_name[]) {
|
||||
.get(lint_name.index(&FullRange)) {
|
||||
Some(v) => {
|
||||
v.iter()
|
||||
.map(|lint_id: &LintId|
|
||||
|
@ -292,7 +292,7 @@ impl LintStore {
|
|||
.collect::<Vec<()>>();
|
||||
}
|
||||
None => sess.err(format!("unknown {} flag: {}",
|
||||
level.as_str(), lint_name)[]),
|
||||
level.as_str(), lint_name).index(&FullRange)),
|
||||
}
|
||||
}
|
||||
}
|
||||
|
@ -403,10 +403,10 @@ pub fn raw_emit_lint(sess: &Session, lint: &'static Lint,
|
|||
if level == Forbid { level = Deny; }
|
||||
|
||||
match (level, span) {
|
||||
(Warn, Some(sp)) => sess.span_warn(sp, msg[]),
|
||||
(Warn, None) => sess.warn(msg[]),
|
||||
(Deny, Some(sp)) => sess.span_err(sp, msg[]),
|
||||
(Deny, None) => sess.err(msg[]),
|
||||
(Warn, Some(sp)) => sess.span_warn(sp, msg.index(&FullRange)),
|
||||
(Warn, None) => sess.warn(msg.index(&FullRange)),
|
||||
(Deny, Some(sp)) => sess.span_err(sp, msg.index(&FullRange)),
|
||||
(Deny, None) => sess.err(msg.index(&FullRange)),
|
||||
_ => sess.bug("impossible level in raw_emit_lint"),
|
||||
}
|
||||
|
||||
|
@ -499,7 +499,7 @@ impl<'a, 'tcx> Context<'a, 'tcx> {
|
|||
None => {
|
||||
self.span_lint(builtin::UNKNOWN_LINTS, span,
|
||||
format!("unknown `{}` attribute: `{}`",
|
||||
level.as_str(), lint_name)[]);
|
||||
level.as_str(), lint_name).index(&FullRange));
|
||||
continue;
|
||||
}
|
||||
}
|
||||
|
@ -515,7 +515,7 @@ impl<'a, 'tcx> Context<'a, 'tcx> {
|
|||
self.tcx.sess.span_err(span,
|
||||
format!("{}({}) overruled by outer forbid({})",
|
||||
level.as_str(), lint_name,
|
||||
lint_name)[]);
|
||||
lint_name).index(&FullRange));
|
||||
} else if now != level {
|
||||
let src = self.lints.get_level_source(lint_id).1;
|
||||
self.level_stack.push((lint_id, (now, src)));
|
||||
|
@ -550,7 +550,7 @@ impl<'a, 'tcx> Context<'a, 'tcx> {
|
|||
|
||||
impl<'a, 'tcx, 'v> Visitor<'v> for Context<'a, 'tcx> {
|
||||
fn visit_item(&mut self, it: &ast::Item) {
|
||||
self.with_lint_attrs(it.attrs[], |cx| {
|
||||
self.with_lint_attrs(it.attrs.index(&FullRange), |cx| {
|
||||
run_lints!(cx, check_item, it);
|
||||
cx.visit_ids(|v| v.visit_item(it));
|
||||
visit::walk_item(cx, it);
|
||||
|
@ -558,14 +558,14 @@ impl<'a, 'tcx, 'v> Visitor<'v> for Context<'a, 'tcx> {
|
|||
}
|
||||
|
||||
fn visit_foreign_item(&mut self, it: &ast::ForeignItem) {
|
||||
self.with_lint_attrs(it.attrs[], |cx| {
|
||||
self.with_lint_attrs(it.attrs.index(&FullRange), |cx| {
|
||||
run_lints!(cx, check_foreign_item, it);
|
||||
visit::walk_foreign_item(cx, it);
|
||||
})
|
||||
}
|
||||
|
||||
fn visit_view_item(&mut self, i: &ast::ViewItem) {
|
||||
self.with_lint_attrs(i.attrs[], |cx| {
|
||||
self.with_lint_attrs(i.attrs.index(&FullRange), |cx| {
|
||||
run_lints!(cx, check_view_item, i);
|
||||
cx.visit_ids(|v| v.visit_view_item(i));
|
||||
visit::walk_view_item(cx, i);
|
||||
|
@ -591,7 +591,7 @@ impl<'a, 'tcx, 'v> Visitor<'v> for Context<'a, 'tcx> {
|
|||
body: &'v ast::Block, span: Span, id: ast::NodeId) {
|
||||
match fk {
|
||||
visit::FkMethod(_, _, m) => {
|
||||
self.with_lint_attrs(m.attrs[], |cx| {
|
||||
self.with_lint_attrs(m.attrs.index(&FullRange), |cx| {
|
||||
run_lints!(cx, check_fn, fk, decl, body, span, id);
|
||||
cx.visit_ids(|v| {
|
||||
v.visit_fn(fk, decl, body, span, id);
|
||||
|
@ -607,7 +607,7 @@ impl<'a, 'tcx, 'v> Visitor<'v> for Context<'a, 'tcx> {
|
|||
}
|
||||
|
||||
fn visit_ty_method(&mut self, t: &ast::TypeMethod) {
|
||||
self.with_lint_attrs(t.attrs[], |cx| {
|
||||
self.with_lint_attrs(t.attrs.index(&FullRange), |cx| {
|
||||
run_lints!(cx, check_ty_method, t);
|
||||
visit::walk_ty_method(cx, t);
|
||||
})
|
||||
|
@ -624,14 +624,14 @@ impl<'a, 'tcx, 'v> Visitor<'v> for Context<'a, 'tcx> {
|
|||
}
|
||||
|
||||
fn visit_struct_field(&mut self, s: &ast::StructField) {
|
||||
self.with_lint_attrs(s.node.attrs[], |cx| {
|
||||
self.with_lint_attrs(s.node.attrs.index(&FullRange), |cx| {
|
||||
run_lints!(cx, check_struct_field, s);
|
||||
visit::walk_struct_field(cx, s);
|
||||
})
|
||||
}
|
||||
|
||||
fn visit_variant(&mut self, v: &ast::Variant, g: &ast::Generics) {
|
||||
self.with_lint_attrs(v.node.attrs[], |cx| {
|
||||
self.with_lint_attrs(v.node.attrs.index(&FullRange), |cx| {
|
||||
run_lints!(cx, check_variant, v, g);
|
||||
visit::walk_variant(cx, v, g);
|
||||
run_lints!(cx, check_variant_post, v, g);
|
||||
|
@ -725,7 +725,7 @@ impl<'a, 'tcx> IdVisitingOperation for Context<'a, 'tcx> {
|
|||
None => {}
|
||||
Some(lints) => {
|
||||
for (lint_id, span, msg) in lints.into_iter() {
|
||||
self.span_lint(lint_id.lint, span, msg[])
|
||||
self.span_lint(lint_id.lint, span, msg.index(&FullRange))
|
||||
}
|
||||
}
|
||||
}
|
||||
|
@ -771,7 +771,7 @@ pub fn check_crate(tcx: &ty::ctxt,
|
|||
let mut cx = Context::new(tcx, krate, exported_items);
|
||||
|
||||
// Visit the whole crate.
|
||||
cx.with_lint_attrs(krate.attrs[], |cx| {
|
||||
cx.with_lint_attrs(krate.attrs.index(&FullRange), |cx| {
|
||||
cx.visit_id(ast::CRATE_NODE_ID);
|
||||
cx.visit_ids(|v| {
|
||||
v.visited_outermost = true;
|
||||
|
@ -791,7 +791,7 @@ pub fn check_crate(tcx: &ty::ctxt,
|
|||
for &(lint, span, ref msg) in v.iter() {
|
||||
tcx.sess.span_bug(span,
|
||||
format!("unprocessed lint {} at {}: {}",
|
||||
lint.as_str(), tcx.map.node_to_string(*id), *msg)[])
|
||||
lint.as_str(), tcx.map.node_to_string(*id), *msg).index(&FullRange))
|
||||
}
|
||||
}
|
||||
|
||||
|
|
|
@ -65,7 +65,8 @@ fn dump_crates(cstore: &CStore) {
|
|||
}
|
||||
|
||||
fn should_link(i: &ast::ViewItem) -> bool {
|
||||
!attr::contains_name(i.attrs[], "no_link")
|
||||
!attr::contains_name(i.attrs.index(&FullRange), "no_link")
|
||||
|
||||
}
|
||||
|
||||
struct CrateInfo {
|
||||
|
@ -89,7 +90,7 @@ pub fn validate_crate_name(sess: Option<&Session>, s: &str, sp: Option<Span>) {
|
|||
for c in s.chars() {
|
||||
if c.is_alphanumeric() { continue }
|
||||
if c == '_' || c == '-' { continue }
|
||||
err(format!("invalid character `{}` in crate name: `{}`", c, s)[]);
|
||||
err(format!("invalid character `{}` in crate name: `{}`", c, s).index(&FullRange));
|
||||
}
|
||||
match sess {
|
||||
Some(sess) => sess.abort_if_errors(),
|
||||
|
@ -97,6 +98,7 @@ pub fn validate_crate_name(sess: Option<&Session>, s: &str, sp: Option<Span>) {
|
|||
}
|
||||
}
|
||||
|
||||
|
||||
fn register_native_lib(sess: &Session,
|
||||
span: Option<Span>,
|
||||
name: String,
|
||||
|
@ -187,8 +189,8 @@ impl<'a> CrateReader<'a> {
|
|||
match self.extract_crate_info(i) {
|
||||
Some(info) => {
|
||||
let (cnum, _, _) = self.resolve_crate(&None,
|
||||
info.ident[],
|
||||
info.name[],
|
||||
info.ident.index(&FullRange),
|
||||
info.name.index(&FullRange),
|
||||
None,
|
||||
i.span,
|
||||
PathKind::Crate);
|
||||
|
@ -433,8 +435,8 @@ impl<'a> CrateReader<'a> {
|
|||
decoder::get_crate_deps(cdata).iter().map(|dep| {
|
||||
debug!("resolving dep crate {} hash: `{}`", dep.name, dep.hash);
|
||||
let (local_cnum, _, _) = self.resolve_crate(root,
|
||||
dep.name[],
|
||||
dep.name[],
|
||||
dep.name.index(&FullRange),
|
||||
dep.name.index(&FullRange),
|
||||
Some(&dep.hash),
|
||||
span,
|
||||
PathKind::Dependency);
|
||||
|
@ -445,7 +447,7 @@ impl<'a> CrateReader<'a> {
|
|||
pub fn read_plugin_metadata<'b>(&'b mut self,
|
||||
vi: &'b ast::ViewItem) -> PluginMetadata<'b> {
|
||||
let info = self.extract_crate_info(vi).unwrap();
|
||||
let target_triple = self.sess.opts.target_triple[];
|
||||
let target_triple = self.sess.opts.target_triple.index(&FullRange);
|
||||
let is_cross = target_triple != config::host_triple();
|
||||
let mut should_link = info.should_link && !is_cross;
|
||||
let mut target_only = false;
|
||||
|
@ -454,8 +456,8 @@ impl<'a> CrateReader<'a> {
|
|||
let mut load_ctxt = loader::Context {
|
||||
sess: self.sess,
|
||||
span: vi.span,
|
||||
ident: ident[],
|
||||
crate_name: name[],
|
||||
ident: ident.index(&FullRange),
|
||||
crate_name: name.index(&FullRange),
|
||||
hash: None,
|
||||
filesearch: self.sess.host_filesearch(PathKind::Crate),
|
||||
triple: config::host_triple(),
|
||||
|
@ -480,11 +482,11 @@ impl<'a> CrateReader<'a> {
|
|||
};
|
||||
|
||||
let dylib = library.dylib.clone();
|
||||
let register = should_link && self.existing_match(info.name[], None).is_none();
|
||||
let register = should_link && self.existing_match(info.name.as_slice(), None).is_none();
|
||||
let metadata = if register {
|
||||
// Register crate now to avoid double-reading metadata
|
||||
let (_, cmd, _) = self.register_crate(&None, info.ident[],
|
||||
info.name[], vi.span, library);
|
||||
let (_, cmd, _) = self.register_crate(&None, info.ident.index(&FullRange),
|
||||
info.name.index(&FullRange), vi.span, library);
|
||||
PMDSource::Registered(cmd)
|
||||
} else {
|
||||
// Not registering the crate; just hold on to the metadata
|
||||
|
@ -505,8 +507,8 @@ impl<'a> CrateReader<'a> {
|
|||
impl<'a> PluginMetadata<'a> {
|
||||
/// Read exported macros
|
||||
pub fn exported_macros(&self) -> Vec<ast::MacroDef> {
|
||||
let imported_from = Some(token::intern(self.info.ident[]).ident());
|
||||
let source_name = format!("<{} macros>", self.info.ident[]);
|
||||
let imported_from = Some(token::intern(self.info.ident.index(&FullRange)).ident());
|
||||
let source_name = format!("<{} macros>", self.info.ident.index(&FullRange));
|
||||
let mut macros = vec![];
|
||||
decoder::each_exported_macro(self.metadata.as_slice(),
|
||||
&*self.sess.cstore.intr,
|
||||
|
@ -548,7 +550,7 @@ impl<'a> PluginMetadata<'a> {
|
|||
self.info.ident,
|
||||
config::host_triple(),
|
||||
self.sess.opts.target_triple);
|
||||
self.sess.span_err(self.vi_span, message[]);
|
||||
self.sess.span_err(self.vi_span, message.index(&FullRange));
|
||||
self.sess.abort_if_errors();
|
||||
}
|
||||
|
||||
|
@ -561,7 +563,7 @@ impl<'a> PluginMetadata<'a> {
|
|||
let message = format!("plugin crate `{}` only found in rlib format, \
|
||||
but must be available in dylib format",
|
||||
self.info.ident);
|
||||
self.sess.span_err(self.vi_span, message[]);
|
||||
self.sess.span_err(self.vi_span, message.index(&FullRange));
|
||||
// No need to abort because the loading code will just ignore this
|
||||
// empty dylib.
|
||||
None
|
||||
|
|
|
@ -95,7 +95,7 @@ pub fn get_item_path(tcx: &ty::ctxt, def: ast::DefId) -> Vec<ast_map::PathElem>
|
|||
|
||||
// FIXME #1920: This path is not always correct if the crate is not linked
|
||||
// into the root namespace.
|
||||
let mut r = vec![ast_map::PathMod(token::intern(cdata.name[]))];
|
||||
let mut r = vec![ast_map::PathMod(token::intern(cdata.name.index(&FullRange)))];
|
||||
r.push_all(path.as_slice());
|
||||
r
|
||||
}
|
||||
|
|
|
@ -75,7 +75,7 @@ fn lookup_hash<'a, F>(d: rbml::Doc<'a>, mut eq_fn: F, hash: u64) -> Option<rbml:
|
|||
let mut ret = None;
|
||||
reader::tagged_docs(tagged_doc.doc, belt, |elt| {
|
||||
let pos = u64_from_be_bytes(elt.data, elt.start, 4) as uint;
|
||||
if eq_fn(elt.data[elt.start + 4 .. elt.end]) {
|
||||
if eq_fn(elt.data.index(&((elt.start + 4) .. elt.end))) {
|
||||
ret = Some(reader::doc_at(d.data, pos).unwrap().doc);
|
||||
false
|
||||
} else {
|
||||
|
@ -89,7 +89,7 @@ pub fn maybe_find_item<'a>(item_id: ast::NodeId,
|
|||
items: rbml::Doc<'a>) -> Option<rbml::Doc<'a>> {
|
||||
fn eq_item(bytes: &[u8], item_id: ast::NodeId) -> bool {
|
||||
return u64_from_be_bytes(
|
||||
bytes[0u..4u], 0u, 4u) as ast::NodeId
|
||||
bytes.index(&(0u..4u)), 0u, 4u) as ast::NodeId
|
||||
== item_id;
|
||||
}
|
||||
lookup_hash(items,
|
||||
|
@ -1191,7 +1191,7 @@ pub fn get_crate_deps(data: &[u8]) -> Vec<CrateDep> {
|
|||
}
|
||||
reader::tagged_docs(depsdoc, tag_crate_dep, |depdoc| {
|
||||
let name = docstr(depdoc, tag_crate_dep_crate_name);
|
||||
let hash = Svh::new(docstr(depdoc, tag_crate_dep_hash)[]);
|
||||
let hash = Svh::new(docstr(depdoc, tag_crate_dep_hash).index(&FullRange));
|
||||
deps.push(CrateDep {
|
||||
cnum: crate_num,
|
||||
name: name,
|
||||
|
|
|
@ -95,7 +95,7 @@ fn encode_impl_type_basename(rbml_w: &mut Encoder, name: ast::Ident) {
|
|||
}
|
||||
|
||||
pub fn encode_def_id(rbml_w: &mut Encoder, id: DefId) {
|
||||
rbml_w.wr_tagged_str(tag_def_id, def_to_string(id)[]);
|
||||
rbml_w.wr_tagged_str(tag_def_id, def_to_string(id).index(&FullRange));
|
||||
}
|
||||
|
||||
#[derive(Clone)]
|
||||
|
@ -154,7 +154,7 @@ fn encode_variant_id(rbml_w: &mut Encoder, vid: DefId) {
|
|||
rbml_w.end_tag();
|
||||
|
||||
rbml_w.start_tag(tag_mod_child);
|
||||
rbml_w.wr_str(s[]);
|
||||
rbml_w.wr_str(s.index(&FullRange));
|
||||
rbml_w.end_tag();
|
||||
}
|
||||
|
||||
|
@ -264,7 +264,7 @@ fn encode_symbol(ecx: &EncodeContext,
|
|||
}
|
||||
None => {
|
||||
ecx.diag.handler().bug(
|
||||
format!("encode_symbol: id not found {}", id)[]);
|
||||
format!("encode_symbol: id not found {}", id).index(&FullRange));
|
||||
}
|
||||
}
|
||||
rbml_w.end_tag();
|
||||
|
@ -332,8 +332,8 @@ fn encode_enum_variant_info(ecx: &EncodeContext,
|
|||
encode_name(rbml_w, variant.node.name.name);
|
||||
encode_parent_item(rbml_w, local_def(id));
|
||||
encode_visibility(rbml_w, variant.node.vis);
|
||||
encode_attributes(rbml_w, variant.node.attrs[]);
|
||||
encode_repr_attrs(rbml_w, ecx, variant.node.attrs[]);
|
||||
encode_attributes(rbml_w, variant.node.attrs.index(&FullRange));
|
||||
encode_repr_attrs(rbml_w, ecx, variant.node.attrs.index(&FullRange));
|
||||
|
||||
let stab = stability::lookup(ecx.tcx, ast_util::local_def(variant.node.id));
|
||||
encode_stability(rbml_w, stab);
|
||||
|
@ -344,9 +344,9 @@ fn encode_enum_variant_info(ecx: &EncodeContext,
|
|||
let fields = ty::lookup_struct_fields(ecx.tcx, def_id);
|
||||
let idx = encode_info_for_struct(ecx,
|
||||
rbml_w,
|
||||
fields[],
|
||||
fields.index(&FullRange),
|
||||
index);
|
||||
encode_struct_fields(rbml_w, fields[], def_id);
|
||||
encode_struct_fields(rbml_w, fields.index(&FullRange), def_id);
|
||||
encode_index(rbml_w, idx, write_i64);
|
||||
}
|
||||
}
|
||||
|
@ -386,12 +386,12 @@ fn encode_reexported_static_method(rbml_w: &mut Encoder,
|
|||
exp.name, token::get_name(method_name));
|
||||
rbml_w.start_tag(tag_items_data_item_reexport);
|
||||
rbml_w.start_tag(tag_items_data_item_reexport_def_id);
|
||||
rbml_w.wr_str(def_to_string(method_def_id)[]);
|
||||
rbml_w.wr_str(def_to_string(method_def_id).index(&FullRange));
|
||||
rbml_w.end_tag();
|
||||
rbml_w.start_tag(tag_items_data_item_reexport_name);
|
||||
rbml_w.wr_str(format!("{}::{}",
|
||||
exp.name,
|
||||
token::get_name(method_name))[]);
|
||||
token::get_name(method_name)).index(&FullRange));
|
||||
rbml_w.end_tag();
|
||||
rbml_w.end_tag();
|
||||
}
|
||||
|
@ -529,7 +529,7 @@ fn encode_reexports(ecx: &EncodeContext,
|
|||
id);
|
||||
rbml_w.start_tag(tag_items_data_item_reexport);
|
||||
rbml_w.start_tag(tag_items_data_item_reexport_def_id);
|
||||
rbml_w.wr_str(def_to_string(exp.def_id)[]);
|
||||
rbml_w.wr_str(def_to_string(exp.def_id).index(&FullRange));
|
||||
rbml_w.end_tag();
|
||||
rbml_w.start_tag(tag_items_data_item_reexport_name);
|
||||
rbml_w.wr_str(exp.name.as_str());
|
||||
|
@ -562,13 +562,13 @@ fn encode_info_for_mod(ecx: &EncodeContext,
|
|||
// Encode info about all the module children.
|
||||
for item in md.items.iter() {
|
||||
rbml_w.start_tag(tag_mod_child);
|
||||
rbml_w.wr_str(def_to_string(local_def(item.id))[]);
|
||||
rbml_w.wr_str(def_to_string(local_def(item.id)).index(&FullRange));
|
||||
rbml_w.end_tag();
|
||||
|
||||
each_auxiliary_node_id(&**item, |auxiliary_node_id| {
|
||||
rbml_w.start_tag(tag_mod_child);
|
||||
rbml_w.wr_str(def_to_string(local_def(
|
||||
auxiliary_node_id))[]);
|
||||
auxiliary_node_id)).index(&FullRange));
|
||||
rbml_w.end_tag();
|
||||
true
|
||||
});
|
||||
|
@ -580,7 +580,7 @@ fn encode_info_for_mod(ecx: &EncodeContext,
|
|||
did, ecx.tcx.map.node_to_string(did));
|
||||
|
||||
rbml_w.start_tag(tag_mod_impl);
|
||||
rbml_w.wr_str(def_to_string(local_def(did))[]);
|
||||
rbml_w.wr_str(def_to_string(local_def(did)).index(&FullRange));
|
||||
rbml_w.end_tag();
|
||||
}
|
||||
}
|
||||
|
@ -615,7 +615,7 @@ fn encode_visibility(rbml_w: &mut Encoder, visibility: ast::Visibility) {
|
|||
ast::Public => 'y',
|
||||
ast::Inherited => 'i',
|
||||
};
|
||||
rbml_w.wr_str(ch.to_string()[]);
|
||||
rbml_w.wr_str(ch.to_string().index(&FullRange));
|
||||
rbml_w.end_tag();
|
||||
}
|
||||
|
||||
|
@ -627,7 +627,7 @@ fn encode_unboxed_closure_kind(rbml_w: &mut Encoder,
|
|||
ty::FnMutUnboxedClosureKind => 'm',
|
||||
ty::FnOnceUnboxedClosureKind => 'o',
|
||||
};
|
||||
rbml_w.wr_str(ch.to_string()[]);
|
||||
rbml_w.wr_str(ch.to_string().index(&FullRange));
|
||||
rbml_w.end_tag();
|
||||
}
|
||||
|
||||
|
@ -788,7 +788,7 @@ fn encode_generics<'a, 'tcx>(rbml_w: &mut Encoder,
|
|||
rbml_w.end_tag();
|
||||
|
||||
rbml_w.wr_tagged_str(tag_region_param_def_def_id,
|
||||
def_to_string(param.def_id)[]);
|
||||
def_to_string(param.def_id).index(&FullRange));
|
||||
|
||||
rbml_w.wr_tagged_u64(tag_region_param_def_space,
|
||||
param.space.to_uint() as u64);
|
||||
|
@ -864,9 +864,9 @@ fn encode_info_for_method<'a, 'tcx>(ecx: &EncodeContext<'a, 'tcx>,
|
|||
encode_path(rbml_w, impl_path.chain(Some(elem).into_iter()));
|
||||
match ast_item_opt {
|
||||
Some(&ast::MethodImplItem(ref ast_method)) => {
|
||||
encode_attributes(rbml_w, ast_method.attrs[]);
|
||||
encode_attributes(rbml_w, ast_method.attrs.index(&FullRange));
|
||||
let any_types = !pty.generics.types.is_empty();
|
||||
if any_types || is_default_impl || should_inline(ast_method.attrs[]) {
|
||||
if any_types || is_default_impl || should_inline(ast_method.attrs.index(&FullRange)) {
|
||||
encode_inlined_item(ecx, rbml_w, IIImplItemRef(local_def(parent_id),
|
||||
ast_item_opt.unwrap()));
|
||||
}
|
||||
|
@ -912,7 +912,7 @@ fn encode_info_for_associated_type(ecx: &EncodeContext,
|
|||
match typedef_opt {
|
||||
None => {}
|
||||
Some(typedef) => {
|
||||
encode_attributes(rbml_w, typedef.attrs[]);
|
||||
encode_attributes(rbml_w, typedef.attrs.index(&FullRange));
|
||||
encode_type(ecx, rbml_w, ty::node_id_to_type(ecx.tcx,
|
||||
typedef.id));
|
||||
}
|
||||
|
@ -1046,7 +1046,7 @@ fn encode_info_for_item(ecx: &EncodeContext,
|
|||
encode_path(rbml_w, path);
|
||||
encode_visibility(rbml_w, vis);
|
||||
encode_stability(rbml_w, stab);
|
||||
encode_attributes(rbml_w, item.attrs[]);
|
||||
encode_attributes(rbml_w, item.attrs.index(&FullRange));
|
||||
rbml_w.end_tag();
|
||||
}
|
||||
ast::ItemConst(_, _) => {
|
||||
|
@ -1072,8 +1072,8 @@ fn encode_info_for_item(ecx: &EncodeContext,
|
|||
encode_bounds_and_type(rbml_w, ecx, &lookup_item_type(tcx, def_id));
|
||||
encode_name(rbml_w, item.ident.name);
|
||||
encode_path(rbml_w, path);
|
||||
encode_attributes(rbml_w, item.attrs[]);
|
||||
if tps_len > 0u || should_inline(item.attrs[]) {
|
||||
encode_attributes(rbml_w, item.attrs.index(&FullRange));
|
||||
if tps_len > 0u || should_inline(item.attrs.index(&FullRange)) {
|
||||
encode_inlined_item(ecx, rbml_w, IIItemRef(item));
|
||||
}
|
||||
if tps_len == 0 {
|
||||
|
@ -1089,7 +1089,7 @@ fn encode_info_for_item(ecx: &EncodeContext,
|
|||
encode_info_for_mod(ecx,
|
||||
rbml_w,
|
||||
m,
|
||||
item.attrs[],
|
||||
item.attrs.index(&FullRange),
|
||||
item.id,
|
||||
path,
|
||||
item.ident,
|
||||
|
@ -1106,7 +1106,7 @@ fn encode_info_for_item(ecx: &EncodeContext,
|
|||
// Encode all the items in this module.
|
||||
for foreign_item in fm.items.iter() {
|
||||
rbml_w.start_tag(tag_mod_child);
|
||||
rbml_w.wr_str(def_to_string(local_def(foreign_item.id))[]);
|
||||
rbml_w.wr_str(def_to_string(local_def(foreign_item.id)).index(&FullRange));
|
||||
rbml_w.end_tag();
|
||||
}
|
||||
encode_visibility(rbml_w, vis);
|
||||
|
@ -1134,8 +1134,8 @@ fn encode_info_for_item(ecx: &EncodeContext,
|
|||
encode_item_variances(rbml_w, ecx, item.id);
|
||||
encode_bounds_and_type(rbml_w, ecx, &lookup_item_type(tcx, def_id));
|
||||
encode_name(rbml_w, item.ident.name);
|
||||
encode_attributes(rbml_w, item.attrs[]);
|
||||
encode_repr_attrs(rbml_w, ecx, item.attrs[]);
|
||||
encode_attributes(rbml_w, item.attrs.index(&FullRange));
|
||||
encode_repr_attrs(rbml_w, ecx, item.attrs.index(&FullRange));
|
||||
for v in (*enum_definition).variants.iter() {
|
||||
encode_variant_id(rbml_w, local_def(v.node.id));
|
||||
}
|
||||
|
@ -1152,7 +1152,7 @@ fn encode_info_for_item(ecx: &EncodeContext,
|
|||
encode_enum_variant_info(ecx,
|
||||
rbml_w,
|
||||
item.id,
|
||||
(*enum_definition).variants[],
|
||||
(*enum_definition).variants.index(&FullRange),
|
||||
index);
|
||||
}
|
||||
ast::ItemStruct(ref struct_def, _) => {
|
||||
|
@ -1164,7 +1164,7 @@ fn encode_info_for_item(ecx: &EncodeContext,
|
|||
class itself */
|
||||
let idx = encode_info_for_struct(ecx,
|
||||
rbml_w,
|
||||
fields[],
|
||||
fields.index(&FullRange),
|
||||
index);
|
||||
|
||||
/* Index the class*/
|
||||
|
@ -1178,16 +1178,16 @@ fn encode_info_for_item(ecx: &EncodeContext,
|
|||
|
||||
encode_item_variances(rbml_w, ecx, item.id);
|
||||
encode_name(rbml_w, item.ident.name);
|
||||
encode_attributes(rbml_w, item.attrs[]);
|
||||
encode_attributes(rbml_w, item.attrs.index(&FullRange));
|
||||
encode_path(rbml_w, path.clone());
|
||||
encode_stability(rbml_w, stab);
|
||||
encode_visibility(rbml_w, vis);
|
||||
encode_repr_attrs(rbml_w, ecx, item.attrs[]);
|
||||
encode_repr_attrs(rbml_w, ecx, item.attrs.index(&FullRange));
|
||||
|
||||
/* Encode def_ids for each field and method
|
||||
for methods, write all the stuff get_trait_method
|
||||
needs to know*/
|
||||
encode_struct_fields(rbml_w, fields[], def_id);
|
||||
encode_struct_fields(rbml_w, fields.index(&FullRange), def_id);
|
||||
|
||||
encode_inlined_item(ecx, rbml_w, IIItemRef(item));
|
||||
|
||||
|
@ -1219,7 +1219,7 @@ fn encode_info_for_item(ecx: &EncodeContext,
|
|||
encode_family(rbml_w, 'i');
|
||||
encode_bounds_and_type(rbml_w, ecx, &lookup_item_type(tcx, def_id));
|
||||
encode_name(rbml_w, item.ident.name);
|
||||
encode_attributes(rbml_w, item.attrs[]);
|
||||
encode_attributes(rbml_w, item.attrs.index(&FullRange));
|
||||
encode_unsafety(rbml_w, unsafety);
|
||||
encode_polarity(rbml_w, polarity);
|
||||
match ty.node {
|
||||
|
@ -1323,7 +1323,7 @@ fn encode_info_for_item(ecx: &EncodeContext,
|
|||
encode_generics(rbml_w, ecx, &trait_def.generics, tag_item_generics);
|
||||
encode_trait_ref(rbml_w, ecx, &*trait_def.trait_ref, tag_item_trait_ref);
|
||||
encode_name(rbml_w, item.ident.name);
|
||||
encode_attributes(rbml_w, item.attrs[]);
|
||||
encode_attributes(rbml_w, item.attrs.index(&FullRange));
|
||||
encode_visibility(rbml_w, vis);
|
||||
encode_stability(rbml_w, stab);
|
||||
for &method_def_id in ty::trait_item_def_ids(tcx, def_id).iter() {
|
||||
|
@ -1341,7 +1341,7 @@ fn encode_info_for_item(ecx: &EncodeContext,
|
|||
rbml_w.end_tag();
|
||||
|
||||
rbml_w.start_tag(tag_mod_child);
|
||||
rbml_w.wr_str(def_to_string(method_def_id.def_id())[]);
|
||||
rbml_w.wr_str(def_to_string(method_def_id.def_id()).index(&FullRange));
|
||||
rbml_w.end_tag();
|
||||
}
|
||||
encode_path(rbml_w, path.clone());
|
||||
|
@ -1433,14 +1433,14 @@ fn encode_info_for_item(ecx: &EncodeContext,
|
|||
};
|
||||
match trait_item {
|
||||
&ast::RequiredMethod(ref m) => {
|
||||
encode_attributes(rbml_w, m.attrs[]);
|
||||
encode_attributes(rbml_w, m.attrs.index(&FullRange));
|
||||
encode_trait_item(rbml_w);
|
||||
encode_item_sort(rbml_w, 'r');
|
||||
encode_method_argument_names(rbml_w, &*m.decl);
|
||||
}
|
||||
|
||||
&ast::ProvidedMethod(ref m) => {
|
||||
encode_attributes(rbml_w, m.attrs[]);
|
||||
encode_attributes(rbml_w, m.attrs.index(&FullRange));
|
||||
encode_trait_item(rbml_w);
|
||||
encode_item_sort(rbml_w, 'p');
|
||||
encode_inlined_item(ecx, rbml_w, IITraitItemRef(def_id, trait_item));
|
||||
|
@ -1449,7 +1449,7 @@ fn encode_info_for_item(ecx: &EncodeContext,
|
|||
|
||||
&ast::TypeTraitItem(ref associated_type) => {
|
||||
encode_attributes(rbml_w,
|
||||
associated_type.attrs[]);
|
||||
associated_type.attrs.index(&FullRange));
|
||||
encode_item_sort(rbml_w, 't');
|
||||
}
|
||||
}
|
||||
|
@ -1603,7 +1603,7 @@ fn encode_index<T, F>(rbml_w: &mut Encoder, index: Vec<entry<T>>, mut write_fn:
|
|||
let mut buckets: Vec<Vec<entry<T>>> = range(0, 256u16).map(|_| Vec::new()).collect();
|
||||
for elt in index.into_iter() {
|
||||
let h = hash::hash(&elt.val) as uint;
|
||||
buckets[h % 256].push(elt);
|
||||
(&mut buckets[h % 256]).push(elt);
|
||||
}
|
||||
|
||||
rbml_w.start_tag(tag_index);
|
||||
|
@ -1869,7 +1869,7 @@ fn encode_struct_field_attrs(rbml_w: &mut Encoder, krate: &ast::Crate) {
|
|||
fn visit_struct_field(&mut self, field: &ast::StructField) {
|
||||
self.rbml_w.start_tag(tag_struct_field);
|
||||
self.rbml_w.wr_tagged_u32(tag_struct_field_id, field.node.id);
|
||||
encode_attributes(self.rbml_w, field.node.attrs[]);
|
||||
encode_attributes(self.rbml_w, field.node.attrs.index(&FullRange));
|
||||
self.rbml_w.end_tag();
|
||||
}
|
||||
}
|
||||
|
@ -1941,13 +1941,13 @@ fn encode_misc_info(ecx: &EncodeContext,
|
|||
rbml_w.start_tag(tag_misc_info_crate_items);
|
||||
for item in krate.module.items.iter() {
|
||||
rbml_w.start_tag(tag_mod_child);
|
||||
rbml_w.wr_str(def_to_string(local_def(item.id))[]);
|
||||
rbml_w.wr_str(def_to_string(local_def(item.id)).index(&FullRange));
|
||||
rbml_w.end_tag();
|
||||
|
||||
each_auxiliary_node_id(&**item, |auxiliary_node_id| {
|
||||
rbml_w.start_tag(tag_mod_child);
|
||||
rbml_w.wr_str(def_to_string(local_def(
|
||||
auxiliary_node_id))[]);
|
||||
auxiliary_node_id)).index(&FullRange));
|
||||
rbml_w.end_tag();
|
||||
true
|
||||
});
|
||||
|
@ -2116,17 +2116,17 @@ fn encode_metadata_inner(wr: &mut SeekableMemWriter,
|
|||
|
||||
let mut rbml_w = writer::Encoder::new(wr);
|
||||
|
||||
encode_crate_name(&mut rbml_w, ecx.link_meta.crate_name[]);
|
||||
encode_crate_name(&mut rbml_w, ecx.link_meta.crate_name.index(&FullRange));
|
||||
encode_crate_triple(&mut rbml_w,
|
||||
tcx.sess
|
||||
.opts
|
||||
.target_triple
|
||||
[]);
|
||||
.index(&FullRange));
|
||||
encode_hash(&mut rbml_w, &ecx.link_meta.crate_hash);
|
||||
encode_dylib_dependency_formats(&mut rbml_w, &ecx);
|
||||
|
||||
let mut i = rbml_w.writer.tell().unwrap();
|
||||
encode_attributes(&mut rbml_w, krate.attrs[]);
|
||||
encode_attributes(&mut rbml_w, krate.attrs.index(&FullRange));
|
||||
stats.attr_bytes = rbml_w.writer.tell().unwrap() - i;
|
||||
|
||||
i = rbml_w.writer.tell().unwrap();
|
||||
|
|
|
@ -315,14 +315,14 @@ impl<'a> Context<'a> {
|
|||
&Some(ref r) => format!("{} which `{}` depends on",
|
||||
message, r.ident)
|
||||
};
|
||||
self.sess.span_err(self.span, message[]);
|
||||
self.sess.span_err(self.span, message.index(&FullRange));
|
||||
|
||||
if self.rejected_via_triple.len() > 0 {
|
||||
let mismatches = self.rejected_via_triple.iter();
|
||||
for (i, &CrateMismatch{ ref path, ref got }) in mismatches.enumerate() {
|
||||
self.sess.fileline_note(self.span,
|
||||
format!("crate `{}`, path #{}, triple {}: {}",
|
||||
self.ident, i+1, got, path.display())[]);
|
||||
self.ident, i+1, got, path.display()).index(&FullRange));
|
||||
}
|
||||
}
|
||||
if self.rejected_via_hash.len() > 0 {
|
||||
|
@ -332,7 +332,7 @@ impl<'a> Context<'a> {
|
|||
for (i, &CrateMismatch{ ref path, .. }) in mismatches.enumerate() {
|
||||
self.sess.fileline_note(self.span,
|
||||
format!("crate `{}` path {}{}: {}",
|
||||
self.ident, "#", i+1, path.display())[]);
|
||||
self.ident, "#", i+1, path.display()).index(&FullRange));
|
||||
}
|
||||
match self.root {
|
||||
&None => {}
|
||||
|
@ -340,7 +340,7 @@ impl<'a> Context<'a> {
|
|||
for (i, path) in r.paths().iter().enumerate() {
|
||||
self.sess.fileline_note(self.span,
|
||||
format!("crate `{}` path #{}: {}",
|
||||
r.ident, i+1, path.display())[]);
|
||||
r.ident, i+1, path.display()).index(&FullRange));
|
||||
}
|
||||
}
|
||||
}
|
||||
|
@ -386,7 +386,7 @@ impl<'a> Context<'a> {
|
|||
None => return FileDoesntMatch,
|
||||
Some(file) => file,
|
||||
};
|
||||
let (hash, rlib) = if file.starts_with(rlib_prefix[]) &&
|
||||
let (hash, rlib) = if file.starts_with(rlib_prefix.index(&FullRange)) &&
|
||||
file.ends_with(".rlib") {
|
||||
(file.slice(rlib_prefix.len(), file.len() - ".rlib".len()),
|
||||
true)
|
||||
|
@ -446,26 +446,26 @@ impl<'a> Context<'a> {
|
|||
_ => {
|
||||
self.sess.span_err(self.span,
|
||||
format!("multiple matching crates for `{}`",
|
||||
self.crate_name)[]);
|
||||
self.crate_name).index(&FullRange));
|
||||
self.sess.note("candidates:");
|
||||
for lib in libraries.iter() {
|
||||
match lib.dylib {
|
||||
Some(ref p) => {
|
||||
self.sess.note(format!("path: {}",
|
||||
p.display())[]);
|
||||
p.display()).index(&FullRange));
|
||||
}
|
||||
None => {}
|
||||
}
|
||||
match lib.rlib {
|
||||
Some(ref p) => {
|
||||
self.sess.note(format!("path: {}",
|
||||
p.display())[]);
|
||||
p.display()).index(&FullRange));
|
||||
}
|
||||
None => {}
|
||||
}
|
||||
let data = lib.metadata.as_slice();
|
||||
let name = decoder::get_crate_name(data);
|
||||
note_crate_name(self.sess.diagnostic(), name[]);
|
||||
note_crate_name(self.sess.diagnostic(), name.index(&FullRange));
|
||||
}
|
||||
None
|
||||
}
|
||||
|
@ -519,11 +519,11 @@ impl<'a> Context<'a> {
|
|||
format!("multiple {} candidates for `{}` \
|
||||
found",
|
||||
flavor,
|
||||
self.crate_name)[]);
|
||||
self.crate_name).index(&FullRange));
|
||||
self.sess.span_note(self.span,
|
||||
format!(r"candidate #1: {}",
|
||||
ret.as_ref().unwrap()
|
||||
.display())[]);
|
||||
.display()).index(&FullRange));
|
||||
error = 1;
|
||||
ret = None;
|
||||
}
|
||||
|
@ -531,7 +531,7 @@ impl<'a> Context<'a> {
|
|||
error += 1;
|
||||
self.sess.span_note(self.span,
|
||||
format!(r"candidate #{}: {}", error,
|
||||
lib.display())[]);
|
||||
lib.display()).index(&FullRange));
|
||||
continue
|
||||
}
|
||||
*slot = Some(metadata);
|
||||
|
@ -606,17 +606,17 @@ impl<'a> Context<'a> {
|
|||
let mut rlibs = HashSet::new();
|
||||
let mut dylibs = HashSet::new();
|
||||
{
|
||||
let mut locs = locs.iter().map(|l| Path::new(l[])).filter(|loc| {
|
||||
let mut locs = locs.iter().map(|l| Path::new(l.index(&FullRange))).filter(|loc| {
|
||||
if !loc.exists() {
|
||||
sess.err(format!("extern location for {} does not exist: {}",
|
||||
self.crate_name, loc.display())[]);
|
||||
self.crate_name, loc.display()).index(&FullRange));
|
||||
return false;
|
||||
}
|
||||
let file = match loc.filename_str() {
|
||||
Some(file) => file,
|
||||
None => {
|
||||
sess.err(format!("extern location for {} is not a file: {}",
|
||||
self.crate_name, loc.display())[]);
|
||||
self.crate_name, loc.display()).index(&FullRange));
|
||||
return false;
|
||||
}
|
||||
};
|
||||
|
@ -624,12 +624,12 @@ impl<'a> Context<'a> {
|
|||
return true
|
||||
} else {
|
||||
let (ref prefix, ref suffix) = dylibname;
|
||||
if file.starts_with(prefix[]) && file.ends_with(suffix[]) {
|
||||
if file.starts_with(prefix.index(&FullRange)) && file.ends_with(suffix.index(&FullRange)) {
|
||||
return true
|
||||
}
|
||||
}
|
||||
sess.err(format!("extern location for {} is of an unknown type: {}",
|
||||
self.crate_name, loc.display())[]);
|
||||
self.crate_name, loc.display()).index(&FullRange));
|
||||
false
|
||||
});
|
||||
|
||||
|
@ -662,7 +662,7 @@ impl<'a> Context<'a> {
|
|||
}
|
||||
|
||||
pub fn note_crate_name(diag: &SpanHandler, name: &str) {
|
||||
diag.handler().note(format!("crate name: {}", name)[]);
|
||||
diag.handler().note(format!("crate name: {}", name).index(&FullRange));
|
||||
}
|
||||
|
||||
impl ArchiveMetadata {
|
||||
|
|
|
@ -98,7 +98,7 @@ fn scan<R, F, G>(st: &mut PState, mut is_last: F, op: G) -> R where
|
|||
}
|
||||
let end_pos = st.pos;
|
||||
st.pos += 1;
|
||||
return op(st.data[start_pos..end_pos]);
|
||||
return op(st.data.index(&(start_pos..end_pos)));
|
||||
}
|
||||
|
||||
pub fn parse_ident(st: &mut PState, last: char) -> ast::Ident {
|
||||
|
@ -251,7 +251,7 @@ fn parse_trait_store_<F>(st: &mut PState, conv: &mut F) -> ty::TraitStore where
|
|||
'&' => ty::RegionTraitStore(parse_region_(st, conv), parse_mutability(st)),
|
||||
c => {
|
||||
st.tcx.sess.bug(format!("parse_trait_store(): bad input '{}'",
|
||||
c)[])
|
||||
c).index(&FullRange))
|
||||
}
|
||||
}
|
||||
}
|
||||
|
@ -318,7 +318,7 @@ fn parse_bound_region_<F>(st: &mut PState, conv: &mut F) -> ty::BoundRegion wher
|
|||
}
|
||||
'[' => {
|
||||
let def = parse_def_(st, RegionParameter, conv);
|
||||
let ident = token::str_to_ident(parse_str(st, ']')[]);
|
||||
let ident = token::str_to_ident(parse_str(st, ']').index(&FullRange));
|
||||
ty::BrNamed(def, ident.name)
|
||||
}
|
||||
'f' => {
|
||||
|
@ -357,7 +357,7 @@ fn parse_region_<F>(st: &mut PState, conv: &mut F) -> ty::Region where
|
|||
assert_eq!(next(st), '|');
|
||||
let index = parse_u32(st);
|
||||
assert_eq!(next(st), '|');
|
||||
let nm = token::str_to_ident(parse_str(st, ']')[]);
|
||||
let nm = token::str_to_ident(parse_str(st, ']').index(&FullRange));
|
||||
ty::ReEarlyBound(node_id, space, index, nm.name)
|
||||
}
|
||||
'f' => {
|
||||
|
@ -481,7 +481,7 @@ fn parse_ty_<'a, 'tcx, F>(st: &mut PState<'a, 'tcx>, conv: &mut F) -> Ty<'tcx> w
|
|||
assert_eq!(next(st), '|');
|
||||
let space = parse_param_space(st);
|
||||
assert_eq!(next(st), '|');
|
||||
let name = token::intern(parse_str(st, ']')[]);
|
||||
let name = token::intern(parse_str(st, ']').index(&FullRange));
|
||||
return ty::mk_param(tcx, space, index, name);
|
||||
}
|
||||
'~' => return ty::mk_uniq(tcx, parse_ty_(st, conv)),
|
||||
|
@ -637,7 +637,7 @@ fn parse_abi_set(st: &mut PState) -> abi::Abi {
|
|||
assert_eq!(next(st), '[');
|
||||
scan(st, |c| c == ']', |bytes| {
|
||||
let abi_str = str::from_utf8(bytes).unwrap();
|
||||
abi::lookup(abi_str[]).expect(abi_str)
|
||||
abi::lookup(abi_str.index(&FullRange)).expect(abi_str)
|
||||
})
|
||||
}
|
||||
|
||||
|
@ -733,8 +733,8 @@ pub fn parse_def_id(buf: &[u8]) -> ast::DefId {
|
|||
panic!();
|
||||
}
|
||||
|
||||
let crate_part = buf[0u..colon_idx];
|
||||
let def_part = buf[colon_idx + 1u..len];
|
||||
let crate_part = buf.index(&(0u..colon_idx));
|
||||
let def_part = buf.index(&((colon_idx + 1u)..len));
|
||||
|
||||
let crate_num = match str::from_utf8(crate_part).ok().and_then(|s| s.parse::<uint>()) {
|
||||
Some(cn) => cn as ast::CrateNum,
|
||||
|
|
|
@ -48,7 +48,7 @@ pub fn ast_ty_to_prim_ty<'tcx>(tcx: &ty::ctxt<'tcx>, ast_ty: &ast::Ty)
|
|||
None => {
|
||||
tcx.sess.span_bug(ast_ty.span,
|
||||
format!("unbound path {}",
|
||||
path.repr(tcx))[])
|
||||
path.repr(tcx)).index(&FullRange))
|
||||
}
|
||||
Some(&d) => d
|
||||
};
|
||||
|
|
|
@ -132,7 +132,7 @@ pub fn decode_inlined_item<'tcx>(cdata: &cstore::crate_metadata,
|
|||
// Do an Option dance to use the path after it is moved below.
|
||||
let s = ast_map::path_to_string(ast_map::Values(path.iter()));
|
||||
path_as_str = Some(s);
|
||||
path_as_str.as_ref().map(|x| x[])
|
||||
path_as_str.as_ref().map(|x| x.index(&FullRange))
|
||||
});
|
||||
let mut ast_dsr = reader::Decoder::new(ast_doc);
|
||||
let from_id_range = Decodable::decode(&mut ast_dsr).unwrap();
|
||||
|
@ -1900,7 +1900,7 @@ fn decode_side_tables(dcx: &DecodeContext,
|
|||
None => {
|
||||
dcx.tcx.sess.bug(
|
||||
format!("unknown tag found in side tables: {:x}",
|
||||
tag)[]);
|
||||
tag).index(&FullRange));
|
||||
}
|
||||
Some(value) => {
|
||||
let val_doc = entry_doc.get(c::tag_table_val as uint);
|
||||
|
@ -1985,7 +1985,7 @@ fn decode_side_tables(dcx: &DecodeContext,
|
|||
_ => {
|
||||
dcx.tcx.sess.bug(
|
||||
format!("unknown tag found in side tables: {:x}",
|
||||
tag)[]);
|
||||
tag).index(&FullRange));
|
||||
}
|
||||
}
|
||||
}
|
||||
|
|
|
@ -362,7 +362,7 @@ impl<'a, 'tcx> CFGBuilder<'a, 'tcx> {
|
|||
let mut cond_exit = discr_exit;
|
||||
for arm in arms.iter() {
|
||||
cond_exit = self.add_dummy_node(&[cond_exit]); // 2
|
||||
let pats_exit = self.pats_any(arm.pats[],
|
||||
let pats_exit = self.pats_any(arm.pats.index(&FullRange),
|
||||
cond_exit); // 3
|
||||
let guard_exit = self.opt_expr(&arm.guard,
|
||||
pats_exit); // 4
|
||||
|
@ -616,14 +616,14 @@ impl<'a, 'tcx> CFGBuilder<'a, 'tcx> {
|
|||
self.tcx.sess.span_bug(
|
||||
expr.span,
|
||||
format!("no loop scope for id {}",
|
||||
loop_id)[]);
|
||||
loop_id).index(&FullRange));
|
||||
}
|
||||
|
||||
r => {
|
||||
self.tcx.sess.span_bug(
|
||||
expr.span,
|
||||
format!("bad entry `{}` in def_map for label",
|
||||
r)[]);
|
||||
r).index(&FullRange));
|
||||
}
|
||||
}
|
||||
}
|
||||
|
|
|
@ -52,7 +52,7 @@ fn replace_newline_with_backslash_l(s: String) -> String {
|
|||
}
|
||||
|
||||
impl<'a, 'ast> dot::Labeller<'a, Node<'a>, Edge<'a>> for LabelledCFG<'a, 'ast> {
|
||||
fn graph_id(&'a self) -> dot::Id<'a> { dot::Id::new(self.name[]).unwrap() }
|
||||
fn graph_id(&'a self) -> dot::Id<'a> { dot::Id::new(self.name.index(&FullRange)).unwrap() }
|
||||
|
||||
fn node_id(&'a self, &(i,_): &Node<'a>) -> dot::Id<'a> {
|
||||
dot::Id::new(format!("N{}", i.node_id())).unwrap()
|
||||
|
@ -85,7 +85,7 @@ impl<'a, 'ast> dot::Labeller<'a, Node<'a>, Edge<'a>> for LabelledCFG<'a, 'ast> {
|
|||
let s = self.ast_map.node_to_string(node_id);
|
||||
// left-aligns the lines
|
||||
let s = replace_newline_with_backslash_l(s);
|
||||
label.push_str(format!("exiting scope_{} {}", i, s[])[]);
|
||||
label.push_str(format!("exiting scope_{} {}", i, s.index(&FullRange)).index(&FullRange));
|
||||
}
|
||||
dot::LabelText::EscStr(label.into_cow())
|
||||
}
|
||||
|
|
|
@ -74,11 +74,11 @@ impl<'a> CheckLoopVisitor<'a> {
|
|||
Loop => {}
|
||||
Closure => {
|
||||
self.sess.span_err(span,
|
||||
format!("`{}` inside of a closure", name)[]);
|
||||
format!("`{}` inside of a closure", name).index(&FullRange));
|
||||
}
|
||||
Normal => {
|
||||
self.sess.span_err(span,
|
||||
format!("`{}` outside of loop", name)[]);
|
||||
format!("`{}` outside of loop", name).index(&FullRange));
|
||||
}
|
||||
}
|
||||
}
|
||||
|
|
|
@ -47,7 +47,7 @@ struct Matrix<'a>(Vec<Vec<&'a Pat>>);
|
|||
|
||||
/// Pretty-printer for matrices of patterns, example:
|
||||
/// ++++++++++++++++++++++++++
|
||||
/// + _ + [] +
|
||||
/// + _ + .index(&FullRange) +
|
||||
/// ++++++++++++++++++++++++++
|
||||
/// + true + [First] +
|
||||
/// ++++++++++++++++++++++++++
|
||||
|
@ -161,7 +161,7 @@ fn check_expr(cx: &mut MatchCheckCtxt, ex: &ast::Expr) {
|
|||
// First, check legality of move bindings.
|
||||
check_legality_of_move_bindings(cx,
|
||||
arm.guard.is_some(),
|
||||
arm.pats[]);
|
||||
arm.pats.index(&FullRange));
|
||||
|
||||
// Second, if there is a guard on each arm, make sure it isn't
|
||||
// assigning or borrowing anything mutably.
|
||||
|
@ -198,7 +198,7 @@ fn check_expr(cx: &mut MatchCheckCtxt, ex: &ast::Expr) {
|
|||
}
|
||||
|
||||
// Fourth, check for unreachable arms.
|
||||
check_arms(cx, inlined_arms[], source);
|
||||
check_arms(cx, inlined_arms.index(&FullRange), source);
|
||||
|
||||
// Finally, check if the whole match expression is exhaustive.
|
||||
// Check for empty enum, because is_useful only works on inhabited types.
|
||||
|
@ -230,7 +230,7 @@ fn check_expr(cx: &mut MatchCheckCtxt, ex: &ast::Expr) {
|
|||
pat.span,
|
||||
format!("refutable pattern in `for` loop binding: \
|
||||
`{}` not covered",
|
||||
pat_to_string(uncovered_pat))[]);
|
||||
pat_to_string(uncovered_pat)).index(&FullRange));
|
||||
});
|
||||
|
||||
// Check legality of move bindings.
|
||||
|
@ -303,7 +303,7 @@ fn check_arms(cx: &MatchCheckCtxt,
|
|||
for pat in pats.iter() {
|
||||
let v = vec![&**pat];
|
||||
|
||||
match is_useful(cx, &seen, v[], LeaveOutWitness) {
|
||||
match is_useful(cx, &seen, v.index(&FullRange), LeaveOutWitness) {
|
||||
NotUseful => {
|
||||
match source {
|
||||
ast::MatchSource::IfLetDesugar { .. } => {
|
||||
|
@ -355,7 +355,7 @@ fn raw_pat<'a>(p: &'a Pat) -> &'a Pat {
|
|||
fn check_exhaustive(cx: &MatchCheckCtxt, sp: Span, matrix: &Matrix) {
|
||||
match is_useful(cx, matrix, &[DUMMY_WILD_PAT], ConstructWitness) {
|
||||
UsefulWithWitness(pats) => {
|
||||
let witness = match pats[] {
|
||||
let witness = match pats.index(&FullRange) {
|
||||
[ref witness] => &**witness,
|
||||
[] => DUMMY_WILD_PAT,
|
||||
_ => unreachable!()
|
||||
|
@ -609,7 +609,7 @@ fn is_useful(cx: &MatchCheckCtxt,
|
|||
UsefulWithWitness(pats) => UsefulWithWitness({
|
||||
let arity = constructor_arity(cx, &c, left_ty);
|
||||
let mut result = {
|
||||
let pat_slice = pats[];
|
||||
let pat_slice = pats.index(&FullRange);
|
||||
let subpats: Vec<_> = range(0, arity).map(|i| {
|
||||
pat_slice.get(i).map_or(DUMMY_WILD_PAT, |p| &**p)
|
||||
}).collect();
|
||||
|
@ -656,10 +656,10 @@ fn is_useful_specialized(cx: &MatchCheckCtxt, &Matrix(ref m): &Matrix,
|
|||
witness: WitnessPreference) -> Usefulness {
|
||||
let arity = constructor_arity(cx, &ctor, lty);
|
||||
let matrix = Matrix(m.iter().filter_map(|r| {
|
||||
specialize(cx, r[], &ctor, 0u, arity)
|
||||
specialize(cx, r.index(&FullRange), &ctor, 0u, arity)
|
||||
}).collect());
|
||||
match specialize(cx, v, &ctor, 0u, arity) {
|
||||
Some(v) => is_useful(cx, &matrix, v[], witness),
|
||||
Some(v) => is_useful(cx, &matrix, v.index(&FullRange), witness),
|
||||
None => NotUseful
|
||||
}
|
||||
}
|
||||
|
@ -729,7 +729,7 @@ fn pat_constructors(cx: &MatchCheckCtxt, p: &Pat,
|
|||
/// This computes the arity of a constructor. The arity of a constructor
|
||||
/// is how many subpattern patterns of that constructor should be expanded to.
|
||||
///
|
||||
/// For instance, a tuple pattern (_, 42u, Some([])) has the arity of 3.
|
||||
/// For instance, a tuple pattern (_, 42u, Some(.index(&FullRange))) has the arity of 3.
|
||||
/// A struct pattern's arity is the number of fields it contains, etc.
|
||||
pub fn constructor_arity(cx: &MatchCheckCtxt, ctor: &Constructor, ty: Ty) -> uint {
|
||||
match ty.sty {
|
||||
|
@ -926,8 +926,8 @@ pub fn specialize<'a>(cx: &MatchCheckCtxt, r: &[&'a Pat],
|
|||
}
|
||||
};
|
||||
head.map(|mut head| {
|
||||
head.push_all(r[..col]);
|
||||
head.push_all(r[col + 1..]);
|
||||
head.push_all(r.index(&(0..col)));
|
||||
head.push_all(r.index(&((col + 1)..)));
|
||||
head
|
||||
})
|
||||
}
|
||||
|
@ -1044,7 +1044,7 @@ fn check_legality_of_move_bindings(cx: &MatchCheckCtxt,
|
|||
format!("binding pattern {} is not an \
|
||||
identifier: {}",
|
||||
p.id,
|
||||
p.node)[]);
|
||||
p.node).index(&FullRange));
|
||||
}
|
||||
}
|
||||
}
|
||||
|
|
|
@ -112,7 +112,7 @@ impl<'a, 'tcx> CheckStaticVisitor<'a, 'tcx> {
|
|||
};
|
||||
|
||||
self.tcx.sess.span_err(e.span, format!("mutable statics are not allowed \
|
||||
to have {}", suffix)[]);
|
||||
to have {}", suffix).index(&FullRange));
|
||||
}
|
||||
|
||||
fn check_static_type(&self, e: &ast::Expr) {
|
||||
|
@ -170,7 +170,7 @@ impl<'a, 'tcx, 'v> Visitor<'v> for CheckStaticVisitor<'a, 'tcx> {
|
|||
ty::ty_enum(did, _) if ty::has_dtor(self.tcx, did) => {
|
||||
self.tcx.sess.span_err(e.span,
|
||||
format!("{} are not allowed to have \
|
||||
destructors", self.msg())[])
|
||||
destructors", self.msg()).index(&FullRange))
|
||||
}
|
||||
_ => {}
|
||||
}
|
||||
|
@ -234,7 +234,7 @@ impl<'a, 'tcx, 'v> Visitor<'v> for CheckStaticVisitor<'a, 'tcx> {
|
|||
let msg = "constants cannot refer to other statics, \
|
||||
insert an intermediate constant \
|
||||
instead";
|
||||
self.tcx.sess.span_err(e.span, msg[]);
|
||||
self.tcx.sess.span_err(e.span, msg.index(&FullRange));
|
||||
}
|
||||
_ => {}
|
||||
}
|
||||
|
|
|
@ -105,7 +105,7 @@ impl<'a, 'ast, 'v> Visitor<'v> for CheckItemRecursionVisitor<'a, 'ast> {
|
|||
_ => {
|
||||
self.sess.span_err(e.span,
|
||||
format!("expected item, found {}",
|
||||
self.ast_map.node_to_string(def_id.node))[]);
|
||||
self.ast_map.node_to_string(def_id.node)).index(&FullRange));
|
||||
return;
|
||||
},
|
||||
}
|
||||
|
|
|
@ -48,7 +48,7 @@ use std::rc::Rc;
|
|||
// target uses". This _includes_ integer-constants, plus the following
|
||||
// constructors:
|
||||
//
|
||||
// fixed-size vectors and strings: [] and ""/_
|
||||
// fixed-size vectors and strings: .index(&FullRange) and ""/_
|
||||
// vector and string slices: &[] and &""
|
||||
// tuples: (,)
|
||||
// enums: foo(...)
|
||||
|
@ -117,7 +117,7 @@ fn lookup_variant_by_id<'a>(tcx: &'a ty::ctxt,
|
|||
None => None,
|
||||
Some(ast_map::NodeItem(it)) => match it.node {
|
||||
ast::ItemEnum(ast::EnumDef { ref variants }, _) => {
|
||||
variant_expr(variants[], variant_def.node)
|
||||
variant_expr(variants.index(&FullRange), variant_def.node)
|
||||
}
|
||||
_ => None
|
||||
},
|
||||
|
@ -138,7 +138,7 @@ fn lookup_variant_by_id<'a>(tcx: &'a ty::ctxt,
|
|||
// NOTE this doesn't do the right thing, it compares inlined
|
||||
// NodeId's to the original variant_def's NodeId, but they
|
||||
// come from different crates, so they will likely never match.
|
||||
variant_expr(variants[], variant_def.node).map(|e| e.id)
|
||||
variant_expr(variants.index(&FullRange), variant_def.node).map(|e| e.id)
|
||||
}
|
||||
_ => None
|
||||
},
|
||||
|
@ -364,7 +364,7 @@ pub fn const_expr_to_pat(tcx: &ty::ctxt, expr: &Expr) -> P<ast::Pat> {
|
|||
pub fn eval_const_expr(tcx: &ty::ctxt, e: &Expr) -> const_val {
|
||||
match eval_const_expr_partial(tcx, e) {
|
||||
Ok(r) => r,
|
||||
Err(s) => tcx.sess.span_fatal(e.span, s[])
|
||||
Err(s) => tcx.sess.span_fatal(e.span, s.index(&FullRange))
|
||||
}
|
||||
}
|
||||
|
||||
|
|
|
@ -312,7 +312,7 @@ impl<'a, 'tcx, O:DataFlowOperator> DataFlowContext<'a, 'tcx, O> {
|
|||
let mut t = on_entry.to_vec();
|
||||
self.apply_gen_kill(cfgidx, t.as_mut_slice());
|
||||
temp_bits = t;
|
||||
temp_bits[]
|
||||
temp_bits.index(&FullRange)
|
||||
}
|
||||
};
|
||||
debug!("{} each_bit_for_node({}, cfgidx={}) bits={}",
|
||||
|
@ -421,7 +421,7 @@ impl<'a, 'tcx, O:DataFlowOperator> DataFlowContext<'a, 'tcx, O> {
|
|||
let bits = self.kills.slice_mut(start, end);
|
||||
debug!("{} add_kills_from_flow_exits flow_exit={} bits={} [before]",
|
||||
self.analysis_name, flow_exit, mut_bits_to_string(bits));
|
||||
bits.clone_from_slice(orig_kills[]);
|
||||
bits.clone_from_slice(orig_kills.index(&FullRange));
|
||||
debug!("{} add_kills_from_flow_exits flow_exit={} bits={} [after]",
|
||||
self.analysis_name, flow_exit, mut_bits_to_string(bits));
|
||||
}
|
||||
|
@ -554,7 +554,7 @@ fn bits_to_string(words: &[uint]) -> String {
|
|||
let mut v = word;
|
||||
for _ in range(0u, uint::BYTES) {
|
||||
result.push(sep);
|
||||
result.push_str(format!("{:02x}", v & 0xFF)[]);
|
||||
result.push_str(format!("{:02x}", v & 0xFF).index(&FullRange));
|
||||
v >>= 8;
|
||||
sep = '-';
|
||||
}
|
||||
|
|
|
@ -118,7 +118,7 @@ fn calculate_type(sess: &session::Session,
|
|||
let src = sess.cstore.get_used_crate_source(cnum).unwrap();
|
||||
if src.rlib.is_some() { return }
|
||||
sess.err(format!("dependency `{}` not found in rlib format",
|
||||
data.name)[]);
|
||||
data.name).index(&FullRange));
|
||||
});
|
||||
return Vec::new();
|
||||
}
|
||||
|
@ -197,7 +197,7 @@ fn calculate_type(sess: &session::Session,
|
|||
match kind {
|
||||
cstore::RequireStatic => "rlib",
|
||||
cstore::RequireDynamic => "dylib",
|
||||
})[]);
|
||||
}).index(&FullRange));
|
||||
}
|
||||
}
|
||||
}
|
||||
|
@ -222,7 +222,7 @@ fn add_library(sess: &session::Session,
|
|||
let data = sess.cstore.get_crate_data(cnum);
|
||||
sess.err(format!("cannot satisfy dependencies so `{}` only \
|
||||
shows up once",
|
||||
data.name)[]);
|
||||
data.name).index(&FullRange));
|
||||
sess.help("having upstream crates all available in one format \
|
||||
will likely make this go away");
|
||||
}
|
||||
|
|
|
@ -869,7 +869,7 @@ impl<'d,'t,'tcx,TYPER:mc::Typer<'tcx>> ExprUseVisitor<'d,'t,'tcx,TYPER> {
|
|||
ty::ty_rptr(r, ref m) => (m.mutbl, r),
|
||||
_ => self.tcx().sess.span_bug(expr.span,
|
||||
format!("bad overloaded deref type {}",
|
||||
method_ty.repr(self.tcx()))[])
|
||||
method_ty.repr(self.tcx())).index(&FullRange))
|
||||
};
|
||||
let bk = ty::BorrowKind::from_mutbl(m);
|
||||
self.delegate.borrow(expr.id, expr.span, cmt,
|
||||
|
@ -1191,7 +1191,7 @@ impl<'d,'t,'tcx,TYPER:mc::Typer<'tcx>> ExprUseVisitor<'d,'t,'tcx,TYPER> {
|
|||
let msg = format!("Pattern has unexpected def: {} and type {}",
|
||||
def,
|
||||
cmt_pat.ty.repr(tcx));
|
||||
tcx.sess.span_bug(pat.span, msg[])
|
||||
tcx.sess.span_bug(pat.span, msg.index(&FullRange))
|
||||
}
|
||||
}
|
||||
}
|
||||
|
|
|
@ -142,7 +142,7 @@ pub trait Combine<'tcx> : Sized {
|
|||
for _ in a_regions.iter() {
|
||||
invariance.push(ty::Invariant);
|
||||
}
|
||||
invariance[]
|
||||
invariance.index(&FullRange)
|
||||
}
|
||||
};
|
||||
|
||||
|
@ -480,7 +480,7 @@ pub fn super_tys<'tcx, C: Combine<'tcx>>(this: &C,
|
|||
format!("{}: bot and var types should have been handled ({},{})",
|
||||
this.tag(),
|
||||
a.repr(this.infcx().tcx),
|
||||
b.repr(this.infcx().tcx))[]);
|
||||
b.repr(this.infcx().tcx)).index(&FullRange));
|
||||
}
|
||||
|
||||
(&ty::ty_err, _) | (_, &ty::ty_err) => {
|
||||
|
@ -856,7 +856,7 @@ impl<'cx, 'tcx> ty_fold::TypeFolder<'tcx> for Generalizer<'cx, 'tcx> {
|
|||
self.tcx().sess.span_bug(
|
||||
self.span,
|
||||
format!("Encountered early bound region when generalizing: {}",
|
||||
r.repr(self.tcx()))[]);
|
||||
r.repr(self.tcx())).index(&FullRange));
|
||||
}
|
||||
|
||||
// Always make a fresh region variable for skolemized regions;
|
||||
|
|
|
@ -200,9 +200,9 @@ impl<'a, 'tcx> ErrorReporting<'tcx> for InferCtxt<'a, 'tcx> {
|
|||
ref trace_origins,
|
||||
ref same_regions) => {
|
||||
if !same_regions.is_empty() {
|
||||
self.report_processed_errors(var_origins[],
|
||||
trace_origins[],
|
||||
same_regions[]);
|
||||
self.report_processed_errors(var_origins.index(&FullRange),
|
||||
trace_origins.index(&FullRange),
|
||||
same_regions.index(&FullRange));
|
||||
}
|
||||
}
|
||||
}
|
||||
|
@ -376,7 +376,7 @@ impl<'a, 'tcx> ErrorReporting<'tcx> for InferCtxt<'a, 'tcx> {
|
|||
format!("{}: {} ({})",
|
||||
message_root_str,
|
||||
expected_found_str,
|
||||
ty::type_err_to_str(self.tcx, terr))[]);
|
||||
ty::type_err_to_str(self.tcx, terr)).index(&FullRange));
|
||||
|
||||
match trace.origin {
|
||||
infer::MatchExpressionArm(_, arm_span) =>
|
||||
|
@ -445,25 +445,25 @@ impl<'a, 'tcx> ErrorReporting<'tcx> for InferCtxt<'a, 'tcx> {
|
|||
// Does the required lifetime have a nice name we can print?
|
||||
self.tcx.sess.span_err(
|
||||
origin.span(),
|
||||
format!("{} may not live long enough", labeled_user_string)[]);
|
||||
format!("{} may not live long enough", labeled_user_string).index(&FullRange));
|
||||
self.tcx.sess.span_help(
|
||||
origin.span(),
|
||||
format!(
|
||||
"consider adding an explicit lifetime bound `{}: {}`...",
|
||||
bound_kind.user_string(self.tcx),
|
||||
sub.user_string(self.tcx))[]);
|
||||
sub.user_string(self.tcx)).index(&FullRange));
|
||||
}
|
||||
|
||||
ty::ReStatic => {
|
||||
// Does the required lifetime have a nice name we can print?
|
||||
self.tcx.sess.span_err(
|
||||
origin.span(),
|
||||
format!("{} may not live long enough", labeled_user_string)[]);
|
||||
format!("{} may not live long enough", labeled_user_string).index(&FullRange));
|
||||
self.tcx.sess.span_help(
|
||||
origin.span(),
|
||||
format!(
|
||||
"consider adding an explicit lifetime bound `{}: 'static`...",
|
||||
bound_kind.user_string(self.tcx))[]);
|
||||
bound_kind.user_string(self.tcx)).index(&FullRange));
|
||||
}
|
||||
|
||||
_ => {
|
||||
|
@ -472,15 +472,15 @@ impl<'a, 'tcx> ErrorReporting<'tcx> for InferCtxt<'a, 'tcx> {
|
|||
origin.span(),
|
||||
format!(
|
||||
"{} may not live long enough",
|
||||
labeled_user_string)[]);
|
||||
labeled_user_string).index(&FullRange));
|
||||
self.tcx.sess.span_help(
|
||||
origin.span(),
|
||||
format!(
|
||||
"consider adding an explicit lifetime bound for `{}`",
|
||||
bound_kind.user_string(self.tcx))[]);
|
||||
bound_kind.user_string(self.tcx)).index(&FullRange));
|
||||
note_and_explain_region(
|
||||
self.tcx,
|
||||
format!("{} must be valid for ", labeled_user_string)[],
|
||||
format!("{} must be valid for ", labeled_user_string).index(&FullRange),
|
||||
sub,
|
||||
"...");
|
||||
}
|
||||
|
@ -522,7 +522,7 @@ impl<'a, 'tcx> ErrorReporting<'tcx> for InferCtxt<'a, 'tcx> {
|
|||
ty::local_var_name_str(self.tcx,
|
||||
upvar_id.var_id)
|
||||
.get()
|
||||
.to_string())[]);
|
||||
.to_string()).index(&FullRange));
|
||||
note_and_explain_region(
|
||||
self.tcx,
|
||||
"...the borrowed pointer is valid for ",
|
||||
|
@ -534,7 +534,7 @@ impl<'a, 'tcx> ErrorReporting<'tcx> for InferCtxt<'a, 'tcx> {
|
|||
ty::local_var_name_str(self.tcx,
|
||||
upvar_id.var_id)
|
||||
.get()
|
||||
.to_string())[],
|
||||
.to_string()).index(&FullRange),
|
||||
sup,
|
||||
"");
|
||||
}
|
||||
|
@ -580,7 +580,7 @@ impl<'a, 'tcx> ErrorReporting<'tcx> for InferCtxt<'a, 'tcx> {
|
|||
outlive the enclosing closure",
|
||||
ty::local_var_name_str(self.tcx,
|
||||
id).get()
|
||||
.to_string())[]);
|
||||
.to_string()).index(&FullRange));
|
||||
note_and_explain_region(
|
||||
self.tcx,
|
||||
"captured variable is valid for ",
|
||||
|
@ -622,7 +622,7 @@ impl<'a, 'tcx> ErrorReporting<'tcx> for InferCtxt<'a, 'tcx> {
|
|||
span,
|
||||
format!("the type `{}` does not fulfill the \
|
||||
required lifetime",
|
||||
self.ty_to_string(ty))[]);
|
||||
self.ty_to_string(ty)).index(&FullRange));
|
||||
note_and_explain_region(self.tcx,
|
||||
"type must outlive ",
|
||||
sub,
|
||||
|
@ -648,7 +648,7 @@ impl<'a, 'tcx> ErrorReporting<'tcx> for InferCtxt<'a, 'tcx> {
|
|||
span,
|
||||
format!("the type `{}` (provided as the value of \
|
||||
a type parameter) is not valid at this point",
|
||||
self.ty_to_string(ty))[]);
|
||||
self.ty_to_string(ty)).index(&FullRange));
|
||||
note_and_explain_region(self.tcx,
|
||||
"type must outlive ",
|
||||
sub,
|
||||
|
@ -714,7 +714,7 @@ impl<'a, 'tcx> ErrorReporting<'tcx> for InferCtxt<'a, 'tcx> {
|
|||
span,
|
||||
format!("type of expression contains references \
|
||||
that are not valid during the expression: `{}`",
|
||||
self.ty_to_string(t))[]);
|
||||
self.ty_to_string(t)).index(&FullRange));
|
||||
note_and_explain_region(
|
||||
self.tcx,
|
||||
"type is only valid for ",
|
||||
|
@ -736,7 +736,7 @@ impl<'a, 'tcx> ErrorReporting<'tcx> for InferCtxt<'a, 'tcx> {
|
|||
span,
|
||||
format!("in type `{}`, reference has a longer lifetime \
|
||||
than the data it references",
|
||||
self.ty_to_string(ty))[]);
|
||||
self.ty_to_string(ty)).index(&FullRange));
|
||||
note_and_explain_region(
|
||||
self.tcx,
|
||||
"the pointer is valid for ",
|
||||
|
@ -861,7 +861,7 @@ impl<'a, 'tcx> ErrorReporting<'tcx> for InferCtxt<'a, 'tcx> {
|
|||
let (fn_decl, generics, unsafety, ident, expl_self, span)
|
||||
= node_inner.expect("expect item fn");
|
||||
let taken = lifetimes_in_scope(self.tcx, scope_id);
|
||||
let life_giver = LifeGiver::with_taken(taken[]);
|
||||
let life_giver = LifeGiver::with_taken(taken.index(&FullRange));
|
||||
let rebuilder = Rebuilder::new(self.tcx, fn_decl, expl_self,
|
||||
generics, same_regions, &life_giver);
|
||||
let (fn_decl, expl_self, generics) = rebuilder.rebuild();
|
||||
|
@ -937,7 +937,7 @@ impl<'a, 'tcx> Rebuilder<'a, 'tcx> {
|
|||
}
|
||||
expl_self_opt = self.rebuild_expl_self(expl_self_opt, lifetime,
|
||||
&anon_nums, ®ion_names);
|
||||
inputs = self.rebuild_args_ty(inputs[], lifetime,
|
||||
inputs = self.rebuild_args_ty(inputs.index(&FullRange), lifetime,
|
||||
&anon_nums, ®ion_names);
|
||||
output = self.rebuild_output(&output, lifetime, &anon_nums, ®ion_names);
|
||||
ty_params = self.rebuild_ty_params(ty_params, lifetime,
|
||||
|
@ -972,7 +972,7 @@ impl<'a, 'tcx> Rebuilder<'a, 'tcx> {
|
|||
names.push(lt_name);
|
||||
}
|
||||
names.sort();
|
||||
let name = token::str_to_ident(names[0][]).name;
|
||||
let name = token::str_to_ident(names[0].index(&FullRange)).name;
|
||||
return (name_to_dummy_lifetime(name), Kept);
|
||||
}
|
||||
return (self.life_giver.give_lifetime(), Fresh);
|
||||
|
@ -1222,7 +1222,7 @@ impl<'a, 'tcx> Rebuilder<'a, 'tcx> {
|
|||
.sess
|
||||
.fatal(format!(
|
||||
"unbound path {}",
|
||||
pprust::path_to_string(path))[])
|
||||
pprust::path_to_string(path)).index(&FullRange))
|
||||
}
|
||||
Some(&d) => d
|
||||
};
|
||||
|
@ -1420,7 +1420,7 @@ impl<'a, 'tcx> ErrorReportingHelpers<'tcx> for InferCtxt<'a, 'tcx> {
|
|||
opt_explicit_self, generics);
|
||||
let msg = format!("consider using an explicit lifetime \
|
||||
parameter as shown: {}", suggested_fn);
|
||||
self.tcx.sess.span_help(span, msg[]);
|
||||
self.tcx.sess.span_help(span, msg.index(&FullRange));
|
||||
}
|
||||
|
||||
fn report_inference_failure(&self,
|
||||
|
@ -1463,7 +1463,7 @@ impl<'a, 'tcx> ErrorReportingHelpers<'tcx> for InferCtxt<'a, 'tcx> {
|
|||
var_origin.span(),
|
||||
format!("cannot infer an appropriate lifetime{} \
|
||||
due to conflicting requirements",
|
||||
var_description)[]);
|
||||
var_description).index(&FullRange));
|
||||
}
|
||||
|
||||
fn note_region_origin(&self, origin: &SubregionOrigin<'tcx>) {
|
||||
|
@ -1511,7 +1511,7 @@ impl<'a, 'tcx> ErrorReportingHelpers<'tcx> for InferCtxt<'a, 'tcx> {
|
|||
self.tcx.sess.span_note(
|
||||
trace.origin.span(),
|
||||
format!("...so that {} ({})",
|
||||
desc, values_str)[]);
|
||||
desc, values_str).index(&FullRange));
|
||||
}
|
||||
None => {
|
||||
// Really should avoid printing this error at
|
||||
|
@ -1520,7 +1520,7 @@ impl<'a, 'tcx> ErrorReportingHelpers<'tcx> for InferCtxt<'a, 'tcx> {
|
|||
// doing right now. - nmatsakis
|
||||
self.tcx.sess.span_note(
|
||||
trace.origin.span(),
|
||||
format!("...so that {}", desc)[]);
|
||||
format!("...so that {}", desc).index(&FullRange));
|
||||
}
|
||||
}
|
||||
}
|
||||
|
@ -1537,7 +1537,7 @@ impl<'a, 'tcx> ErrorReportingHelpers<'tcx> for InferCtxt<'a, 'tcx> {
|
|||
"...so that closure can access `{}`",
|
||||
ty::local_var_name_str(self.tcx, upvar_id.var_id)
|
||||
.get()
|
||||
.to_string())[])
|
||||
.to_string()).index(&FullRange))
|
||||
}
|
||||
infer::InfStackClosure(span) => {
|
||||
self.tcx.sess.span_note(
|
||||
|
@ -1562,7 +1562,7 @@ impl<'a, 'tcx> ErrorReportingHelpers<'tcx> for InferCtxt<'a, 'tcx> {
|
|||
does not outlive the enclosing closure",
|
||||
ty::local_var_name_str(
|
||||
self.tcx,
|
||||
id).get().to_string())[]);
|
||||
id).get().to_string()).index(&FullRange));
|
||||
}
|
||||
infer::IndexSlice(span) => {
|
||||
self.tcx.sess.span_note(
|
||||
|
@ -1606,7 +1606,7 @@ impl<'a, 'tcx> ErrorReportingHelpers<'tcx> for InferCtxt<'a, 'tcx> {
|
|||
span,
|
||||
format!("...so type `{}` of expression is valid during the \
|
||||
expression",
|
||||
self.ty_to_string(t))[]);
|
||||
self.ty_to_string(t)).index(&FullRange));
|
||||
}
|
||||
infer::BindingTypeIsNotValidAtDecl(span) => {
|
||||
self.tcx.sess.span_note(
|
||||
|
@ -1618,14 +1618,14 @@ impl<'a, 'tcx> ErrorReportingHelpers<'tcx> for InferCtxt<'a, 'tcx> {
|
|||
span,
|
||||
format!("...so that the reference type `{}` \
|
||||
does not outlive the data it points at",
|
||||
self.ty_to_string(ty))[]);
|
||||
self.ty_to_string(ty)).index(&FullRange));
|
||||
}
|
||||
infer::RelateParamBound(span, t) => {
|
||||
self.tcx.sess.span_note(
|
||||
span,
|
||||
format!("...so that the type `{}` \
|
||||
will meet the declared lifetime bounds",
|
||||
self.ty_to_string(t))[]);
|
||||
self.ty_to_string(t)).index(&FullRange));
|
||||
}
|
||||
infer::RelateDefaultParamBound(span, t) => {
|
||||
self.tcx.sess.span_note(
|
||||
|
@ -1633,13 +1633,13 @@ impl<'a, 'tcx> ErrorReportingHelpers<'tcx> for InferCtxt<'a, 'tcx> {
|
|||
format!("...so that type parameter \
|
||||
instantiated with `{}`, \
|
||||
will meet its declared lifetime bounds",
|
||||
self.ty_to_string(t))[]);
|
||||
self.ty_to_string(t)).index(&FullRange));
|
||||
}
|
||||
infer::RelateRegionParamBound(span) => {
|
||||
self.tcx.sess.span_note(
|
||||
span,
|
||||
format!("...so that the declared lifetime parameter bounds \
|
||||
are satisfied")[]);
|
||||
are satisfied").index(&FullRange));
|
||||
}
|
||||
}
|
||||
}
|
||||
|
@ -1691,7 +1691,7 @@ fn lifetimes_in_scope(tcx: &ty::ctxt,
|
|||
Some(node) => match node {
|
||||
ast_map::NodeItem(item) => match item.node {
|
||||
ast::ItemFn(_, _, _, ref gen, _) => {
|
||||
taken.push_all(gen.lifetimes[]);
|
||||
taken.push_all(gen.lifetimes.index(&FullRange));
|
||||
None
|
||||
},
|
||||
_ => None
|
||||
|
@ -1699,7 +1699,7 @@ fn lifetimes_in_scope(tcx: &ty::ctxt,
|
|||
ast_map::NodeImplItem(ii) => {
|
||||
match *ii {
|
||||
ast::MethodImplItem(ref m) => {
|
||||
taken.push_all(m.pe_generics().lifetimes[]);
|
||||
taken.push_all(m.pe_generics().lifetimes.index(&FullRange));
|
||||
Some(m.id)
|
||||
}
|
||||
ast::TypeImplItem(_) => None,
|
||||
|
@ -1758,10 +1758,10 @@ impl LifeGiver {
|
|||
let mut lifetime;
|
||||
loop {
|
||||
let mut s = String::from_str("'");
|
||||
s.push_str(num_to_string(self.counter.get())[]);
|
||||
s.push_str(num_to_string(self.counter.get()).index(&FullRange));
|
||||
if !self.taken.contains(&s) {
|
||||
lifetime = name_to_dummy_lifetime(
|
||||
token::str_to_ident(s[]).name);
|
||||
token::str_to_ident(s.index(&FullRange)).name);
|
||||
self.generated.borrow_mut().push(lifetime);
|
||||
break;
|
||||
}
|
||||
|
|
|
@ -189,7 +189,7 @@ impl<'tcx,C> HigherRankedRelations<'tcx> for C
|
|||
span,
|
||||
format!("region {} is not associated with \
|
||||
any bound region from A!",
|
||||
r0)[])
|
||||
r0).index(&FullRange))
|
||||
}
|
||||
}
|
||||
|
||||
|
@ -322,7 +322,7 @@ impl<'tcx,C> HigherRankedRelations<'tcx> for C
|
|||
}
|
||||
infcx.tcx.sess.span_bug(
|
||||
span,
|
||||
format!("could not find original bound region for {}", r)[]);
|
||||
format!("could not find original bound region for {}", r).index(&FullRange));
|
||||
}
|
||||
|
||||
fn fresh_bound_variable(infcx: &InferCtxt, debruijn: ty::DebruijnIndex) -> ty::Region {
|
||||
|
@ -339,7 +339,7 @@ fn var_ids<'tcx, T: Combine<'tcx>>(combiner: &T,
|
|||
r => {
|
||||
combiner.infcx().tcx.sess.span_bug(
|
||||
combiner.trace().origin.span(),
|
||||
format!("found non-region-vid: {}", r)[]);
|
||||
format!("found non-region-vid: {}", r).index(&FullRange));
|
||||
}
|
||||
}).collect()
|
||||
}
|
||||
|
|
|
@ -1002,7 +1002,7 @@ impl<'a, 'tcx> InferCtxt<'a, 'tcx> {
|
|||
|
||||
self.tcx.sess.span_err(sp, format!("{}{}",
|
||||
mk_msg(resolved_expected.map(|t| self.ty_to_string(t)), actual_ty),
|
||||
error_str)[]);
|
||||
error_str).index(&FullRange));
|
||||
|
||||
for err in err.iter() {
|
||||
ty::note_and_explain_type_err(self.tcx, *err)
|
||||
|
|
|
@ -475,7 +475,7 @@ impl<'a, 'tcx> RegionVarBindings<'a, 'tcx> {
|
|||
origin.span(),
|
||||
format!("cannot relate bound region: {} <= {}",
|
||||
sub.repr(self.tcx),
|
||||
sup.repr(self.tcx))[]);
|
||||
sup.repr(self.tcx)).index(&FullRange));
|
||||
}
|
||||
(_, ReStatic) => {
|
||||
// all regions are subregions of static, so we can ignore this
|
||||
|
@ -736,7 +736,7 @@ impl<'a, 'tcx> RegionVarBindings<'a, 'tcx> {
|
|||
self.tcx.sess.bug(
|
||||
format!("cannot relate bound region: LUB({}, {})",
|
||||
a.repr(self.tcx),
|
||||
b.repr(self.tcx))[]);
|
||||
b.repr(self.tcx)).index(&FullRange));
|
||||
}
|
||||
|
||||
(ReStatic, _) | (_, ReStatic) => {
|
||||
|
@ -753,7 +753,7 @@ impl<'a, 'tcx> RegionVarBindings<'a, 'tcx> {
|
|||
format!("lub_concrete_regions invoked with \
|
||||
non-concrete regions: {}, {}",
|
||||
a,
|
||||
b)[]);
|
||||
b).index(&FullRange));
|
||||
}
|
||||
|
||||
(ReFree(ref fr), ReScope(s_id)) |
|
||||
|
@ -836,7 +836,7 @@ impl<'a, 'tcx> RegionVarBindings<'a, 'tcx> {
|
|||
self.tcx.sess.bug(
|
||||
format!("cannot relate bound region: GLB({}, {})",
|
||||
a.repr(self.tcx),
|
||||
b.repr(self.tcx))[]);
|
||||
b.repr(self.tcx)).index(&FullRange));
|
||||
}
|
||||
|
||||
(ReStatic, r) | (r, ReStatic) => {
|
||||
|
@ -856,7 +856,7 @@ impl<'a, 'tcx> RegionVarBindings<'a, 'tcx> {
|
|||
format!("glb_concrete_regions invoked with \
|
||||
non-concrete regions: {}, {}",
|
||||
a,
|
||||
b)[]);
|
||||
b).index(&FullRange));
|
||||
}
|
||||
|
||||
(ReFree(ref fr), ReScope(s_id)) |
|
||||
|
@ -977,7 +977,7 @@ impl<'a, 'tcx> RegionVarBindings<'a, 'tcx> {
|
|||
self.expansion(var_data.as_mut_slice());
|
||||
self.contraction(var_data.as_mut_slice());
|
||||
let values =
|
||||
self.extract_values_and_collect_conflicts(var_data[],
|
||||
self.extract_values_and_collect_conflicts(var_data.index(&FullRange),
|
||||
errors);
|
||||
self.collect_concrete_region_errors(&values, errors);
|
||||
values
|
||||
|
@ -1415,7 +1415,7 @@ impl<'a, 'tcx> RegionVarBindings<'a, 'tcx> {
|
|||
for var {}, lower_bounds={}, upper_bounds={}",
|
||||
node_idx,
|
||||
lower_bounds.repr(self.tcx),
|
||||
upper_bounds.repr(self.tcx))[]);
|
||||
upper_bounds.repr(self.tcx)).index(&FullRange));
|
||||
}
|
||||
|
||||
fn collect_error_for_contracting_node(
|
||||
|
@ -1459,7 +1459,7 @@ impl<'a, 'tcx> RegionVarBindings<'a, 'tcx> {
|
|||
format!("collect_error_for_contracting_node() could not find error \
|
||||
for var {}, upper_bounds={}",
|
||||
node_idx,
|
||||
upper_bounds.repr(self.tcx))[]);
|
||||
upper_bounds.repr(self.tcx)).index(&FullRange));
|
||||
}
|
||||
|
||||
fn collect_concrete_regions(&self,
|
||||
|
|
|
@ -96,7 +96,7 @@ impl<'a, 'tcx> ty_fold::TypeFolder<'tcx> for FullTypeResolver<'a, 'tcx> {
|
|||
ty::ty_infer(_) => {
|
||||
self.infcx.tcx.sess.bug(
|
||||
format!("Unexpected type in full type resolver: {}",
|
||||
t.repr(self.infcx.tcx))[]);
|
||||
t.repr(self.infcx.tcx)).index(&FullRange));
|
||||
}
|
||||
_ => {
|
||||
ty_fold::super_fold_ty(self, t)
|
||||
|
|
|
@ -326,7 +326,7 @@ impl<'a, 'tcx> IrMaps<'a, 'tcx> {
|
|||
self.tcx
|
||||
.sess
|
||||
.span_bug(span, format!("no variable registered for id {}",
|
||||
node_id)[]);
|
||||
node_id).index(&FullRange));
|
||||
}
|
||||
}
|
||||
}
|
||||
|
@ -597,7 +597,7 @@ impl<'a, 'tcx> Liveness<'a, 'tcx> {
|
|||
self.ir.tcx.sess.span_bug(
|
||||
span,
|
||||
format!("no live node registered for node {}",
|
||||
node_id)[]);
|
||||
node_id).index(&FullRange));
|
||||
}
|
||||
}
|
||||
}
|
||||
|
@ -1132,7 +1132,7 @@ impl<'a, 'tcx> Liveness<'a, 'tcx> {
|
|||
// Uninteresting cases: just propagate in rev exec order
|
||||
|
||||
ast::ExprVec(ref exprs) => {
|
||||
self.propagate_through_exprs(exprs[], succ)
|
||||
self.propagate_through_exprs(exprs.index(&FullRange), succ)
|
||||
}
|
||||
|
||||
ast::ExprRepeat(ref element, ref count) => {
|
||||
|
@ -1157,7 +1157,7 @@ impl<'a, 'tcx> Liveness<'a, 'tcx> {
|
|||
} else {
|
||||
succ
|
||||
};
|
||||
let succ = self.propagate_through_exprs(args[], succ);
|
||||
let succ = self.propagate_through_exprs(args.index(&FullRange), succ);
|
||||
self.propagate_through_expr(&**f, succ)
|
||||
}
|
||||
|
||||
|
@ -1170,11 +1170,11 @@ impl<'a, 'tcx> Liveness<'a, 'tcx> {
|
|||
} else {
|
||||
succ
|
||||
};
|
||||
self.propagate_through_exprs(args[], succ)
|
||||
self.propagate_through_exprs(args.index(&FullRange), succ)
|
||||
}
|
||||
|
||||
ast::ExprTup(ref exprs) => {
|
||||
self.propagate_through_exprs(exprs[], succ)
|
||||
self.propagate_through_exprs(exprs.index(&FullRange), succ)
|
||||
}
|
||||
|
||||
ast::ExprBinary(op, ref l, ref r) if ast_util::lazy_binop(op) => {
|
||||
|
|
|
@ -594,7 +594,7 @@ impl<'t,'tcx,TYPER:Typer<'tcx>> MemCategorizationContext<'t,TYPER> {
|
|||
span,
|
||||
format!("Upvar of non-closure {} - {}",
|
||||
fn_node_id,
|
||||
ty.repr(self.tcx()))[]);
|
||||
ty.repr(self.tcx())).index(&FullRange));
|
||||
}
|
||||
}
|
||||
}
|
||||
|
@ -1505,7 +1505,7 @@ impl<'tcx> Repr<'tcx> for InteriorKind {
|
|||
token::get_name(fld).get().to_string()
|
||||
}
|
||||
InteriorField(PositionalField(i)) => format!("#{}", i),
|
||||
InteriorElement(_) => "[]".to_string(),
|
||||
InteriorElement(_) => ".index(&FullRange)".to_string(),
|
||||
}
|
||||
}
|
||||
}
|
||||
|
|
|
@ -615,10 +615,10 @@ impl<'a, 'tcx> PrivacyVisitor<'a, 'tcx> {
|
|||
match result {
|
||||
None => true,
|
||||
Some((span, msg, note)) => {
|
||||
self.tcx.sess.span_err(span, msg[]);
|
||||
self.tcx.sess.span_err(span, msg.index(&FullRange));
|
||||
match note {
|
||||
Some((span, msg)) => {
|
||||
self.tcx.sess.span_note(span, msg[])
|
||||
self.tcx.sess.span_note(span, msg.index(&FullRange))
|
||||
}
|
||||
None => {},
|
||||
}
|
||||
|
@ -720,7 +720,7 @@ impl<'a, 'tcx> PrivacyVisitor<'a, 'tcx> {
|
|||
UnnamedField(idx) => format!("field #{} of {} is private",
|
||||
idx + 1, struct_desc),
|
||||
};
|
||||
self.tcx.sess.span_err(span, msg[]);
|
||||
self.tcx.sess.span_err(span, msg.index(&FullRange));
|
||||
}
|
||||
|
||||
// Given the ID of a method, checks to ensure it's in scope.
|
||||
|
@ -742,7 +742,7 @@ impl<'a, 'tcx> PrivacyVisitor<'a, 'tcx> {
|
|||
method_id,
|
||||
None,
|
||||
format!("method `{}`",
|
||||
string)[]));
|
||||
string).index(&FullRange)));
|
||||
}
|
||||
|
||||
// Checks that a path is in scope.
|
||||
|
@ -756,7 +756,7 @@ impl<'a, 'tcx> PrivacyVisitor<'a, 'tcx> {
|
|||
self.ensure_public(span,
|
||||
def,
|
||||
Some(origdid),
|
||||
format!("{} `{}`", tyname, name)[])
|
||||
format!("{} `{}`", tyname, name).index(&FullRange))
|
||||
};
|
||||
|
||||
match self.last_private_map[path_id] {
|
||||
|
|
|
@ -50,7 +50,7 @@ fn generics_require_inlining(generics: &ast::Generics) -> bool {
|
|||
// monomorphized or it was marked with `#[inline]`. This will only return
|
||||
// true for functions.
|
||||
fn item_might_be_inlined(item: &ast::Item) -> bool {
|
||||
if attributes_specify_inlining(item.attrs[]) {
|
||||
if attributes_specify_inlining(item.attrs.index(&FullRange)) {
|
||||
return true
|
||||
}
|
||||
|
||||
|
@ -65,7 +65,7 @@ fn item_might_be_inlined(item: &ast::Item) -> bool {
|
|||
|
||||
fn method_might_be_inlined(tcx: &ty::ctxt, method: &ast::Method,
|
||||
impl_src: ast::DefId) -> bool {
|
||||
if attributes_specify_inlining(method.attrs[]) ||
|
||||
if attributes_specify_inlining(method.attrs.index(&FullRange)) ||
|
||||
generics_require_inlining(method.pe_generics()) {
|
||||
return true
|
||||
}
|
||||
|
@ -202,7 +202,7 @@ impl<'a, 'tcx> ReachableContext<'a, 'tcx> {
|
|||
ast::MethodImplItem(ref method) => {
|
||||
if generics_require_inlining(method.pe_generics()) ||
|
||||
attributes_specify_inlining(
|
||||
method.attrs[]) {
|
||||
method.attrs.index(&FullRange)) {
|
||||
true
|
||||
} else {
|
||||
let impl_did = self.tcx
|
||||
|
@ -249,7 +249,7 @@ impl<'a, 'tcx> ReachableContext<'a, 'tcx> {
|
|||
None => {
|
||||
self.tcx.sess.bug(format!("found unmapped ID in worklist: \
|
||||
{}",
|
||||
search_item)[])
|
||||
search_item).index(&FullRange))
|
||||
}
|
||||
}
|
||||
}
|
||||
|
@ -341,7 +341,7 @@ impl<'a, 'tcx> ReachableContext<'a, 'tcx> {
|
|||
.bug(format!("found unexpected thingy in worklist: {}",
|
||||
self.tcx
|
||||
.map
|
||||
.node_to_string(search_item))[])
|
||||
.node_to_string(search_item)).index(&FullRange))
|
||||
}
|
||||
}
|
||||
}
|
||||
|
|
|
@ -643,7 +643,7 @@ fn resolve_local(visitor: &mut RegionResolutionVisitor, local: &ast::Local) {
|
|||
// A, but the inner rvalues `a()` and `b()` have an extended lifetime
|
||||
// due to rule C.
|
||||
//
|
||||
// FIXME(#6308) -- Note that `[]` patterns work more smoothly post-DST.
|
||||
// FIXME(#6308) -- Note that `.index(&FullRange)` patterns work more smoothly post-DST.
|
||||
|
||||
match local.init {
|
||||
Some(ref expr) => {
|
||||
|
|
|
@ -399,7 +399,7 @@ impl<'a> LifetimeContext<'a> {
|
|||
self.sess.span_err(
|
||||
lifetime_ref.span,
|
||||
format!("use of undeclared lifetime name `{}`",
|
||||
token::get_name(lifetime_ref.name))[]);
|
||||
token::get_name(lifetime_ref.name)).index(&FullRange));
|
||||
}
|
||||
|
||||
fn check_lifetime_defs(&mut self, old_scope: Scope, lifetimes: &Vec<ast::LifetimeDef>) {
|
||||
|
@ -413,7 +413,7 @@ impl<'a> LifetimeContext<'a> {
|
|||
lifetime.lifetime.span,
|
||||
format!("illegal lifetime parameter name: `{}`",
|
||||
token::get_name(lifetime.lifetime.name))
|
||||
[]);
|
||||
.index(&FullRange));
|
||||
}
|
||||
}
|
||||
|
||||
|
@ -427,7 +427,7 @@ impl<'a> LifetimeContext<'a> {
|
|||
format!("lifetime name `{}` declared twice in \
|
||||
the same scope",
|
||||
token::get_name(lifetime_j.lifetime.name))
|
||||
[]);
|
||||
.index(&FullRange));
|
||||
}
|
||||
}
|
||||
|
||||
|
|
|
@ -604,7 +604,7 @@ impl<'a, 'tcx> TypeFolder<'tcx> for SubstFolder<'a, 'tcx> {
|
|||
(space={}, index={})",
|
||||
region_name.as_str(),
|
||||
self.root_ty.repr(self.tcx()),
|
||||
space, i)[]);
|
||||
space, i).index(&FullRange));
|
||||
}
|
||||
}
|
||||
}
|
||||
|
@ -661,7 +661,7 @@ impl<'a,'tcx> SubstFolder<'a,'tcx> {
|
|||
p.space,
|
||||
p.idx,
|
||||
self.root_ty.repr(self.tcx()),
|
||||
self.substs.repr(self.tcx()))[]);
|
||||
self.substs.repr(self.tcx())).index(&FullRange));
|
||||
}
|
||||
};
|
||||
|
||||
|
|
|
@ -137,7 +137,7 @@ fn ty_is_local_constructor<'tcx>(tcx: &ty::ctxt<'tcx>, ty: Ty<'tcx>) -> bool {
|
|||
ty::ty_err => {
|
||||
tcx.sess.bug(
|
||||
format!("ty_is_local invoked on unexpected type: {}",
|
||||
ty.repr(tcx))[])
|
||||
ty.repr(tcx)).index(&FullRange))
|
||||
}
|
||||
}
|
||||
}
|
||||
|
|
|
@ -339,5 +339,5 @@ pub fn suggest_new_overflow_limit(tcx: &ty::ctxt, span: Span) {
|
|||
span,
|
||||
format!(
|
||||
"consider adding a `#![recursion_limit=\"{}\"]` attribute to your crate",
|
||||
suggested_limit)[]);
|
||||
suggested_limit).index(&FullRange));
|
||||
}
|
||||
|
|
|
@ -227,7 +227,7 @@ impl<'tcx> FulfillmentContext<'tcx> {
|
|||
}
|
||||
|
||||
pub fn pending_obligations(&self) -> &[PredicateObligation<'tcx>] {
|
||||
self.predicates[]
|
||||
self.predicates.index(&FullRange)
|
||||
}
|
||||
|
||||
/// Attempts to select obligations using `selcx`. If `only_new_obligations` is true, then it
|
||||
|
|
|
@ -903,7 +903,7 @@ impl<'cx, 'tcx> SelectionContext<'cx, 'tcx> {
|
|||
|
||||
let all_bounds =
|
||||
util::transitive_bounds(
|
||||
self.tcx(), caller_trait_refs[]);
|
||||
self.tcx(), caller_trait_refs.index(&FullRange));
|
||||
|
||||
let matching_bounds =
|
||||
all_bounds.filter(
|
||||
|
@ -1467,7 +1467,7 @@ impl<'cx, 'tcx> SelectionContext<'cx, 'tcx> {
|
|||
self.tcx().sess.bug(
|
||||
format!(
|
||||
"asked to assemble builtin bounds of unexpected type: {}",
|
||||
self_ty.repr(self.tcx()))[]);
|
||||
self_ty.repr(self.tcx())).index(&FullRange));
|
||||
}
|
||||
};
|
||||
|
||||
|
@ -1637,7 +1637,7 @@ impl<'cx, 'tcx> SelectionContext<'cx, 'tcx> {
|
|||
self.tcx().sess.span_bug(
|
||||
obligation.cause.span,
|
||||
format!("builtin bound for {} was ambig",
|
||||
obligation.repr(self.tcx()))[]);
|
||||
obligation.repr(self.tcx())).index(&FullRange));
|
||||
}
|
||||
}
|
||||
}
|
||||
|
@ -1816,7 +1816,7 @@ impl<'cx, 'tcx> SelectionContext<'cx, 'tcx> {
|
|||
self.tcx().sess.span_bug(
|
||||
obligation.cause.span,
|
||||
format!("Fn pointer candidate for inappropriate self type: {}",
|
||||
self_ty.repr(self.tcx()))[]);
|
||||
self_ty.repr(self.tcx())).index(&FullRange));
|
||||
}
|
||||
};
|
||||
|
||||
|
@ -1946,7 +1946,7 @@ impl<'cx, 'tcx> SelectionContext<'cx, 'tcx> {
|
|||
self.tcx().sess.bug(
|
||||
format!("Impl {} was matchable against {} but now is not",
|
||||
impl_def_id.repr(self.tcx()),
|
||||
obligation.repr(self.tcx()))[]);
|
||||
obligation.repr(self.tcx())).index(&FullRange));
|
||||
}
|
||||
}
|
||||
}
|
||||
|
|
|
@ -2006,8 +2006,8 @@ impl<'tcx> Predicate<'tcx> {
|
|||
/// struct Foo<T,U:Bar<T>> { ... }
|
||||
///
|
||||
/// Here, the `Generics` for `Foo` would contain a list of bounds like
|
||||
/// `[[], [U:Bar<T>]]`. Now if there were some particular reference
|
||||
/// like `Foo<int,uint>`, then the `GenericBounds` would be `[[],
|
||||
/// `[.index(&FullRange), [U:Bar<T>]]`. Now if there were some particular reference
|
||||
/// like `Foo<int,uint>`, then the `GenericBounds` would be `[.index(&FullRange),
|
||||
/// [uint:Bar<int>]]`.
|
||||
#[derive(Clone, Show)]
|
||||
pub struct GenericBounds<'tcx> {
|
||||
|
@ -2184,7 +2184,7 @@ impl<'a, 'tcx> ParameterEnvironment<'a, 'tcx> {
|
|||
_ => {
|
||||
cx.sess.bug(format!("ParameterEnvironment::from_item(): \
|
||||
`{}` is not an item",
|
||||
cx.map.node_to_string(id))[])
|
||||
cx.map.node_to_string(id)).index(&FullRange))
|
||||
}
|
||||
}
|
||||
}
|
||||
|
@ -2269,7 +2269,7 @@ impl UnboxedClosureKind {
|
|||
};
|
||||
match result {
|
||||
Ok(trait_did) => trait_did,
|
||||
Err(err) => cx.sess.fatal(err[]),
|
||||
Err(err) => cx.sess.fatal(err.index(&FullRange)),
|
||||
}
|
||||
}
|
||||
}
|
||||
|
@ -2590,7 +2590,7 @@ impl FlagComputation {
|
|||
}
|
||||
|
||||
&ty_tup(ref ts) => {
|
||||
self.add_tys(ts[]);
|
||||
self.add_tys(ts.index(&FullRange));
|
||||
}
|
||||
|
||||
&ty_bare_fn(_, ref f) => {
|
||||
|
@ -2613,7 +2613,7 @@ impl FlagComputation {
|
|||
fn add_fn_sig(&mut self, fn_sig: &PolyFnSig) {
|
||||
let mut computation = FlagComputation::new();
|
||||
|
||||
computation.add_tys(fn_sig.0.inputs[]);
|
||||
computation.add_tys(fn_sig.0.inputs.index(&FullRange));
|
||||
|
||||
if let ty::FnConverging(output) = fn_sig.0.output {
|
||||
computation.add_ty(output);
|
||||
|
@ -2782,7 +2782,7 @@ pub fn mk_trait<'tcx>(cx: &ctxt<'tcx>,
|
|||
|
||||
fn bound_list_is_sorted(bounds: &[ty::PolyProjectionPredicate]) -> bool {
|
||||
bounds.len() == 0 ||
|
||||
bounds[1..].iter().enumerate().all(
|
||||
bounds.index(&(1..)).iter().enumerate().all(
|
||||
|(index, bound)| bounds[index].sort_key() <= bound.sort_key())
|
||||
}
|
||||
|
||||
|
@ -3037,7 +3037,7 @@ pub fn sequence_element_type<'tcx>(cx: &ctxt<'tcx>, ty: Ty<'tcx>) -> Ty<'tcx> {
|
|||
ty_str => mk_mach_uint(cx, ast::TyU8),
|
||||
ty_open(ty) => sequence_element_type(cx, ty),
|
||||
_ => cx.sess.bug(format!("sequence_element_type called on non-sequence value: {}",
|
||||
ty_to_string(cx, ty))[]),
|
||||
ty_to_string(cx, ty)).index(&FullRange)),
|
||||
}
|
||||
}
|
||||
|
||||
|
@ -3371,7 +3371,7 @@ pub fn type_contents<'tcx>(cx: &ctxt<'tcx>, ty: Ty<'tcx>) -> TypeContents {
|
|||
ty_struct(did, substs) => {
|
||||
let flds = struct_fields(cx, did, substs);
|
||||
let mut res =
|
||||
TypeContents::union(flds[],
|
||||
TypeContents::union(flds.index(&FullRange),
|
||||
|f| tc_mt(cx, f.mt, cache));
|
||||
|
||||
if !lookup_repr_hints(cx, did).contains(&attr::ReprExtern) {
|
||||
|
@ -3395,15 +3395,15 @@ pub fn type_contents<'tcx>(cx: &ctxt<'tcx>, ty: Ty<'tcx>) -> TypeContents {
|
|||
}
|
||||
|
||||
ty_tup(ref tys) => {
|
||||
TypeContents::union(tys[],
|
||||
TypeContents::union(tys.index(&FullRange),
|
||||
|ty| tc_ty(cx, *ty, cache))
|
||||
}
|
||||
|
||||
ty_enum(did, substs) => {
|
||||
let variants = substd_enum_variants(cx, did, substs);
|
||||
let mut res =
|
||||
TypeContents::union(variants[], |variant| {
|
||||
TypeContents::union(variant.args[],
|
||||
TypeContents::union(variants.index(&FullRange), |variant| {
|
||||
TypeContents::union(variant.args.index(&FullRange),
|
||||
|arg_ty| {
|
||||
tc_ty(cx, *arg_ty, cache)
|
||||
})
|
||||
|
@ -3986,7 +3986,7 @@ pub fn close_type<'tcx>(cx: &ctxt<'tcx>, ty: Ty<'tcx>) -> Ty<'tcx> {
|
|||
match ty.sty {
|
||||
ty_open(ty) => mk_rptr(cx, cx.mk_region(ReStatic), mt {ty: ty, mutbl:ast::MutImmutable}),
|
||||
_ => cx.sess.bug(format!("Trying to close a non-open type {}",
|
||||
ty_to_string(cx, ty))[])
|
||||
ty_to_string(cx, ty)).index(&FullRange))
|
||||
}
|
||||
}
|
||||
|
||||
|
@ -4087,7 +4087,7 @@ pub fn node_id_to_trait_ref<'tcx>(cx: &ctxt<'tcx>, id: ast::NodeId)
|
|||
Some(ty) => ty.clone(),
|
||||
None => cx.sess.bug(
|
||||
format!("node_id_to_trait_ref: no trait ref for node `{}`",
|
||||
cx.map.node_to_string(id))[])
|
||||
cx.map.node_to_string(id)).index(&FullRange))
|
||||
}
|
||||
}
|
||||
|
||||
|
@ -4100,7 +4100,7 @@ pub fn node_id_to_type<'tcx>(cx: &ctxt<'tcx>, id: ast::NodeId) -> Ty<'tcx> {
|
|||
Some(ty) => ty,
|
||||
None => cx.sess.bug(
|
||||
format!("node_id_to_type: no type for node `{}`",
|
||||
cx.map.node_to_string(id))[])
|
||||
cx.map.node_to_string(id)).index(&FullRange))
|
||||
}
|
||||
}
|
||||
|
||||
|
@ -4187,7 +4187,7 @@ pub fn ty_region(tcx: &ctxt,
|
|||
tcx.sess.span_bug(
|
||||
span,
|
||||
format!("ty_region() invoked on an inappropriate ty: {}",
|
||||
s)[]);
|
||||
s).index(&FullRange));
|
||||
}
|
||||
}
|
||||
}
|
||||
|
@ -4248,11 +4248,11 @@ pub fn expr_span(cx: &ctxt, id: NodeId) -> Span {
|
|||
Some(f) => {
|
||||
cx.sess.bug(format!("Node id {} is not an expr: {}",
|
||||
id,
|
||||
f)[]);
|
||||
f).index(&FullRange));
|
||||
}
|
||||
None => {
|
||||
cx.sess.bug(format!("Node id {} is not present \
|
||||
in the node map", id)[]);
|
||||
in the node map", id).index(&FullRange));
|
||||
}
|
||||
}
|
||||
}
|
||||
|
@ -4268,14 +4268,14 @@ pub fn local_var_name_str(cx: &ctxt, id: NodeId) -> InternedString {
|
|||
cx.sess.bug(
|
||||
format!("Variable id {} maps to {}, not local",
|
||||
id,
|
||||
pat)[]);
|
||||
pat).index(&FullRange));
|
||||
}
|
||||
}
|
||||
}
|
||||
r => {
|
||||
cx.sess.bug(format!("Variable id {} maps to {}, not local",
|
||||
id,
|
||||
r)[]);
|
||||
r).index(&FullRange));
|
||||
}
|
||||
}
|
||||
}
|
||||
|
@ -4306,7 +4306,7 @@ pub fn adjust_ty<'tcx, F>(cx: &ctxt<'tcx>,
|
|||
cx.sess.bug(
|
||||
format!("AdjustReifyFnPointer adjustment on non-fn-item: \
|
||||
{}",
|
||||
b)[]);
|
||||
b).index(&FullRange));
|
||||
}
|
||||
}
|
||||
}
|
||||
|
@ -4334,7 +4334,7 @@ pub fn adjust_ty<'tcx, F>(cx: &ctxt<'tcx>,
|
|||
{}",
|
||||
i,
|
||||
ty_to_string(cx, adjusted_ty))
|
||||
[]);
|
||||
.index(&FullRange));
|
||||
}
|
||||
}
|
||||
}
|
||||
|
@ -4397,7 +4397,7 @@ pub fn unsize_ty<'tcx>(cx: &ctxt<'tcx>,
|
|||
}
|
||||
_ => cx.sess.span_bug(span,
|
||||
format!("UnsizeLength with bad sty: {}",
|
||||
ty_to_string(cx, ty))[])
|
||||
ty_to_string(cx, ty)).index(&FullRange))
|
||||
},
|
||||
&UnsizeStruct(box ref k, tp_index) => match ty.sty {
|
||||
ty_struct(did, substs) => {
|
||||
|
@ -4409,7 +4409,7 @@ pub fn unsize_ty<'tcx>(cx: &ctxt<'tcx>,
|
|||
}
|
||||
_ => cx.sess.span_bug(span,
|
||||
format!("UnsizeStruct with bad sty: {}",
|
||||
ty_to_string(cx, ty))[])
|
||||
ty_to_string(cx, ty)).index(&FullRange))
|
||||
},
|
||||
&UnsizeVtable(TyTrait { ref principal, ref bounds }, _) => {
|
||||
mk_trait(cx, principal.clone(), bounds.clone())
|
||||
|
@ -4422,7 +4422,7 @@ pub fn resolve_expr(tcx: &ctxt, expr: &ast::Expr) -> def::Def {
|
|||
Some(&def) => def,
|
||||
None => {
|
||||
tcx.sess.span_bug(expr.span, format!(
|
||||
"no def-map entry for expr {}", expr.id)[]);
|
||||
"no def-map entry for expr {}", expr.id).index(&FullRange));
|
||||
}
|
||||
}
|
||||
}
|
||||
|
@ -4517,7 +4517,7 @@ pub fn expr_kind(tcx: &ctxt, expr: &ast::Expr) -> ExprKind {
|
|||
expr.span,
|
||||
format!("uncategorized def for expr {}: {}",
|
||||
expr.id,
|
||||
def)[]);
|
||||
def).index(&FullRange));
|
||||
}
|
||||
}
|
||||
}
|
||||
|
@ -4642,7 +4642,7 @@ pub fn field_idx_strict(tcx: &ctxt, name: ast::Name, fields: &[field])
|
|||
token::get_name(name),
|
||||
fields.iter()
|
||||
.map(|f| token::get_name(f.name).get().to_string())
|
||||
.collect::<Vec<String>>())[]);
|
||||
.collect::<Vec<String>>()).index(&FullRange));
|
||||
}
|
||||
|
||||
pub fn impl_or_trait_item_idx(id: ast::Name, trait_items: &[ImplOrTraitItem])
|
||||
|
@ -4897,7 +4897,7 @@ pub fn provided_trait_methods<'tcx>(cx: &ctxt<'tcx>, id: ast::DefId)
|
|||
match item.node {
|
||||
ItemTrait(_, _, _, ref ms) => {
|
||||
let (_, p) =
|
||||
ast_util::split_trait_methods(ms[]);
|
||||
ast_util::split_trait_methods(ms.index(&FullRange));
|
||||
p.iter()
|
||||
.map(|m| {
|
||||
match impl_or_trait_item(
|
||||
|
@ -4916,14 +4916,14 @@ pub fn provided_trait_methods<'tcx>(cx: &ctxt<'tcx>, id: ast::DefId)
|
|||
_ => {
|
||||
cx.sess.bug(format!("provided_trait_methods: `{}` is \
|
||||
not a trait",
|
||||
id)[])
|
||||
id).index(&FullRange))
|
||||
}
|
||||
}
|
||||
}
|
||||
_ => {
|
||||
cx.sess.bug(format!("provided_trait_methods: `{}` is not a \
|
||||
trait",
|
||||
id)[])
|
||||
id).index(&FullRange))
|
||||
}
|
||||
}
|
||||
} else {
|
||||
|
@ -5160,7 +5160,7 @@ impl<'tcx> VariantInfo<'tcx> {
|
|||
},
|
||||
ast::StructVariantKind(ref struct_def) => {
|
||||
|
||||
let fields: &[StructField] = struct_def.fields[];
|
||||
let fields: &[StructField] = struct_def.fields.index(&FullRange);
|
||||
|
||||
assert!(fields.len() > 0);
|
||||
|
||||
|
@ -5311,7 +5311,7 @@ pub fn enum_variants<'tcx>(cx: &ctxt<'tcx>, id: ast::DefId)
|
|||
cx.sess
|
||||
.span_err(e.span,
|
||||
format!("expected constant: {}",
|
||||
*err)[]);
|
||||
*err).index(&FullRange));
|
||||
}
|
||||
},
|
||||
None => {}
|
||||
|
@ -5601,7 +5601,7 @@ pub fn lookup_struct_fields(cx: &ctxt, did: ast::DefId) -> Vec<field_ty> {
|
|||
_ => {
|
||||
cx.sess.bug(
|
||||
format!("ID not mapped to struct fields: {}",
|
||||
cx.map.node_to_string(did.node))[]);
|
||||
cx.map.node_to_string(did.node)).index(&FullRange));
|
||||
}
|
||||
}
|
||||
} else {
|
||||
|
@ -5634,7 +5634,7 @@ pub fn struct_fields<'tcx>(cx: &ctxt<'tcx>, did: ast::DefId, substs: &Substs<'tc
|
|||
pub fn tup_fields<'tcx>(v: &[Ty<'tcx>]) -> Vec<field<'tcx>> {
|
||||
v.iter().enumerate().map(|(i, &f)| {
|
||||
field {
|
||||
name: token::intern(i.to_string()[]),
|
||||
name: token::intern(i.to_string().index(&FullRange)),
|
||||
mt: mt {
|
||||
ty: f,
|
||||
mutbl: MutImmutable
|
||||
|
@ -5845,7 +5845,7 @@ pub fn eval_repeat_count(tcx: &ctxt, count_expr: &ast::Expr) -> uint {
|
|||
};
|
||||
tcx.sess.span_err(count_expr.span, format!(
|
||||
"expected positive integer for repeat count, found {}",
|
||||
found)[]);
|
||||
found).index(&FullRange));
|
||||
}
|
||||
Err(_) => {
|
||||
let found = match count_expr.node {
|
||||
|
@ -5860,7 +5860,7 @@ pub fn eval_repeat_count(tcx: &ctxt, count_expr: &ast::Expr) -> uint {
|
|||
};
|
||||
tcx.sess.span_err(count_expr.span, format!(
|
||||
"expected constant integer for repeat count, found {}",
|
||||
found)[]);
|
||||
found).index(&FullRange));
|
||||
}
|
||||
}
|
||||
0
|
||||
|
@ -6644,7 +6644,7 @@ pub fn with_freevars<T, F>(tcx: &ty::ctxt, fid: ast::NodeId, f: F) -> T where
|
|||
{
|
||||
match tcx.freevars.borrow().get(&fid) {
|
||||
None => f(&[]),
|
||||
Some(d) => f(d[])
|
||||
Some(d) => f(d.index(&FullRange))
|
||||
}
|
||||
}
|
||||
|
||||
|
|
|
@ -223,17 +223,17 @@ impl<'a> PluginLoader<'a> {
|
|||
// this is fatal: there are almost certainly macros we need
|
||||
// inside this crate, so continue would spew "macro undefined"
|
||||
// errors
|
||||
Err(err) => self.sess.span_fatal(vi.span, err[])
|
||||
Err(err) => self.sess.span_fatal(vi.span, err.index(&FullRange))
|
||||
};
|
||||
|
||||
unsafe {
|
||||
let registrar =
|
||||
match lib.symbol(symbol[]) {
|
||||
match lib.symbol(symbol.index(&FullRange)) {
|
||||
Ok(registrar) => {
|
||||
mem::transmute::<*mut u8,PluginRegistrarFun>(registrar)
|
||||
}
|
||||
// again fatal if we can't register macros
|
||||
Err(err) => self.sess.span_fatal(vi.span, err[])
|
||||
Err(err) => self.sess.span_fatal(vi.span, err.index(&FullRange))
|
||||
};
|
||||
|
||||
// Intentionally leak the dynamic library. We can't ever unload it
|
||||
|
|
|
@ -559,17 +559,17 @@ pub fn build_codegen_options(matches: &getopts::Matches) -> CodegenOptions
|
|||
match (value, opt_type_desc) {
|
||||
(Some(..), None) => {
|
||||
early_error(format!("codegen option `{}` takes no \
|
||||
value", key)[])
|
||||
value", key).index(&FullRange))
|
||||
}
|
||||
(None, Some(type_desc)) => {
|
||||
early_error(format!("codegen option `{0}` requires \
|
||||
{1} (-C {0}=<value>)",
|
||||
key, type_desc)[])
|
||||
key, type_desc).index(&FullRange))
|
||||
}
|
||||
(Some(value), Some(type_desc)) => {
|
||||
early_error(format!("incorrect value `{}` for codegen \
|
||||
option `{}` - {} was expected",
|
||||
value, key, type_desc)[])
|
||||
value, key, type_desc).index(&FullRange))
|
||||
}
|
||||
(None, None) => unreachable!()
|
||||
}
|
||||
|
@ -579,7 +579,7 @@ pub fn build_codegen_options(matches: &getopts::Matches) -> CodegenOptions
|
|||
}
|
||||
if !found {
|
||||
early_error(format!("unknown codegen option: `{}`",
|
||||
key)[]);
|
||||
key).index(&FullRange));
|
||||
}
|
||||
}
|
||||
return cg;
|
||||
|
@ -592,10 +592,10 @@ pub fn default_lib_output() -> CrateType {
|
|||
pub fn default_configuration(sess: &Session) -> ast::CrateConfig {
|
||||
use syntax::parse::token::intern_and_get_ident as intern;
|
||||
|
||||
let end = sess.target.target.target_endian[];
|
||||
let arch = sess.target.target.arch[];
|
||||
let wordsz = sess.target.target.target_word_size[];
|
||||
let os = sess.target.target.target_os[];
|
||||
let end = sess.target.target.target_endian.index(&FullRange);
|
||||
let arch = sess.target.target.arch.index(&FullRange);
|
||||
let wordsz = sess.target.target.target_word_size.index(&FullRange);
|
||||
let os = sess.target.target.target_os.index(&FullRange);
|
||||
|
||||
let fam = match sess.target.target.options.is_like_windows {
|
||||
true => InternedString::new("windows"),
|
||||
|
@ -631,23 +631,23 @@ pub fn build_configuration(sess: &Session) -> ast::CrateConfig {
|
|||
append_configuration(&mut user_cfg, InternedString::new("test"))
|
||||
}
|
||||
let mut v = user_cfg.into_iter().collect::<Vec<_>>();
|
||||
v.push_all(default_cfg[]);
|
||||
v.push_all(default_cfg.index(&FullRange));
|
||||
v
|
||||
}
|
||||
|
||||
pub fn build_target_config(opts: &Options, sp: &SpanHandler) -> Config {
|
||||
let target = match Target::search(opts.target_triple[]) {
|
||||
let target = match Target::search(opts.target_triple.index(&FullRange)) {
|
||||
Ok(t) => t,
|
||||
Err(e) => {
|
||||
sp.handler().fatal((format!("Error loading target specification: {}", e))[]);
|
||||
sp.handler().fatal((format!("Error loading target specification: {}", e)).index(&FullRange));
|
||||
}
|
||||
};
|
||||
|
||||
let (int_type, uint_type) = match target.target_word_size[] {
|
||||
let (int_type, uint_type) = match target.target_word_size.index(&FullRange) {
|
||||
"32" => (ast::TyI32, ast::TyU32),
|
||||
"64" => (ast::TyI64, ast::TyU64),
|
||||
w => sp.handler().fatal((format!("target specification was invalid: unrecognized \
|
||||
target-word-size {}", w))[])
|
||||
target-word-size {}", w)).index(&FullRange))
|
||||
};
|
||||
|
||||
Config {
|
||||
|
@ -845,7 +845,7 @@ pub fn build_session_options(matches: &getopts::Matches) -> Options {
|
|||
|
||||
let unparsed_crate_types = matches.opt_strs("crate-type");
|
||||
let crate_types = parse_crate_types_from_list(unparsed_crate_types)
|
||||
.unwrap_or_else(|e| early_error(e[]));
|
||||
.unwrap_or_else(|e| early_error(e.index(&FullRange)));
|
||||
|
||||
let mut lint_opts = vec!();
|
||||
let mut describe_lints = false;
|
||||
|
@ -873,7 +873,7 @@ pub fn build_session_options(matches: &getopts::Matches) -> Options {
|
|||
}
|
||||
if this_bit == 0 {
|
||||
early_error(format!("unknown debug flag: {}",
|
||||
*debug_flag)[])
|
||||
*debug_flag).index(&FullRange))
|
||||
}
|
||||
debugging_opts |= this_bit;
|
||||
}
|
||||
|
@ -918,7 +918,7 @@ pub fn build_session_options(matches: &getopts::Matches) -> Options {
|
|||
"dep-info" => OutputTypeDepInfo,
|
||||
_ => {
|
||||
early_error(format!("unknown emission type: `{}`",
|
||||
part)[])
|
||||
part).index(&FullRange))
|
||||
}
|
||||
};
|
||||
output_types.push(output_type)
|
||||
|
@ -957,7 +957,7 @@ pub fn build_session_options(matches: &getopts::Matches) -> Options {
|
|||
Some(arg) => {
|
||||
early_error(format!("optimization level needs to be \
|
||||
between 0-3 (instead was `{}`)",
|
||||
arg)[]);
|
||||
arg).index(&FullRange));
|
||||
}
|
||||
}
|
||||
} else {
|
||||
|
@ -995,7 +995,7 @@ pub fn build_session_options(matches: &getopts::Matches) -> Options {
|
|||
Some(arg) => {
|
||||
early_error(format!("debug info level needs to be between \
|
||||
0-2 (instead was `{}`)",
|
||||
arg)[]);
|
||||
arg).index(&FullRange));
|
||||
}
|
||||
}
|
||||
} else {
|
||||
|
@ -1013,7 +1013,7 @@ pub fn build_session_options(matches: &getopts::Matches) -> Options {
|
|||
|
||||
let mut search_paths = SearchPaths::new();
|
||||
for s in matches.opt_strs("L").iter() {
|
||||
search_paths.add_path(s[]);
|
||||
search_paths.add_path(s.index(&FullRange));
|
||||
}
|
||||
|
||||
let libs = matches.opt_strs("l").into_iter().map(|s| {
|
||||
|
@ -1045,7 +1045,7 @@ pub fn build_session_options(matches: &getopts::Matches) -> Options {
|
|||
(_, s) => {
|
||||
early_error(format!("unknown library kind `{}`, expected \
|
||||
one of dylib, framework, or static",
|
||||
s)[]);
|
||||
s).index(&FullRange));
|
||||
}
|
||||
};
|
||||
(name.to_string(), kind)
|
||||
|
@ -1089,7 +1089,7 @@ pub fn build_session_options(matches: &getopts::Matches) -> Options {
|
|||
--debuginfo");
|
||||
}
|
||||
|
||||
let color = match matches.opt_str("color").as_ref().map(|s| s[]) {
|
||||
let color = match matches.opt_str("color").as_ref().map(|s| s.index(&FullRange)) {
|
||||
Some("auto") => Auto,
|
||||
Some("always") => Always,
|
||||
Some("never") => Never,
|
||||
|
@ -1099,7 +1099,7 @@ pub fn build_session_options(matches: &getopts::Matches) -> Options {
|
|||
Some(arg) => {
|
||||
early_error(format!("argument for --color must be auto, always \
|
||||
or never (instead was `{}`)",
|
||||
arg)[])
|
||||
arg).index(&FullRange))
|
||||
}
|
||||
};
|
||||
|
||||
|
@ -1201,7 +1201,7 @@ mod test {
|
|||
#[test]
|
||||
fn test_switch_implies_cfg_test() {
|
||||
let matches =
|
||||
&match getopts(&["--test".to_string()], optgroups()[]) {
|
||||
&match getopts(&["--test".to_string()], optgroups().index(&FullRange)) {
|
||||
Ok(m) => m,
|
||||
Err(f) => panic!("test_switch_implies_cfg_test: {}", f)
|
||||
};
|
||||
|
@ -1209,7 +1209,7 @@ mod test {
|
|||
let sessopts = build_session_options(matches);
|
||||
let sess = build_session(sessopts, None, registry);
|
||||
let cfg = build_configuration(&sess);
|
||||
assert!((attr::contains_name(cfg[], "test")));
|
||||
assert!((attr::contains_name(cfg.index(&FullRange), "test")));
|
||||
}
|
||||
|
||||
// When the user supplies --test and --cfg test, don't implicitly add
|
||||
|
@ -1218,7 +1218,7 @@ mod test {
|
|||
fn test_switch_implies_cfg_test_unless_cfg_test() {
|
||||
let matches =
|
||||
&match getopts(&["--test".to_string(), "--cfg=test".to_string()],
|
||||
optgroups()[]) {
|
||||
optgroups().index(&FullRange)) {
|
||||
Ok(m) => m,
|
||||
Err(f) => {
|
||||
panic!("test_switch_implies_cfg_test_unless_cfg_test: {}", f)
|
||||
|
@ -1238,7 +1238,7 @@ mod test {
|
|||
{
|
||||
let matches = getopts(&[
|
||||
"-Awarnings".to_string()
|
||||
], optgroups()[]).unwrap();
|
||||
], optgroups().index(&FullRange)).unwrap();
|
||||
let registry = diagnostics::registry::Registry::new(&[]);
|
||||
let sessopts = build_session_options(&matches);
|
||||
let sess = build_session(sessopts, None, registry);
|
||||
|
@ -1249,7 +1249,7 @@ mod test {
|
|||
let matches = getopts(&[
|
||||
"-Awarnings".to_string(),
|
||||
"-Dwarnings".to_string()
|
||||
], optgroups()[]).unwrap();
|
||||
], optgroups().index(&FullRange)).unwrap();
|
||||
let registry = diagnostics::registry::Registry::new(&[]);
|
||||
let sessopts = build_session_options(&matches);
|
||||
let sess = build_session(sessopts, None, registry);
|
||||
|
@ -1259,7 +1259,7 @@ mod test {
|
|||
{
|
||||
let matches = getopts(&[
|
||||
"-Adead_code".to_string()
|
||||
], optgroups()[]).unwrap();
|
||||
], optgroups().index(&FullRange)).unwrap();
|
||||
let registry = diagnostics::registry::Registry::new(&[]);
|
||||
let sessopts = build_session_options(&matches);
|
||||
let sess = build_session(sessopts, None, registry);
|
||||
|
|
|
@ -174,7 +174,7 @@ impl Session {
|
|||
// cases later on
|
||||
pub fn impossible_case(&self, sp: Span, msg: &str) -> ! {
|
||||
self.span_bug(sp,
|
||||
format!("impossible case reached: {}", msg)[]);
|
||||
format!("impossible case reached: {}", msg).index(&FullRange));
|
||||
}
|
||||
pub fn verbose(&self) -> bool { self.debugging_opt(config::VERBOSE) }
|
||||
pub fn time_passes(&self) -> bool { self.debugging_opt(config::TIME_PASSES) }
|
||||
|
@ -216,7 +216,7 @@ impl Session {
|
|||
}
|
||||
pub fn target_filesearch(&self, kind: PathKind) -> filesearch::FileSearch {
|
||||
filesearch::FileSearch::new(self.sysroot(),
|
||||
self.opts.target_triple[],
|
||||
self.opts.target_triple.index(&FullRange),
|
||||
&self.opts.search_paths,
|
||||
kind)
|
||||
}
|
||||
|
|
|
@ -48,7 +48,7 @@ fn test_lev_distance() {
|
|||
for c in range(0u32, MAX as u32)
|
||||
.filter_map(|i| from_u32(i))
|
||||
.map(|i| i.to_string()) {
|
||||
assert_eq!(lev_distance(c[], c[]), 0);
|
||||
assert_eq!(lev_distance(c.index(&FullRange), c.index(&FullRange)), 0);
|
||||
}
|
||||
|
||||
let a = "\nMäry häd ä little lämb\n\nLittle lämb\n";
|
||||
|
|
|
@ -55,12 +55,12 @@ pub fn note_and_explain_region(cx: &ctxt,
|
|||
(ref str, Some(span)) => {
|
||||
cx.sess.span_note(
|
||||
span,
|
||||
format!("{}{}{}", prefix, *str, suffix)[]);
|
||||
format!("{}{}{}", prefix, *str, suffix).index(&FullRange));
|
||||
Some(span)
|
||||
}
|
||||
(ref str, None) => {
|
||||
cx.sess.note(
|
||||
format!("{}{}{}", prefix, *str, suffix)[]);
|
||||
format!("{}{}{}", prefix, *str, suffix).index(&FullRange));
|
||||
None
|
||||
}
|
||||
}
|
||||
|
@ -271,7 +271,7 @@ pub fn ty_to_string<'tcx>(cx: &ctxt<'tcx>, typ: &ty::TyS<'tcx>) -> String {
|
|||
};
|
||||
|
||||
if abi != abi::Rust {
|
||||
s.push_str(format!("extern {} ", abi.to_string())[]);
|
||||
s.push_str(format!("extern {} ", abi.to_string()).index(&FullRange));
|
||||
};
|
||||
|
||||
s.push_str("fn");
|
||||
|
@ -290,7 +290,7 @@ pub fn ty_to_string<'tcx>(cx: &ctxt<'tcx>, typ: &ty::TyS<'tcx>) -> String {
|
|||
Some(def_id) => {
|
||||
s.push_str(" {");
|
||||
let path_str = ty::item_path_str(cx, def_id);
|
||||
s.push_str(path_str[]);
|
||||
s.push_str(path_str.index(&FullRange));
|
||||
s.push_str("}");
|
||||
}
|
||||
None => { }
|
||||
|
@ -305,7 +305,7 @@ pub fn ty_to_string<'tcx>(cx: &ctxt<'tcx>, typ: &ty::TyS<'tcx>) -> String {
|
|||
match cty.store {
|
||||
ty::UniqTraitStore => {}
|
||||
ty::RegionTraitStore(region, _) => {
|
||||
s.push_str(region_to_string(cx, "", true, region)[]);
|
||||
s.push_str(region_to_string(cx, "", true, region).index(&FullRange));
|
||||
}
|
||||
}
|
||||
|
||||
|
@ -324,7 +324,7 @@ pub fn ty_to_string<'tcx>(cx: &ctxt<'tcx>, typ: &ty::TyS<'tcx>) -> String {
|
|||
assert_eq!(cty.onceness, ast::Once);
|
||||
s.push_str("proc");
|
||||
push_sig_to_string(cx, &mut s, '(', ')', &cty.sig,
|
||||
bounds_str[]);
|
||||
bounds_str.index(&FullRange));
|
||||
}
|
||||
ty::RegionTraitStore(..) => {
|
||||
match cty.onceness {
|
||||
|
@ -332,7 +332,7 @@ pub fn ty_to_string<'tcx>(cx: &ctxt<'tcx>, typ: &ty::TyS<'tcx>) -> String {
|
|||
ast::Once => s.push_str("once ")
|
||||
}
|
||||
push_sig_to_string(cx, &mut s, '|', '|', &cty.sig,
|
||||
bounds_str[]);
|
||||
bounds_str.index(&FullRange));
|
||||
}
|
||||
}
|
||||
|
||||
|
@ -365,7 +365,7 @@ pub fn ty_to_string<'tcx>(cx: &ctxt<'tcx>, typ: &ty::TyS<'tcx>) -> String {
|
|||
ty::FnConverging(t) => {
|
||||
if !ty::type_is_nil(t) {
|
||||
s.push_str(" -> ");
|
||||
s.push_str(ty_to_string(cx, t)[]);
|
||||
s.push_str(ty_to_string(cx, t).index(&FullRange));
|
||||
}
|
||||
}
|
||||
ty::FnDiverging => {
|
||||
|
@ -402,7 +402,7 @@ pub fn ty_to_string<'tcx>(cx: &ctxt<'tcx>, typ: &ty::TyS<'tcx>) -> String {
|
|||
}
|
||||
ty_rptr(r, ref tm) => {
|
||||
let mut buf = region_ptr_to_string(cx, *r);
|
||||
buf.push_str(mt_to_string(cx, tm)[]);
|
||||
buf.push_str(mt_to_string(cx, tm).index(&FullRange));
|
||||
buf
|
||||
}
|
||||
ty_open(typ) =>
|
||||
|
@ -412,7 +412,7 @@ pub fn ty_to_string<'tcx>(cx: &ctxt<'tcx>, typ: &ty::TyS<'tcx>) -> String {
|
|||
.iter()
|
||||
.map(|elem| ty_to_string(cx, *elem))
|
||||
.collect::<Vec<_>>();
|
||||
match strs[] {
|
||||
match strs.index(&FullRange) {
|
||||
[ref string] => format!("({},)", string),
|
||||
strs => format!("({})", strs.connect(", "))
|
||||
}
|
||||
|
@ -541,7 +541,7 @@ pub fn parameterized<'tcx>(cx: &ctxt<'tcx>,
|
|||
0
|
||||
};
|
||||
|
||||
for t in tps[..tps.len() - num_defaults].iter() {
|
||||
for t in tps.index(&(0..(tps.len() - num_defaults))).iter() {
|
||||
strs.push(ty_to_string(cx, *t))
|
||||
}
|
||||
|
||||
|
@ -549,11 +549,11 @@ pub fn parameterized<'tcx>(cx: &ctxt<'tcx>,
|
|||
format!("{}({}){}",
|
||||
base,
|
||||
if strs[0].starts_with("(") && strs[0].ends_with(",)") {
|
||||
strs[0][1 .. strs[0].len() - 2] // Remove '(' and ',)'
|
||||
strs[0].index(&(1 .. (strs[0].len() - 2))) // Remove '(' and ',)'
|
||||
} else if strs[0].starts_with("(") && strs[0].ends_with(")") {
|
||||
strs[0][1 .. strs[0].len() - 1] // Remove '(' and ')'
|
||||
strs[0].index(&(1 .. (strs[0].len() - 1))) // Remove '(' and ')'
|
||||
} else {
|
||||
strs[0][]
|
||||
strs[0].index(&FullRange)
|
||||
},
|
||||
if &*strs[1] == "()" { String::new() } else { format!(" -> {}", strs[1]) })
|
||||
} else if strs.len() > 0 {
|
||||
|
@ -566,7 +566,7 @@ pub fn parameterized<'tcx>(cx: &ctxt<'tcx>,
|
|||
pub fn ty_to_short_str<'tcx>(cx: &ctxt<'tcx>, typ: Ty<'tcx>) -> String {
|
||||
let mut s = typ.repr(cx).to_string();
|
||||
if s.len() >= 32u {
|
||||
s = s[0u..32u].to_string();
|
||||
s = s.index(&(0u..32u)).to_string();
|
||||
}
|
||||
return s;
|
||||
}
|
||||
|
@ -631,7 +631,7 @@ impl<'tcx, T:Repr<'tcx>> Repr<'tcx> for [T] {
|
|||
|
||||
impl<'tcx, T:Repr<'tcx>> Repr<'tcx> for OwnedSlice<T> {
|
||||
fn repr(&self, tcx: &ctxt<'tcx>) -> String {
|
||||
repr_vec(tcx, self[])
|
||||
repr_vec(tcx, self.index(&FullRange))
|
||||
}
|
||||
}
|
||||
|
||||
|
@ -639,7 +639,7 @@ impl<'tcx, T:Repr<'tcx>> Repr<'tcx> for OwnedSlice<T> {
|
|||
// autoderef cannot convert the &[T] handler
|
||||
impl<'tcx, T:Repr<'tcx>> Repr<'tcx> for Vec<T> {
|
||||
fn repr(&self, tcx: &ctxt<'tcx>) -> String {
|
||||
repr_vec(tcx, self[])
|
||||
repr_vec(tcx, self.index(&FullRange))
|
||||
}
|
||||
}
|
||||
|
||||
|
|
|
@ -116,7 +116,7 @@ impl<T,U,D:SnapshotVecDelegate<T,U>> SnapshotVec<T,U,D> {
|
|||
pub fn actions_since_snapshot(&self,
|
||||
snapshot: &Snapshot)
|
||||
-> &[UndoLog<T,U>] {
|
||||
self.undo_log[snapshot.length..]
|
||||
self.undo_log.index(&(snapshot.length..))
|
||||
}
|
||||
|
||||
fn assert_open_snapshot(&self, snapshot: &Snapshot) {
|
||||
|
|
|
@ -53,7 +53,7 @@ fn run_ar(handler: &ErrorHandler, maybe_ar_prog: &Option<String>,
|
|||
args: &str, cwd: Option<&Path>,
|
||||
paths: &[&Path]) -> ProcessOutput {
|
||||
let ar = match *maybe_ar_prog {
|
||||
Some(ref ar) => ar[],
|
||||
Some(ref ar) => ar.index(&FullRange),
|
||||
None => "ar"
|
||||
};
|
||||
let mut cmd = Command::new(ar);
|
||||
|
@ -75,22 +75,22 @@ fn run_ar(handler: &ErrorHandler, maybe_ar_prog: &Option<String>,
|
|||
if !o.status.success() {
|
||||
handler.err(format!("{} failed with: {}",
|
||||
cmd,
|
||||
o.status)[]);
|
||||
o.status).index(&FullRange));
|
||||
handler.note(format!("stdout ---\n{}",
|
||||
str::from_utf8(o.output
|
||||
[]).unwrap())
|
||||
[]);
|
||||
.index(&FullRange)).unwrap())
|
||||
.index(&FullRange));
|
||||
handler.note(format!("stderr ---\n{}",
|
||||
str::from_utf8(o.error
|
||||
[]).unwrap())
|
||||
[]);
|
||||
.index(&FullRange)).unwrap())
|
||||
.index(&FullRange));
|
||||
handler.abort_if_errors();
|
||||
}
|
||||
o
|
||||
},
|
||||
Err(e) => {
|
||||
handler.err(format!("could not exec `{}`: {}", ar[],
|
||||
e)[]);
|
||||
handler.err(format!("could not exec `{}`: {}", ar.index(&FullRange),
|
||||
e).index(&FullRange));
|
||||
handler.abort_if_errors();
|
||||
panic!("rustc::back::archive::run_ar() should not reach this point");
|
||||
}
|
||||
|
@ -106,16 +106,16 @@ pub fn find_library(name: &str, osprefix: &str, ossuffix: &str,
|
|||
|
||||
for path in search_paths.iter() {
|
||||
debug!("looking for {} inside {}", name, path.display());
|
||||
let test = path.join(oslibname[]);
|
||||
let test = path.join(oslibname.index(&FullRange));
|
||||
if test.exists() { return test }
|
||||
if oslibname != unixlibname {
|
||||
let test = path.join(unixlibname[]);
|
||||
let test = path.join(unixlibname.index(&FullRange));
|
||||
if test.exists() { return test }
|
||||
}
|
||||
}
|
||||
handler.fatal(format!("could not find native static library `{}`, \
|
||||
perhaps an -L flag is missing?",
|
||||
name)[]);
|
||||
name).index(&FullRange));
|
||||
}
|
||||
|
||||
impl<'a> Archive<'a> {
|
||||
|
@ -147,7 +147,7 @@ impl<'a> Archive<'a> {
|
|||
/// Lists all files in an archive
|
||||
pub fn files(&self) -> Vec<String> {
|
||||
let output = run_ar(self.handler, &self.maybe_ar_prog, "t", None, &[&self.dst]);
|
||||
let output = str::from_utf8(output.output[]).unwrap();
|
||||
let output = str::from_utf8(output.output.index(&FullRange)).unwrap();
|
||||
// use lines_any because windows delimits output with `\r\n` instead of
|
||||
// just `\n`
|
||||
output.lines_any().map(|s| s.to_string()).collect()
|
||||
|
@ -179,9 +179,9 @@ impl<'a> ArchiveBuilder<'a> {
|
|||
/// search in the relevant locations for a library named `name`.
|
||||
pub fn add_native_library(&mut self, name: &str) -> io::IoResult<()> {
|
||||
let location = find_library(name,
|
||||
self.archive.slib_prefix[],
|
||||
self.archive.slib_suffix[],
|
||||
self.archive.lib_search_paths[],
|
||||
self.archive.slib_prefix.index(&FullRange),
|
||||
self.archive.slib_suffix.index(&FullRange),
|
||||
self.archive.lib_search_paths.index(&FullRange),
|
||||
self.archive.handler);
|
||||
self.add_archive(&location, name, |_| false)
|
||||
}
|
||||
|
@ -197,12 +197,12 @@ impl<'a> ArchiveBuilder<'a> {
|
|||
// as simple comparison is not enough - there
|
||||
// might be also an extra name suffix
|
||||
let obj_start = format!("{}", name);
|
||||
let obj_start = obj_start[];
|
||||
let obj_start = obj_start.index(&FullRange);
|
||||
// Ignoring all bytecode files, no matter of
|
||||
// name
|
||||
let bc_ext = ".bytecode.deflate";
|
||||
|
||||
self.add_archive(rlib, name[], |fname: &str| {
|
||||
self.add_archive(rlib, name.index(&FullRange), |fname: &str| {
|
||||
let skip_obj = lto && fname.starts_with(obj_start)
|
||||
&& fname.ends_with(".o");
|
||||
skip_obj || fname.ends_with(bc_ext) || fname == METADATA_FILENAME
|
||||
|
@ -239,7 +239,7 @@ impl<'a> ArchiveBuilder<'a> {
|
|||
// allow running `ar s file.a` to update symbols only.
|
||||
if self.should_update_symbols {
|
||||
run_ar(self.archive.handler, &self.archive.maybe_ar_prog,
|
||||
"s", Some(self.work_dir.path()), args[]);
|
||||
"s", Some(self.work_dir.path()), args.index(&FullRange));
|
||||
}
|
||||
return self.archive;
|
||||
}
|
||||
|
@ -259,7 +259,7 @@ impl<'a> ArchiveBuilder<'a> {
|
|||
// Add the archive members seen so far, without updating the
|
||||
// symbol table (`S`).
|
||||
run_ar(self.archive.handler, &self.archive.maybe_ar_prog,
|
||||
"cruS", Some(self.work_dir.path()), args[]);
|
||||
"cruS", Some(self.work_dir.path()), args.index(&FullRange));
|
||||
|
||||
args.clear();
|
||||
args.push(&abs_dst);
|
||||
|
@ -274,7 +274,7 @@ impl<'a> ArchiveBuilder<'a> {
|
|||
// necessary.
|
||||
let flags = if self.should_update_symbols { "crus" } else { "cruS" };
|
||||
run_ar(self.archive.handler, &self.archive.maybe_ar_prog,
|
||||
flags, Some(self.work_dir.path()), args[]);
|
||||
flags, Some(self.work_dir.path()), args.index(&FullRange));
|
||||
|
||||
self.archive
|
||||
}
|
||||
|
@ -316,7 +316,7 @@ impl<'a> ArchiveBuilder<'a> {
|
|||
} else {
|
||||
filename
|
||||
};
|
||||
let new_filename = self.work_dir.path().join(filename[]);
|
||||
let new_filename = self.work_dir.path().join(filename.index(&FullRange));
|
||||
try!(fs::rename(file, &new_filename));
|
||||
self.members.push(Path::new(filename));
|
||||
}
|
||||
|
|
|
@ -44,15 +44,15 @@ pub fn get_rpath_flags<F, G>(config: RPathConfig<F, G>) -> Vec<String> where
|
|||
l.map(|p| p.clone())
|
||||
}).collect::<Vec<_>>();
|
||||
|
||||
let rpaths = get_rpaths(config, libs[]);
|
||||
flags.push_all(rpaths_to_flags(rpaths[])[]);
|
||||
let rpaths = get_rpaths(config, libs.index(&FullRange));
|
||||
flags.push_all(rpaths_to_flags(rpaths.index(&FullRange)).index(&FullRange));
|
||||
flags
|
||||
}
|
||||
|
||||
fn rpaths_to_flags(rpaths: &[String]) -> Vec<String> {
|
||||
let mut ret = Vec::new();
|
||||
for rpath in rpaths.iter() {
|
||||
ret.push(format!("-Wl,-rpath,{}", (*rpath)[]));
|
||||
ret.push(format!("-Wl,-rpath,{}", (*rpath).index(&FullRange)));
|
||||
}
|
||||
return ret;
|
||||
}
|
||||
|
@ -82,14 +82,14 @@ fn get_rpaths<F, G>(mut config: RPathConfig<F, G>, libs: &[Path]) -> Vec<String>
|
|||
}
|
||||
}
|
||||
|
||||
log_rpaths("relative", rel_rpaths[]);
|
||||
log_rpaths("fallback", fallback_rpaths[]);
|
||||
log_rpaths("relative", rel_rpaths.index(&FullRange));
|
||||
log_rpaths("fallback", fallback_rpaths.index(&FullRange));
|
||||
|
||||
let mut rpaths = rel_rpaths;
|
||||
rpaths.push_all(fallback_rpaths[]);
|
||||
rpaths.push_all(fallback_rpaths.index(&FullRange));
|
||||
|
||||
// Remove duplicates
|
||||
let rpaths = minimize_rpaths(rpaths[]);
|
||||
let rpaths = minimize_rpaths(rpaths.index(&FullRange));
|
||||
return rpaths;
|
||||
}
|
||||
|
||||
|
@ -140,7 +140,7 @@ fn minimize_rpaths(rpaths: &[String]) -> Vec<String> {
|
|||
let mut set = HashSet::new();
|
||||
let mut minimized = Vec::new();
|
||||
for rpath in rpaths.iter() {
|
||||
if set.insert(rpath[]) {
|
||||
if set.insert(rpath.index(&FullRange)) {
|
||||
minimized.push(rpath.clone());
|
||||
}
|
||||
}
|
||||
|
|
|
@ -140,7 +140,7 @@ impl FixedBuffer for FixedBuffer64 {
|
|||
if input.len() >= buffer_remaining {
|
||||
copy_memory(
|
||||
self.buffer.slice_mut(self.buffer_idx, size),
|
||||
input[..buffer_remaining]);
|
||||
input.index(&(0..buffer_remaining)));
|
||||
self.buffer_idx = 0;
|
||||
func(&self.buffer);
|
||||
i += buffer_remaining;
|
||||
|
@ -156,7 +156,7 @@ impl FixedBuffer for FixedBuffer64 {
|
|||
// While we have at least a full buffer size chunk's worth of data, process that data
|
||||
// without copying it into the buffer
|
||||
while input.len() - i >= size {
|
||||
func(input[i..i + size]);
|
||||
func(input.index(&(i..(i + size))));
|
||||
i += size;
|
||||
}
|
||||
|
||||
|
@ -166,7 +166,7 @@ impl FixedBuffer for FixedBuffer64 {
|
|||
let input_remaining = input.len() - i;
|
||||
copy_memory(
|
||||
self.buffer.slice_to_mut(input_remaining),
|
||||
input[i..]);
|
||||
input.index(&(i..)));
|
||||
self.buffer_idx += input_remaining;
|
||||
}
|
||||
|
||||
|
@ -188,7 +188,7 @@ impl FixedBuffer for FixedBuffer64 {
|
|||
fn full_buffer<'s>(&'s mut self) -> &'s [u8] {
|
||||
assert!(self.buffer_idx == 64);
|
||||
self.buffer_idx = 0;
|
||||
return self.buffer[..64];
|
||||
return self.buffer.index(&(0..64));
|
||||
}
|
||||
|
||||
fn position(&self) -> uint { self.buffer_idx }
|
||||
|
|
|
@ -65,7 +65,7 @@ impl Svh {
|
|||
}
|
||||
|
||||
pub fn as_str<'a>(&'a self) -> &'a str {
|
||||
self.hash[]
|
||||
self.hash.index(&FullRange)
|
||||
}
|
||||
|
||||
pub fn calculate(metadata: &Vec<String>, krate: &ast::Crate) -> Svh {
|
||||
|
@ -358,7 +358,7 @@ mod svh_visitor {
|
|||
fn macro_name(mac: &Mac) -> token::InternedString {
|
||||
match &mac.node {
|
||||
&MacInvocTT(ref path, ref _tts, ref _stx_ctxt) => {
|
||||
let s = path.segments[];
|
||||
let s = path.segments.index(&FullRange);
|
||||
assert_eq!(s.len(), 1);
|
||||
content(s[0].identifier)
|
||||
}
|
||||
|
|
|
@ -225,7 +225,7 @@ impl Target {
|
|||
Some(val) => val,
|
||||
None =>
|
||||
handler.fatal((format!("Field {} in target specification is required", name))
|
||||
[])
|
||||
.index(&FullRange))
|
||||
}
|
||||
};
|
||||
|
||||
|
@ -242,16 +242,16 @@ impl Target {
|
|||
macro_rules! key {
|
||||
($key_name:ident) => ( {
|
||||
let name = (stringify!($key_name)).replace("_", "-");
|
||||
obj.find(name[]).map(|o| o.as_string()
|
||||
obj.find(name.index(&FullRange)).map(|o| o.as_string()
|
||||
.map(|s| base.options.$key_name = s.to_string()));
|
||||
} );
|
||||
($key_name:ident, bool) => ( {
|
||||
let name = (stringify!($key_name)).replace("_", "-");
|
||||
obj.find(name[]).map(|o| o.as_boolean().map(|s| base.options.$key_name = s));
|
||||
obj.find(name.index(&FullRange)).map(|o| o.as_boolean().map(|s| base.options.$key_name = s));
|
||||
} );
|
||||
($key_name:ident, list) => ( {
|
||||
let name = (stringify!($key_name)).replace("_", "-");
|
||||
obj.find(name[]).map(|o| o.as_array()
|
||||
obj.find(name.index(&FullRange)).map(|o| o.as_array()
|
||||
.map(|v| base.options.$key_name = v.iter()
|
||||
.map(|a| a.as_string().unwrap().to_string()).collect()
|
||||
)
|
||||
|
@ -367,7 +367,7 @@ impl Target {
|
|||
|
||||
let target_path = os::getenv("RUST_TARGET_PATH").unwrap_or(String::new());
|
||||
|
||||
let paths = os::split_paths(target_path[]);
|
||||
let paths = os::split_paths(target_path.index(&FullRange));
|
||||
// FIXME 16351: add a sane default search path?
|
||||
|
||||
for dir in paths.iter() {
|
||||
|
|
|
@ -465,7 +465,7 @@ impl<'a, 'tcx> CheckLoanCtxt<'a, 'tcx> {
|
|||
new_loan.span,
|
||||
format!("cannot borrow `{}`{} as mutable \
|
||||
more than once at a time",
|
||||
nl, new_loan_msg)[])
|
||||
nl, new_loan_msg).index(&FullRange))
|
||||
}
|
||||
|
||||
(ty::UniqueImmBorrow, _) => {
|
||||
|
@ -473,7 +473,7 @@ impl<'a, 'tcx> CheckLoanCtxt<'a, 'tcx> {
|
|||
new_loan.span,
|
||||
format!("closure requires unique access to `{}` \
|
||||
but {} is already borrowed{}",
|
||||
nl, ol_pronoun, old_loan_msg)[]);
|
||||
nl, ol_pronoun, old_loan_msg).index(&FullRange));
|
||||
}
|
||||
|
||||
(_, ty::UniqueImmBorrow) => {
|
||||
|
@ -481,7 +481,7 @@ impl<'a, 'tcx> CheckLoanCtxt<'a, 'tcx> {
|
|||
new_loan.span,
|
||||
format!("cannot borrow `{}`{} as {} because \
|
||||
previous closure requires unique access",
|
||||
nl, new_loan_msg, new_loan.kind.to_user_str())[]);
|
||||
nl, new_loan_msg, new_loan.kind.to_user_str()).index(&FullRange));
|
||||
}
|
||||
|
||||
(_, _) => {
|
||||
|
@ -494,7 +494,7 @@ impl<'a, 'tcx> CheckLoanCtxt<'a, 'tcx> {
|
|||
new_loan.kind.to_user_str(),
|
||||
ol_pronoun,
|
||||
old_loan.kind.to_user_str(),
|
||||
old_loan_msg)[]);
|
||||
old_loan_msg).index(&FullRange));
|
||||
}
|
||||
}
|
||||
|
||||
|
@ -503,7 +503,7 @@ impl<'a, 'tcx> CheckLoanCtxt<'a, 'tcx> {
|
|||
self.bccx.span_note(
|
||||
span,
|
||||
format!("borrow occurs due to use of `{}` in closure",
|
||||
nl)[]);
|
||||
nl).index(&FullRange));
|
||||
}
|
||||
_ => { }
|
||||
}
|
||||
|
@ -552,7 +552,7 @@ impl<'a, 'tcx> CheckLoanCtxt<'a, 'tcx> {
|
|||
|
||||
self.bccx.span_note(
|
||||
old_loan.span,
|
||||
format!("{}; {}", borrow_summary, rule_summary)[]);
|
||||
format!("{}; {}", borrow_summary, rule_summary).index(&FullRange));
|
||||
|
||||
let old_loan_span = self.tcx().map.span(old_loan.kill_scope.node_id());
|
||||
self.bccx.span_end_note(old_loan_span,
|
||||
|
@ -622,13 +622,13 @@ impl<'a, 'tcx> CheckLoanCtxt<'a, 'tcx> {
|
|||
self.bccx.span_err(
|
||||
span,
|
||||
format!("cannot use `{}` because it was mutably borrowed",
|
||||
self.bccx.loan_path_to_string(copy_path)[])
|
||||
[]);
|
||||
self.bccx.loan_path_to_string(copy_path).index(&FullRange))
|
||||
.index(&FullRange));
|
||||
self.bccx.span_note(
|
||||
loan_span,
|
||||
format!("borrow of `{}` occurs here",
|
||||
self.bccx.loan_path_to_string(&*loan_path)[])
|
||||
[]);
|
||||
self.bccx.loan_path_to_string(&*loan_path).index(&FullRange))
|
||||
.index(&FullRange));
|
||||
}
|
||||
}
|
||||
}
|
||||
|
@ -647,20 +647,20 @@ impl<'a, 'tcx> CheckLoanCtxt<'a, 'tcx> {
|
|||
let err_message = match move_kind {
|
||||
move_data::Captured =>
|
||||
format!("cannot move `{}` into closure because it is borrowed",
|
||||
self.bccx.loan_path_to_string(move_path)[]),
|
||||
self.bccx.loan_path_to_string(move_path).index(&FullRange)),
|
||||
move_data::Declared |
|
||||
move_data::MoveExpr |
|
||||
move_data::MovePat =>
|
||||
format!("cannot move out of `{}` because it is borrowed",
|
||||
self.bccx.loan_path_to_string(move_path)[])
|
||||
self.bccx.loan_path_to_string(move_path).index(&FullRange))
|
||||
};
|
||||
|
||||
self.bccx.span_err(span, err_message[]);
|
||||
self.bccx.span_err(span, err_message.index(&FullRange));
|
||||
self.bccx.span_note(
|
||||
loan_span,
|
||||
format!("borrow of `{}` occurs here",
|
||||
self.bccx.loan_path_to_string(&*loan_path)[])
|
||||
[]);
|
||||
self.bccx.loan_path_to_string(&*loan_path).index(&FullRange))
|
||||
.index(&FullRange));
|
||||
}
|
||||
}
|
||||
}
|
||||
|
@ -810,7 +810,7 @@ impl<'a, 'tcx> CheckLoanCtxt<'a, 'tcx> {
|
|||
self.bccx.span_err(
|
||||
assignment_span,
|
||||
format!("cannot assign to {}",
|
||||
self.bccx.cmt_to_string(&*assignee_cmt))[]);
|
||||
self.bccx.cmt_to_string(&*assignee_cmt)).index(&FullRange));
|
||||
self.bccx.span_help(
|
||||
self.tcx().map.span(upvar_id.closure_expr_id),
|
||||
"consider changing this closure to take self by mutable reference");
|
||||
|
@ -819,7 +819,7 @@ impl<'a, 'tcx> CheckLoanCtxt<'a, 'tcx> {
|
|||
assignment_span,
|
||||
format!("cannot assign to {} {}",
|
||||
assignee_cmt.mutbl.to_user_str(),
|
||||
self.bccx.cmt_to_string(&*assignee_cmt))[]);
|
||||
self.bccx.cmt_to_string(&*assignee_cmt)).index(&FullRange));
|
||||
}
|
||||
}
|
||||
_ => match opt_loan_path(&assignee_cmt) {
|
||||
|
@ -829,14 +829,14 @@ impl<'a, 'tcx> CheckLoanCtxt<'a, 'tcx> {
|
|||
format!("cannot assign to {} {} `{}`",
|
||||
assignee_cmt.mutbl.to_user_str(),
|
||||
self.bccx.cmt_to_string(&*assignee_cmt),
|
||||
self.bccx.loan_path_to_string(&*lp))[]);
|
||||
self.bccx.loan_path_to_string(&*lp)).index(&FullRange));
|
||||
}
|
||||
None => {
|
||||
self.bccx.span_err(
|
||||
assignment_span,
|
||||
format!("cannot assign to {} {}",
|
||||
assignee_cmt.mutbl.to_user_str(),
|
||||
self.bccx.cmt_to_string(&*assignee_cmt))[]);
|
||||
self.bccx.cmt_to_string(&*assignee_cmt)).index(&FullRange));
|
||||
}
|
||||
}
|
||||
}
|
||||
|
@ -956,10 +956,10 @@ impl<'a, 'tcx> CheckLoanCtxt<'a, 'tcx> {
|
|||
self.bccx.span_err(
|
||||
span,
|
||||
format!("cannot assign to `{}` because it is borrowed",
|
||||
self.bccx.loan_path_to_string(loan_path))[]);
|
||||
self.bccx.loan_path_to_string(loan_path)).index(&FullRange));
|
||||
self.bccx.span_note(
|
||||
loan.span,
|
||||
format!("borrow of `{}` occurs here",
|
||||
self.bccx.loan_path_to_string(loan_path))[]);
|
||||
self.bccx.loan_path_to_string(loan_path)).index(&FullRange));
|
||||
}
|
||||
}
|
||||
|
|
|
@ -138,7 +138,7 @@
|
|||
//! - `FREEZE` means that the `LV` cannot be borrowed immutably;
|
||||
//!
|
||||
//! Finally, it is never possible to move from an lvalue that appears in a
|
||||
//! restriction. This implies that the "empty restriction" `(LV, [])`,
|
||||
//! restriction. This implies that the "empty restriction" `(LV, .index(&FullRange))`,
|
||||
//! which contains an empty set of actions, still has a purpose---it
|
||||
//! prevents moves from `LV`. I chose not to make `MOVE` a fourth kind of
|
||||
//! action because that would imply that sometimes moves are permitted
|
||||
|
@ -476,7 +476,7 @@
|
|||
//! ```text
|
||||
//! &mut LV => RESTRICTIONS(LV, LT, MUTATE|CLAIM|FREEZE)
|
||||
//! &LV => RESTRICTIONS(LV, LT, MUTATE|CLAIM)
|
||||
//! &const LV => RESTRICTIONS(LV, LT, [])
|
||||
//! &const LV => RESTRICTIONS(LV, LT, .index(&FullRange))
|
||||
//! ```
|
||||
//!
|
||||
//! The reasoning here is that a mutable borrow must be the only writer,
|
||||
|
@ -542,7 +542,7 @@
|
|||
//! restricting `MUTATE` and `CLAIM` actions:
|
||||
//!
|
||||
//! ```text
|
||||
//! RESTRICTIONS(*LV, LT, ACTIONS) = [] // R-Deref-Imm-Borrowed
|
||||
//! RESTRICTIONS(*LV, LT, ACTIONS) = .index(&FullRange) // R-Deref-Imm-Borrowed
|
||||
//! TYPE(LV) = <' Ty
|
||||
//! LT <= LT' // (1)
|
||||
//! ACTIONS subset of [MUTATE, CLAIM]
|
||||
|
@ -660,7 +660,7 @@
|
|||
//! necessary to add any restrictions at all to the final result.
|
||||
//!
|
||||
//! ```text
|
||||
//! RESTRICTIONS(*LV, LT, []) = [] // R-Deref-Freeze-Borrowed
|
||||
//! RESTRICTIONS(*LV, LT, .index(&FullRange)) = .index(&FullRange) // R-Deref-Freeze-Borrowed
|
||||
//! TYPE(LV) = &const Ty
|
||||
//! ```
|
||||
//!
|
||||
|
|
|
@ -38,7 +38,7 @@ enum Fragment {
|
|||
// This represents the collection of all but one of the elements
|
||||
// from an array at the path described by the move path index.
|
||||
// Note that attached MovePathIndex should have mem_categorization
|
||||
// of InteriorElement (i.e. array dereference `[]`).
|
||||
// of InteriorElement (i.e. array dereference `.index(&FullRange)`).
|
||||
AllButOneFrom(MovePathIndex),
|
||||
}
|
||||
|
||||
|
@ -123,12 +123,12 @@ pub fn instrument_move_fragments<'tcx>(this: &MoveData<'tcx>,
|
|||
let attrs : &[ast::Attribute];
|
||||
attrs = match tcx.map.find(id) {
|
||||
Some(ast_map::NodeItem(ref item)) =>
|
||||
item.attrs[],
|
||||
item.attrs.index(&FullRange),
|
||||
Some(ast_map::NodeImplItem(&ast::MethodImplItem(ref m))) =>
|
||||
m.attrs[],
|
||||
m.attrs.index(&FullRange),
|
||||
Some(ast_map::NodeTraitItem(&ast::ProvidedMethod(ref m))) =>
|
||||
m.attrs[],
|
||||
_ => [][],
|
||||
m.attrs.index(&FullRange),
|
||||
_ => [].index(&FullRange),
|
||||
};
|
||||
|
||||
let span_err =
|
||||
|
@ -144,7 +144,7 @@ pub fn instrument_move_fragments<'tcx>(this: &MoveData<'tcx>,
|
|||
for (i, mpi) in vec_rc.iter().enumerate() {
|
||||
let render = |&:| this.path_loan_path(*mpi).user_string(tcx);
|
||||
if span_err {
|
||||
tcx.sess.span_err(sp, format!("{}: `{}`", kind, render())[]);
|
||||
tcx.sess.span_err(sp, format!("{}: `{}`", kind, render()).index(&FullRange));
|
||||
}
|
||||
if print {
|
||||
println!("id:{} {}[{}] `{}`", id, kind, i, render());
|
||||
|
@ -156,7 +156,7 @@ pub fn instrument_move_fragments<'tcx>(this: &MoveData<'tcx>,
|
|||
for (i, f) in vec_rc.iter().enumerate() {
|
||||
let render = |&:| f.loan_path_user_string(this, tcx);
|
||||
if span_err {
|
||||
tcx.sess.span_err(sp, format!("{}: `{}`", kind, render())[]);
|
||||
tcx.sess.span_err(sp, format!("{}: `{}`", kind, render()).index(&FullRange));
|
||||
}
|
||||
if print {
|
||||
println!("id:{} {}[{}] `{}`", id, kind, i, render());
|
||||
|
@ -198,11 +198,11 @@ pub fn fixup_fragment_sets<'tcx>(this: &MoveData<'tcx>, tcx: &ty::ctxt<'tcx>) {
|
|||
// First, filter out duplicates
|
||||
moved.sort();
|
||||
moved.dedup();
|
||||
debug!("fragments 1 moved: {}", path_lps(moved[]));
|
||||
debug!("fragments 1 moved: {}", path_lps(moved.index(&FullRange)));
|
||||
|
||||
assigned.sort();
|
||||
assigned.dedup();
|
||||
debug!("fragments 1 assigned: {}", path_lps(assigned[]));
|
||||
debug!("fragments 1 assigned: {}", path_lps(assigned.index(&FullRange)));
|
||||
|
||||
// Second, build parents from the moved and assigned.
|
||||
for m in moved.iter() {
|
||||
|
@ -222,14 +222,14 @@ pub fn fixup_fragment_sets<'tcx>(this: &MoveData<'tcx>, tcx: &ty::ctxt<'tcx>) {
|
|||
|
||||
parents.sort();
|
||||
parents.dedup();
|
||||
debug!("fragments 2 parents: {}", path_lps(parents[]));
|
||||
debug!("fragments 2 parents: {}", path_lps(parents.index(&FullRange)));
|
||||
|
||||
// Third, filter the moved and assigned fragments down to just the non-parents
|
||||
moved.retain(|f| non_member(*f, parents[]));
|
||||
debug!("fragments 3 moved: {}", path_lps(moved[]));
|
||||
moved.retain(|f| non_member(*f, parents.index(&FullRange)));
|
||||
debug!("fragments 3 moved: {}", path_lps(moved.index(&FullRange)));
|
||||
|
||||
assigned.retain(|f| non_member(*f, parents[]));
|
||||
debug!("fragments 3 assigned: {}", path_lps(assigned[]));
|
||||
assigned.retain(|f| non_member(*f, parents.index(&FullRange)));
|
||||
debug!("fragments 3 assigned: {}", path_lps(assigned.index(&FullRange)));
|
||||
|
||||
// Fourth, build the leftover from the moved, assigned, and parents.
|
||||
for m in moved.iter() {
|
||||
|
@ -247,16 +247,16 @@ pub fn fixup_fragment_sets<'tcx>(this: &MoveData<'tcx>, tcx: &ty::ctxt<'tcx>) {
|
|||
|
||||
unmoved.sort();
|
||||
unmoved.dedup();
|
||||
debug!("fragments 4 unmoved: {}", frag_lps(unmoved[]));
|
||||
debug!("fragments 4 unmoved: {}", frag_lps(unmoved.index(&FullRange)));
|
||||
|
||||
// Fifth, filter the leftover fragments down to its core.
|
||||
unmoved.retain(|f| match *f {
|
||||
AllButOneFrom(_) => true,
|
||||
Just(mpi) => non_member(mpi, parents[]) &&
|
||||
non_member(mpi, moved[]) &&
|
||||
non_member(mpi, assigned[])
|
||||
Just(mpi) => non_member(mpi, parents.index(&FullRange)) &&
|
||||
non_member(mpi, moved.index(&FullRange)) &&
|
||||
non_member(mpi, assigned.index(&FullRange))
|
||||
});
|
||||
debug!("fragments 5 unmoved: {}", frag_lps(unmoved[]));
|
||||
debug!("fragments 5 unmoved: {}", frag_lps(unmoved.index(&FullRange)));
|
||||
|
||||
// Swap contents back in.
|
||||
fragments.unmoved_fragments = unmoved;
|
||||
|
@ -433,7 +433,7 @@ fn add_fragment_siblings_for_extension<'tcx>(this: &MoveData<'tcx>,
|
|||
let msg = format!("type {} ({}) is not fragmentable",
|
||||
parent_ty.repr(tcx), sty_and_variant_info);
|
||||
let opt_span = origin_id.and_then(|id|tcx.map.opt_span(id));
|
||||
tcx.sess.opt_span_bug(opt_span, msg[])
|
||||
tcx.sess.opt_span_bug(opt_span, msg.index(&FullRange))
|
||||
}
|
||||
}
|
||||
}
|
||||
|
|
|
@ -307,7 +307,7 @@ impl<'a, 'tcx> GatherLoanCtxt<'a, 'tcx> {
|
|||
self.tcx().sess.span_bug(
|
||||
cmt.span,
|
||||
format!("invalid borrow lifetime: {}",
|
||||
loan_region)[]);
|
||||
loan_region).index(&FullRange));
|
||||
}
|
||||
};
|
||||
debug!("loan_scope = {}", loan_scope);
|
||||
|
|
|
@ -120,7 +120,7 @@ fn report_cannot_move_out_of<'a, 'tcx>(bccx: &BorrowckCtxt<'a, 'tcx>,
|
|||
bccx.span_err(
|
||||
move_from.span,
|
||||
format!("cannot move out of {}",
|
||||
bccx.cmt_to_string(&*move_from))[]);
|
||||
bccx.cmt_to_string(&*move_from)).index(&FullRange));
|
||||
}
|
||||
|
||||
mc::cat_downcast(ref b, _) |
|
||||
|
@ -132,7 +132,7 @@ fn report_cannot_move_out_of<'a, 'tcx>(bccx: &BorrowckCtxt<'a, 'tcx>,
|
|||
move_from.span,
|
||||
format!("cannot move out of type `{}`, \
|
||||
which defines the `Drop` trait",
|
||||
b.ty.user_string(bccx.tcx))[]);
|
||||
b.ty.user_string(bccx.tcx)).index(&FullRange));
|
||||
},
|
||||
_ => panic!("this path should not cause illegal move")
|
||||
}
|
||||
|
@ -155,10 +155,10 @@ fn note_move_destination(bccx: &BorrowckCtxt,
|
|||
format!("to prevent the move, \
|
||||
use `ref {0}` or `ref mut {0}` to capture value by \
|
||||
reference",
|
||||
pat_name)[]);
|
||||
pat_name).index(&FullRange));
|
||||
} else {
|
||||
bccx.span_note(move_to_span,
|
||||
format!("and here (use `ref {0}` or `ref mut {0}`)",
|
||||
pat_name)[]);
|
||||
pat_name).index(&FullRange));
|
||||
}
|
||||
}
|
||||
|
|
|
@ -137,7 +137,7 @@ fn borrowck_fn(this: &mut BorrowckCtxt,
|
|||
check_loans::check_loans(this,
|
||||
&loan_dfcx,
|
||||
flowed_moves,
|
||||
all_loans[],
|
||||
all_loans.index(&FullRange),
|
||||
id,
|
||||
decl,
|
||||
body);
|
||||
|
@ -505,7 +505,7 @@ impl<'a, 'tcx> BorrowckCtxt<'a, 'tcx> {
|
|||
pub fn report(&self, err: BckError<'tcx>) {
|
||||
self.span_err(
|
||||
err.span,
|
||||
self.bckerr_to_string(&err)[]);
|
||||
self.bckerr_to_string(&err).index(&FullRange));
|
||||
self.note_and_explain_bckerr(err);
|
||||
}
|
||||
|
||||
|
@ -527,7 +527,7 @@ impl<'a, 'tcx> BorrowckCtxt<'a, 'tcx> {
|
|||
use_span,
|
||||
format!("{} of possibly uninitialized variable: `{}`",
|
||||
verb,
|
||||
self.loan_path_to_string(lp))[]);
|
||||
self.loan_path_to_string(lp)).index(&FullRange));
|
||||
(self.loan_path_to_string(moved_lp),
|
||||
String::new())
|
||||
}
|
||||
|
@ -569,7 +569,7 @@ impl<'a, 'tcx> BorrowckCtxt<'a, 'tcx> {
|
|||
format!("{} of {}moved value: `{}`",
|
||||
verb,
|
||||
msg,
|
||||
nl)[]);
|
||||
nl).index(&FullRange));
|
||||
(ol, moved_lp_msg)
|
||||
}
|
||||
};
|
||||
|
@ -588,7 +588,7 @@ impl<'a, 'tcx> BorrowckCtxt<'a, 'tcx> {
|
|||
self.tcx.sess.bug(format!("MoveExpr({}) maps to \
|
||||
{}, not Expr",
|
||||
the_move.id,
|
||||
r)[])
|
||||
r).index(&FullRange))
|
||||
}
|
||||
};
|
||||
let (suggestion, _) =
|
||||
|
@ -599,7 +599,7 @@ impl<'a, 'tcx> BorrowckCtxt<'a, 'tcx> {
|
|||
ol,
|
||||
moved_lp_msg,
|
||||
expr_ty.user_string(self.tcx),
|
||||
suggestion)[]);
|
||||
suggestion).index(&FullRange));
|
||||
}
|
||||
|
||||
move_data::MovePat => {
|
||||
|
@ -610,7 +610,7 @@ impl<'a, 'tcx> BorrowckCtxt<'a, 'tcx> {
|
|||
which is moved by default",
|
||||
ol,
|
||||
moved_lp_msg,
|
||||
pat_ty.user_string(self.tcx))[]);
|
||||
pat_ty.user_string(self.tcx)).index(&FullRange));
|
||||
self.tcx.sess.span_help(span,
|
||||
"use `ref` to override");
|
||||
}
|
||||
|
@ -626,7 +626,7 @@ impl<'a, 'tcx> BorrowckCtxt<'a, 'tcx> {
|
|||
self.tcx.sess.bug(format!("Captured({}) maps to \
|
||||
{}, not Expr",
|
||||
the_move.id,
|
||||
r)[])
|
||||
r).index(&FullRange))
|
||||
}
|
||||
};
|
||||
let (suggestion, help) =
|
||||
|
@ -642,7 +642,7 @@ impl<'a, 'tcx> BorrowckCtxt<'a, 'tcx> {
|
|||
ol,
|
||||
moved_lp_msg,
|
||||
expr_ty.user_string(self.tcx),
|
||||
suggestion)[]);
|
||||
suggestion).index(&FullRange));
|
||||
self.tcx.sess.span_help(expr_span, help);
|
||||
}
|
||||
}
|
||||
|
@ -673,7 +673,7 @@ impl<'a, 'tcx> BorrowckCtxt<'a, 'tcx> {
|
|||
self.tcx.sess.span_err(
|
||||
span,
|
||||
format!("re-assignment of immutable variable `{}`",
|
||||
self.loan_path_to_string(lp))[]);
|
||||
self.loan_path_to_string(lp)).index(&FullRange));
|
||||
self.tcx.sess.span_note(assign.span, "prior assignment occurs here");
|
||||
}
|
||||
|
||||
|
@ -799,12 +799,12 @@ impl<'a, 'tcx> BorrowckCtxt<'a, 'tcx> {
|
|||
self.tcx.sess.span_err(
|
||||
span,
|
||||
format!("{} in an aliasable location",
|
||||
prefix)[]);
|
||||
prefix).index(&FullRange));
|
||||
}
|
||||
mc::AliasableClosure(id) => {
|
||||
self.tcx.sess.span_err(span,
|
||||
format!("{} in a captured outer \
|
||||
variable in an `Fn` closure", prefix)[]);
|
||||
variable in an `Fn` closure", prefix).index(&FullRange));
|
||||
span_help!(self.tcx.sess, self.tcx.map.span(id),
|
||||
"consider changing this closure to take self by mutable reference");
|
||||
}
|
||||
|
@ -812,12 +812,12 @@ impl<'a, 'tcx> BorrowckCtxt<'a, 'tcx> {
|
|||
mc::AliasableStaticMut(..) => {
|
||||
self.tcx.sess.span_err(
|
||||
span,
|
||||
format!("{} in a static location", prefix)[]);
|
||||
format!("{} in a static location", prefix).index(&FullRange));
|
||||
}
|
||||
mc::AliasableBorrowed => {
|
||||
self.tcx.sess.span_err(
|
||||
span,
|
||||
format!("{} in a `&` reference", prefix)[]);
|
||||
format!("{} in a `&` reference", prefix).index(&FullRange));
|
||||
}
|
||||
}
|
||||
|
||||
|
@ -885,12 +885,12 @@ impl<'a, 'tcx> BorrowckCtxt<'a, 'tcx> {
|
|||
note_and_explain_region(
|
||||
self.tcx,
|
||||
format!("{} would have to be valid for ",
|
||||
descr)[],
|
||||
descr).index(&FullRange),
|
||||
loan_scope,
|
||||
"...");
|
||||
note_and_explain_region(
|
||||
self.tcx,
|
||||
format!("...but {} is only valid for ", descr)[],
|
||||
format!("...but {} is only valid for ", descr).index(&FullRange),
|
||||
ptr_scope,
|
||||
"");
|
||||
}
|
||||
|
@ -910,7 +910,7 @@ impl<'a, 'tcx> BorrowckCtxt<'a, 'tcx> {
|
|||
out.push('(');
|
||||
self.append_loan_path_to_string(&**lp_base, out);
|
||||
out.push_str(DOWNCAST_PRINTED_OPERATOR);
|
||||
out.push_str(ty::item_path_str(self.tcx, variant_def_id)[]);
|
||||
out.push_str(ty::item_path_str(self.tcx, variant_def_id).index(&FullRange));
|
||||
out.push(')');
|
||||
}
|
||||
|
||||
|
@ -924,7 +924,7 @@ impl<'a, 'tcx> BorrowckCtxt<'a, 'tcx> {
|
|||
}
|
||||
mc::PositionalField(idx) => {
|
||||
out.push('.');
|
||||
out.push_str(idx.to_string()[]);
|
||||
out.push_str(idx.to_string().index(&FullRange));
|
||||
}
|
||||
}
|
||||
}
|
||||
|
@ -956,7 +956,7 @@ impl<'a, 'tcx> BorrowckCtxt<'a, 'tcx> {
|
|||
out.push('(');
|
||||
self.append_autoderefd_loan_path_to_string(&**lp_base, out);
|
||||
out.push(':');
|
||||
out.push_str(ty::item_path_str(self.tcx, variant_def_id)[]);
|
||||
out.push_str(ty::item_path_str(self.tcx, variant_def_id).index(&FullRange));
|
||||
out.push(')');
|
||||
}
|
||||
|
||||
|
|
|
@ -60,7 +60,7 @@ impl<'a, 'tcx> DataflowLabeller<'a, 'tcx> {
|
|||
if seen_one { sets.push_str(" "); } else { seen_one = true; }
|
||||
sets.push_str(variant.short_name());
|
||||
sets.push_str(": ");
|
||||
sets.push_str(self.dataflow_for_variant(e, n, variant)[]);
|
||||
sets.push_str(self.dataflow_for_variant(e, n, variant).index(&FullRange));
|
||||
}
|
||||
sets
|
||||
}
|
||||
|
@ -89,7 +89,7 @@ impl<'a, 'tcx> DataflowLabeller<'a, 'tcx> {
|
|||
set.push_str(", ");
|
||||
}
|
||||
let loan_str = self.borrowck_ctxt.loan_path_to_string(&*lp);
|
||||
set.push_str(loan_str[]);
|
||||
set.push_str(loan_str.index(&FullRange));
|
||||
saw_some = true;
|
||||
true
|
||||
});
|
||||
|
@ -101,7 +101,8 @@ impl<'a, 'tcx> DataflowLabeller<'a, 'tcx> {
|
|||
let dfcx = &self.analysis_data.loans;
|
||||
let loan_index_to_path = |&mut: loan_index| {
|
||||
let all_loans = &self.analysis_data.all_loans;
|
||||
all_loans[loan_index].loan_path()
|
||||
let l: &borrowck::Loan = &all_loans[loan_index];
|
||||
l.loan_path()
|
||||
};
|
||||
self.build_set(e, cfgidx, dfcx, loan_index_to_path)
|
||||
}
|
||||
|
@ -111,7 +112,7 @@ impl<'a, 'tcx> DataflowLabeller<'a, 'tcx> {
|
|||
let move_index_to_path = |&mut: move_index| {
|
||||
let move_data = &self.analysis_data.move_data.move_data;
|
||||
let moves = move_data.moves.borrow();
|
||||
let the_move = &(*moves)[move_index];
|
||||
let the_move: &borrowck::move_data::Move = &(*moves)[move_index];
|
||||
move_data.path_loan_path(the_move.path)
|
||||
};
|
||||
self.build_set(e, cfgidx, dfcx, move_index_to_path)
|
||||
|
@ -122,7 +123,7 @@ impl<'a, 'tcx> DataflowLabeller<'a, 'tcx> {
|
|||
let assign_index_to_path = |&mut: assign_index| {
|
||||
let move_data = &self.analysis_data.move_data.move_data;
|
||||
let assignments = move_data.var_assignments.borrow();
|
||||
let assignment = &(*assignments)[assign_index];
|
||||
let assignment: &borrowck::move_data::Assignment = &(*assignments)[assign_index];
|
||||
move_data.path_loan_path(assignment.path)
|
||||
};
|
||||
self.build_set(e, cfgidx, dfcx, assign_index_to_path)
|
||||
|
|
|
@ -58,12 +58,12 @@ pub fn compile_input(sess: Session,
|
|||
let outputs = build_output_filenames(input,
|
||||
outdir,
|
||||
output,
|
||||
krate.attrs[],
|
||||
krate.attrs.index(&FullRange),
|
||||
&sess);
|
||||
let id = link::find_crate_name(Some(&sess), krate.attrs[],
|
||||
let id = link::find_crate_name(Some(&sess), krate.attrs.index(&FullRange),
|
||||
input);
|
||||
let expanded_crate
|
||||
= match phase_2_configure_and_expand(&sess, krate, id[],
|
||||
= match phase_2_configure_and_expand(&sess, krate, id.index(&FullRange),
|
||||
addl_plugins) {
|
||||
None => return,
|
||||
Some(k) => k
|
||||
|
@ -75,7 +75,7 @@ pub fn compile_input(sess: Session,
|
|||
let mut forest = ast_map::Forest::new(expanded_crate);
|
||||
let ast_map = assign_node_ids_and_map(&sess, &mut forest);
|
||||
|
||||
write_out_deps(&sess, input, &outputs, id[]);
|
||||
write_out_deps(&sess, input, &outputs, id.index(&FullRange));
|
||||
|
||||
if stop_after_phase_2(&sess) { return; }
|
||||
|
||||
|
@ -171,9 +171,9 @@ pub fn phase_2_configure_and_expand(sess: &Session,
|
|||
let time_passes = sess.time_passes();
|
||||
|
||||
*sess.crate_types.borrow_mut() =
|
||||
collect_crate_types(sess, krate.attrs[]);
|
||||
collect_crate_types(sess, krate.attrs.index(&FullRange));
|
||||
*sess.crate_metadata.borrow_mut() =
|
||||
collect_crate_metadata(sess, krate.attrs[]);
|
||||
collect_crate_metadata(sess, krate.attrs.index(&FullRange));
|
||||
|
||||
time(time_passes, "recursion limit", (), |_| {
|
||||
middle::recursion_limit::update_recursion_limit(sess, &krate);
|
||||
|
@ -268,8 +268,8 @@ pub fn phase_2_configure_and_expand(sess: &Session,
|
|||
if cfg!(windows) {
|
||||
_old_path = os::getenv("PATH").unwrap_or(_old_path);
|
||||
let mut new_path = sess.host_filesearch(PathKind::All).get_dylib_search_paths();
|
||||
new_path.extend(os::split_paths(_old_path[]).into_iter());
|
||||
os::setenv("PATH", os::join_paths(new_path[]).unwrap());
|
||||
new_path.extend(os::split_paths(_old_path.index(&FullRange)).into_iter());
|
||||
os::setenv("PATH", os::join_paths(new_path.index(&FullRange)).unwrap());
|
||||
}
|
||||
let cfg = syntax::ext::expand::ExpansionConfig {
|
||||
crate_name: crate_name.to_string(),
|
||||
|
@ -533,7 +533,7 @@ pub fn phase_5_run_llvm_passes(sess: &Session,
|
|||
time(sess.time_passes(), "LLVM passes", (), |_|
|
||||
write::run_passes(sess,
|
||||
trans,
|
||||
sess.opts.output_types[],
|
||||
sess.opts.output_types.index(&FullRange),
|
||||
outputs));
|
||||
}
|
||||
|
||||
|
@ -547,14 +547,14 @@ pub fn phase_6_link_output(sess: &Session,
|
|||
outputs: &OutputFilenames) {
|
||||
let old_path = os::getenv("PATH").unwrap_or_else(||String::new());
|
||||
let mut new_path = sess.host_filesearch(PathKind::All).get_tools_search_paths();
|
||||
new_path.extend(os::split_paths(old_path[]).into_iter());
|
||||
os::setenv("PATH", os::join_paths(new_path[]).unwrap());
|
||||
new_path.extend(os::split_paths(old_path.index(&FullRange)).into_iter());
|
||||
os::setenv("PATH", os::join_paths(new_path.index(&FullRange)).unwrap());
|
||||
|
||||
time(sess.time_passes(), "linking", (), |_|
|
||||
link::link_binary(sess,
|
||||
trans,
|
||||
outputs,
|
||||
trans.link.crate_name[]));
|
||||
trans.link.crate_name.index(&FullRange)));
|
||||
|
||||
os::setenv("PATH", old_path);
|
||||
}
|
||||
|
@ -643,7 +643,7 @@ fn write_out_deps(sess: &Session,
|
|||
// write Makefile-compatible dependency rules
|
||||
let files: Vec<String> = sess.codemap().files.borrow()
|
||||
.iter().filter(|fmap| fmap.is_real_file())
|
||||
.map(|fmap| escape_dep_filename(fmap.name[]))
|
||||
.map(|fmap| escape_dep_filename(fmap.name.index(&FullRange)))
|
||||
.collect();
|
||||
let mut file = try!(io::File::create(&deps_filename));
|
||||
for path in out_filenames.iter() {
|
||||
|
@ -657,7 +657,7 @@ fn write_out_deps(sess: &Session,
|
|||
Ok(()) => {}
|
||||
Err(e) => {
|
||||
sess.fatal(format!("error writing dependencies to `{}`: {}",
|
||||
deps_filename.display(), e)[]);
|
||||
deps_filename.display(), e).index(&FullRange));
|
||||
}
|
||||
}
|
||||
}
|
||||
|
@ -728,7 +728,7 @@ pub fn collect_crate_types(session: &Session,
|
|||
if !res {
|
||||
session.warn(format!("dropping unsupported crate type `{}` \
|
||||
for target `{}`",
|
||||
*crate_type, session.opts.target_triple)[]);
|
||||
*crate_type, session.opts.target_triple).index(&FullRange));
|
||||
}
|
||||
|
||||
res
|
||||
|
|
|
@ -105,12 +105,12 @@ fn run_compiler(args: &[String]) {
|
|||
let descriptions = diagnostics::registry::Registry::new(&DIAGNOSTICS);
|
||||
match matches.opt_str("explain") {
|
||||
Some(ref code) => {
|
||||
match descriptions.find_description(code[]) {
|
||||
match descriptions.find_description(code.index(&FullRange)) {
|
||||
Some(ref description) => {
|
||||
println!("{}", description);
|
||||
}
|
||||
None => {
|
||||
early_error(format!("no extended information for {}", code)[]);
|
||||
early_error(format!("no extended information for {}", code).index(&FullRange));
|
||||
}
|
||||
}
|
||||
return;
|
||||
|
@ -136,7 +136,7 @@ fn run_compiler(args: &[String]) {
|
|||
early_error("no input filename given");
|
||||
}
|
||||
1u => {
|
||||
let ifile = matches.free[0][];
|
||||
let ifile = matches.free[0].index(&FullRange);
|
||||
if ifile == "-" {
|
||||
let contents = io::stdin().read_to_end().unwrap();
|
||||
let src = String::from_utf8(contents).unwrap();
|
||||
|
@ -313,7 +313,7 @@ Available lint options:
|
|||
for lint in lints.into_iter() {
|
||||
let name = lint.name_lower().replace("_", "-");
|
||||
println!(" {} {:7.7} {}",
|
||||
padded(name[]), lint.default_level.as_str(), lint.desc);
|
||||
padded(name.index(&FullRange)), lint.default_level.as_str(), lint.desc);
|
||||
}
|
||||
println!("\n");
|
||||
};
|
||||
|
@ -343,7 +343,7 @@ Available lint options:
|
|||
let desc = to.into_iter().map(|x| x.as_str().replace("_", "-"))
|
||||
.collect::<Vec<String>>().connect(", ");
|
||||
println!(" {} {}",
|
||||
padded(name[]), desc);
|
||||
padded(name.index(&FullRange)), desc);
|
||||
}
|
||||
println!("\n");
|
||||
};
|
||||
|
@ -409,7 +409,7 @@ pub fn handle_options(mut args: Vec<String>) -> Option<getopts::Matches> {
|
|||
}
|
||||
|
||||
let matches =
|
||||
match getopts::getopts(args[], config::optgroups()[]) {
|
||||
match getopts::getopts(args.index(&FullRange), config::optgroups().index(&FullRange)) {
|
||||
Ok(m) => m,
|
||||
Err(f_stable_attempt) => {
|
||||
// redo option parsing, including unstable options this time,
|
||||
|
@ -583,7 +583,7 @@ pub fn monitor<F:FnOnce()+Send>(f: F) {
|
|||
"run with `RUST_BACKTRACE=1` for a backtrace".to_string(),
|
||||
];
|
||||
for note in xs.iter() {
|
||||
emitter.emit(None, note[], None, diagnostic::Note)
|
||||
emitter.emit(None, note.index(&FullRange), None, diagnostic::Note)
|
||||
}
|
||||
|
||||
match r.read_to_string() {
|
||||
|
@ -591,7 +591,7 @@ pub fn monitor<F:FnOnce()+Send>(f: F) {
|
|||
Err(e) => {
|
||||
emitter.emit(None,
|
||||
format!("failed to read internal \
|
||||
stderr: {}", e)[],
|
||||
stderr: {}", e).index(&FullRange),
|
||||
None,
|
||||
diagnostic::Error)
|
||||
}
|
||||
|
|
|
@ -296,7 +296,7 @@ impl<'tcx> pprust::PpAnn for TypedAnnotation<'tcx> {
|
|||
try!(pp::word(&mut s.s,
|
||||
ppaux::ty_to_string(
|
||||
tcx,
|
||||
ty::expr_ty(tcx, expr))[]));
|
||||
ty::expr_ty(tcx, expr)).index(&FullRange)));
|
||||
s.pclose()
|
||||
}
|
||||
_ => Ok(())
|
||||
|
@ -370,7 +370,7 @@ impl UserIdentifiedItem {
|
|||
ItemViaNode(node_id) =>
|
||||
NodesMatchingDirect(Some(node_id).into_iter()),
|
||||
ItemViaPath(ref parts) =>
|
||||
NodesMatchingSuffix(map.nodes_matching_suffix(parts[])),
|
||||
NodesMatchingSuffix(map.nodes_matching_suffix(parts.index(&FullRange))),
|
||||
}
|
||||
}
|
||||
|
||||
|
@ -382,7 +382,7 @@ impl UserIdentifiedItem {
|
|||
user_option,
|
||||
self.reconstructed_input(),
|
||||
is_wrong_because);
|
||||
sess.fatal(message[])
|
||||
sess.fatal(message.index(&FullRange))
|
||||
};
|
||||
|
||||
let mut saw_node = ast::DUMMY_NODE_ID;
|
||||
|
@ -509,7 +509,7 @@ pub fn pretty_print_input(sess: Session,
|
|||
let is_expanded = needs_expansion(&ppm);
|
||||
let compute_ast_map = needs_ast_map(&ppm, &opt_uii);
|
||||
let krate = if compute_ast_map {
|
||||
match driver::phase_2_configure_and_expand(&sess, krate, id[], None) {
|
||||
match driver::phase_2_configure_and_expand(&sess, krate, id.index(&FullRange), None) {
|
||||
None => return,
|
||||
Some(k) => k
|
||||
}
|
||||
|
@ -528,7 +528,7 @@ pub fn pretty_print_input(sess: Session,
|
|||
};
|
||||
|
||||
let src_name = driver::source_name(input);
|
||||
let src = sess.codemap().get_filemap(src_name[])
|
||||
let src = sess.codemap().get_filemap(src_name.index(&FullRange))
|
||||
.src.as_bytes().to_vec();
|
||||
let mut rdr = MemReader::new(src);
|
||||
|
||||
|
@ -589,7 +589,7 @@ pub fn pretty_print_input(sess: Session,
|
|||
debug!("pretty printing flow graph for {}", opt_uii);
|
||||
let uii = opt_uii.unwrap_or_else(|| {
|
||||
sess.fatal(format!("`pretty flowgraph=..` needs NodeId (int) or
|
||||
unique path suffix (b::c::d)")[])
|
||||
unique path suffix (b::c::d)").index(&FullRange))
|
||||
|
||||
});
|
||||
let ast_map = ast_map.expect("--pretty flowgraph missing ast_map");
|
||||
|
@ -597,7 +597,7 @@ pub fn pretty_print_input(sess: Session,
|
|||
|
||||
let node = ast_map.find(nodeid).unwrap_or_else(|| {
|
||||
sess.fatal(format!("--pretty flowgraph couldn't find id: {}",
|
||||
nodeid)[])
|
||||
nodeid).index(&FullRange))
|
||||
});
|
||||
|
||||
let code = blocks::Code::from_node(node);
|
||||
|
@ -615,8 +615,8 @@ pub fn pretty_print_input(sess: Session,
|
|||
// point to what was found, if there's an
|
||||
// accessible span.
|
||||
match ast_map.opt_span(nodeid) {
|
||||
Some(sp) => sess.span_fatal(sp, message[]),
|
||||
None => sess.fatal(message[])
|
||||
Some(sp) => sess.span_fatal(sp, message.index(&FullRange)),
|
||||
None => sess.fatal(message.index(&FullRange))
|
||||
}
|
||||
}
|
||||
}
|
||||
|
|
|
@ -279,7 +279,7 @@ impl<'a, 'tcx> Env<'a, 'tcx> {
|
|||
|
||||
pub fn t_param(&self, space: subst::ParamSpace, index: u32) -> Ty<'tcx> {
|
||||
let name = format!("T{}", index);
|
||||
ty::mk_param(self.infcx.tcx, space, index, token::intern(name[]))
|
||||
ty::mk_param(self.infcx.tcx, space, index, token::intern(name.index(&FullRange)))
|
||||
}
|
||||
|
||||
pub fn re_early_bound(&self,
|
||||
|
|
|
@ -221,14 +221,14 @@ impl<'a, 'b:'a, 'tcx:'b> GraphBuilder<'a, 'b, 'tcx> {
|
|||
self.resolve_error(sp,
|
||||
format!("duplicate definition of {} `{}`",
|
||||
namespace_error_to_string(duplicate_type),
|
||||
token::get_name(name))[]);
|
||||
token::get_name(name)).index(&FullRange));
|
||||
{
|
||||
let r = child.span_for_namespace(ns);
|
||||
for sp in r.iter() {
|
||||
self.session.span_note(*sp,
|
||||
format!("first definition of {} `{}` here",
|
||||
namespace_error_to_string(duplicate_type),
|
||||
token::get_name(name))[]);
|
||||
token::get_name(name)).index(&FullRange));
|
||||
}
|
||||
}
|
||||
}
|
||||
|
@ -1201,7 +1201,7 @@ impl<'a, 'b:'a, 'tcx:'b> GraphBuilder<'a, 'b, 'tcx> {
|
|||
debug!("(building import directive) building import \
|
||||
directive: {}::{}",
|
||||
self.names_to_string(module_.imports.borrow().last().unwrap()
|
||||
.module_path[]),
|
||||
.module_path.index(&FullRange)),
|
||||
token::get_name(target));
|
||||
|
||||
let mut import_resolutions = module_.import_resolutions
|
||||
|
|
|
@ -1071,10 +1071,10 @@ impl<'a, 'tcx> Resolver<'a, 'tcx> {
|
|||
let msg = format!("unresolved import `{}`{}",
|
||||
self.import_path_to_string(
|
||||
import_directive.module_path
|
||||
[],
|
||||
.index(&FullRange),
|
||||
import_directive.subclass),
|
||||
help);
|
||||
self.resolve_error(span, msg[]);
|
||||
self.resolve_error(span, msg.index(&FullRange));
|
||||
}
|
||||
Indeterminate => break, // Bail out. We'll come around next time.
|
||||
Success(()) => () // Good. Continue.
|
||||
|
@ -1104,7 +1104,7 @@ impl<'a, 'tcx> Resolver<'a, 'tcx> {
|
|||
.iter()
|
||||
.map(|seg| seg.identifier.name)
|
||||
.collect();
|
||||
self.names_to_string(names[])
|
||||
self.names_to_string(names.index(&FullRange))
|
||||
}
|
||||
|
||||
fn import_directive_subclass_to_string(&mut self,
|
||||
|
@ -1168,7 +1168,7 @@ impl<'a, 'tcx> Resolver<'a, 'tcx> {
|
|||
let module_path = &import_directive.module_path;
|
||||
|
||||
debug!("(resolving import for module) resolving import `{}::...` in `{}`",
|
||||
self.names_to_string(module_path[]),
|
||||
self.names_to_string(module_path.index(&FullRange)),
|
||||
self.module_to_string(&*module_));
|
||||
|
||||
// First, resolve the module path for the directive, if necessary.
|
||||
|
@ -1177,7 +1177,7 @@ impl<'a, 'tcx> Resolver<'a, 'tcx> {
|
|||
Some((self.graph_root.get_module(), LastMod(AllPublic)))
|
||||
} else {
|
||||
match self.resolve_module_path(module_.clone(),
|
||||
module_path[],
|
||||
module_path.index(&FullRange),
|
||||
DontUseLexicalScope,
|
||||
import_directive.span,
|
||||
ImportSearch) {
|
||||
|
@ -1774,7 +1774,7 @@ impl<'a, 'tcx> Resolver<'a, 'tcx> {
|
|||
ValueNS => "value",
|
||||
},
|
||||
token::get_name(name).get());
|
||||
self.session.span_err(import_span, msg[]);
|
||||
self.session.span_err(import_span, msg.index(&FullRange));
|
||||
}
|
||||
Some(_) | None => {}
|
||||
}
|
||||
|
@ -1789,7 +1789,7 @@ impl<'a, 'tcx> Resolver<'a, 'tcx> {
|
|||
if !name_bindings.defined_in_namespace_with(namespace, IMPORTABLE) {
|
||||
let msg = format!("`{}` is not directly importable",
|
||||
token::get_name(name));
|
||||
self.session.span_err(import_span, msg[]);
|
||||
self.session.span_err(import_span, msg.index(&FullRange));
|
||||
}
|
||||
}
|
||||
|
||||
|
@ -1814,7 +1814,7 @@ impl<'a, 'tcx> Resolver<'a, 'tcx> {
|
|||
crate in this module \
|
||||
(maybe you meant `use {0}::*`?)",
|
||||
token::get_name(name).get());
|
||||
self.session.span_err(import_span, msg[]);
|
||||
self.session.span_err(import_span, msg.index(&FullRange));
|
||||
}
|
||||
Some(_) | None => {}
|
||||
}
|
||||
|
@ -1836,7 +1836,7 @@ impl<'a, 'tcx> Resolver<'a, 'tcx> {
|
|||
let msg = format!("import `{}` conflicts with value \
|
||||
in this module",
|
||||
token::get_name(name).get());
|
||||
self.session.span_err(import_span, msg[]);
|
||||
self.session.span_err(import_span, msg.index(&FullRange));
|
||||
if let Some(span) = value.value_span {
|
||||
self.session.span_note(span,
|
||||
"conflicting value here");
|
||||
|
@ -1854,7 +1854,7 @@ impl<'a, 'tcx> Resolver<'a, 'tcx> {
|
|||
let msg = format!("import `{}` conflicts with type in \
|
||||
this module",
|
||||
token::get_name(name).get());
|
||||
self.session.span_err(import_span, msg[]);
|
||||
self.session.span_err(import_span, msg.index(&FullRange));
|
||||
if let Some(span) = ty.type_span {
|
||||
self.session.span_note(span,
|
||||
"note conflicting type here")
|
||||
|
@ -1867,7 +1867,7 @@ impl<'a, 'tcx> Resolver<'a, 'tcx> {
|
|||
let msg = format!("inherent implementations \
|
||||
are only allowed on types \
|
||||
defined in the current module");
|
||||
self.session.span_err(span, msg[]);
|
||||
self.session.span_err(span, msg.index(&FullRange));
|
||||
self.session.span_note(import_span,
|
||||
"import from other module here")
|
||||
}
|
||||
|
@ -1876,7 +1876,7 @@ impl<'a, 'tcx> Resolver<'a, 'tcx> {
|
|||
let msg = format!("import `{}` conflicts with existing \
|
||||
submodule",
|
||||
token::get_name(name).get());
|
||||
self.session.span_err(import_span, msg[]);
|
||||
self.session.span_err(import_span, msg.index(&FullRange));
|
||||
if let Some(span) = ty.type_span {
|
||||
self.session.span_note(span,
|
||||
"note conflicting module here")
|
||||
|
@ -1906,7 +1906,7 @@ impl<'a, 'tcx> Resolver<'a, 'tcx> {
|
|||
.span_err(span,
|
||||
format!("an external crate named `{}` has already \
|
||||
been imported into this module",
|
||||
token::get_name(name).get())[]);
|
||||
token::get_name(name).get()).index(&FullRange));
|
||||
}
|
||||
}
|
||||
|
||||
|
@ -1925,7 +1925,7 @@ impl<'a, 'tcx> Resolver<'a, 'tcx> {
|
|||
format!("the name `{}` conflicts with an external \
|
||||
crate that has been imported into this \
|
||||
module",
|
||||
token::get_name(name).get())[]);
|
||||
token::get_name(name).get()).index(&FullRange));
|
||||
}
|
||||
}
|
||||
|
||||
|
@ -1973,7 +1973,7 @@ impl<'a, 'tcx> Resolver<'a, 'tcx> {
|
|||
let segment_name = token::get_name(name);
|
||||
let module_name = self.module_to_string(&*search_module);
|
||||
let mut span = span;
|
||||
let msg = if "???" == module_name[] {
|
||||
let msg = if "???" == module_name.index(&FullRange) {
|
||||
span.hi = span.lo + Pos::from_uint(segment_name.get().len());
|
||||
|
||||
match search_parent_externals(name,
|
||||
|
@ -2086,14 +2086,14 @@ impl<'a, 'tcx> Resolver<'a, 'tcx> {
|
|||
match module_prefix_result {
|
||||
Failed(None) => {
|
||||
let mpath = self.names_to_string(module_path);
|
||||
let mpath = mpath[];
|
||||
let mpath = mpath.index(&FullRange);
|
||||
match mpath.rfind(':') {
|
||||
Some(idx) => {
|
||||
let msg = format!("Could not find `{}` in `{}`",
|
||||
// idx +- 1 to account for the
|
||||
// colons on either side
|
||||
mpath[idx + 1..],
|
||||
mpath[0..idx - 1]);
|
||||
mpath.index(&((idx + 1)..)),
|
||||
mpath.index(&(0..(idx - 1))));
|
||||
return Failed(Some((span, msg)));
|
||||
},
|
||||
None => {
|
||||
|
@ -2268,7 +2268,7 @@ impl<'a, 'tcx> Resolver<'a, 'tcx> {
|
|||
true) {
|
||||
Failed(Some((span, msg))) =>
|
||||
self.resolve_error(span, format!("failed to resolve. {}",
|
||||
msg)[]),
|
||||
msg).index(&FullRange)),
|
||||
Failed(None) => (), // Continue up the search chain.
|
||||
Indeterminate => {
|
||||
// We couldn't see through the higher scope because of an
|
||||
|
@ -2528,7 +2528,7 @@ impl<'a, 'tcx> Resolver<'a, 'tcx> {
|
|||
} else {
|
||||
let err = format!("unresolved import (maybe you meant `{}::*`?)",
|
||||
sn);
|
||||
self.resolve_error((*imports)[index].span, err[]);
|
||||
self.resolve_error((*imports)[index].span, err.index(&FullRange));
|
||||
}
|
||||
}
|
||||
|
||||
|
@ -2620,7 +2620,7 @@ impl<'a, 'tcx> Resolver<'a, 'tcx> {
|
|||
match def_like {
|
||||
DlDef(d @ DefUpvar(..)) => {
|
||||
self.session.span_bug(span,
|
||||
format!("unexpected {} in bindings", d)[])
|
||||
format!("unexpected {} in bindings", d).index(&FullRange))
|
||||
}
|
||||
DlDef(d @ DefLocal(_)) => {
|
||||
let node_id = d.def_id().node;
|
||||
|
@ -2766,7 +2766,7 @@ impl<'a, 'tcx> Resolver<'a, 'tcx> {
|
|||
for (i, rib) in ribs.iter().enumerate().rev() {
|
||||
match rib.bindings.get(&name).cloned() {
|
||||
Some(def_like) => {
|
||||
return self.upvarify(ribs[i + 1..], def_like, span);
|
||||
return self.upvarify(ribs.index(&((i + 1)..)), def_like, span);
|
||||
}
|
||||
None => {
|
||||
// Continue.
|
||||
|
@ -2859,7 +2859,7 @@ impl<'a, 'tcx> Resolver<'a, 'tcx> {
|
|||
generics,
|
||||
implemented_traits,
|
||||
&**self_type,
|
||||
impl_items[]);
|
||||
impl_items.index(&FullRange));
|
||||
}
|
||||
|
||||
ItemTrait(_, ref generics, ref bounds, ref trait_items) => {
|
||||
|
@ -2937,7 +2937,7 @@ impl<'a, 'tcx> Resolver<'a, 'tcx> {
|
|||
ItemStruct(ref struct_def, ref generics) => {
|
||||
self.resolve_struct(item.id,
|
||||
generics,
|
||||
struct_def.fields[]);
|
||||
struct_def.fields.index(&FullRange));
|
||||
}
|
||||
|
||||
ItemMod(ref module_) => {
|
||||
|
@ -3010,7 +3010,7 @@ impl<'a, 'tcx> Resolver<'a, 'tcx> {
|
|||
parameter in this type \
|
||||
parameter list",
|
||||
token::get_name(
|
||||
name))[])
|
||||
name)).index(&FullRange))
|
||||
}
|
||||
seen_bindings.insert(name);
|
||||
|
||||
|
@ -3182,7 +3182,7 @@ impl<'a, 'tcx> Resolver<'a, 'tcx> {
|
|||
};
|
||||
|
||||
let msg = format!("attempt to {} a nonexistent trait `{}`", usage_str, path_str);
|
||||
self.resolve_error(trait_reference.path.span, msg[]);
|
||||
self.resolve_error(trait_reference.path.span, msg.index(&FullRange));
|
||||
}
|
||||
Some(def) => {
|
||||
match def {
|
||||
|
@ -3194,14 +3194,14 @@ impl<'a, 'tcx> Resolver<'a, 'tcx> {
|
|||
self.resolve_error(trait_reference.path.span,
|
||||
format!("`{}` is not a trait",
|
||||
self.path_names_to_string(
|
||||
&trait_reference.path))[]);
|
||||
&trait_reference.path)).index(&FullRange));
|
||||
|
||||
// If it's a typedef, give a note
|
||||
if let DefTy(..) = def {
|
||||
self.session.span_note(
|
||||
trait_reference.path.span,
|
||||
format!("`type` aliases cannot be used for traits")
|
||||
[]);
|
||||
.index(&FullRange));
|
||||
}
|
||||
}
|
||||
}
|
||||
|
@ -3398,7 +3398,7 @@ impl<'a, 'tcx> Resolver<'a, 'tcx> {
|
|||
self.resolve_error(span,
|
||||
format!("method `{}` is not a member of trait `{}`",
|
||||
token::get_name(name),
|
||||
path_str)[]);
|
||||
path_str).index(&FullRange));
|
||||
}
|
||||
}
|
||||
}
|
||||
|
@ -3467,7 +3467,7 @@ impl<'a, 'tcx> Resolver<'a, 'tcx> {
|
|||
format!("variable `{}` from pattern #1 is \
|
||||
not bound in pattern #{}",
|
||||
token::get_name(key),
|
||||
i + 1)[]);
|
||||
i + 1).index(&FullRange));
|
||||
}
|
||||
Some(binding_i) => {
|
||||
if binding_0.binding_mode != binding_i.binding_mode {
|
||||
|
@ -3476,7 +3476,7 @@ impl<'a, 'tcx> Resolver<'a, 'tcx> {
|
|||
format!("variable `{}` is bound with different \
|
||||
mode in pattern #{} than in pattern #1",
|
||||
token::get_name(key),
|
||||
i + 1)[]);
|
||||
i + 1).index(&FullRange));
|
||||
}
|
||||
}
|
||||
}
|
||||
|
@ -3489,7 +3489,7 @@ impl<'a, 'tcx> Resolver<'a, 'tcx> {
|
|||
format!("variable `{}` from pattern {}{} is \
|
||||
not bound in pattern {}1",
|
||||
token::get_name(key),
|
||||
"#", i + 1, "#")[]);
|
||||
"#", i + 1, "#").index(&FullRange));
|
||||
}
|
||||
}
|
||||
}
|
||||
|
@ -3604,7 +3604,7 @@ impl<'a, 'tcx> Resolver<'a, 'tcx> {
|
|||
None => {
|
||||
let msg = format!("use of undeclared type name `{}`",
|
||||
self.path_names_to_string(path));
|
||||
self.resolve_error(ty.span, msg[]);
|
||||
self.resolve_error(ty.span, msg.index(&FullRange));
|
||||
}
|
||||
}
|
||||
}
|
||||
|
@ -3676,7 +3676,7 @@ impl<'a, 'tcx> Resolver<'a, 'tcx> {
|
|||
format!("declaration of `{}` shadows an enum \
|
||||
variant or unit-like struct in \
|
||||
scope",
|
||||
token::get_name(renamed))[]);
|
||||
token::get_name(renamed)).index(&FullRange));
|
||||
}
|
||||
FoundConst(ref def, lp) if mode == RefutableMode => {
|
||||
debug!("(resolving pattern) resolving `{}` to \
|
||||
|
@ -3728,7 +3728,7 @@ impl<'a, 'tcx> Resolver<'a, 'tcx> {
|
|||
list",
|
||||
token::get_ident(
|
||||
ident))
|
||||
[])
|
||||
.index(&FullRange))
|
||||
} else if bindings_list.get(&renamed) ==
|
||||
Some(&pat_id) {
|
||||
// Then this is a duplicate variable in the
|
||||
|
@ -3737,7 +3737,7 @@ impl<'a, 'tcx> Resolver<'a, 'tcx> {
|
|||
format!("identifier `{}` is bound \
|
||||
more than once in the same \
|
||||
pattern",
|
||||
token::get_ident(ident))[]);
|
||||
token::get_ident(ident)).index(&FullRange));
|
||||
}
|
||||
// Else, not bound in the same pattern: do
|
||||
// nothing.
|
||||
|
@ -3763,13 +3763,13 @@ impl<'a, 'tcx> Resolver<'a, 'tcx> {
|
|||
self.resolve_error(path.span,
|
||||
format!("`{}` is not an enum variant, struct or const",
|
||||
token::get_ident(
|
||||
path.segments.last().unwrap().identifier))[]);
|
||||
path.segments.last().unwrap().identifier)).index(&FullRange));
|
||||
}
|
||||
None => {
|
||||
self.resolve_error(path.span,
|
||||
format!("unresolved enum variant, struct or const `{}`",
|
||||
token::get_ident(
|
||||
path.segments.last().unwrap().identifier))[]);
|
||||
path.segments.last().unwrap().identifier)).index(&FullRange));
|
||||
}
|
||||
}
|
||||
|
||||
|
@ -3800,7 +3800,7 @@ impl<'a, 'tcx> Resolver<'a, 'tcx> {
|
|||
def: {}", result);
|
||||
let msg = format!("`{}` does not name a structure",
|
||||
self.path_names_to_string(path));
|
||||
self.resolve_error(path.span, msg[]);
|
||||
self.resolve_error(path.span, msg.index(&FullRange));
|
||||
}
|
||||
}
|
||||
}
|
||||
|
@ -3862,7 +3862,7 @@ impl<'a, 'tcx> Resolver<'a, 'tcx> {
|
|||
match err {
|
||||
Some((span, msg)) => {
|
||||
self.resolve_error(span, format!("failed to resolve: {}",
|
||||
msg)[]);
|
||||
msg).index(&FullRange));
|
||||
}
|
||||
None => ()
|
||||
}
|
||||
|
@ -4057,7 +4057,7 @@ impl<'a, 'tcx> Resolver<'a, 'tcx> {
|
|||
let last_private;
|
||||
let module = self.current_module.clone();
|
||||
match self.resolve_module_path(module,
|
||||
module_path[],
|
||||
module_path.index(&FullRange),
|
||||
UseLexicalScope,
|
||||
path.span,
|
||||
PathSearch) {
|
||||
|
@ -4072,7 +4072,7 @@ impl<'a, 'tcx> Resolver<'a, 'tcx> {
|
|||
};
|
||||
|
||||
self.resolve_error(span, format!("failed to resolve. {}",
|
||||
msg)[]);
|
||||
msg).index(&FullRange));
|
||||
return None;
|
||||
}
|
||||
Indeterminate => panic!("indeterminate unexpected"),
|
||||
|
@ -4115,7 +4115,7 @@ impl<'a, 'tcx> Resolver<'a, 'tcx> {
|
|||
let containing_module;
|
||||
let last_private;
|
||||
match self.resolve_module_path_from_root(root_module,
|
||||
module_path[],
|
||||
module_path.index(&FullRange),
|
||||
0,
|
||||
path.span,
|
||||
PathSearch,
|
||||
|
@ -4125,13 +4125,13 @@ impl<'a, 'tcx> Resolver<'a, 'tcx> {
|
|||
Some((span, msg)) => (span, msg),
|
||||
None => {
|
||||
let msg = format!("Use of undeclared module `::{}`",
|
||||
self.names_to_string(module_path[]));
|
||||
self.names_to_string(module_path.index(&FullRange)));
|
||||
(path.span, msg)
|
||||
}
|
||||
};
|
||||
|
||||
self.resolve_error(span, format!("failed to resolve. {}",
|
||||
msg)[]);
|
||||
msg).index(&FullRange));
|
||||
return None;
|
||||
}
|
||||
|
||||
|
@ -4172,7 +4172,7 @@ impl<'a, 'tcx> Resolver<'a, 'tcx> {
|
|||
}
|
||||
TypeNS => {
|
||||
let name = ident.name;
|
||||
self.search_ribs(self.type_ribs[], name, span)
|
||||
self.search_ribs(self.type_ribs.index(&FullRange), name, span)
|
||||
}
|
||||
};
|
||||
|
||||
|
@ -4227,7 +4227,7 @@ impl<'a, 'tcx> Resolver<'a, 'tcx> {
|
|||
match err {
|
||||
Some((span, msg)) =>
|
||||
self.resolve_error(span, format!("failed to resolve. {}",
|
||||
msg)[]),
|
||||
msg).index(&FullRange)),
|
||||
None => ()
|
||||
}
|
||||
|
||||
|
@ -4284,7 +4284,7 @@ impl<'a, 'tcx> Resolver<'a, 'tcx> {
|
|||
}
|
||||
} else {
|
||||
match this.resolve_module_path(root,
|
||||
name_path[],
|
||||
name_path.index(&FullRange),
|
||||
UseLexicalScope,
|
||||
span,
|
||||
PathSearch) {
|
||||
|
@ -4322,7 +4322,7 @@ impl<'a, 'tcx> Resolver<'a, 'tcx> {
|
|||
let name_path = path.segments.iter().map(|seg| seg.identifier.name).collect::<Vec<_>>();
|
||||
|
||||
// Look for a method in the current self type's impl module.
|
||||
match get_module(self, path.span, name_path[]) {
|
||||
match get_module(self, path.span, name_path.index(&FullRange)) {
|
||||
Some(module) => match module.children.borrow().get(&name) {
|
||||
Some(binding) => {
|
||||
let p_str = self.path_names_to_string(&path);
|
||||
|
@ -4533,7 +4533,7 @@ impl<'a, 'tcx> Resolver<'a, 'tcx> {
|
|||
def: {}", result);
|
||||
let msg = format!("`{}` does not name a structure",
|
||||
self.path_names_to_string(path));
|
||||
self.resolve_error(path.span, msg[]);
|
||||
self.resolve_error(path.span, msg.index(&FullRange));
|
||||
}
|
||||
}
|
||||
|
||||
|
@ -4594,7 +4594,7 @@ impl<'a, 'tcx> Resolver<'a, 'tcx> {
|
|||
self.resolve_error(
|
||||
expr.span,
|
||||
format!("use of undeclared label `{}`",
|
||||
token::get_ident(label))[])
|
||||
token::get_ident(label)).index(&FullRange))
|
||||
}
|
||||
Some(DlDef(def @ DefLabel(_))) => {
|
||||
// Since this def is a label, it is never read.
|
||||
|
@ -4733,7 +4733,7 @@ impl<'a, 'tcx> Resolver<'a, 'tcx> {
|
|||
then {}",
|
||||
node_id,
|
||||
*entry.get(),
|
||||
def)[]);
|
||||
def).index(&FullRange));
|
||||
},
|
||||
Vacant(entry) => { entry.insert(def); },
|
||||
}
|
||||
|
@ -4749,7 +4749,7 @@ impl<'a, 'tcx> Resolver<'a, 'tcx> {
|
|||
self.resolve_error(pat.span,
|
||||
format!("cannot use `ref` binding mode \
|
||||
with {}",
|
||||
descr)[]);
|
||||
descr).index(&FullRange));
|
||||
}
|
||||
}
|
||||
}
|
||||
|
@ -4785,7 +4785,7 @@ impl<'a, 'tcx> Resolver<'a, 'tcx> {
|
|||
return "???".to_string();
|
||||
}
|
||||
self.names_to_string(names.into_iter().rev()
|
||||
.collect::<Vec<ast::Name>>()[])
|
||||
.collect::<Vec<ast::Name>>().index(&FullRange))
|
||||
}
|
||||
|
||||
#[allow(dead_code)] // useful for debugging
|
||||
|
|
|
@ -128,7 +128,7 @@ pub fn find_crate_name(sess: Option<&Session>,
|
|||
attrs: &[ast::Attribute],
|
||||
input: &Input) -> String {
|
||||
let validate = |&: s: String, span: Option<Span>| {
|
||||
creader::validate_crate_name(sess, s[], span);
|
||||
creader::validate_crate_name(sess, s.index(&FullRange), span);
|
||||
s
|
||||
};
|
||||
|
||||
|
@ -146,7 +146,7 @@ pub fn find_crate_name(sess: Option<&Session>,
|
|||
let msg = format!("--crate-name and #[crate_name] are \
|
||||
required to match, but `{}` != `{}`",
|
||||
s, name);
|
||||
sess.span_err(attr.span, msg[]);
|
||||
sess.span_err(attr.span, msg.index(&FullRange));
|
||||
}
|
||||
}
|
||||
return validate(s.clone(), None);
|
||||
|
@ -192,17 +192,17 @@ fn symbol_hash<'tcx>(tcx: &ty::ctxt<'tcx>,
|
|||
// to be independent of one another in the crate.
|
||||
|
||||
symbol_hasher.reset();
|
||||
symbol_hasher.input_str(link_meta.crate_name[]);
|
||||
symbol_hasher.input_str(link_meta.crate_name.index(&FullRange));
|
||||
symbol_hasher.input_str("-");
|
||||
symbol_hasher.input_str(link_meta.crate_hash.as_str());
|
||||
for meta in tcx.sess.crate_metadata.borrow().iter() {
|
||||
symbol_hasher.input_str(meta[]);
|
||||
symbol_hasher.input_str(meta.index(&FullRange));
|
||||
}
|
||||
symbol_hasher.input_str("-");
|
||||
symbol_hasher.input_str(encoder::encoded_ty(tcx, t)[]);
|
||||
symbol_hasher.input_str(encoder::encoded_ty(tcx, t).index(&FullRange));
|
||||
// Prefix with 'h' so that it never blends into adjacent digits
|
||||
let mut hash = String::from_str("h");
|
||||
hash.push_str(truncated_hash_result(symbol_hasher)[]);
|
||||
hash.push_str(truncated_hash_result(symbol_hasher).index(&FullRange));
|
||||
hash
|
||||
}
|
||||
|
||||
|
@ -251,7 +251,7 @@ pub fn sanitize(s: &str) -> String {
|
|||
let mut tstr = String::new();
|
||||
for c in c.escape_unicode() { tstr.push(c) }
|
||||
result.push('$');
|
||||
result.push_str(tstr[1..]);
|
||||
result.push_str(tstr.index(&(1..)));
|
||||
}
|
||||
}
|
||||
}
|
||||
|
@ -260,7 +260,7 @@ pub fn sanitize(s: &str) -> String {
|
|||
if result.len() > 0u &&
|
||||
result.as_bytes()[0] != '_' as u8 &&
|
||||
! (result.as_bytes()[0] as char).is_xid_start() {
|
||||
return format!("_{}", result[]);
|
||||
return format!("_{}", result.index(&FullRange));
|
||||
}
|
||||
|
||||
return result;
|
||||
|
@ -286,12 +286,12 @@ pub fn mangle<PI: Iterator<Item=PathElem>>(mut path: PI,
|
|||
|
||||
fn push(n: &mut String, s: &str) {
|
||||
let sani = sanitize(s);
|
||||
n.push_str(format!("{}{}", sani.len(), sani)[]);
|
||||
n.push_str(format!("{}{}", sani.len(), sani).index(&FullRange));
|
||||
}
|
||||
|
||||
// First, connect each component with <len, name> pairs.
|
||||
for e in path {
|
||||
push(&mut n, token::get_name(e.name()).get()[])
|
||||
push(&mut n, token::get_name(e.name()).get().index(&FullRange))
|
||||
}
|
||||
|
||||
match hash {
|
||||
|
@ -329,17 +329,17 @@ pub fn mangle_exported_name<'a, 'tcx>(ccx: &CrateContext<'a, 'tcx>, path: PathEl
|
|||
hash.push(EXTRA_CHARS.as_bytes()[extra2] as char);
|
||||
hash.push(EXTRA_CHARS.as_bytes()[extra3] as char);
|
||||
|
||||
exported_name(path, hash[])
|
||||
exported_name(path, hash.index(&FullRange))
|
||||
}
|
||||
|
||||
pub fn mangle_internal_name_by_type_and_seq<'a, 'tcx>(ccx: &CrateContext<'a, 'tcx>,
|
||||
t: Ty<'tcx>,
|
||||
name: &str) -> String {
|
||||
let s = ppaux::ty_to_string(ccx.tcx(), t);
|
||||
let path = [PathName(token::intern(s[])),
|
||||
let path = [PathName(token::intern(s.index(&FullRange))),
|
||||
gensym_name(name)];
|
||||
let hash = get_symbol_hash(ccx, t);
|
||||
mangle(ast_map::Values(path.iter()), Some(hash[]))
|
||||
mangle(ast_map::Values(path.iter()), Some(hash.index(&FullRange)))
|
||||
}
|
||||
|
||||
pub fn mangle_internal_name_by_path_and_seq(path: PathElems, flav: &str) -> String {
|
||||
|
@ -359,7 +359,7 @@ pub fn remove(sess: &Session, path: &Path) {
|
|||
Err(e) => {
|
||||
sess.err(format!("failed to remove {}: {}",
|
||||
path.display(),
|
||||
e)[]);
|
||||
e).index(&FullRange));
|
||||
}
|
||||
}
|
||||
}
|
||||
|
@ -374,7 +374,7 @@ pub fn link_binary(sess: &Session,
|
|||
for &crate_type in sess.crate_types.borrow().iter() {
|
||||
if invalid_output_for_target(sess, crate_type) {
|
||||
sess.bug(format!("invalid output type `{}` for target os `{}`",
|
||||
crate_type, sess.opts.target_triple)[]);
|
||||
crate_type, sess.opts.target_triple).index(&FullRange));
|
||||
}
|
||||
let out_file = link_binary_output(sess, trans, crate_type, outputs,
|
||||
crate_name);
|
||||
|
@ -439,8 +439,8 @@ pub fn filename_for_input(sess: &Session,
|
|||
out_filename.with_filename(format!("lib{}.rlib", libname))
|
||||
}
|
||||
config::CrateTypeDylib => {
|
||||
let (prefix, suffix) = (sess.target.target.options.dll_prefix[],
|
||||
sess.target.target.options.dll_suffix[]);
|
||||
let (prefix, suffix) = (sess.target.target.options.dll_prefix.index(&FullRange),
|
||||
sess.target.target.options.dll_suffix.index(&FullRange));
|
||||
out_filename.with_filename(format!("{}{}{}",
|
||||
prefix,
|
||||
libname,
|
||||
|
@ -450,7 +450,7 @@ pub fn filename_for_input(sess: &Session,
|
|||
out_filename.with_filename(format!("lib{}.a", libname))
|
||||
}
|
||||
config::CrateTypeExecutable => {
|
||||
let suffix = sess.target.target.options.exe_suffix[];
|
||||
let suffix = sess.target.target.options.exe_suffix.index(&FullRange);
|
||||
out_filename.with_filename(format!("{}{}", libname, suffix))
|
||||
}
|
||||
}
|
||||
|
@ -479,12 +479,12 @@ fn link_binary_output(sess: &Session,
|
|||
if !out_is_writeable {
|
||||
sess.fatal(format!("output file {} is not writeable -- check its \
|
||||
permissions.",
|
||||
out_filename.display())[]);
|
||||
out_filename.display()).index(&FullRange));
|
||||
}
|
||||
else if !obj_is_writeable {
|
||||
sess.fatal(format!("object file {} is not writeable -- check its \
|
||||
permissions.",
|
||||
obj_filename.display())[]);
|
||||
obj_filename.display()).index(&FullRange));
|
||||
}
|
||||
|
||||
match crate_type {
|
||||
|
@ -539,7 +539,7 @@ fn link_rlib<'a>(sess: &'a Session,
|
|||
for &(ref l, kind) in sess.cstore.get_used_libraries().borrow().iter() {
|
||||
match kind {
|
||||
cstore::NativeStatic => {
|
||||
ab.add_native_library(l[]).unwrap();
|
||||
ab.add_native_library(l.index(&FullRange)).unwrap();
|
||||
}
|
||||
cstore::NativeFramework | cstore::NativeUnknown => {}
|
||||
}
|
||||
|
@ -587,12 +587,12 @@ fn link_rlib<'a>(sess: &'a Session,
|
|||
let tmpdir = TempDir::new("rustc").ok().expect("needs a temp dir");
|
||||
let metadata = tmpdir.path().join(METADATA_FILENAME);
|
||||
match fs::File::create(&metadata).write(trans.metadata
|
||||
[]) {
|
||||
.index(&FullRange)) {
|
||||
Ok(..) => {}
|
||||
Err(e) => {
|
||||
sess.err(format!("failed to write {}: {}",
|
||||
metadata.display(),
|
||||
e)[]);
|
||||
e).index(&FullRange));
|
||||
sess.abort_if_errors();
|
||||
}
|
||||
}
|
||||
|
@ -608,27 +608,27 @@ fn link_rlib<'a>(sess: &'a Session,
|
|||
// extension to it. This is to work around a bug in LLDB that
|
||||
// would cause it to crash if the name of a file in an archive
|
||||
// was exactly 16 bytes.
|
||||
let bc_filename = obj_filename.with_extension(format!("{}.bc", i)[]);
|
||||
let bc_filename = obj_filename.with_extension(format!("{}.bc", i).index(&FullRange));
|
||||
let bc_deflated_filename = obj_filename.with_extension(
|
||||
format!("{}.bytecode.deflate", i)[]);
|
||||
format!("{}.bytecode.deflate", i).index(&FullRange));
|
||||
|
||||
let bc_data = match fs::File::open(&bc_filename).read_to_end() {
|
||||
Ok(buffer) => buffer,
|
||||
Err(e) => sess.fatal(format!("failed to read bytecode: {}",
|
||||
e)[])
|
||||
e).index(&FullRange))
|
||||
};
|
||||
|
||||
let bc_data_deflated = match flate::deflate_bytes(bc_data[]) {
|
||||
let bc_data_deflated = match flate::deflate_bytes(bc_data.index(&FullRange)) {
|
||||
Some(compressed) => compressed,
|
||||
None => sess.fatal(format!("failed to compress bytecode from {}",
|
||||
bc_filename.display())[])
|
||||
bc_filename.display()).index(&FullRange))
|
||||
};
|
||||
|
||||
let mut bc_file_deflated = match fs::File::create(&bc_deflated_filename) {
|
||||
Ok(file) => file,
|
||||
Err(e) => {
|
||||
sess.fatal(format!("failed to create compressed bytecode \
|
||||
file: {}", e)[])
|
||||
file: {}", e).index(&FullRange))
|
||||
}
|
||||
};
|
||||
|
||||
|
@ -637,7 +637,7 @@ fn link_rlib<'a>(sess: &'a Session,
|
|||
Ok(()) => {}
|
||||
Err(e) => {
|
||||
sess.err(format!("failed to write compressed bytecode: \
|
||||
{}", e)[]);
|
||||
{}", e).index(&FullRange));
|
||||
sess.abort_if_errors()
|
||||
}
|
||||
};
|
||||
|
@ -677,7 +677,7 @@ fn write_rlib_bytecode_object_v1<T: Writer>(writer: &mut T,
|
|||
try! { writer.write(RLIB_BYTECODE_OBJECT_MAGIC) };
|
||||
try! { writer.write_le_u32(1) };
|
||||
try! { writer.write_le_u64(bc_data_deflated_size) };
|
||||
try! { writer.write(bc_data_deflated[]) };
|
||||
try! { writer.write(bc_data_deflated.index(&FullRange)) };
|
||||
|
||||
let number_of_bytes_written_so_far =
|
||||
RLIB_BYTECODE_OBJECT_MAGIC.len() + // magic id
|
||||
|
@ -728,11 +728,11 @@ fn link_staticlib(sess: &Session, obj_filename: &Path, out_filename: &Path) {
|
|||
let p = match *path {
|
||||
Some(ref p) => p.clone(), None => {
|
||||
sess.err(format!("could not find rlib for: `{}`",
|
||||
name)[]);
|
||||
name).index(&FullRange));
|
||||
continue
|
||||
}
|
||||
};
|
||||
ab.add_rlib(&p, name[], sess.lto()).unwrap();
|
||||
ab.add_rlib(&p, name.index(&FullRange), sess.lto()).unwrap();
|
||||
|
||||
let native_libs = csearch::get_native_libraries(&sess.cstore, cnum);
|
||||
all_native_libs.extend(native_libs.into_iter());
|
||||
|
@ -754,7 +754,7 @@ fn link_staticlib(sess: &Session, obj_filename: &Path, out_filename: &Path) {
|
|||
cstore::NativeUnknown => "library",
|
||||
cstore::NativeFramework => "framework",
|
||||
};
|
||||
sess.note(format!("{}: {}", name, *lib)[]);
|
||||
sess.note(format!("{}: {}", name, *lib).index(&FullRange));
|
||||
}
|
||||
}
|
||||
|
||||
|
@ -768,12 +768,12 @@ fn link_natively(sess: &Session, trans: &CrateTranslation, dylib: bool,
|
|||
|
||||
// The invocations of cc share some flags across platforms
|
||||
let pname = get_cc_prog(sess);
|
||||
let mut cmd = Command::new(pname[]);
|
||||
let mut cmd = Command::new(pname.index(&FullRange));
|
||||
|
||||
cmd.args(sess.target.target.options.pre_link_args[]);
|
||||
cmd.args(sess.target.target.options.pre_link_args.index(&FullRange));
|
||||
link_args(&mut cmd, sess, dylib, tmpdir.path(),
|
||||
trans, obj_filename, out_filename);
|
||||
cmd.args(sess.target.target.options.post_link_args[]);
|
||||
cmd.args(sess.target.target.options.post_link_args.index(&FullRange));
|
||||
if !sess.target.target.options.no_compiler_rt {
|
||||
cmd.arg("-lcompiler-rt");
|
||||
}
|
||||
|
@ -793,11 +793,11 @@ fn link_natively(sess: &Session, trans: &CrateTranslation, dylib: bool,
|
|||
if !prog.status.success() {
|
||||
sess.err(format!("linking with `{}` failed: {}",
|
||||
pname,
|
||||
prog.status)[]);
|
||||
sess.note(format!("{}", &cmd)[]);
|
||||
prog.status).index(&FullRange));
|
||||
sess.note(format!("{}", &cmd).index(&FullRange));
|
||||
let mut output = prog.error.clone();
|
||||
output.push_all(prog.output[]);
|
||||
sess.note(str::from_utf8(output[]).unwrap());
|
||||
output.push_all(prog.output.index(&FullRange));
|
||||
sess.note(str::from_utf8(output.index(&FullRange)).unwrap());
|
||||
sess.abort_if_errors();
|
||||
}
|
||||
debug!("linker stderr:\n{}", String::from_utf8(prog.error).unwrap());
|
||||
|
@ -806,7 +806,7 @@ fn link_natively(sess: &Session, trans: &CrateTranslation, dylib: bool,
|
|||
Err(e) => {
|
||||
sess.err(format!("could not exec the linker `{}`: {}",
|
||||
pname,
|
||||
e)[]);
|
||||
e).index(&FullRange));
|
||||
sess.abort_if_errors();
|
||||
}
|
||||
}
|
||||
|
@ -818,7 +818,7 @@ fn link_natively(sess: &Session, trans: &CrateTranslation, dylib: bool,
|
|||
match Command::new("dsymutil").arg(out_filename).output() {
|
||||
Ok(..) => {}
|
||||
Err(e) => {
|
||||
sess.err(format!("failed to run dsymutil: {}", e)[]);
|
||||
sess.err(format!("failed to run dsymutil: {}", e).index(&FullRange));
|
||||
sess.abort_if_errors();
|
||||
}
|
||||
}
|
||||
|
@ -867,7 +867,7 @@ fn link_args(cmd: &mut Command,
|
|||
|
||||
let mut v = b"-Wl,-force_load,".to_vec();
|
||||
v.push_all(morestack.as_vec());
|
||||
cmd.arg(v[]);
|
||||
cmd.arg(v.index(&FullRange));
|
||||
} else {
|
||||
cmd.args(&["-Wl,--whole-archive", "-lmorestack", "-Wl,--no-whole-archive"]);
|
||||
}
|
||||
|
@ -992,7 +992,7 @@ fn link_args(cmd: &mut Command,
|
|||
if sess.opts.cg.rpath {
|
||||
let mut v = "-Wl,-install_name,@rpath/".as_bytes().to_vec();
|
||||
v.push_all(out_filename.filename().unwrap());
|
||||
cmd.arg(v[]);
|
||||
cmd.arg(v.index(&FullRange));
|
||||
}
|
||||
} else {
|
||||
cmd.arg("-shared");
|
||||
|
@ -1004,7 +1004,7 @@ fn link_args(cmd: &mut Command,
|
|||
// addl_lib_search_paths
|
||||
if sess.opts.cg.rpath {
|
||||
let sysroot = sess.sysroot();
|
||||
let target_triple = sess.opts.target_triple[];
|
||||
let target_triple = sess.opts.target_triple.index(&FullRange);
|
||||
let get_install_prefix_lib_path = |:| {
|
||||
let install_prefix = option_env!("CFG_PREFIX").expect("CFG_PREFIX");
|
||||
let tlib = filesearch::relative_target_lib_path(sysroot, target_triple);
|
||||
|
@ -1021,14 +1021,14 @@ fn link_args(cmd: &mut Command,
|
|||
get_install_prefix_lib_path: get_install_prefix_lib_path,
|
||||
realpath: ::util::fs::realpath
|
||||
};
|
||||
cmd.args(rpath::get_rpath_flags(rpath_config)[]);
|
||||
cmd.args(rpath::get_rpath_flags(rpath_config).index(&FullRange));
|
||||
}
|
||||
|
||||
// Finally add all the linker arguments provided on the command line along
|
||||
// with any #[link_args] attributes found inside the crate
|
||||
let empty = Vec::new();
|
||||
cmd.args(sess.opts.cg.link_args.as_ref().unwrap_or(&empty)[]);
|
||||
cmd.args(used_link_args[]);
|
||||
cmd.args(sess.opts.cg.link_args.as_ref().unwrap_or(&empty).index(&FullRange));
|
||||
cmd.args(used_link_args.index(&FullRange));
|
||||
}
|
||||
|
||||
// # Native library linking
|
||||
|
@ -1082,14 +1082,14 @@ fn add_local_native_libraries(cmd: &mut Command, sess: &Session) {
|
|||
} else {
|
||||
// -force_load is the OSX equivalent of --whole-archive, but it
|
||||
// involves passing the full path to the library to link.
|
||||
let lib = archive::find_library(l[],
|
||||
sess.target.target.options.staticlib_prefix[],
|
||||
sess.target.target.options.staticlib_suffix[],
|
||||
search_path[],
|
||||
let lib = archive::find_library(l.index(&FullRange),
|
||||
sess.target.target.options.staticlib_prefix.index(&FullRange),
|
||||
sess.target.target.options.staticlib_suffix.index(&FullRange),
|
||||
search_path.index(&FullRange),
|
||||
&sess.diagnostic().handler);
|
||||
let mut v = b"-Wl,-force_load,".to_vec();
|
||||
v.push_all(lib.as_vec());
|
||||
cmd.arg(v[]);
|
||||
cmd.arg(v.index(&FullRange));
|
||||
}
|
||||
}
|
||||
if takes_hints {
|
||||
|
@ -1102,7 +1102,7 @@ fn add_local_native_libraries(cmd: &mut Command, sess: &Session) {
|
|||
cmd.arg(format!("-l{}", l));
|
||||
}
|
||||
cstore::NativeFramework => {
|
||||
cmd.arg("-framework").arg(l[]);
|
||||
cmd.arg("-framework").arg(l.index(&FullRange));
|
||||
}
|
||||
cstore::NativeStatic => unreachable!(),
|
||||
}
|
||||
|
@ -1158,7 +1158,7 @@ fn add_upstream_rust_crates(cmd: &mut Command, sess: &Session,
|
|||
// Converts a library file-stem into a cc -l argument
|
||||
fn unlib<'a>(config: &config::Config, stem: &'a [u8]) -> &'a [u8] {
|
||||
if stem.starts_with("lib".as_bytes()) && !config.target.options.is_like_windows {
|
||||
stem[3..]
|
||||
stem.index(&(3..))
|
||||
} else {
|
||||
stem
|
||||
}
|
||||
|
@ -1183,9 +1183,9 @@ fn add_upstream_rust_crates(cmd: &mut Command, sess: &Session,
|
|||
// against the archive.
|
||||
if sess.lto() {
|
||||
let name = cratepath.filename_str().unwrap();
|
||||
let name = name[3..name.len() - 5]; // chop off lib/.rlib
|
||||
let name = name.index(&(3..(name.len() - 5))); // chop off lib/.rlib
|
||||
time(sess.time_passes(),
|
||||
format!("altering {}.rlib", name)[],
|
||||
format!("altering {}.rlib", name).index(&FullRange),
|
||||
(), |()| {
|
||||
let dst = tmpdir.join(cratepath.filename().unwrap());
|
||||
match fs::copy(&cratepath, &dst) {
|
||||
|
@ -1194,7 +1194,7 @@ fn add_upstream_rust_crates(cmd: &mut Command, sess: &Session,
|
|||
sess.err(format!("failed to copy {} to {}: {}",
|
||||
cratepath.display(),
|
||||
dst.display(),
|
||||
e)[]);
|
||||
e).index(&FullRange));
|
||||
sess.abort_if_errors();
|
||||
}
|
||||
}
|
||||
|
@ -1206,7 +1206,7 @@ fn add_upstream_rust_crates(cmd: &mut Command, sess: &Session,
|
|||
Err(e) => {
|
||||
sess.err(format!("failed to chmod {} when preparing \
|
||||
for LTO: {}", dst.display(),
|
||||
e)[]);
|
||||
e).index(&FullRange));
|
||||
sess.abort_if_errors();
|
||||
}
|
||||
}
|
||||
|
@ -1220,9 +1220,9 @@ fn add_upstream_rust_crates(cmd: &mut Command, sess: &Session,
|
|||
maybe_ar_prog: sess.opts.cg.ar.clone()
|
||||
};
|
||||
let mut archive = Archive::open(config);
|
||||
archive.remove_file(format!("{}.o", name)[]);
|
||||
archive.remove_file(format!("{}.o", name).index(&FullRange));
|
||||
let files = archive.files();
|
||||
if files.iter().any(|s| s[].ends_with(".o")) {
|
||||
if files.iter().any(|s| s.index(&FullRange).ends_with(".o")) {
|
||||
cmd.arg(dst);
|
||||
}
|
||||
});
|
||||
|
@ -1244,7 +1244,7 @@ fn add_upstream_rust_crates(cmd: &mut Command, sess: &Session,
|
|||
|
||||
let mut v = "-l".as_bytes().to_vec();
|
||||
v.push_all(unlib(&sess.target, cratepath.filestem().unwrap()));
|
||||
cmd.arg(v[]);
|
||||
cmd.arg(v.index(&FullRange));
|
||||
}
|
||||
}
|
||||
|
||||
|
@ -1286,7 +1286,7 @@ fn add_upstream_native_libraries(cmd: &mut Command, sess: &Session) {
|
|||
}
|
||||
cstore::NativeFramework => {
|
||||
cmd.arg("-framework");
|
||||
cmd.arg(lib[]);
|
||||
cmd.arg(lib.index(&FullRange));
|
||||
}
|
||||
cstore::NativeStatic => {
|
||||
sess.bug("statics shouldn't be propagated");
|
||||
|
|
|
@ -54,21 +54,21 @@ pub fn run(sess: &session::Session, llmod: ModuleRef,
|
|||
Some(p) => p,
|
||||
None => {
|
||||
sess.fatal(format!("could not find rlib for: `{}`",
|
||||
name)[]);
|
||||
name).index(&FullRange));
|
||||
}
|
||||
};
|
||||
|
||||
let archive = ArchiveRO::open(&path).expect("wanted an rlib");
|
||||
let file = path.filename_str().unwrap();
|
||||
let file = file[3..file.len() - 5]; // chop off lib/.rlib
|
||||
let file = file.index(&(3..(file.len() - 5))); // chop off lib/.rlib
|
||||
debug!("reading {}", file);
|
||||
for i in iter::count(0u, 1) {
|
||||
let bc_encoded = time(sess.time_passes(),
|
||||
format!("check for {}.{}.bytecode.deflate", name, i)[],
|
||||
format!("check for {}.{}.bytecode.deflate", name, i).index(&FullRange),
|
||||
(),
|
||||
|_| {
|
||||
archive.read(format!("{}.{}.bytecode.deflate",
|
||||
file, i)[])
|
||||
file, i).index(&FullRange))
|
||||
});
|
||||
let bc_encoded = match bc_encoded {
|
||||
Some(data) => data,
|
||||
|
@ -76,7 +76,7 @@ pub fn run(sess: &session::Session, llmod: ModuleRef,
|
|||
if i == 0 {
|
||||
// No bitcode was found at all.
|
||||
sess.fatal(format!("missing compressed bytecode in {}",
|
||||
path.display())[]);
|
||||
path.display()).index(&FullRange));
|
||||
}
|
||||
// No more bitcode files to read.
|
||||
break;
|
||||
|
@ -91,20 +91,20 @@ pub fn run(sess: &session::Session, llmod: ModuleRef,
|
|||
if version == 1 {
|
||||
// The only version existing so far
|
||||
let data_size = extract_compressed_bytecode_size_v1(bc_encoded);
|
||||
let compressed_data = bc_encoded[
|
||||
let compressed_data = bc_encoded.index(&(
|
||||
link::RLIB_BYTECODE_OBJECT_V1_DATA_OFFSET..
|
||||
link::RLIB_BYTECODE_OBJECT_V1_DATA_OFFSET + data_size as uint];
|
||||
(link::RLIB_BYTECODE_OBJECT_V1_DATA_OFFSET + data_size as uint)));
|
||||
|
||||
match flate::inflate_bytes(compressed_data) {
|
||||
Some(inflated) => inflated,
|
||||
None => {
|
||||
sess.fatal(format!("failed to decompress bc of `{}`",
|
||||
name)[])
|
||||
name).index(&FullRange))
|
||||
}
|
||||
}
|
||||
} else {
|
||||
sess.fatal(format!("Unsupported bytecode format version {}",
|
||||
version)[])
|
||||
version).index(&FullRange))
|
||||
}
|
||||
})
|
||||
} else {
|
||||
|
@ -115,7 +115,7 @@ pub fn run(sess: &session::Session, llmod: ModuleRef,
|
|||
Some(bc) => bc,
|
||||
None => {
|
||||
sess.fatal(format!("failed to decompress bc of `{}`",
|
||||
name)[])
|
||||
name).index(&FullRange))
|
||||
}
|
||||
}
|
||||
})
|
||||
|
@ -124,7 +124,7 @@ pub fn run(sess: &session::Session, llmod: ModuleRef,
|
|||
let ptr = bc_decoded.as_slice().as_ptr();
|
||||
debug!("linking {}, part {}", name, i);
|
||||
time(sess.time_passes(),
|
||||
format!("ll link {}.{}", name, i)[],
|
||||
format!("ll link {}.{}", name, i).index(&FullRange),
|
||||
(),
|
||||
|()| unsafe {
|
||||
if !llvm::LLVMRustLinkInExternalBitcode(llmod,
|
||||
|
@ -132,7 +132,7 @@ pub fn run(sess: &session::Session, llmod: ModuleRef,
|
|||
bc_decoded.len() as libc::size_t) {
|
||||
write::llvm_err(sess.diagnostic().handler(),
|
||||
format!("failed to load bc of `{}`",
|
||||
name[]));
|
||||
name.index(&FullRange)));
|
||||
}
|
||||
});
|
||||
}
|
||||
|
@ -186,7 +186,7 @@ pub fn run(sess: &session::Session, llmod: ModuleRef,
|
|||
fn is_versioned_bytecode_format(bc: &[u8]) -> bool {
|
||||
let magic_id_byte_count = link::RLIB_BYTECODE_OBJECT_MAGIC.len();
|
||||
return bc.len() > magic_id_byte_count &&
|
||||
bc[..magic_id_byte_count] == link::RLIB_BYTECODE_OBJECT_MAGIC;
|
||||
bc.index(&(0..magic_id_byte_count)) == link::RLIB_BYTECODE_OBJECT_MAGIC;
|
||||
}
|
||||
|
||||
fn extract_bytecode_format_version(bc: &[u8]) -> u32 {
|
||||
|
@ -198,8 +198,8 @@ fn extract_compressed_bytecode_size_v1(bc: &[u8]) -> u64 {
|
|||
}
|
||||
|
||||
fn read_from_le_bytes<T: Int>(bytes: &[u8], position_in_bytes: uint) -> T {
|
||||
let byte_data = bytes[position_in_bytes..
|
||||
position_in_bytes + mem::size_of::<T>()];
|
||||
let byte_data = bytes.index(&(position_in_bytes..
|
||||
(position_in_bytes + mem::size_of::<T>())));
|
||||
let data = unsafe {
|
||||
*(byte_data.as_ptr() as *const T)
|
||||
};
|
||||
|
|
|
@ -47,14 +47,14 @@ pub fn llvm_err(handler: &diagnostic::Handler, msg: String) -> ! {
|
|||
unsafe {
|
||||
let cstr = llvm::LLVMRustGetLastError();
|
||||
if cstr == ptr::null() {
|
||||
handler.fatal(msg[]);
|
||||
handler.fatal(msg.index(&FullRange));
|
||||
} else {
|
||||
let err = ffi::c_str_to_bytes(&cstr);
|
||||
let err = String::from_utf8_lossy(err.as_slice()).to_string();
|
||||
libc::free(cstr as *mut _);
|
||||
handler.fatal(format!("{}: {}",
|
||||
msg[],
|
||||
err[])[]);
|
||||
msg.index(&FullRange),
|
||||
err.index(&FullRange)).index(&FullRange));
|
||||
}
|
||||
}
|
||||
}
|
||||
|
@ -104,13 +104,13 @@ impl SharedEmitter {
|
|||
match diag.code {
|
||||
Some(ref code) => {
|
||||
handler.emit_with_code(None,
|
||||
diag.msg[],
|
||||
code[],
|
||||
diag.msg.index(&FullRange),
|
||||
code.index(&FullRange),
|
||||
diag.lvl);
|
||||
},
|
||||
None => {
|
||||
handler.emit(None,
|
||||
diag.msg[],
|
||||
diag.msg.index(&FullRange),
|
||||
diag.lvl);
|
||||
},
|
||||
}
|
||||
|
@ -165,8 +165,8 @@ fn get_llvm_opt_level(optimize: config::OptLevel) -> llvm::CodeGenOptLevel {
|
|||
|
||||
fn create_target_machine(sess: &Session) -> TargetMachineRef {
|
||||
let reloc_model_arg = match sess.opts.cg.relocation_model {
|
||||
Some(ref s) => s[],
|
||||
None => sess.target.target.options.relocation_model[]
|
||||
Some(ref s) => s.index(&FullRange),
|
||||
None => sess.target.target.options.relocation_model.index(&FullRange)
|
||||
};
|
||||
let reloc_model = match reloc_model_arg {
|
||||
"pic" => llvm::RelocPIC,
|
||||
|
@ -177,7 +177,7 @@ fn create_target_machine(sess: &Session) -> TargetMachineRef {
|
|||
sess.err(format!("{} is not a valid relocation mode",
|
||||
sess.opts
|
||||
.cg
|
||||
.relocation_model)[]);
|
||||
.relocation_model).index(&FullRange));
|
||||
sess.abort_if_errors();
|
||||
unreachable!();
|
||||
}
|
||||
|
@ -198,8 +198,8 @@ fn create_target_machine(sess: &Session) -> TargetMachineRef {
|
|||
let fdata_sections = ffunction_sections;
|
||||
|
||||
let code_model_arg = match sess.opts.cg.code_model {
|
||||
Some(ref s) => s[],
|
||||
None => sess.target.target.options.code_model[]
|
||||
Some(ref s) => s.index(&FullRange),
|
||||
None => sess.target.target.options.code_model.index(&FullRange)
|
||||
};
|
||||
|
||||
let code_model = match code_model_arg {
|
||||
|
@ -212,13 +212,13 @@ fn create_target_machine(sess: &Session) -> TargetMachineRef {
|
|||
sess.err(format!("{} is not a valid code model",
|
||||
sess.opts
|
||||
.cg
|
||||
.code_model)[]);
|
||||
.code_model).index(&FullRange));
|
||||
sess.abort_if_errors();
|
||||
unreachable!();
|
||||
}
|
||||
};
|
||||
|
||||
let triple = sess.target.target.llvm_target[];
|
||||
let triple = sess.target.target.llvm_target.index(&FullRange);
|
||||
|
||||
let tm = unsafe {
|
||||
let triple = CString::from_slice(triple.as_bytes());
|
||||
|
@ -350,13 +350,13 @@ unsafe extern "C" fn inline_asm_handler(diag: SMDiagnosticRef,
|
|||
match cgcx.lto_ctxt {
|
||||
Some((sess, _)) => {
|
||||
sess.codemap().with_expn_info(ExpnId::from_llvm_cookie(cookie), |info| match info {
|
||||
Some(ei) => sess.span_err(ei.call_site, msg[]),
|
||||
None => sess.err(msg[]),
|
||||
Some(ei) => sess.span_err(ei.call_site, msg.index(&FullRange)),
|
||||
None => sess.err(msg.index(&FullRange)),
|
||||
});
|
||||
}
|
||||
|
||||
None => {
|
||||
cgcx.handler.err(msg[]);
|
||||
cgcx.handler.err(msg.index(&FullRange));
|
||||
cgcx.handler.note("build without -C codegen-units for more exact errors");
|
||||
}
|
||||
}
|
||||
|
@ -381,8 +381,8 @@ unsafe extern "C" fn diagnostic_handler(info: DiagnosticInfoRef, user: *mut c_vo
|
|||
cgcx.handler.note(format!("optimization {} for {} at {}: {}",
|
||||
opt.kind.describe(),
|
||||
pass_name,
|
||||
if loc.is_empty() { "[unknown]" } else { loc[] },
|
||||
llvm::twine_to_string(opt.message))[]);
|
||||
if loc.is_empty() { "[unknown]" } else { loc.index(&FullRange) },
|
||||
llvm::twine_to_string(opt.message)).index(&FullRange));
|
||||
}
|
||||
}
|
||||
|
||||
|
@ -518,14 +518,14 @@ unsafe fn optimize_and_codegen(cgcx: &CodegenContext,
|
|||
}
|
||||
|
||||
if config.emit_asm {
|
||||
let path = output_names.with_extension(format!("{}.s", name_extra)[]);
|
||||
let path = output_names.with_extension(format!("{}.s", name_extra).index(&FullRange));
|
||||
with_codegen(tm, llmod, config.no_builtins, |cpm| {
|
||||
write_output_file(cgcx.handler, tm, cpm, llmod, &path, llvm::AssemblyFileType);
|
||||
});
|
||||
}
|
||||
|
||||
if config.emit_obj {
|
||||
let path = output_names.with_extension(format!("{}.o", name_extra)[]);
|
||||
let path = output_names.with_extension(format!("{}.o", name_extra).index(&FullRange));
|
||||
with_codegen(tm, llmod, config.no_builtins, |cpm| {
|
||||
write_output_file(cgcx.handler, tm, cpm, llmod, &path, llvm::ObjectFileType);
|
||||
});
|
||||
|
@ -639,7 +639,7 @@ pub fn run_passes(sess: &Session,
|
|||
|
||||
// Process the work items, optionally using worker threads.
|
||||
if sess.opts.cg.codegen_units == 1 {
|
||||
run_work_singlethreaded(sess, trans.reachable[], work_items);
|
||||
run_work_singlethreaded(sess, trans.reachable.index(&FullRange), work_items);
|
||||
} else {
|
||||
run_work_multithreaded(sess, work_items, sess.opts.cg.codegen_units);
|
||||
}
|
||||
|
@ -667,7 +667,7 @@ pub fn run_passes(sess: &Session,
|
|||
// 2) Multiple codegen units, with `-o some_name`. We have
|
||||
// no good solution for this case, so warn the user.
|
||||
sess.warn(format!("ignoring -o because multiple .{} files were produced",
|
||||
ext)[]);
|
||||
ext).index(&FullRange));
|
||||
} else {
|
||||
// 3) Multiple codegen units, but no `-o some_name`. We
|
||||
// just leave the `foo.0.x` files in place.
|
||||
|
@ -700,20 +700,20 @@ pub fn run_passes(sess: &Session,
|
|||
};
|
||||
|
||||
let pname = get_cc_prog(sess);
|
||||
let mut cmd = Command::new(pname[]);
|
||||
let mut cmd = Command::new(pname.index(&FullRange));
|
||||
|
||||
cmd.args(sess.target.target.options.pre_link_args[]);
|
||||
cmd.args(sess.target.target.options.pre_link_args.index(&FullRange));
|
||||
cmd.arg("-nostdlib");
|
||||
|
||||
for index in range(0, trans.modules.len()) {
|
||||
cmd.arg(crate_output.with_extension(format!("{}.o", index)[]));
|
||||
cmd.arg(crate_output.with_extension(format!("{}.o", index).index(&FullRange)));
|
||||
}
|
||||
|
||||
cmd.arg("-r")
|
||||
.arg("-o")
|
||||
.arg(windows_output_path.as_ref().unwrap_or(output_path));
|
||||
|
||||
cmd.args(sess.target.target.options.post_link_args[]);
|
||||
cmd.args(sess.target.target.options.post_link_args.index(&FullRange));
|
||||
|
||||
if (sess.opts.debugging_opts & config::PRINT_LINK_ARGS) != 0 {
|
||||
println!("{}", &cmd);
|
||||
|
@ -726,14 +726,14 @@ pub fn run_passes(sess: &Session,
|
|||
Ok(status) => {
|
||||
if !status.success() {
|
||||
sess.err(format!("linking of {} with `{}` failed",
|
||||
output_path.display(), cmd)[]);
|
||||
output_path.display(), cmd).index(&FullRange));
|
||||
sess.abort_if_errors();
|
||||
}
|
||||
},
|
||||
Err(e) => {
|
||||
sess.err(format!("could not exec the linker `{}`: {}",
|
||||
pname,
|
||||
e)[]);
|
||||
e).index(&FullRange));
|
||||
sess.abort_if_errors();
|
||||
},
|
||||
}
|
||||
|
@ -818,12 +818,12 @@ pub fn run_passes(sess: &Session,
|
|||
for i in range(0, trans.modules.len()) {
|
||||
if modules_config.emit_obj {
|
||||
let ext = format!("{}.o", i);
|
||||
remove(sess, &crate_output.with_extension(ext[]));
|
||||
remove(sess, &crate_output.with_extension(ext.index(&FullRange)));
|
||||
}
|
||||
|
||||
if modules_config.emit_bc && !keep_numbered_bitcode {
|
||||
let ext = format!("{}.bc", i);
|
||||
remove(sess, &crate_output.with_extension(ext[]));
|
||||
remove(sess, &crate_output.with_extension(ext.index(&FullRange)));
|
||||
}
|
||||
}
|
||||
|
||||
|
@ -949,7 +949,7 @@ fn run_work_multithreaded(sess: &Session,
|
|||
|
||||
pub fn run_assembler(sess: &Session, outputs: &OutputFilenames) {
|
||||
let pname = get_cc_prog(sess);
|
||||
let mut cmd = Command::new(pname[]);
|
||||
let mut cmd = Command::new(pname.index(&FullRange));
|
||||
|
||||
cmd.arg("-c").arg("-o").arg(outputs.path(config::OutputTypeObject))
|
||||
.arg(outputs.temp_path(config::OutputTypeAssembly));
|
||||
|
@ -960,18 +960,18 @@ pub fn run_assembler(sess: &Session, outputs: &OutputFilenames) {
|
|||
if !prog.status.success() {
|
||||
sess.err(format!("linking with `{}` failed: {}",
|
||||
pname,
|
||||
prog.status)[]);
|
||||
sess.note(format!("{}", &cmd)[]);
|
||||
prog.status).index(&FullRange));
|
||||
sess.note(format!("{}", &cmd).index(&FullRange));
|
||||
let mut note = prog.error.clone();
|
||||
note.push_all(prog.output[]);
|
||||
sess.note(str::from_utf8(note[]).unwrap());
|
||||
note.push_all(prog.output.index(&FullRange));
|
||||
sess.note(str::from_utf8(note.index(&FullRange)).unwrap());
|
||||
sess.abort_if_errors();
|
||||
}
|
||||
},
|
||||
Err(e) => {
|
||||
sess.err(format!("could not exec the linker `{}`: {}",
|
||||
pname,
|
||||
e)[]);
|
||||
e).index(&FullRange));
|
||||
sess.abort_if_errors();
|
||||
}
|
||||
}
|
||||
|
@ -1004,7 +1004,7 @@ unsafe fn configure_llvm(sess: &Session) {
|
|||
if sess.print_llvm_passes() { add("-debug-pass=Structure"); }
|
||||
|
||||
for arg in sess.opts.cg.llvm_args.iter() {
|
||||
add((*arg)[]);
|
||||
add((*arg).index(&FullRange));
|
||||
}
|
||||
}
|
||||
|
||||
|
|
|
@ -94,7 +94,7 @@ impl <'l, 'tcx> DxrVisitor<'l, 'tcx> {
|
|||
|
||||
// dump info about all the external crates referenced from this crate
|
||||
self.sess.cstore.iter_crate_data(|n, cmd| {
|
||||
self.fmt.external_crate_str(krate.span, cmd.name[], n);
|
||||
self.fmt.external_crate_str(krate.span, cmd.name.index(&FullRange), n);
|
||||
});
|
||||
self.fmt.recorder.record("end_external_crates\n");
|
||||
}
|
||||
|
@ -143,7 +143,7 @@ impl <'l, 'tcx> DxrVisitor<'l, 'tcx> {
|
|||
for &(ref span, ref qualname) in sub_paths.iter() {
|
||||
self.fmt.sub_mod_ref_str(path.span,
|
||||
*span,
|
||||
qualname[],
|
||||
qualname.index(&FullRange),
|
||||
self.cur_scope);
|
||||
}
|
||||
}
|
||||
|
@ -161,7 +161,7 @@ impl <'l, 'tcx> DxrVisitor<'l, 'tcx> {
|
|||
for &(ref span, ref qualname) in sub_paths.iter() {
|
||||
self.fmt.sub_mod_ref_str(path.span,
|
||||
*span,
|
||||
qualname[],
|
||||
qualname.index(&FullRange),
|
||||
self.cur_scope);
|
||||
}
|
||||
}
|
||||
|
@ -180,17 +180,17 @@ impl <'l, 'tcx> DxrVisitor<'l, 'tcx> {
|
|||
let (ref span, ref qualname) = sub_paths[len-2];
|
||||
self.fmt.sub_type_ref_str(path.span,
|
||||
*span,
|
||||
qualname[]);
|
||||
qualname.index(&FullRange));
|
||||
|
||||
// write the other sub-paths
|
||||
if len <= 2 {
|
||||
return;
|
||||
}
|
||||
let sub_paths = sub_paths[..len-2];
|
||||
let sub_paths = sub_paths.index(&(0..(len-2)));
|
||||
for &(ref span, ref qualname) in sub_paths.iter() {
|
||||
self.fmt.sub_mod_ref_str(path.span,
|
||||
*span,
|
||||
qualname[],
|
||||
qualname.index(&FullRange),
|
||||
self.cur_scope);
|
||||
}
|
||||
}
|
||||
|
@ -199,7 +199,7 @@ impl <'l, 'tcx> DxrVisitor<'l, 'tcx> {
|
|||
fn lookup_type_ref(&self, ref_id: NodeId) -> Option<DefId> {
|
||||
if !self.analysis.ty_cx.def_map.borrow().contains_key(&ref_id) {
|
||||
self.sess.bug(format!("def_map has no key for {} in lookup_type_ref",
|
||||
ref_id)[]);
|
||||
ref_id).index(&FullRange));
|
||||
}
|
||||
let def = (*self.analysis.ty_cx.def_map.borrow())[ref_id];
|
||||
match def {
|
||||
|
@ -212,7 +212,7 @@ impl <'l, 'tcx> DxrVisitor<'l, 'tcx> {
|
|||
let def_map = self.analysis.ty_cx.def_map.borrow();
|
||||
if !def_map.contains_key(&ref_id) {
|
||||
self.sess.span_bug(span, format!("def_map has no key for {} in lookup_def_kind",
|
||||
ref_id)[]);
|
||||
ref_id).index(&FullRange));
|
||||
}
|
||||
let def = (*def_map)[ref_id];
|
||||
match def {
|
||||
|
@ -241,7 +241,7 @@ impl <'l, 'tcx> DxrVisitor<'l, 'tcx> {
|
|||
def::DefMethod(..) |
|
||||
def::DefPrimTy(_) => {
|
||||
self.sess.span_bug(span, format!("lookup_def_kind for unexpected item: {}",
|
||||
def)[]);
|
||||
def).index(&FullRange));
|
||||
},
|
||||
}
|
||||
}
|
||||
|
@ -262,8 +262,8 @@ impl <'l, 'tcx> DxrVisitor<'l, 'tcx> {
|
|||
span_utils.span_for_last_ident(p.span),
|
||||
id,
|
||||
qualname,
|
||||
path_to_string(p)[],
|
||||
typ[]);
|
||||
path_to_string(p).index(&FullRange),
|
||||
typ.index(&FullRange));
|
||||
}
|
||||
self.collected_paths.clear();
|
||||
}
|
||||
|
@ -285,14 +285,14 @@ impl <'l, 'tcx> DxrVisitor<'l, 'tcx> {
|
|||
match item.node {
|
||||
ast::ItemImpl(_, _, _, _, ref ty, _) => {
|
||||
let mut result = String::from_str("<");
|
||||
result.push_str(ty_to_string(&**ty)[]);
|
||||
result.push_str(ty_to_string(&**ty).index(&FullRange));
|
||||
|
||||
match ty::trait_of_item(&self.analysis.ty_cx,
|
||||
ast_util::local_def(method.id)) {
|
||||
Some(def_id) => {
|
||||
result.push_str(" as ");
|
||||
result.push_str(
|
||||
ty::item_path_str(&self.analysis.ty_cx, def_id)[]);
|
||||
ty::item_path_str(&self.analysis.ty_cx, def_id).index(&FullRange));
|
||||
},
|
||||
None => {}
|
||||
}
|
||||
|
@ -302,7 +302,7 @@ impl <'l, 'tcx> DxrVisitor<'l, 'tcx> {
|
|||
_ => {
|
||||
self.sess.span_bug(method.span,
|
||||
format!("Container {} for method {} not an impl?",
|
||||
impl_id.node, method.id)[]);
|
||||
impl_id.node, method.id).index(&FullRange));
|
||||
},
|
||||
}
|
||||
},
|
||||
|
@ -312,7 +312,7 @@ impl <'l, 'tcx> DxrVisitor<'l, 'tcx> {
|
|||
impl_id.node,
|
||||
method.id,
|
||||
self.analysis.ty_cx.map.get(impl_id.node)
|
||||
)[]);
|
||||
).index(&FullRange));
|
||||
},
|
||||
},
|
||||
None => match ty::trait_of_item(&self.analysis.ty_cx,
|
||||
|
@ -328,20 +328,20 @@ impl <'l, 'tcx> DxrVisitor<'l, 'tcx> {
|
|||
_ => {
|
||||
self.sess.span_bug(method.span,
|
||||
format!("Could not find container {} for method {}",
|
||||
def_id.node, method.id)[]);
|
||||
def_id.node, method.id).index(&FullRange));
|
||||
}
|
||||
}
|
||||
},
|
||||
None => {
|
||||
self.sess.span_bug(method.span,
|
||||
format!("Could not find container for method {}",
|
||||
method.id)[]);
|
||||
method.id).index(&FullRange));
|
||||
},
|
||||
},
|
||||
};
|
||||
|
||||
qualname.push_str(get_ident(method.pe_ident()).get());
|
||||
let qualname = qualname[];
|
||||
let qualname = qualname.index(&FullRange);
|
||||
|
||||
// record the decl for this def (if it has one)
|
||||
let decl_id = ty::trait_item_of_item(&self.analysis.ty_cx,
|
||||
|
@ -430,13 +430,13 @@ impl <'l, 'tcx> DxrVisitor<'l, 'tcx> {
|
|||
Some(sub_span) => self.fmt.field_str(field.span,
|
||||
Some(sub_span),
|
||||
field.node.id,
|
||||
name.get()[],
|
||||
qualname[],
|
||||
typ[],
|
||||
name.get().index(&FullRange),
|
||||
qualname.index(&FullRange),
|
||||
typ.index(&FullRange),
|
||||
scope_id),
|
||||
None => self.sess.span_bug(field.span,
|
||||
format!("Could not find sub-span for field {}",
|
||||
qualname)[]),
|
||||
qualname).index(&FullRange)),
|
||||
}
|
||||
},
|
||||
_ => (),
|
||||
|
@ -463,7 +463,7 @@ impl <'l, 'tcx> DxrVisitor<'l, 'tcx> {
|
|||
self.fmt.typedef_str(full_span,
|
||||
Some(*param_ss),
|
||||
param.id,
|
||||
name[],
|
||||
name.index(&FullRange),
|
||||
"");
|
||||
}
|
||||
self.visit_generics(generics);
|
||||
|
@ -480,10 +480,10 @@ impl <'l, 'tcx> DxrVisitor<'l, 'tcx> {
|
|||
self.fmt.fn_str(item.span,
|
||||
sub_span,
|
||||
item.id,
|
||||
qualname[],
|
||||
qualname.index(&FullRange),
|
||||
self.cur_scope);
|
||||
|
||||
self.process_formals(&decl.inputs, qualname[]);
|
||||
self.process_formals(&decl.inputs, qualname.index(&FullRange));
|
||||
|
||||
// walk arg and return types
|
||||
for arg in decl.inputs.iter() {
|
||||
|
@ -497,7 +497,7 @@ impl <'l, 'tcx> DxrVisitor<'l, 'tcx> {
|
|||
// walk the body
|
||||
self.nest(item.id, |v| v.visit_block(&*body));
|
||||
|
||||
self.process_generic_params(ty_params, item.span, qualname[], item.id);
|
||||
self.process_generic_params(ty_params, item.span, qualname.index(&FullRange), item.id);
|
||||
}
|
||||
|
||||
fn process_static(&mut self,
|
||||
|
@ -519,9 +519,9 @@ impl <'l, 'tcx> DxrVisitor<'l, 'tcx> {
|
|||
sub_span,
|
||||
item.id,
|
||||
get_ident(item.ident).get(),
|
||||
qualname[],
|
||||
value[],
|
||||
ty_to_string(&*typ)[],
|
||||
qualname.index(&FullRange),
|
||||
value.index(&FullRange),
|
||||
ty_to_string(&*typ).index(&FullRange),
|
||||
self.cur_scope);
|
||||
|
||||
// walk type and init value
|
||||
|
@ -542,9 +542,9 @@ impl <'l, 'tcx> DxrVisitor<'l, 'tcx> {
|
|||
sub_span,
|
||||
item.id,
|
||||
get_ident(item.ident).get(),
|
||||
qualname[],
|
||||
qualname.index(&FullRange),
|
||||
"",
|
||||
ty_to_string(&*typ)[],
|
||||
ty_to_string(&*typ).index(&FullRange),
|
||||
self.cur_scope);
|
||||
|
||||
// walk type and init value
|
||||
|
@ -568,17 +568,17 @@ impl <'l, 'tcx> DxrVisitor<'l, 'tcx> {
|
|||
sub_span,
|
||||
item.id,
|
||||
ctor_id,
|
||||
qualname[],
|
||||
qualname.index(&FullRange),
|
||||
self.cur_scope,
|
||||
val[]);
|
||||
val.index(&FullRange));
|
||||
|
||||
// fields
|
||||
for field in def.fields.iter() {
|
||||
self.process_struct_field_def(field, qualname[], item.id);
|
||||
self.process_struct_field_def(field, qualname.index(&FullRange), item.id);
|
||||
self.visit_ty(&*field.node.ty);
|
||||
}
|
||||
|
||||
self.process_generic_params(ty_params, item.span, qualname[], item.id);
|
||||
self.process_generic_params(ty_params, item.span, qualname.index(&FullRange), item.id);
|
||||
}
|
||||
|
||||
fn process_enum(&mut self,
|
||||
|
@ -591,12 +591,12 @@ impl <'l, 'tcx> DxrVisitor<'l, 'tcx> {
|
|||
Some(sub_span) => self.fmt.enum_str(item.span,
|
||||
Some(sub_span),
|
||||
item.id,
|
||||
enum_name[],
|
||||
enum_name.index(&FullRange),
|
||||
self.cur_scope,
|
||||
val[]),
|
||||
val.index(&FullRange)),
|
||||
None => self.sess.span_bug(item.span,
|
||||
format!("Could not find subspan for enum {}",
|
||||
enum_name)[]),
|
||||
enum_name).index(&FullRange)),
|
||||
}
|
||||
for variant in enum_definition.variants.iter() {
|
||||
let name = get_ident(variant.node.name);
|
||||
|
@ -612,9 +612,9 @@ impl <'l, 'tcx> DxrVisitor<'l, 'tcx> {
|
|||
self.span.span_for_first_ident(variant.span),
|
||||
variant.node.id,
|
||||
name,
|
||||
qualname[],
|
||||
enum_name[],
|
||||
val[],
|
||||
qualname.index(&FullRange),
|
||||
enum_name.index(&FullRange),
|
||||
val.index(&FullRange),
|
||||
item.id);
|
||||
for arg in args.iter() {
|
||||
self.visit_ty(&*arg.ty);
|
||||
|
@ -630,20 +630,20 @@ impl <'l, 'tcx> DxrVisitor<'l, 'tcx> {
|
|||
self.span.span_for_first_ident(variant.span),
|
||||
variant.node.id,
|
||||
ctor_id,
|
||||
qualname[],
|
||||
enum_name[],
|
||||
val[],
|
||||
qualname.index(&FullRange),
|
||||
enum_name.index(&FullRange),
|
||||
val.index(&FullRange),
|
||||
item.id);
|
||||
|
||||
for field in struct_def.fields.iter() {
|
||||
self.process_struct_field_def(field, qualname[], variant.node.id);
|
||||
self.process_struct_field_def(field, qualname.index(&FullRange), variant.node.id);
|
||||
self.visit_ty(&*field.node.ty);
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
self.process_generic_params(ty_params, item.span, enum_name[], item.id);
|
||||
self.process_generic_params(ty_params, item.span, enum_name.index(&FullRange), item.id);
|
||||
}
|
||||
|
||||
fn process_impl(&mut self,
|
||||
|
@ -703,9 +703,9 @@ impl <'l, 'tcx> DxrVisitor<'l, 'tcx> {
|
|||
self.fmt.trait_str(item.span,
|
||||
sub_span,
|
||||
item.id,
|
||||
qualname[],
|
||||
qualname.index(&FullRange),
|
||||
self.cur_scope,
|
||||
val[]);
|
||||
val.index(&FullRange));
|
||||
|
||||
// super-traits
|
||||
for super_bound in trait_refs.iter() {
|
||||
|
@ -737,7 +737,7 @@ impl <'l, 'tcx> DxrVisitor<'l, 'tcx> {
|
|||
}
|
||||
|
||||
// walk generics and methods
|
||||
self.process_generic_params(generics, item.span, qualname[], item.id);
|
||||
self.process_generic_params(generics, item.span, qualname.index(&FullRange), item.id);
|
||||
for method in methods.iter() {
|
||||
self.visit_trait_item(method)
|
||||
}
|
||||
|
@ -755,9 +755,9 @@ impl <'l, 'tcx> DxrVisitor<'l, 'tcx> {
|
|||
self.fmt.mod_str(item.span,
|
||||
sub_span,
|
||||
item.id,
|
||||
qualname[],
|
||||
qualname.index(&FullRange),
|
||||
self.cur_scope,
|
||||
filename[]);
|
||||
filename.index(&FullRange));
|
||||
|
||||
self.nest(item.id, |v| visit::walk_mod(v, m));
|
||||
}
|
||||
|
@ -774,7 +774,7 @@ impl <'l, 'tcx> DxrVisitor<'l, 'tcx> {
|
|||
let def_map = self.analysis.ty_cx.def_map.borrow();
|
||||
if !def_map.contains_key(&id) {
|
||||
self.sess.span_bug(span,
|
||||
format!("def_map has no key for {} in visit_expr", id)[]);
|
||||
format!("def_map has no key for {} in visit_expr", id).index(&FullRange));
|
||||
}
|
||||
let def = &(*def_map)[id];
|
||||
let sub_span = self.span.span_for_last_ident(span);
|
||||
|
@ -841,7 +841,7 @@ impl <'l, 'tcx> DxrVisitor<'l, 'tcx> {
|
|||
self.cur_scope),
|
||||
_ => self.sess.span_bug(span,
|
||||
format!("Unexpected def kind while looking up path in '{}'",
|
||||
self.span.snippet(span))[]),
|
||||
self.span.snippet(span)).index(&FullRange)),
|
||||
}
|
||||
// modules or types in the path prefix
|
||||
match *def {
|
||||
|
@ -959,7 +959,7 @@ impl <'l, 'tcx> DxrVisitor<'l, 'tcx> {
|
|||
self.cur_scope);
|
||||
|
||||
// walk receiver and args
|
||||
visit::walk_exprs(self, args[]);
|
||||
visit::walk_exprs(self, args.index(&FullRange));
|
||||
}
|
||||
|
||||
fn process_pat(&mut self, p:&ast::Pat) {
|
||||
|
@ -976,7 +976,7 @@ impl <'l, 'tcx> DxrVisitor<'l, 'tcx> {
|
|||
None => {
|
||||
self.sess.span_bug(p.span,
|
||||
format!("Could not find struct_def for `{}`",
|
||||
self.span.snippet(p.span))[]);
|
||||
self.span.snippet(p.span)).index(&FullRange));
|
||||
}
|
||||
};
|
||||
for &Spanned { node: ref field, span } in fields.iter() {
|
||||
|
@ -1061,11 +1061,11 @@ impl<'l, 'tcx, 'v> Visitor<'v> for DxrVisitor<'l, 'tcx> {
|
|||
self.fmt.typedef_str(item.span,
|
||||
sub_span,
|
||||
item.id,
|
||||
qualname[],
|
||||
value[]);
|
||||
qualname.index(&FullRange),
|
||||
value.index(&FullRange));
|
||||
|
||||
self.visit_ty(&**ty);
|
||||
self.process_generic_params(ty_params, item.span, qualname[], item.id);
|
||||
self.process_generic_params(ty_params, item.span, qualname.index(&FullRange), item.id);
|
||||
},
|
||||
ast::ItemMac(_) => (),
|
||||
_ => visit::walk_item(self, item),
|
||||
|
@ -1122,12 +1122,12 @@ impl<'l, 'tcx, 'v> Visitor<'v> for DxrVisitor<'l, 'tcx> {
|
|||
None => {
|
||||
self.sess.span_bug(method_type.span,
|
||||
format!("Could not find trait for method {}",
|
||||
method_type.id)[]);
|
||||
method_type.id).index(&FullRange));
|
||||
},
|
||||
};
|
||||
|
||||
qualname.push_str(get_ident(method_type.ident).get());
|
||||
let qualname = qualname[];
|
||||
let qualname = qualname.index(&FullRange);
|
||||
|
||||
let sub_span = self.span.sub_span_after_keyword(method_type.span, keywords::Fn);
|
||||
self.fmt.method_decl_str(method_type.span,
|
||||
|
@ -1262,7 +1262,7 @@ impl<'l, 'tcx, 'v> Visitor<'v> for DxrVisitor<'l, 'tcx> {
|
|||
id,
|
||||
cnum,
|
||||
name,
|
||||
s[],
|
||||
s.index(&FullRange),
|
||||
self.cur_scope);
|
||||
},
|
||||
}
|
||||
|
@ -1371,8 +1371,8 @@ impl<'l, 'tcx, 'v> Visitor<'v> for DxrVisitor<'l, 'tcx> {
|
|||
}
|
||||
|
||||
let mut id = String::from_str("$");
|
||||
id.push_str(ex.id.to_string()[]);
|
||||
self.process_formals(&decl.inputs, id[]);
|
||||
id.push_str(ex.id.to_string().index(&FullRange));
|
||||
self.process_formals(&decl.inputs, id.index(&FullRange));
|
||||
|
||||
// walk arg and return types
|
||||
for arg in decl.inputs.iter() {
|
||||
|
@ -1418,7 +1418,7 @@ impl<'l, 'tcx, 'v> Visitor<'v> for DxrVisitor<'l, 'tcx> {
|
|||
let def_map = self.analysis.ty_cx.def_map.borrow();
|
||||
if !def_map.contains_key(&id) {
|
||||
self.sess.span_bug(p.span,
|
||||
format!("def_map has no key for {} in visit_arm", id)[]);
|
||||
format!("def_map has no key for {} in visit_arm", id).index(&FullRange));
|
||||
}
|
||||
let def = &(*def_map)[id];
|
||||
match *def {
|
||||
|
@ -1433,8 +1433,8 @@ impl<'l, 'tcx, 'v> Visitor<'v> for DxrVisitor<'l, 'tcx> {
|
|||
self.fmt.variable_str(p.span,
|
||||
Some(p.span),
|
||||
id,
|
||||
path_to_string(p)[],
|
||||
value[],
|
||||
path_to_string(p).index(&FullRange),
|
||||
value.index(&FullRange),
|
||||
"")
|
||||
}
|
||||
def::DefVariant(..) => {
|
||||
|
@ -1488,9 +1488,9 @@ impl<'l, 'tcx, 'v> Visitor<'v> for DxrVisitor<'l, 'tcx> {
|
|||
self.fmt.variable_str(p.span,
|
||||
sub_span,
|
||||
id,
|
||||
path_to_string(p)[],
|
||||
value[],
|
||||
typ[]);
|
||||
path_to_string(p).index(&FullRange),
|
||||
value.index(&FullRange),
|
||||
typ.index(&FullRange));
|
||||
}
|
||||
self.collected_paths.clear();
|
||||
|
||||
|
@ -1509,7 +1509,7 @@ pub fn process_crate(sess: &Session,
|
|||
}
|
||||
|
||||
assert!(analysis.glob_map.is_some());
|
||||
let cratename = match attr::find_crate_name(krate.attrs[]) {
|
||||
let cratename = match attr::find_crate_name(krate.attrs.index(&FullRange)) {
|
||||
Some(name) => name.get().to_string(),
|
||||
None => {
|
||||
info!("Could not find crate name, using 'unknown_crate'");
|
||||
|
@ -1530,7 +1530,7 @@ pub fn process_crate(sess: &Session,
|
|||
|
||||
match fs::mkdir_recursive(&root_path, io::USER_RWX) {
|
||||
Err(e) => sess.err(format!("Could not create directory {}: {}",
|
||||
root_path.display(), e)[]),
|
||||
root_path.display(), e).index(&FullRange)),
|
||||
_ => (),
|
||||
}
|
||||
|
||||
|
@ -1547,7 +1547,7 @@ pub fn process_crate(sess: &Session,
|
|||
Ok(f) => box f,
|
||||
Err(e) => {
|
||||
let disp = root_path.display();
|
||||
sess.fatal(format!("Could not open {}: {}", disp, e)[]);
|
||||
sess.fatal(format!("Could not open {}: {}", disp, e).index(&FullRange));
|
||||
}
|
||||
};
|
||||
root_path.pop();
|
||||
|
@ -1573,7 +1573,7 @@ pub fn process_crate(sess: &Session,
|
|||
cur_scope: 0
|
||||
};
|
||||
|
||||
visitor.dump_crate_info(cratename[], krate);
|
||||
visitor.dump_crate_info(cratename.index(&FullRange), krate);
|
||||
|
||||
visit::walk_crate(&mut visitor, krate);
|
||||
}
|
||||
|
|
|
@ -41,7 +41,7 @@ impl Recorder {
|
|||
assert!(self.dump_spans);
|
||||
let result = format!("span,kind,{},{},text,\"{}\"\n",
|
||||
kind, su.extent_str(span), escape(su.snippet(span)));
|
||||
self.record(result[]);
|
||||
self.record(result.index(&FullRange));
|
||||
}
|
||||
}
|
||||
|
||||
|
@ -160,15 +160,15 @@ impl<'a> FmtStrs<'a> {
|
|||
if values.len() != fields.len() {
|
||||
self.span.sess.span_bug(span, format!(
|
||||
"Mismatch between length of fields for '{}', expected '{}', found '{}'",
|
||||
kind, fields.len(), values.len())[]);
|
||||
kind, fields.len(), values.len()).index(&FullRange));
|
||||
}
|
||||
|
||||
let values = values.iter().map(|s| {
|
||||
// Never take more than 1020 chars
|
||||
if s.len() > 1020 {
|
||||
s[..1020]
|
||||
s.index(&(0..1020))
|
||||
} else {
|
||||
s[]
|
||||
s.index(&FullRange)
|
||||
}
|
||||
});
|
||||
|
||||
|
@ -184,7 +184,7 @@ impl<'a> FmtStrs<'a> {
|
|||
}
|
||||
)));
|
||||
Some(strs.fold(String::new(), |mut s, ss| {
|
||||
s.push_str(ss[]);
|
||||
s.push_str(ss.index(&FullRange));
|
||||
s
|
||||
}))
|
||||
}
|
||||
|
@ -198,7 +198,7 @@ impl<'a> FmtStrs<'a> {
|
|||
if needs_span {
|
||||
self.span.sess.span_bug(span, format!(
|
||||
"Called record_without_span for '{}' which does requires a span",
|
||||
label)[]);
|
||||
label).index(&FullRange));
|
||||
}
|
||||
assert!(!dump_spans);
|
||||
|
||||
|
@ -212,9 +212,9 @@ impl<'a> FmtStrs<'a> {
|
|||
};
|
||||
|
||||
let mut result = String::from_str(label);
|
||||
result.push_str(values_str[]);
|
||||
result.push_str(values_str.index(&FullRange));
|
||||
result.push_str("\n");
|
||||
self.recorder.record(result[]);
|
||||
self.recorder.record(result.index(&FullRange));
|
||||
}
|
||||
|
||||
pub fn record_with_span(&mut self,
|
||||
|
@ -237,7 +237,7 @@ impl<'a> FmtStrs<'a> {
|
|||
if !needs_span {
|
||||
self.span.sess.span_bug(span,
|
||||
format!("Called record_with_span for '{}' \
|
||||
which does not require a span", label)[]);
|
||||
which does not require a span", label).index(&FullRange));
|
||||
}
|
||||
|
||||
let values_str = match self.make_values_str(label, fields, values, span) {
|
||||
|
@ -245,7 +245,7 @@ impl<'a> FmtStrs<'a> {
|
|||
None => return,
|
||||
};
|
||||
let result = format!("{},{}{}\n", label, self.span.extent_str(sub_span), values_str);
|
||||
self.recorder.record(result[]);
|
||||
self.recorder.record(result.index(&FullRange));
|
||||
}
|
||||
|
||||
pub fn check_and_record(&mut self,
|
||||
|
@ -275,7 +275,7 @@ impl<'a> FmtStrs<'a> {
|
|||
// variable def's node id
|
||||
let mut qualname = String::from_str(name);
|
||||
qualname.push_str("$");
|
||||
qualname.push_str(id.to_string()[]);
|
||||
qualname.push_str(id.to_string().index(&FullRange));
|
||||
self.check_and_record(Variable,
|
||||
span,
|
||||
sub_span,
|
||||
|
|
|
@ -218,7 +218,7 @@ impl<'a> SpanUtils<'a> {
|
|||
let loc = self.sess.codemap().lookup_char_pos(span.lo);
|
||||
self.sess.span_bug(span,
|
||||
format!("Mis-counted brackets when breaking path? Parsing '{}' in {}, line {}",
|
||||
self.snippet(span), loc.file.name, loc.line)[]);
|
||||
self.snippet(span), loc.file.name, loc.line).index(&FullRange));
|
||||
}
|
||||
if result.is_none() && prev.tok.is_ident() && bracket_count == 0 {
|
||||
return self.make_sub_span(span, Some(prev.sp));
|
||||
|
@ -244,7 +244,7 @@ impl<'a> SpanUtils<'a> {
|
|||
let loc = self.sess.codemap().lookup_char_pos(span.lo);
|
||||
self.sess.span_bug(span, format!(
|
||||
"Mis-counted brackets when breaking path? Parsing '{}' in {}, line {}",
|
||||
self.snippet(span), loc.file.name, loc.line)[]);
|
||||
self.snippet(span), loc.file.name, loc.line).index(&FullRange));
|
||||
}
|
||||
return result
|
||||
}
|
||||
|
|
Some files were not shown because too many files have changed in this diff Show More
Loading…
Reference in New Issue