Rebasing and reviewer changes

This commit is contained in:
Nick Cameron 2014-12-23 16:23:11 +13:00
parent 3bf405682d
commit 113f8aa86b
6 changed files with 47 additions and 44 deletions

View file

@ -453,7 +453,7 @@ impl<T> RingBuf<T> {
if contiguous { if contiguous {
let (empty, buf) = buf.split_at_mut(0); let (empty, buf) = buf.split_at_mut(0);
(buf[mut tail..head], empty) (buf.slice_mut(tail, head), empty)
} else { } else {
let (mid, right) = buf.split_at_mut(tail); let (mid, right) = buf.split_at_mut(tail);
let (left, _) = mid.split_at_mut(head); let (left, _) = mid.split_at_mut(head);

View file

@ -735,7 +735,7 @@ mod tests {
fn test_input(g: LabelledGraph) -> IoResult<String> { fn test_input(g: LabelledGraph) -> IoResult<String> {
let mut writer = Vec::new(); let mut writer = Vec::new();
render(&g, &mut writer).unwrap(); 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, // 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, ";" ))); edge(1, 3, ";"), edge(2, 3, ";" )));
render(&g, &mut writer).unwrap(); 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(), assert_eq!(r.unwrap(),
r#"digraph syntax_tree { r#"digraph syntax_tree {

View file

@ -519,8 +519,7 @@ impl<'t,'tcx,TYPER:Typer<'tcx>> MemCategorizationContext<'t,TYPER> {
ret_ty), 1, true) ret_ty), 1, true)
} }
None => { None => {
let base_cmt = if_ok!(self.cat_expr(&**base)); self.cat_index(expr, self.cat_expr(&**base))
self.cat_index(expr, base_cmt)
} }
} }
} }

View file

@ -1074,18 +1074,18 @@ fn trans_rvalue_dps_unadjusted<'blk, 'tcx>(bcx: Block<'blk, 'tcx>,
let (did, fields, ty_params) = match (start, end) { let (did, fields, ty_params) = match (start, end) {
(&Some(ref start), &Some(ref end)) => { (&Some(ref start), &Some(ref end)) => {
// Desugar to Range // Desugar to Range
let fields = vec!(make_field("start", start.clone()), let fields = vec![make_field("start", start.clone()),
make_field("end", end.clone())); make_field("end", end.clone())];
(tcx.lang_items.range_struct(), fields, vec![node_id_type(bcx, start.id)]) (tcx.lang_items.range_struct(), fields, vec![node_id_type(bcx, start.id)])
} }
(&Some(ref start), &None) => { (&Some(ref start), &None) => {
// Desugar to RangeFrom // 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)]) (tcx.lang_items.range_from_struct(), fields, vec![node_id_type(bcx, start.id)])
} }
(&None, &Some(ref end)) => { (&None, &Some(ref end)) => {
// Desugar to RangeTo // 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)]) (tcx.lang_items.range_to_struct(), fields, vec![node_id_type(bcx, end.id)])
} }
_ => { _ => {

View file

@ -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). // A slice, rather than an index. Special cased for now (KILLME).
let base_t = structurally_resolved_type(fcx, expr.span, base_t); let base_t = structurally_resolved_type(fcx, expr.span, base_t);
if lvalue_pref == PreferMutLvalue {
println!("mutable lvalue_pref");
}
let result = let result =
autoderef_for_index(fcx, &**base, base_t, lvalue_pref, |adj_ty, adj| { autoderef_for_index(fcx, &**base, base_t, lvalue_pref, |adj_ty, adj| {
try_overloaded_slice_step(fcx, try_overloaded_slice_step(fcx,
@ -4299,30 +4296,24 @@ 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 // 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. // some bounds, then we'll need to check `t_start` against them here.
let range_type = if idx_type == Some(ty::mk_err()) { let range_type = match idx_type {
ty::mk_err() Some(idx_type) if ty::type_is_error(idx_type) => {
} 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 {
ty::mk_err() ty::mk_err()
} }
} else { Some(idx_type) => {
// Find the did from the appropriate lang item. // Find the did from the appropriate lang item.
let did = match (start, end) { let did = match (start, end) {
(&Some(_), &Some(_)) => tcx.lang_items.range_struct(), (&Some(_), &Some(_)) => tcx.lang_items.range_struct(),
(&Some(_), &None) => tcx.lang_items.range_from_struct(), (&Some(_), &None) => tcx.lang_items.range_from_struct(),
(&None, &Some(_)) => tcx.lang_items.range_to_struct(), (&None, &Some(_)) => tcx.lang_items.range_to_struct(),
(&None, &None) => { (&None, &None) => {
tcx.sess.span_bug(expr.span,"full range should be dealt with above") tcx.sess.span_bug(expr.span, "full range should be dealt with above")
} }
}; };
if let Some(did) = did { if let Some(did) = did {
let polytype = ty::lookup_item_type(tcx, did); let polytype = ty::lookup_item_type(tcx, did);
let substs = Substs::new_type(vec![idx_type.unwrap()], vec![]); let substs = Substs::new_type(vec![idx_type], vec![]);
let bounds = polytype.generics.to_bounds(tcx, &substs); let bounds = polytype.generics.to_bounds(tcx, &substs);
fcx.add_obligations_for_parameters( fcx.add_obligations_for_parameters(
traits::ObligationCause::new(expr.span, traits::ObligationCause::new(expr.span,
@ -4332,9 +4323,22 @@ fn check_expr_with_unifier<'a, 'tcx, F>(fcx: &FnCtxt<'a, 'tcx>,
ty::mk_struct(tcx, did, tcx.mk_substs(substs)) ty::mk_struct(tcx, did, tcx.mk_substs(substs))
} else { } else {
tcx.sess.span_err(expr.span, "No lang item for range syntax");
ty::mk_err() 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()
}
}
}; };
fcx.write_ty(id, range_type); fcx.write_ty(id, range_type);
} }

View file

@ -521,7 +521,7 @@ impl<I> Iterator<u16> for Utf16Encoder<I> where I: Iterator<char> {
let mut buf = [0u16, ..2]; let mut buf = [0u16, ..2];
self.chars.next().map(|ch| { 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]; } if n == 2 { self.extra = buf[1]; }
buf[0] buf[0]
}) })