]> git.lizzy.rs Git - rust.git/blobdiff - src/librustc_borrowck/borrowck/fragments.rs
use slicing sugar
[rust.git] / src / librustc_borrowck / borrowck / fragments.rs
index d7527487465895db0aea649a865ba5f807cea5f4..1b1202082177112e35ba939fa52196442f8d111c 100644 (file)
@@ -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 `.index(&FullRange)`).
+    // of InteriorElement (i.e. array dereference `&foo[]`).
     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.index(&FullRange),
+                &item.attrs[],
             Some(ast_map::NodeImplItem(&ast::MethodImplItem(ref m))) =>
-                m.attrs.index(&FullRange),
+                &m.attrs[],
             Some(ast_map::NodeTraitItem(&ast::ProvidedMethod(ref m))) =>
-                m.attrs.index(&FullRange),
-            _ => [].index(&FullRange),
+                &m.attrs[],
+            _ => &[][],
         };
 
         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()).index(&FullRange));
+                tcx.sess.span_err(sp, &format!("{}: `{}`", kind, render())[]);
             }
             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()).index(&FullRange));
+                tcx.sess.span_err(sp, &format!("{}: `{}`", kind, render())[]);
             }
             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.index(&FullRange)));
+    debug!("fragments 1 moved: {:?}", path_lps(&moved[]));
 
     assigned.sort();
     assigned.dedup();
-    debug!("fragments 1 assigned: {:?}", path_lps(assigned.index(&FullRange)));
+    debug!("fragments 1 assigned: {:?}", path_lps(&assigned[]));
 
     // 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.index(&FullRange)));
+    debug!("fragments 2 parents: {:?}", path_lps(&parents[]));
 
     // Third, filter the moved and assigned fragments down to just the non-parents
-    moved.retain(|f| non_member(*f, parents.index(&FullRange)));
-    debug!("fragments 3 moved: {:?}", path_lps(moved.index(&FullRange)));
+    moved.retain(|f| non_member(*f, &parents[]));
+    debug!("fragments 3 moved: {:?}", path_lps(&moved[]));
 
-    assigned.retain(|f| non_member(*f, parents.index(&FullRange)));
-    debug!("fragments 3 assigned: {:?}", path_lps(assigned.index(&FullRange)));
+    assigned.retain(|f| non_member(*f, &parents[]));
+    debug!("fragments 3 assigned: {:?}", path_lps(&assigned[]));
 
     // 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.index(&FullRange)));
+    debug!("fragments 4 unmoved: {:?}", frag_lps(&unmoved[]));
 
     // Fifth, filter the leftover fragments down to its core.
     unmoved.retain(|f| match *f {
         AllButOneFrom(_) => true,
-        Just(mpi) => non_member(mpi, parents.index(&FullRange)) &&
-            non_member(mpi, moved.index(&FullRange)) &&
-            non_member(mpi, assigned.index(&FullRange))
+        Just(mpi) => non_member(mpi, &parents[]) &&
+            non_member(mpi, &moved[]) &&
+            non_member(mpi, &assigned[])
     });
-    debug!("fragments 5 unmoved: {:?}", frag_lps(unmoved.index(&FullRange)));
+    debug!("fragments 5 unmoved: {:?}", frag_lps(&unmoved[]));
 
     // 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.index(&FullRange))
+            tcx.sess.opt_span_bug(opt_span, &msg[])
         }
     }
 }