mirror of
https://github.com/rust-lang/rust.git
synced 2025-04-28 02:57:37 +00:00
Fallout from stabilization.
This commit is contained in:
parent
092ba6a856
commit
a506d4cbfe
@ -332,8 +332,7 @@ pub fn parse_name_value_directive(line: &str, directive: &str)
|
||||
let keycolon = format!("{}:", directive);
|
||||
match line.find_str(keycolon.as_slice()) {
|
||||
Some(colon) => {
|
||||
let value = line.slice(colon + keycolon.len(),
|
||||
line.len()).to_string();
|
||||
let value = line[(colon + keycolon.len()) .. line.len()].to_string();
|
||||
debug!("{}: {}", directive, value);
|
||||
Some(value)
|
||||
}
|
||||
|
@ -862,7 +862,7 @@ fn check_debugger_output(debugger_run_result: &ProcRes, check_lines: &[String])
|
||||
break;
|
||||
}
|
||||
Some(i) => {
|
||||
rest = rest.slice_from(i + frag.len());
|
||||
rest = &rest[(i + frag.len())..];
|
||||
}
|
||||
}
|
||||
first = false;
|
||||
@ -1045,7 +1045,7 @@ fn scan_until_char(haystack: &str, needle: char, idx: &mut uint) -> bool {
|
||||
if *idx >= haystack.len() {
|
||||
return false;
|
||||
}
|
||||
let opt = haystack.slice_from(*idx).find(needle);
|
||||
let opt = haystack[(*idx)..].find(needle);
|
||||
if opt.is_none() {
|
||||
return false;
|
||||
}
|
||||
|
@ -485,9 +485,9 @@ fn main() {
|
||||
Thread::spawn(move || {
|
||||
let mut array = number.lock().unwrap();
|
||||
|
||||
(*array)[i] += 1;
|
||||
array[i as usize] += 1;
|
||||
|
||||
println!("numbers[{}] is {}", i, (*array)[i]);
|
||||
println!("numbers[{}] is {}", i, array[i as usize]);
|
||||
});
|
||||
}
|
||||
}
|
||||
|
@ -21,7 +21,7 @@ use core::prelude::*;
|
||||
use core::borrow::BorrowFrom;
|
||||
use core::cmp::Ordering::{Greater, Less, Equal};
|
||||
use core::iter::Zip;
|
||||
use core::ops::{Deref, DerefMut};
|
||||
use core::ops::{Deref, DerefMut, Index, IndexMut};
|
||||
use core::ptr::Unique;
|
||||
use core::{slice, mem, ptr, cmp, num, raw};
|
||||
use alloc::heap;
|
||||
@ -1487,7 +1487,7 @@ impl<K, V, E, Impl> AbsTraversal<Impl>
|
||||
|
||||
macro_rules! node_slice_impl {
|
||||
($NodeSlice:ident, $Traversal:ident,
|
||||
$as_slices_internal:ident, $slice_from:ident, $slice_to:ident, $iter:ident) => {
|
||||
$as_slices_internal:ident, $index:ident, $iter:ident) => {
|
||||
impl<'a, K: Ord + 'a, V: 'a> $NodeSlice<'a, K, V> {
|
||||
/// Performs linear search in a slice. Returns a tuple of (index, is_exact_match).
|
||||
fn search_linear<Q: ?Sized>(&self, key: &Q) -> (uint, bool)
|
||||
@ -1521,10 +1521,10 @@ macro_rules! node_slice_impl {
|
||||
edges: if !self.has_edges {
|
||||
self.edges
|
||||
} else {
|
||||
self.edges.$slice_from(pos)
|
||||
self.edges.$index(&(pos ..))
|
||||
},
|
||||
keys: self.keys.slice_from(pos),
|
||||
vals: self.vals.$slice_from(pos),
|
||||
keys: &self.keys[pos ..],
|
||||
vals: self.vals.$index(&(pos ..)),
|
||||
head_is_edge: !pos_is_kv,
|
||||
tail_is_edge: self.tail_is_edge,
|
||||
}
|
||||
@ -1550,10 +1550,10 @@ macro_rules! node_slice_impl {
|
||||
edges: if !self.has_edges {
|
||||
self.edges
|
||||
} else {
|
||||
self.edges.$slice_to(pos + 1)
|
||||
self.edges.$index(&(.. (pos + 1)))
|
||||
},
|
||||
keys: self.keys.slice_to(pos),
|
||||
vals: self.vals.$slice_to(pos),
|
||||
keys: &self.keys[..pos],
|
||||
vals: self.vals.$index(&(.. pos)),
|
||||
head_is_edge: self.head_is_edge,
|
||||
tail_is_edge: !pos_is_kv,
|
||||
}
|
||||
@ -1583,6 +1583,5 @@ macro_rules! node_slice_impl {
|
||||
}
|
||||
}
|
||||
|
||||
node_slice_impl!(NodeSlice, Traversal, as_slices_internal, slice_from, slice_to, iter);
|
||||
node_slice_impl!(MutNodeSlice, MutTraversal, as_slices_internal_mut, slice_from_mut,
|
||||
slice_to_mut, iter_mut);
|
||||
node_slice_impl!(NodeSlice, Traversal, as_slices_internal, index, iter);
|
||||
node_slice_impl!(MutNodeSlice, MutTraversal, as_slices_internal_mut, index_mut, iter_mut);
|
||||
|
@ -578,7 +578,7 @@ impl<T> RingBuf<T> {
|
||||
|
||||
if contiguous {
|
||||
let (empty, buf) = buf.split_at_mut(0);
|
||||
(buf.slice_mut(tail, head), empty)
|
||||
(&mut buf[tail .. head], empty)
|
||||
} else {
|
||||
let (mid, right) = buf.split_at_mut(tail);
|
||||
let (left, _) = mid.split_at_mut(head);
|
||||
|
@ -686,7 +686,7 @@ impl<T> SliceExt for [T] {
|
||||
|
||||
#[inline]
|
||||
fn move_from(&mut self, mut src: Vec<T>, start: uint, end: uint) -> uint {
|
||||
for (a, b) in self.iter_mut().zip(src.slice_mut(start, end).iter_mut()) {
|
||||
for (a, b) in self.iter_mut().zip(src[start .. end].iter_mut()) {
|
||||
mem::swap(a, b);
|
||||
}
|
||||
cmp::min(self.len(), end-start)
|
||||
|
@ -752,21 +752,15 @@ pub trait StrExt: Index<FullRange, Output = str> {
|
||||
|
||||
/// Deprecated: use `s[a .. b]` instead.
|
||||
#[deprecated = "use slice notation [a..b] instead"]
|
||||
fn slice(&self, begin: uint, end: uint) -> &str {
|
||||
core_str::StrExt::slice(&self[], begin, end)
|
||||
}
|
||||
fn slice(&self, begin: uint, end: uint) -> &str;
|
||||
|
||||
/// Deprecated: use `s[a..]` instead.
|
||||
#[deprecated = "use slice notation [a..] instead"]
|
||||
fn slice_from(&self, begin: uint) -> &str {
|
||||
core_str::StrExt::slice_from(&self[], begin)
|
||||
}
|
||||
fn slice_from(&self, begin: uint) -> &str;
|
||||
|
||||
/// Deprecated: use `s[..a]` instead.
|
||||
#[deprecated = "use slice notation [..a] instead"]
|
||||
fn slice_to(&self, end: uint) -> &str {
|
||||
core_str::StrExt::slice_to(&self[], end)
|
||||
}
|
||||
fn slice_to(&self, end: uint) -> &str;
|
||||
|
||||
/// Returns a slice of the string from the character range
|
||||
/// [`begin`..`end`).
|
||||
@ -1304,7 +1298,19 @@ pub trait StrExt: Index<FullRange, Output = str> {
|
||||
}
|
||||
|
||||
#[stable]
|
||||
impl StrExt for str {}
|
||||
impl StrExt for str {
|
||||
fn slice(&self, begin: uint, end: uint) -> &str {
|
||||
&self[begin..end]
|
||||
}
|
||||
|
||||
fn slice_from(&self, begin: uint) -> &str {
|
||||
&self[begin..]
|
||||
}
|
||||
|
||||
fn slice_to(&self, end: uint) -> &str {
|
||||
&self[..end]
|
||||
}
|
||||
}
|
||||
|
||||
#[cfg(test)]
|
||||
mod tests {
|
||||
|
@ -179,7 +179,7 @@ pub fn float_to_str_bytes_common<T: Float, U, F>(
|
||||
_ => ()
|
||||
}
|
||||
|
||||
buf.slice_to_mut(end).reverse();
|
||||
buf[..end].reverse();
|
||||
|
||||
// Remember start of the fractional digits.
|
||||
// Points one beyond end of buf if none get generated,
|
||||
@ -316,7 +316,7 @@ pub fn float_to_str_bytes_common<T: Float, U, F>(
|
||||
|
||||
impl<'a> fmt::Writer for Filler<'a> {
|
||||
fn write_str(&mut self, s: &str) -> fmt::Result {
|
||||
slice::bytes::copy_memory(self.buf.slice_from_mut(*self.end),
|
||||
slice::bytes::copy_memory(&mut self.buf[(*self.end)..],
|
||||
s.as_bytes());
|
||||
*self.end += s.len();
|
||||
Ok(())
|
||||
|
@ -174,7 +174,7 @@ impl<'a> SeedableRng<&'a [u32]> for ChaChaRng {
|
||||
// reset state
|
||||
self.init(&[0u32; KEY_WORDS]);
|
||||
// set key in place
|
||||
let key = self.state.slice_mut(4, 4+KEY_WORDS);
|
||||
let key = &mut self.state[4 .. 4+KEY_WORDS];
|
||||
for (k, s) in key.iter_mut().zip(seed.iter()) {
|
||||
*k = *s;
|
||||
}
|
||||
@ -292,4 +292,3 @@ mod test {
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
|
@ -103,7 +103,7 @@ impl Writer for SeekableMemWriter {
|
||||
|
||||
// Do the necessary writes
|
||||
if left.len() > 0 {
|
||||
slice::bytes::copy_memory(self.buf.slice_from_mut(self.pos), left);
|
||||
slice::bytes::copy_memory(&mut self.buf[self.pos..], left);
|
||||
}
|
||||
if right.len() > 0 {
|
||||
self.buf.push_all(right);
|
||||
|
@ -459,7 +459,7 @@ impl<'t> Captures<'t> {
|
||||
pub fn at(&self, i: uint) -> Option<&'t str> {
|
||||
match self.pos(i) {
|
||||
None => None,
|
||||
Some((s, e)) => Some(self.text.slice(s, e))
|
||||
Some((s, e)) => Some(&self.text[s.. e])
|
||||
}
|
||||
}
|
||||
|
||||
|
@ -242,7 +242,7 @@ impl MetadataBlob {
|
||||
((slice[2] as u32) << 8) |
|
||||
((slice[3] as u32) << 0)) as uint;
|
||||
if len + 4 <= slice.len() {
|
||||
slice.slice(4, len + 4)
|
||||
&slice[4.. len + 4]
|
||||
} else {
|
||||
&[] // corrupt or old metadata
|
||||
}
|
||||
|
@ -392,11 +392,11 @@ impl<'a> Context<'a> {
|
||||
};
|
||||
let (hash, rlib) = if file.starts_with(&rlib_prefix[]) &&
|
||||
file.ends_with(".rlib") {
|
||||
(file.slice(rlib_prefix.len(), file.len() - ".rlib".len()),
|
||||
(&file[(rlib_prefix.len()) .. (file.len() - ".rlib".len())],
|
||||
true)
|
||||
} else if file.starts_with(dylib_prefix.as_slice()) &&
|
||||
file.ends_with(dypair.1.as_slice()) {
|
||||
(file.slice(dylib_prefix.len(), file.len() - dypair.1.len()),
|
||||
(&file[(dylib_prefix.len()) .. (file.len() - dypair.1.len())],
|
||||
false)
|
||||
} else {
|
||||
return FileDoesntMatch
|
||||
|
@ -424,7 +424,7 @@ impl<'a, 'tcx> CFGBuilder<'a, 'tcx> {
|
||||
}
|
||||
|
||||
ast::ExprMethodCall(_, _, ref args) => {
|
||||
self.call(expr, pred, &*args[0], args.slice_from(1).iter().map(|e| &**e))
|
||||
self.call(expr, pred, &*args[0], args[1..].iter().map(|e| &**e))
|
||||
}
|
||||
|
||||
ast::ExprIndex(ref l, ref r) |
|
||||
|
@ -118,17 +118,17 @@ impl<'a, 'tcx, O:DataFlowOperator> pprust::PpAnn for DataFlowContext<'a, 'tcx, O
|
||||
assert!(self.bits_per_id > 0);
|
||||
let cfgidx = to_cfgidx_or_die(id, &self.nodeid_to_index);
|
||||
let (start, end) = self.compute_id_range(cfgidx);
|
||||
let on_entry = self.on_entry.slice(start, end);
|
||||
let on_entry = &self.on_entry[start.. end];
|
||||
let entry_str = bits_to_string(on_entry);
|
||||
|
||||
let gens = self.gens.slice(start, end);
|
||||
let gens = &self.gens[start.. end];
|
||||
let gens_str = if gens.iter().any(|&u| u != 0) {
|
||||
format!(" gen: {}", bits_to_string(gens))
|
||||
} else {
|
||||
"".to_string()
|
||||
};
|
||||
|
||||
let kills = self.kills.slice(start, end);
|
||||
let kills = &self.kills[start .. end];
|
||||
let kills_str = if kills.iter().any(|&u| u != 0) {
|
||||
format!(" kill: {}", bits_to_string(kills))
|
||||
} else {
|
||||
@ -232,7 +232,7 @@ impl<'a, 'tcx, O:DataFlowOperator> DataFlowContext<'a, 'tcx, O> {
|
||||
|
||||
let cfgidx = to_cfgidx_or_die(id, &self.nodeid_to_index);
|
||||
let (start, end) = self.compute_id_range(cfgidx);
|
||||
let gens = self.gens.slice_mut(start, end);
|
||||
let gens = &mut self.gens[start.. end];
|
||||
set_bit(gens, bit);
|
||||
}
|
||||
|
||||
@ -245,7 +245,7 @@ impl<'a, 'tcx, O:DataFlowOperator> DataFlowContext<'a, 'tcx, O> {
|
||||
|
||||
let cfgidx = to_cfgidx_or_die(id, &self.nodeid_to_index);
|
||||
let (start, end) = self.compute_id_range(cfgidx);
|
||||
let kills = self.kills.slice_mut(start, end);
|
||||
let kills = &mut self.kills[start.. end];
|
||||
set_bit(kills, bit);
|
||||
}
|
||||
|
||||
@ -256,9 +256,9 @@ impl<'a, 'tcx, O:DataFlowOperator> DataFlowContext<'a, 'tcx, O> {
|
||||
assert!(self.bits_per_id > 0);
|
||||
|
||||
let (start, end) = self.compute_id_range(cfgidx);
|
||||
let gens = self.gens.slice(start, end);
|
||||
let gens = &self.gens[start.. end];
|
||||
bitwise(bits, gens, &Union);
|
||||
let kills = self.kills.slice(start, end);
|
||||
let kills = &self.kills[start.. end];
|
||||
bitwise(bits, kills, &Subtract);
|
||||
|
||||
debug!("{} apply_gen_kill(cfgidx={:?}, bits={}) [after]",
|
||||
@ -304,7 +304,7 @@ impl<'a, 'tcx, O:DataFlowOperator> DataFlowContext<'a, 'tcx, O> {
|
||||
}
|
||||
|
||||
let (start, end) = self.compute_id_range(cfgidx);
|
||||
let on_entry = self.on_entry.slice(start, end);
|
||||
let on_entry = &self.on_entry[start.. end];
|
||||
let temp_bits;
|
||||
let slice = match e {
|
||||
Entry => on_entry,
|
||||
@ -336,7 +336,7 @@ impl<'a, 'tcx, O:DataFlowOperator> DataFlowContext<'a, 'tcx, O> {
|
||||
|
||||
let cfgidx = to_cfgidx_or_die(id, &self.nodeid_to_index);
|
||||
let (start, end) = self.compute_id_range(cfgidx);
|
||||
let gens = self.gens.slice(start, end);
|
||||
let gens = &self.gens[start.. end];
|
||||
debug!("{} each_gen_bit(id={}, gens={})",
|
||||
self.analysis_name, id, bits_to_string(gens));
|
||||
self.each_bit(gens, f)
|
||||
@ -396,7 +396,7 @@ impl<'a, 'tcx, O:DataFlowOperator> DataFlowContext<'a, 'tcx, O> {
|
||||
cfg.graph.each_edge(|_edge_index, edge| {
|
||||
let flow_exit = edge.source();
|
||||
let (start, end) = self.compute_id_range(flow_exit);
|
||||
let mut orig_kills = self.kills.slice(start, end).to_vec();
|
||||
let mut orig_kills = self.kills[start.. end].to_vec();
|
||||
|
||||
let mut changed = false;
|
||||
for &node_id in edge.data.exiting_scopes.iter() {
|
||||
@ -404,7 +404,7 @@ impl<'a, 'tcx, O:DataFlowOperator> DataFlowContext<'a, 'tcx, O> {
|
||||
match opt_cfg_idx {
|
||||
Some(cfg_idx) => {
|
||||
let (start, end) = self.compute_id_range(cfg_idx);
|
||||
let kills = self.kills.slice(start, end);
|
||||
let kills = &self.kills[start.. end];
|
||||
if bitwise(orig_kills.as_mut_slice(), kills, &Union) {
|
||||
changed = true;
|
||||
}
|
||||
@ -418,7 +418,7 @@ impl<'a, 'tcx, O:DataFlowOperator> DataFlowContext<'a, 'tcx, O> {
|
||||
}
|
||||
|
||||
if changed {
|
||||
let bits = self.kills.slice_mut(start, end);
|
||||
let bits = &mut self.kills[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[]);
|
||||
@ -487,7 +487,7 @@ impl<'a, 'b, 'tcx, O:DataFlowOperator> PropagationContext<'a, 'b, 'tcx, O> {
|
||||
let (start, end) = self.dfcx.compute_id_range(node_index);
|
||||
|
||||
// Initialize local bitvector with state on-entry.
|
||||
in_out.clone_from_slice(self.dfcx.on_entry.slice(start, end));
|
||||
in_out.clone_from_slice(&self.dfcx.on_entry[start.. end]);
|
||||
|
||||
// Compute state on-exit by applying transfer function to
|
||||
// state on-entry.
|
||||
@ -528,13 +528,13 @@ impl<'a, 'b, 'tcx, O:DataFlowOperator> PropagationContext<'a, 'b, 'tcx, O> {
|
||||
let (start, end) = self.dfcx.compute_id_range(cfgidx);
|
||||
let changed = {
|
||||
// (scoping mutable borrow of self.dfcx.on_entry)
|
||||
let on_entry = self.dfcx.on_entry.slice_mut(start, end);
|
||||
let on_entry = &mut self.dfcx.on_entry[start.. end];
|
||||
bitwise(on_entry, pred_bits, &self.dfcx.oper)
|
||||
};
|
||||
if changed {
|
||||
debug!("{} changed entry set for {:?} to {}",
|
||||
self.dfcx.analysis_name, cfgidx,
|
||||
bits_to_string(self.dfcx.on_entry.slice(start, end)));
|
||||
bits_to_string(&self.dfcx.on_entry[start.. end]));
|
||||
self.changed = true;
|
||||
}
|
||||
}
|
||||
|
@ -609,8 +609,7 @@ impl<'a, 'tcx> RegionVarBindings<'a, 'tcx> {
|
||||
pub fn vars_created_since_snapshot(&self, mark: &RegionSnapshot)
|
||||
-> Vec<RegionVid>
|
||||
{
|
||||
self.undo_log.borrow()
|
||||
.slice_from(mark.length)
|
||||
self.undo_log.borrow()[mark.length..]
|
||||
.iter()
|
||||
.filter_map(|&elt| match elt {
|
||||
AddVar(vid) => Some(vid),
|
||||
@ -637,7 +636,7 @@ impl<'a, 'tcx> RegionVarBindings<'a, 'tcx> {
|
||||
debug!("result_index={}, r={:?}", result_index, r);
|
||||
|
||||
for undo_entry in
|
||||
self.undo_log.borrow().slice_from(mark.length).iter()
|
||||
self.undo_log.borrow()[mark.length..].iter()
|
||||
{
|
||||
match undo_entry {
|
||||
&AddConstraint(ConstrainVarSubVar(a, b)) => {
|
||||
|
@ -373,12 +373,12 @@ impl<T> VecPerParamSpace<T> {
|
||||
|
||||
pub fn get_slice<'a>(&'a self, space: ParamSpace) -> &'a [T] {
|
||||
let (start, limit) = self.limits(space);
|
||||
self.content.slice(start, limit)
|
||||
&self.content[start.. limit]
|
||||
}
|
||||
|
||||
pub fn get_mut_slice<'a>(&'a mut self, space: ParamSpace) -> &'a mut [T] {
|
||||
let (start, limit) = self.limits(space);
|
||||
self.content.slice_mut(start, limit)
|
||||
&mut self.content[start.. limit]
|
||||
}
|
||||
|
||||
pub fn opt_get<'a>(&'a self,
|
||||
|
@ -36,13 +36,13 @@ impl SearchPaths {
|
||||
|
||||
pub fn add_path(&mut self, path: &str) {
|
||||
let (kind, path) = if path.starts_with("native=") {
|
||||
(PathKind::Native, path.slice_from("native=".len()))
|
||||
(PathKind::Native, &path["native=".len()..])
|
||||
} else if path.starts_with("crate=") {
|
||||
(PathKind::Crate, path.slice_from("crate=".len()))
|
||||
(PathKind::Crate, &path["crate=".len()..])
|
||||
} else if path.starts_with("dependency=") {
|
||||
(PathKind::Dependency, path.slice_from("dependency=".len()))
|
||||
(PathKind::Dependency, &path["dependency=".len()..])
|
||||
} else if path.starts_with("all=") {
|
||||
(PathKind::All, path.slice_from("all=".len()))
|
||||
(PathKind::All, &path["all=".len()..])
|
||||
} else {
|
||||
(PathKind::All, path)
|
||||
};
|
||||
|
@ -370,7 +370,7 @@ impl<'a, 'tcx> CheckLoanCtxt<'a, 'tcx> {
|
||||
|
||||
for (i, &x) in new_loan_indices.iter().enumerate() {
|
||||
let old_loan = &self.all_loans[x];
|
||||
for &y in new_loan_indices.slice_from(i+1).iter() {
|
||||
for &y in new_loan_indices[(i+1) ..].iter() {
|
||||
let new_loan = &self.all_loans[y];
|
||||
self.report_error_if_loans_conflict(old_loan, new_loan);
|
||||
}
|
||||
|
@ -178,7 +178,7 @@ pub fn build_link_meta(sess: &Session, krate: &ast::Crate,
|
||||
fn truncated_hash_result(symbol_hasher: &mut Sha256) -> String {
|
||||
let output = symbol_hasher.result_bytes();
|
||||
// 64 bits should be enough to avoid collisions.
|
||||
output.slice_to(8).to_hex().to_string()
|
||||
output[.. 8].to_hex().to_string()
|
||||
}
|
||||
|
||||
|
||||
|
@ -157,7 +157,7 @@ impl <'l, 'tcx> DxrVisitor<'l, 'tcx> {
|
||||
return;
|
||||
}
|
||||
|
||||
let sub_paths = sub_paths.slice(0, len-1);
|
||||
let sub_paths = &sub_paths[.. (len-1)];
|
||||
for &(ref span, ref qualname) in sub_paths.iter() {
|
||||
self.fmt.sub_mod_ref_str(path.span,
|
||||
*span,
|
||||
@ -174,7 +174,7 @@ impl <'l, 'tcx> DxrVisitor<'l, 'tcx> {
|
||||
if len <= 1 {
|
||||
return;
|
||||
}
|
||||
let sub_paths = sub_paths.slice_to(len-1);
|
||||
let sub_paths = &sub_paths[.. (len-1)];
|
||||
|
||||
// write the trait part of the sub-path
|
||||
let (ref span, ref qualname) = sub_paths[len-2];
|
||||
|
@ -1615,8 +1615,8 @@ fn compile_unit_metadata(cx: &CrateContext) -> DIDescriptor {
|
||||
let prefix: &[u8] = &[dotdot[0], ::std::path::SEP_BYTE];
|
||||
let mut path_bytes = p.as_vec().to_vec();
|
||||
|
||||
if path_bytes.slice_to(2) != prefix &&
|
||||
path_bytes.slice_to(2) != dotdot {
|
||||
if &path_bytes[..2] != prefix &&
|
||||
&path_bytes[..2] != dotdot {
|
||||
path_bytes.insert(0, prefix[0]);
|
||||
path_bytes.insert(1, prefix[1]);
|
||||
}
|
||||
@ -4122,4 +4122,3 @@ fn needs_gdb_debug_scripts_section(ccx: &CrateContext) -> bool {
|
||||
!ccx.sess().target.target.options.is_like_windows &&
|
||||
ccx.sess().opts.debuginfo != NoDebugInfo
|
||||
}
|
||||
|
||||
|
@ -494,7 +494,7 @@ pub fn trans_trait_callee_from_llval<'blk, 'tcx>(bcx: Block<'blk, 'tcx>,
|
||||
ty::ty_bare_fn(_, ref f) if f.abi == Rust || f.abi == RustCall => {
|
||||
let fake_sig =
|
||||
ty::Binder(ty::FnSig {
|
||||
inputs: f.sig.0.inputs.slice_from(1).to_vec(),
|
||||
inputs: f.sig.0.inputs[1..].to_vec(),
|
||||
output: f.sig.0.output,
|
||||
variadic: f.sig.0.variadic,
|
||||
});
|
||||
@ -634,7 +634,7 @@ pub fn trans_object_shim<'a, 'tcx>(
|
||||
}
|
||||
_ => {
|
||||
// skip the self parameter:
|
||||
sig.inputs.slice_from(1)
|
||||
&sig.inputs[1..]
|
||||
}
|
||||
};
|
||||
|
||||
|
@ -1321,7 +1321,7 @@ fn ty_of_method_or_bare_fn<'a, 'tcx>(this: &AstConv<'tcx>,
|
||||
|
||||
// HACK(eddyb) replace the fake self type in the AST with the actual type.
|
||||
let input_params = if self_ty.is_some() {
|
||||
decl.inputs.slice_from(1)
|
||||
&decl.inputs[1..]
|
||||
} else {
|
||||
&decl.inputs[]
|
||||
};
|
||||
@ -1339,9 +1339,9 @@ fn ty_of_method_or_bare_fn<'a, 'tcx>(this: &AstConv<'tcx>,
|
||||
let lifetimes_for_params = if implied_output_region.is_none() {
|
||||
let input_tys = if self_ty.is_some() {
|
||||
// Skip the first argument if `self` is present.
|
||||
self_and_input_tys.slice_from(1)
|
||||
&self_and_input_tys[1..]
|
||||
} else {
|
||||
self_and_input_tys.slice_from(0)
|
||||
&self_and_input_tys[]
|
||||
};
|
||||
|
||||
let (ior, lfp) = find_implied_output_region(input_tys, input_pats);
|
||||
@ -1665,7 +1665,7 @@ fn compute_opt_region_bound<'tcx>(tcx: &ty::ctxt<'tcx>,
|
||||
// of derived region bounds. If so, use that. Otherwise, report an
|
||||
// error.
|
||||
let r = derived_region_bounds[0];
|
||||
if derived_region_bounds.slice_from(1).iter().any(|r1| r != *r1) {
|
||||
if derived_region_bounds[1..].iter().any(|r1| r != *r1) {
|
||||
tcx.sess.span_err(
|
||||
span,
|
||||
&format!("ambiguous lifetime bound, \
|
||||
|
@ -531,7 +531,7 @@ fn visit_expr(rcx: &mut Rcx, expr: &ast::Expr) {
|
||||
|
||||
ast::ExprMethodCall(_, _, ref args) => {
|
||||
constrain_call(rcx, expr, Some(&*args[0]),
|
||||
args.slice_from(1).iter().map(|e| &**e), false);
|
||||
args[1..].iter().map(|e| &**e), false);
|
||||
|
||||
visit::walk_expr(rcx, expr);
|
||||
}
|
||||
|
@ -65,7 +65,7 @@ impl<'cx, 'tcx> OverlapChecker<'cx, 'tcx> {
|
||||
continue;
|
||||
}
|
||||
|
||||
for &impl2_def_id in trait_impls.slice_from(i+1).iter() {
|
||||
for &impl2_def_id in trait_impls[(i+1)..].iter() {
|
||||
self.check_if_impls_overlap(trait_def_id,
|
||||
impl1_def_id,
|
||||
impl2_def_id);
|
||||
|
@ -29,7 +29,7 @@ impl<'a> fmt::String for Escape<'a> {
|
||||
for (i, ch) in s.bytes().enumerate() {
|
||||
match ch as char {
|
||||
'<' | '>' | '&' | '\'' | '"' => {
|
||||
try!(fmt.write_str(pile_o_bits.slice(last, i)));
|
||||
try!(fmt.write_str(&pile_o_bits[last.. i]));
|
||||
let s = match ch as char {
|
||||
'>' => ">",
|
||||
'<' => "<",
|
||||
@ -46,7 +46,7 @@ impl<'a> fmt::String for Escape<'a> {
|
||||
}
|
||||
|
||||
if last < s.len() {
|
||||
try!(fmt.write_str(pile_o_bits.slice_from(last)));
|
||||
try!(fmt.write_str(&pile_o_bits[last..]));
|
||||
}
|
||||
Ok(())
|
||||
}
|
||||
|
@ -146,7 +146,7 @@ extern {
|
||||
fn stripped_filtered_line<'a>(s: &'a str) -> Option<&'a str> {
|
||||
let trimmed = s.trim();
|
||||
if trimmed.starts_with("# ") {
|
||||
Some(trimmed.slice_from(2))
|
||||
Some(&trimmed[2..])
|
||||
} else {
|
||||
None
|
||||
}
|
||||
|
@ -749,7 +749,7 @@ impl<'a> SourceCollector<'a> {
|
||||
|
||||
// Remove the utf-8 BOM if any
|
||||
let contents = if contents.starts_with("\u{feff}") {
|
||||
contents.slice_from(3)
|
||||
&contents[3..]
|
||||
} else {
|
||||
contents
|
||||
};
|
||||
@ -1469,7 +1469,7 @@ fn full_path(cx: &Context, item: &clean::Item) -> String {
|
||||
fn shorter<'a>(s: Option<&'a str>) -> &'a str {
|
||||
match s {
|
||||
Some(s) => match s.find_str("\n\n") {
|
||||
Some(pos) => s.slice_to(pos),
|
||||
Some(pos) => &s[..pos],
|
||||
None => s,
|
||||
},
|
||||
None => ""
|
||||
|
@ -28,10 +28,10 @@ fn extract_leading_metadata<'a>(s: &'a str) -> (Vec<&'a str>, &'a str) {
|
||||
for line in s.lines() {
|
||||
if line.starts_with("%") {
|
||||
// remove %<whitespace>
|
||||
metadata.push(line.slice_from(1).trim_left())
|
||||
metadata.push(line[1..].trim_left())
|
||||
} else {
|
||||
let line_start_byte = s.subslice_offset(line);
|
||||
return (metadata, s.slice_from(line_start_byte));
|
||||
return (metadata, &s[line_start_byte..]);
|
||||
}
|
||||
}
|
||||
// if we're here, then all lines were metadata % lines.
|
||||
|
@ -357,7 +357,7 @@ pub fn unindent(s: &str) -> String {
|
||||
line.to_string()
|
||||
} else {
|
||||
assert!(line.len() >= min_indent);
|
||||
line.slice_from(min_indent).to_string()
|
||||
line[min_indent..].to_string()
|
||||
}
|
||||
}).collect::<Vec<_>>().as_slice());
|
||||
unindented.connect("\n")
|
||||
|
@ -115,7 +115,7 @@ impl Deref for CString {
|
||||
type Target = [libc::c_char];
|
||||
|
||||
fn deref(&self) -> &[libc::c_char] {
|
||||
self.inner.slice_to(self.inner.len() - 1)
|
||||
&self.inner[..(self.inner.len() - 1)]
|
||||
}
|
||||
}
|
||||
|
||||
|
@ -219,7 +219,7 @@ impl<W: Writer> Writer for BufferedWriter<W> {
|
||||
if buf.len() > self.buf.len() {
|
||||
self.inner.as_mut().unwrap().write(buf)
|
||||
} else {
|
||||
let dst = self.buf.slice_from_mut(self.pos);
|
||||
let dst = &mut self.buf[self.pos..];
|
||||
slice::bytes::copy_memory(dst, buf);
|
||||
self.pos += buf.len();
|
||||
Ok(())
|
||||
|
@ -72,7 +72,7 @@ impl Buffer for ChanReader {
|
||||
if self.closed {
|
||||
Err(io::standard_error(io::EndOfFile))
|
||||
} else {
|
||||
Ok(self.buf.slice_from(self.pos))
|
||||
Ok(&self.buf[self.pos..])
|
||||
}
|
||||
}
|
||||
|
||||
@ -88,7 +88,7 @@ impl Reader for ChanReader {
|
||||
loop {
|
||||
let count = match self.fill_buf().ok() {
|
||||
Some(src) => {
|
||||
let dst = buf.slice_from_mut(num_read);
|
||||
let dst = &mut buf[num_read..];
|
||||
let count = cmp::min(src.len(), dst.len());
|
||||
bytes::copy_memory(dst, &src[..count]);
|
||||
count
|
||||
|
@ -160,7 +160,7 @@ impl Reader for MemReader {
|
||||
let write_len = min(buf.len(), self.buf.len() - self.pos);
|
||||
{
|
||||
let input = &self.buf[self.pos.. (self.pos + write_len)];
|
||||
let output = buf.slice_to_mut(write_len);
|
||||
let output = &mut buf[.. write_len];
|
||||
assert_eq!(input.len(), output.len());
|
||||
slice::bytes::copy_memory(output, input);
|
||||
}
|
||||
@ -205,11 +205,11 @@ impl<'a> Reader for &'a [u8] {
|
||||
let write_len = min(buf.len(), self.len());
|
||||
{
|
||||
let input = &self[..write_len];
|
||||
let output = buf.slice_to_mut(write_len);
|
||||
let output = &mut buf[.. write_len];
|
||||
slice::bytes::copy_memory(output, input);
|
||||
}
|
||||
|
||||
*self = self.slice_from(write_len);
|
||||
*self = &self[write_len..];
|
||||
|
||||
Ok(write_len)
|
||||
}
|
||||
@ -270,7 +270,7 @@ impl<'a> BufWriter<'a> {
|
||||
impl<'a> Writer for BufWriter<'a> {
|
||||
#[inline]
|
||||
fn write(&mut self, src: &[u8]) -> IoResult<()> {
|
||||
let dst = self.buf.slice_from_mut(self.pos);
|
||||
let dst = &mut self.buf[self.pos..];
|
||||
let dst_len = dst.len();
|
||||
|
||||
if dst_len == 0 {
|
||||
@ -350,7 +350,7 @@ impl<'a> Reader for BufReader<'a> {
|
||||
let write_len = min(buf.len(), self.buf.len() - self.pos);
|
||||
{
|
||||
let input = &self.buf[self.pos.. (self.pos + write_len)];
|
||||
let output = buf.slice_to_mut(write_len);
|
||||
let output = &mut buf[.. write_len];
|
||||
assert_eq!(input.len(), output.len());
|
||||
slice::bytes::copy_memory(output, input);
|
||||
}
|
||||
|
@ -516,7 +516,7 @@ pub trait Reader {
|
||||
while read < min {
|
||||
let mut zeroes = 0;
|
||||
loop {
|
||||
match self.read(buf.slice_from_mut(read)) {
|
||||
match self.read(&mut buf[read..]) {
|
||||
Ok(0) => {
|
||||
zeroes += 1;
|
||||
if zeroes >= NO_PROGRESS_LIMIT {
|
||||
@ -1481,7 +1481,7 @@ pub trait Buffer: Reader {
|
||||
{
|
||||
let mut start = 1;
|
||||
while start < width {
|
||||
match try!(self.read(buf.slice_mut(start, width))) {
|
||||
match try!(self.read(&mut buf[start .. width])) {
|
||||
n if n == width - start => break,
|
||||
n if n < width - start => { start += n; }
|
||||
_ => return Err(standard_error(InvalidInput)),
|
||||
|
@ -251,7 +251,7 @@ impl<'a> Parser<'a> {
|
||||
assert!(head.len() + tail.len() <= 8);
|
||||
let mut gs = [0u16; 8];
|
||||
gs.clone_from_slice(head);
|
||||
gs.slice_mut(8 - tail.len(), 8).clone_from_slice(tail);
|
||||
gs[(8 - tail.len()) .. 8].clone_from_slice(tail);
|
||||
Ipv6Addr(gs[0], gs[1], gs[2], gs[3], gs[4], gs[5], gs[6], gs[7])
|
||||
}
|
||||
|
||||
|
@ -48,7 +48,7 @@ impl<R: Reader> Reader for LimitReader<R> {
|
||||
}
|
||||
|
||||
let len = cmp::min(self.limit, buf.len());
|
||||
let res = self.inner.read(buf.slice_to_mut(len));
|
||||
let res = self.inner.read(&mut buf[..len]);
|
||||
match res {
|
||||
Ok(len) => self.limit -= len,
|
||||
_ => {}
|
||||
|
@ -379,14 +379,14 @@ pub fn float_to_str_bytes_common<T: Float>(
|
||||
|
||||
// only resize buf if we actually remove digits
|
||||
if i < buf_max_i {
|
||||
buf = buf.slice(0, i + 1).to_vec();
|
||||
buf = buf[.. (i + 1)].to_vec();
|
||||
}
|
||||
}
|
||||
} // If exact and trailing '.', just cut that
|
||||
else {
|
||||
let max_i = buf.len() - 1;
|
||||
if buf[max_i] == b'.' {
|
||||
buf = buf.slice(0, max_i).to_vec();
|
||||
buf = buf[.. max_i].to_vec();
|
||||
}
|
||||
}
|
||||
|
||||
|
@ -65,7 +65,7 @@ mod imp {
|
||||
let mut read = 0;
|
||||
let len = v.len();
|
||||
while read < len {
|
||||
let result = getrandom(v.slice_from_mut(read));
|
||||
let result = getrandom(&mut v[read..]);
|
||||
if result == -1 {
|
||||
let err = errno() as libc::c_int;
|
||||
if err == libc::EINTR {
|
||||
|
@ -130,7 +130,7 @@ pub fn abort(args: fmt::Arguments) -> ! {
|
||||
}
|
||||
impl<'a> fmt::Writer for BufWriter<'a> {
|
||||
fn write_str(&mut self, bytes: &str) -> fmt::Result {
|
||||
let left = self.buf.slice_from_mut(self.pos);
|
||||
let left = &mut self.buf[self.pos..];
|
||||
let to_write = &bytes.as_bytes()[..cmp::min(bytes.len(), left.len())];
|
||||
slice::bytes::copy_memory(left, to_write);
|
||||
self.pos += to_write.len();
|
||||
|
@ -42,10 +42,10 @@ pub fn demangle(writer: &mut Writer, s: &str) -> IoResult<()> {
|
||||
let mut valid = true;
|
||||
let mut inner = s;
|
||||
if s.len() > 4 && s.starts_with("_ZN") && s.ends_with("E") {
|
||||
inner = s.slice(3, s.len() - 1);
|
||||
inner = &s[3 .. s.len() - 1];
|
||||
// On Windows, dbghelp strips leading underscores, so we accept "ZN...E" form too.
|
||||
} else if s.len() > 3 && s.starts_with("ZN") && s.ends_with("E") {
|
||||
inner = s.slice(2, s.len() - 1);
|
||||
inner = &s[2 .. s.len() - 1];
|
||||
} else {
|
||||
valid = false;
|
||||
}
|
||||
@ -83,11 +83,11 @@ pub fn demangle(writer: &mut Writer, s: &str) -> IoResult<()> {
|
||||
}
|
||||
let mut rest = inner;
|
||||
while rest.char_at(0).is_numeric() {
|
||||
rest = rest.slice_from(1);
|
||||
rest = &rest[1..];
|
||||
}
|
||||
let i: uint = inner.slice_to(inner.len() - rest.len()).parse().unwrap();
|
||||
inner = rest.slice_from(i);
|
||||
rest = rest.slice_to(i);
|
||||
let i: uint = inner[.. (inner.len() - rest.len())].parse().unwrap();
|
||||
inner = &rest[i..];
|
||||
rest = &rest[..i];
|
||||
while rest.len() > 0 {
|
||||
if rest.starts_with("$") {
|
||||
macro_rules! demangle {
|
||||
@ -128,8 +128,8 @@ pub fn demangle(writer: &mut Writer, s: &str) -> IoResult<()> {
|
||||
None => rest.len(),
|
||||
Some(i) => i,
|
||||
};
|
||||
try!(writer.write_str(rest.slice_to(idx)));
|
||||
rest = rest.slice_from(idx);
|
||||
try!(writer.write_str(&rest[..idx]));
|
||||
rest = &rest[idx..];
|
||||
}
|
||||
}
|
||||
}
|
||||
|
@ -125,9 +125,9 @@ impl Process {
|
||||
let mut bytes = [0; 8];
|
||||
return match input.read(&mut bytes) {
|
||||
Ok(8) => {
|
||||
assert!(combine(CLOEXEC_MSG_FOOTER) == combine(bytes.slice(4, 8)),
|
||||
assert!(combine(CLOEXEC_MSG_FOOTER) == combine(&bytes[4.. 8]),
|
||||
"Validation on the CLOEXEC pipe failed: {:?}", bytes);
|
||||
let errno = combine(bytes.slice(0, 4));
|
||||
let errno = combine(&bytes[0.. 4]);
|
||||
assert!(p.wait(0).is_ok(), "wait(0) should either return Ok or panic");
|
||||
Err(super::decode_error(errno))
|
||||
}
|
||||
|
@ -376,7 +376,7 @@ pub fn readlink(p: &Path) -> IoResult<Path> {
|
||||
});
|
||||
let ret = match ret {
|
||||
Some(ref s) if s.starts_with(r"\\?\") => { // "
|
||||
Ok(Path::new(s.slice_from(4)))
|
||||
Ok(Path::new(&s[4..]))
|
||||
}
|
||||
Some(s) => Ok(Path::new(s)),
|
||||
None => Err(super::last_error()),
|
||||
|
@ -146,7 +146,7 @@ pub fn fill_utf16_buf_and_decode<F>(mut f: F) -> Option<String> where
|
||||
done = true;
|
||||
}
|
||||
if k != 0 && done {
|
||||
let sub = buf.slice(0, k as uint);
|
||||
let sub = &buf[.. (k as uint)];
|
||||
// We want to explicitly catch the case when the
|
||||
// closure returned invalid UTF-16, rather than
|
||||
// set `res` to None and continue.
|
||||
|
@ -271,9 +271,9 @@ impl<'a> StringReader<'a> {
|
||||
fn with_str_from_to<T, F>(&self, start: BytePos, end: BytePos, f: F) -> T where
|
||||
F: FnOnce(&str) -> T,
|
||||
{
|
||||
f(self.filemap.src.slice(
|
||||
self.byte_offset(start).to_uint(),
|
||||
self.byte_offset(end).to_uint()))
|
||||
f(&self.filemap.src[
|
||||
self.byte_offset(start).to_uint()..
|
||||
self.byte_offset(end).to_uint()])
|
||||
}
|
||||
|
||||
/// Converts CRLF to LF in the given string, raising an error on bare CR.
|
||||
|
@ -5223,7 +5223,7 @@ impl<'a> Parser<'a> {
|
||||
Some(i) => {
|
||||
let mut err = String::from_str("circular modules: ");
|
||||
let len = included_mod_stack.len();
|
||||
for p in included_mod_stack.slice(i, len).iter() {
|
||||
for p in included_mod_stack[i.. len].iter() {
|
||||
err.push_str(&p.display().as_cow()[]);
|
||||
err.push_str(" -> ");
|
||||
}
|
||||
|
@ -1590,7 +1590,7 @@ impl<'a> State<'a> {
|
||||
ident: ast::SpannedIdent,
|
||||
tys: &[P<ast::Ty>],
|
||||
args: &[P<ast::Expr>]) -> IoResult<()> {
|
||||
let base_args = args.slice_from(1);
|
||||
let base_args = &args[1..];
|
||||
try!(self.print_expr(&*args[0]));
|
||||
try!(word(&mut self.s, "."));
|
||||
try!(self.print_ident(ident.node));
|
||||
@ -2312,7 +2312,7 @@ impl<'a> State<'a> {
|
||||
let args = if first {
|
||||
&decl.inputs[]
|
||||
} else {
|
||||
decl.inputs.slice_from(1)
|
||||
&decl.inputs[1..]
|
||||
};
|
||||
|
||||
for arg in args.iter() {
|
||||
|
@ -249,8 +249,8 @@ impl<'a> Iterator for Graphemes<'a> {
|
||||
Some(cat)
|
||||
};
|
||||
|
||||
let retstr = self.string.slice_to(idx);
|
||||
self.string = self.string.slice_from(idx);
|
||||
let retstr = &self.string[..idx];
|
||||
self.string = &self.string[idx..];
|
||||
Some(retstr)
|
||||
}
|
||||
}
|
||||
@ -350,8 +350,8 @@ impl<'a> DoubleEndedIterator for Graphemes<'a> {
|
||||
Some(cat)
|
||||
};
|
||||
|
||||
let retstr = self.string.slice_from(idx);
|
||||
self.string = self.string.slice_to(idx);
|
||||
let retstr = &self.string[idx..];
|
||||
self.string = &self.string[..idx];
|
||||
Some(retstr)
|
||||
}
|
||||
}
|
||||
|
Loading…
Reference in New Issue
Block a user