diff --git a/src/libcollections/ring_buf.rs b/src/libcollections/ring_buf.rs index 2715ff0678a..df8e08f07a3 100644 --- a/src/libcollections/ring_buf.rs +++ b/src/libcollections/ring_buf.rs @@ -453,7 +453,7 @@ impl RingBuf { if contiguous { let (empty, buf) = buf.split_at_mut(0); - (buf[mut tail..head], empty) + (buf.slice_mut(tail, head), empty) } else { let (mid, right) = buf.split_at_mut(tail); let (left, _) = mid.split_at_mut(head); diff --git a/src/libgraphviz/lib.rs b/src/libgraphviz/lib.rs index ce3df1090bd..7dd0649e483 100644 --- a/src/libgraphviz/lib.rs +++ b/src/libgraphviz/lib.rs @@ -735,7 +735,7 @@ mod tests { fn test_input(g: LabelledGraph) -> IoResult { let mut writer = Vec::new(); render(&g, &mut writer).unwrap(); - (&mut writer[]).read_to_string() + (&mut writer.as_slice()).read_to_string() } // All of the tests use raw-strings as the format for the expected outputs, @@ -847,7 +847,7 @@ r#"digraph hasse_diagram { edge(1, 3, ";"), edge(2, 3, ";" ))); render(&g, &mut writer).unwrap(); - let r = (&mut writer[]).read_to_string(); + let r = (&mut writer.as_slice()).read_to_string(); assert_eq!(r.unwrap(), r#"digraph syntax_tree { diff --git a/src/librustc/middle/mem_categorization.rs b/src/librustc/middle/mem_categorization.rs index b48e41ceb73..5d3134b9629 100644 --- a/src/librustc/middle/mem_categorization.rs +++ b/src/librustc/middle/mem_categorization.rs @@ -519,8 +519,7 @@ impl<'t,'tcx,TYPER:Typer<'tcx>> MemCategorizationContext<'t,TYPER> { ret_ty), 1, true) } None => { - let base_cmt = if_ok!(self.cat_expr(&**base)); - self.cat_index(expr, base_cmt) + self.cat_index(expr, self.cat_expr(&**base)) } } } diff --git a/src/librustc_trans/trans/expr.rs b/src/librustc_trans/trans/expr.rs index c88a1b5e187..f49769ba0d9 100644 --- a/src/librustc_trans/trans/expr.rs +++ b/src/librustc_trans/trans/expr.rs @@ -1074,18 +1074,18 @@ fn trans_rvalue_dps_unadjusted<'blk, 'tcx>(bcx: Block<'blk, 'tcx>, let (did, fields, ty_params) = match (start, end) { (&Some(ref start), &Some(ref end)) => { // Desugar to Range - let fields = vec!(make_field("start", start.clone()), - make_field("end", end.clone())); + let fields = vec![make_field("start", start.clone()), + make_field("end", end.clone())]; (tcx.lang_items.range_struct(), fields, vec![node_id_type(bcx, start.id)]) } (&Some(ref start), &None) => { // Desugar to RangeFrom - let fields = vec!(make_field("start", start.clone())); + let fields = vec![make_field("start", start.clone())]; (tcx.lang_items.range_from_struct(), fields, vec![node_id_type(bcx, start.id)]) } (&None, &Some(ref end)) => { // Desugar to RangeTo - let fields = vec!(make_field("end", end.clone())); + let fields = vec![make_field("end", end.clone())]; (tcx.lang_items.range_to_struct(), fields, vec![node_id_type(bcx, end.id)]) } _ => { diff --git a/src/librustc_typeck/check/mod.rs b/src/librustc_typeck/check/mod.rs index 9ae42fed07f..fb23ad8e340 100644 --- a/src/librustc_typeck/check/mod.rs +++ b/src/librustc_typeck/check/mod.rs @@ -4183,9 +4183,6 @@ fn check_expr_with_unifier<'a, 'tcx, F>(fcx: &FnCtxt<'a, 'tcx>, // A slice, rather than an index. Special cased for now (KILLME). let base_t = structurally_resolved_type(fcx, expr.span, base_t); - if lvalue_pref == PreferMutLvalue { - println!("mutable lvalue_pref"); - } let result = autoderef_for_index(fcx, &**base, base_t, lvalue_pref, |adj_ty, adj| { try_overloaded_slice_step(fcx, @@ -4299,42 +4296,49 @@ fn check_expr_with_unifier<'a, 'tcx, F>(fcx: &FnCtxt<'a, 'tcx>, // bounds because right the range structs do not have any. If we add // some bounds, then we'll need to check `t_start` against them here. - let range_type = if idx_type == Some(ty::mk_err()) { - ty::mk_err() - } else if idx_type.is_none() { - // Neither start nor end => FullRange - if let Some(did) = tcx.lang_items.full_range_struct() { - let substs = Substs::new_type(vec![], vec![]); - ty::mk_struct(tcx, did, substs) - } else { + let range_type = match idx_type { + Some(idx_type) if ty::type_is_error(idx_type) => { ty::mk_err() } - } else { - // Find the did from the appropriate lang item. - let did = match (start, end) { - (&Some(_), &Some(_)) => tcx.lang_items.range_struct(), - (&Some(_), &None) => tcx.lang_items.range_from_struct(), - (&None, &Some(_)) => tcx.lang_items.range_to_struct(), - (&None, &None) => { - tcx.sess.span_bug(expr.span,"full range should be dealt with above") + Some(idx_type) => { + // Find the did from the appropriate lang item. + let did = match (start, end) { + (&Some(_), &Some(_)) => tcx.lang_items.range_struct(), + (&Some(_), &None) => tcx.lang_items.range_from_struct(), + (&None, &Some(_)) => tcx.lang_items.range_to_struct(), + (&None, &None) => { + tcx.sess.span_bug(expr.span, "full range should be dealt with above") + } + }; + + if let Some(did) = did { + let polytype = ty::lookup_item_type(tcx, did); + let substs = Substs::new_type(vec![idx_type], vec![]); + let bounds = polytype.generics.to_bounds(tcx, &substs); + fcx.add_obligations_for_parameters( + traits::ObligationCause::new(expr.span, + fcx.body_id, + traits::ItemObligation(did)), + &bounds); + + ty::mk_struct(tcx, did, tcx.mk_substs(substs)) + } else { + tcx.sess.span_err(expr.span, "No lang item for range syntax"); + ty::mk_err() + } + } + None => { + // Neither start nor end => FullRange + if let Some(did) = tcx.lang_items.full_range_struct() { + let substs = Substs::new_type(vec![], vec![]); + ty::mk_struct(tcx, did, tcx.mk_substs(substs)) + } else { + tcx.sess.span_err(expr.span, "No lang item for range syntax"); + ty::mk_err() } - }; - - if let Some(did) = did { - let polytype = ty::lookup_item_type(tcx, did); - let substs = Substs::new_type(vec![idx_type.unwrap()], vec![]); - let bounds = polytype.generics.to_bounds(tcx, &substs); - fcx.add_obligations_for_parameters( - traits::ObligationCause::new(expr.span, - fcx.body_id, - traits::ItemObligation(did)), - &bounds); - - ty::mk_struct(tcx, did, tcx.mk_substs(substs)) - } else { - ty::mk_err() } }; + fcx.write_ty(id, range_type); } diff --git a/src/libunicode/u_str.rs b/src/libunicode/u_str.rs index 3b0cc1443f0..398728bb516 100644 --- a/src/libunicode/u_str.rs +++ b/src/libunicode/u_str.rs @@ -521,7 +521,7 @@ impl Iterator for Utf16Encoder where I: Iterator { let mut buf = [0u16, ..2]; self.chars.next().map(|ch| { - let n = ch.encode_utf16(buf[mut]).unwrap_or(0); + let n = ch.encode_utf16(buf.as_mut_slice()).unwrap_or(0); if n == 2 { self.extra = buf[1]; } buf[0] })