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 {
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);

View file

@ -735,7 +735,7 @@ mod tests {
fn test_input(g: LabelledGraph) -> IoResult<String> {
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 {

View file

@ -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))
}
}
}

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) {
(&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)])
}
_ => {

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).
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);
}

View file

@ -521,7 +521,7 @@ impl<I> Iterator<u16> for Utf16Encoder<I> where I: Iterator<char> {
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]
})