Skip to content

Make some slice coercions explicit - part 3 #18668

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Closed
wants to merge 1 commit into from
Closed
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
66 changes: 33 additions & 33 deletions src/librustc/middle/cfg/construct.rs
Original file line number Diff line number Diff line change
Expand Up @@ -73,19 +73,19 @@ impl<'a, 'tcx> CFGBuilder<'a, 'tcx> {

let expr_exit = self.opt_expr(&blk.expr, stmts_exit);

self.add_node(blk.id, [expr_exit])
self.add_node(blk.id, &[expr_exit])
}

fn stmt(&mut self, stmt: &ast::Stmt, pred: CFGIndex) -> CFGIndex {
match stmt.node {
ast::StmtDecl(ref decl, id) => {
let exit = self.decl(&**decl, pred);
self.add_node(id, [exit])
self.add_node(id, &[exit])
}

ast::StmtExpr(ref expr, id) | ast::StmtSemi(ref expr, id) => {
let exit = self.expr(&**expr, pred);
self.add_node(id, [exit])
self.add_node(id, &[exit])
}

ast::StmtMac(..) => {
Expand Down Expand Up @@ -114,33 +114,33 @@ impl<'a, 'tcx> CFGBuilder<'a, 'tcx> {
ast::PatLit(..) |
ast::PatRange(..) |
ast::PatWild(_) => {
self.add_node(pat.id, [pred])
self.add_node(pat.id, &[pred])
}

ast::PatBox(ref subpat) |
ast::PatRegion(ref subpat) |
ast::PatIdent(_, _, Some(ref subpat)) => {
let subpat_exit = self.pat(&**subpat, pred);
self.add_node(pat.id, [subpat_exit])
self.add_node(pat.id, &[subpat_exit])
}

ast::PatEnum(_, Some(ref subpats)) |
ast::PatTup(ref subpats) => {
let pats_exit = self.pats_all(subpats.iter(), pred);
self.add_node(pat.id, [pats_exit])
self.add_node(pat.id, &[pats_exit])
}

ast::PatStruct(_, ref subpats, _) => {
let pats_exit =
self.pats_all(subpats.iter().map(|f| &f.node.pat), pred);
self.add_node(pat.id, [pats_exit])
self.add_node(pat.id, &[pats_exit])
}

ast::PatVec(ref pre, ref vec, ref post) => {
let pre_exit = self.pats_all(pre.iter(), pred);
let vec_exit = self.pats_all(vec.iter(), pre_exit);
let post_exit = self.pats_all(post.iter(), vec_exit);
self.add_node(pat.id, [post_exit])
self.add_node(pat.id, &[post_exit])
}

ast::PatMac(_) => {
Expand All @@ -165,7 +165,7 @@ impl<'a, 'tcx> CFGBuilder<'a, 'tcx> {
if pats.len() == 1 {
self.pat(&*pats[0], pred)
} else {
let collect = self.add_dummy_node([]);
let collect = self.add_dummy_node(&[]);
for pat in pats.iter() {
let pat_exit = self.pat(&**pat, pred);
self.add_contained_edge(pat_exit, collect);
Expand All @@ -178,7 +178,7 @@ impl<'a, 'tcx> CFGBuilder<'a, 'tcx> {
match expr.node {
ast::ExprBlock(ref blk) => {
let blk_exit = self.block(&**blk, pred);
self.add_node(expr.id, [blk_exit])
self.add_node(expr.id, &[blk_exit])
}

ast::ExprIf(ref cond, ref then, None) => {
Expand All @@ -198,7 +198,7 @@ impl<'a, 'tcx> CFGBuilder<'a, 'tcx> {
//
let cond_exit = self.expr(&**cond, pred); // 1
let then_exit = self.block(&**then, cond_exit); // 2
self.add_node(expr.id, [cond_exit, then_exit]) // 3,4
self.add_node(expr.id, &[cond_exit, then_exit]) // 3,4
}

ast::ExprIf(ref cond, ref then, Some(ref otherwise)) => {
Expand All @@ -219,7 +219,7 @@ impl<'a, 'tcx> CFGBuilder<'a, 'tcx> {
let cond_exit = self.expr(&**cond, pred); // 1
let then_exit = self.block(&**then, cond_exit); // 2
let else_exit = self.expr(&**otherwise, cond_exit); // 3
self.add_node(expr.id, [then_exit, else_exit]) // 4, 5
self.add_node(expr.id, &[then_exit, else_exit]) // 4, 5
}

ast::ExprIfLet(..) => {
Expand All @@ -245,9 +245,9 @@ impl<'a, 'tcx> CFGBuilder<'a, 'tcx> {
// may cause additional edges.

// Is the condition considered part of the loop?
let loopback = self.add_dummy_node([pred]); // 1
let cond_exit = self.expr(&**cond, loopback); // 2
let expr_exit = self.add_node(expr.id, [cond_exit]); // 3
let loopback = self.add_dummy_node(&[pred]); // 1
let cond_exit = self.expr(&**cond, loopback); // 2
let expr_exit = self.add_node(expr.id, &[cond_exit]); // 3
self.loop_scopes.push(LoopScope {
loop_id: expr.id,
continue_index: loopback,
Expand Down Expand Up @@ -286,10 +286,10 @@ impl<'a, 'tcx> CFGBuilder<'a, 'tcx> {
// Note that `break` and `continue` statements
// may cause additional edges.

let head = self.expr(&**head, pred); // 1
let loopback = self.add_dummy_node([head]); // 2
let cond = self.add_dummy_node([loopback]); // 3
let expr_exit = self.add_node(expr.id, [cond]); // 4
let head = self.expr(&**head, pred); // 1
let loopback = self.add_dummy_node(&[head]); // 2
let cond = self.add_dummy_node(&[loopback]); // 3
let expr_exit = self.add_node(expr.id, &[cond]); // 4
self.loop_scopes.push(LoopScope {
loop_id: expr.id,
continue_index: loopback,
Expand Down Expand Up @@ -317,8 +317,8 @@ impl<'a, 'tcx> CFGBuilder<'a, 'tcx> {
// Note that `break` and `loop` statements
// may cause additional edges.

let loopback = self.add_dummy_node([pred]); // 1
let expr_exit = self.add_node(expr.id, []); // 2
let loopback = self.add_dummy_node(&[pred]); // 1
let expr_exit = self.add_node(expr.id, &[]); // 2
self.loop_scopes.push(LoopScope {
loop_id: expr.id,
continue_index: loopback,
Expand Down Expand Up @@ -358,10 +358,10 @@ impl<'a, 'tcx> CFGBuilder<'a, 'tcx> {
//
let discr_exit = self.expr(&**discr, pred); // 1

let expr_exit = self.add_node(expr.id, []);
let expr_exit = self.add_node(expr.id, &[]);
let mut cond_exit = discr_exit;
for arm in arms.iter() {
cond_exit = self.add_dummy_node([cond_exit]); // 2
cond_exit = self.add_dummy_node(&[cond_exit]); // 2
let pats_exit = self.pats_any(arm.pats.as_slice(),
cond_exit); // 3
let guard_exit = self.opt_expr(&arm.guard,
Expand Down Expand Up @@ -389,30 +389,30 @@ impl<'a, 'tcx> CFGBuilder<'a, 'tcx> {
//
let l_exit = self.expr(&**l, pred); // 1
let r_exit = self.expr(&**r, l_exit); // 2
self.add_node(expr.id, [l_exit, r_exit]) // 3,4
self.add_node(expr.id, &[l_exit, r_exit]) // 3,4
}

ast::ExprRet(ref v) => {
let v_exit = self.opt_expr(v, pred);
let b = self.add_node(expr.id, [v_exit]);
let b = self.add_node(expr.id, &[v_exit]);
self.add_returning_edge(expr, b);
self.add_node(ast::DUMMY_NODE_ID, [])
self.add_node(ast::DUMMY_NODE_ID, &[])
}

ast::ExprBreak(label) => {
let loop_scope = self.find_scope(expr, label);
let b = self.add_node(expr.id, [pred]);
let b = self.add_node(expr.id, &[pred]);
self.add_exiting_edge(expr, b,
loop_scope, loop_scope.break_index);
self.add_node(ast::DUMMY_NODE_ID, [])
self.add_node(ast::DUMMY_NODE_ID, &[])
}

ast::ExprAgain(label) => {
let loop_scope = self.find_scope(expr, label);
let a = self.add_node(expr.id, [pred]);
let a = self.add_node(expr.id, &[pred]);
self.add_exiting_edge(expr, a,
loop_scope, loop_scope.continue_index);
self.add_node(ast::DUMMY_NODE_ID, [])
self.add_node(ast::DUMMY_NODE_ID, &[])
}

ast::ExprVec(ref elems) => {
Expand Down Expand Up @@ -492,7 +492,7 @@ impl<'a, 'tcx> CFGBuilder<'a, 'tcx> {
let &(_, ref expr, _) = a;
&**expr
}), post_inputs);
self.add_node(expr.id, [post_outputs])
self.add_node(expr.id, &[post_outputs])
}

ast::ExprMac(..) |
Expand Down Expand Up @@ -520,7 +520,7 @@ impl<'a, 'tcx> CFGBuilder<'a, 'tcx> {
let func_or_rcvr_exit = self.expr(func_or_rcvr, pred);
let ret = self.straightline(call_expr, func_or_rcvr_exit, args);
if return_ty == ty::FnDiverging {
self.add_node(ast::DUMMY_NODE_ID, [])
self.add_node(ast::DUMMY_NODE_ID, &[])
} else {
ret
}
Expand All @@ -547,7 +547,7 @@ impl<'a, 'tcx> CFGBuilder<'a, 'tcx> {
//! Handles case of an expression that evaluates `subexprs` in order
let subexprs_exit = self.exprs(subexprs, pred);
self.add_node(expr.id, [subexprs_exit])
self.add_node(expr.id, &[subexprs_exit])
}

fn add_dummy_node(&mut self, preds: &[CFGIndex]) -> CFGIndex {
Expand Down
2 changes: 1 addition & 1 deletion src/librustc/middle/cfg/graphviz.rs
Original file line number Diff line number Diff line change
Expand Up @@ -40,7 +40,7 @@ fn replace_newline_with_backslash_l(s: String) -> String {
let mut last_two: Vec<_> =
s.as_slice().chars().rev().take(2).collect();
last_two.reverse();
if last_two.as_slice() != ['\\', 'l'] {
if last_two.as_slice() != &['\\', 'l'] {
s.push_str("\\l");
}
s
Expand Down
2 changes: 1 addition & 1 deletion src/librustc/middle/check_match.rs
Original file line number Diff line number Diff line change
Expand Up @@ -935,7 +935,7 @@ fn check_fn(cx: &mut MatchCheckCtxt,

fn is_refutable<A>(cx: &MatchCheckCtxt, pat: &Pat, refutable: |&Pat| -> A) -> Option<A> {
let pats = Matrix(vec!(vec!(pat)));
match is_useful(cx, &pats, [DUMMY_WILD_PAT], ConstructWitness) {
match is_useful(cx, &pats, &[DUMMY_WILD_PAT], ConstructWitness) {
UsefulWithWitness(pats) => {
assert_eq!(pats.len(), 1);
Some(refutable(&*pats[0]))
Expand Down
16 changes: 8 additions & 8 deletions src/librustc/middle/graph.rs
Original file line number Diff line number Diff line change
Expand Up @@ -419,31 +419,31 @@ mod test {
fn each_adjacent_from_a() {
let graph = create_graph();
test_adjacent_edges(&graph, NodeIndex(0), "A",
[],
[("AB", "B")]);
&[],
&[("AB", "B")]);
}

#[test]
fn each_adjacent_from_b() {
let graph = create_graph();
test_adjacent_edges(&graph, NodeIndex(1), "B",
[("FB", "F"), ("AB", "A"),],
[("BD", "D"), ("BC", "C"),]);
&[("FB", "F"), ("AB", "A"),],
&[("BD", "D"), ("BC", "C"),]);
}

#[test]
fn each_adjacent_from_c() {
let graph = create_graph();
test_adjacent_edges(&graph, NodeIndex(2), "C",
[("EC", "E"), ("BC", "B")],
[]);
&[("EC", "E"), ("BC", "B")],
&[]);
}

#[test]
fn each_adjacent_from_d() {
let graph = create_graph();
test_adjacent_edges(&graph, NodeIndex(3), "D",
[("BD", "B")],
[("DE", "E")]);
&[("BD", "B")],
&[("DE", "E")]);
}
}
2 changes: 1 addition & 1 deletion src/librustc/middle/traits/util.rs
Original file line number Diff line number Diff line change
Expand Up @@ -57,7 +57,7 @@ pub fn supertraits<'cx, 'tcx>(tcx: &'cx ty::ctxt<'tcx>,
* `supertraits(Baz)` yields `[Baz, Bar, Foo, Foo]` in some order.
*/

transitive_bounds(tcx, [trait_ref])
transitive_bounds(tcx, &[trait_ref])
}

pub fn transitive_bounds<'cx, 'tcx>(tcx: &'cx ty::ctxt<'tcx>,
Expand Down
12 changes: 6 additions & 6 deletions src/librustc/middle/trans/_match.rs
Original file line number Diff line number Diff line change
Expand Up @@ -643,8 +643,8 @@ fn bind_subslice_pat(bcx: Block,
ty::mt {ty: vt.unit_ty, mutbl: ast::MutImmutable});
let scratch = rvalue_scratch_datum(bcx, slice_ty, "");
Store(bcx, slice_begin,
GEPi(bcx, scratch.val, [0u, abi::slice_elt_base]));
Store(bcx, slice_len, GEPi(bcx, scratch.val, [0u, abi::slice_elt_len]));
GEPi(bcx, scratch.val, &[0u, abi::slice_elt_base]));
Store(bcx, slice_len, GEPi(bcx, scratch.val, &[0u, abi::slice_elt_len]));
scratch.val
}

Expand All @@ -658,9 +658,9 @@ fn extract_vec_elems<'blk, 'tcx>(bcx: Block<'blk, 'tcx>,
let vec_datum = match_datum(val, left_ty);
let (base, len) = vec_datum.get_vec_base_and_len(bcx);
let mut elems = vec![];
elems.extend(range(0, before).map(|i| GEPi(bcx, base, [i])));
elems.extend(range(0, before).map(|i| GEPi(bcx, base, &[i])));
elems.extend(range(0, after).rev().map(|i| {
InBoundsGEP(bcx, base, [
InBoundsGEP(bcx, base, &[
Sub(bcx, len, C_uint(bcx.ccx(), i + 1))
])
}));
Expand Down Expand Up @@ -796,7 +796,7 @@ fn compare_values<'blk, 'tcx>(cx: Block<'blk, 'tcx>,
format!("comparison of `{}`",
cx.ty_to_string(rhs_t)).as_slice(),
StrEqFnLangItem);
callee::trans_lang_call(cx, did, [lhs, rhs], None)
callee::trans_lang_call(cx, did, &[lhs, rhs], None)
}

let _icx = push_ctxt("compare_values");
Expand Down Expand Up @@ -1390,7 +1390,7 @@ fn trans_match_inner<'blk, 'tcx>(scope_cx: Block<'blk, 'tcx>,
&& arm.pats.last().unwrap().node == ast::PatWild(ast::PatWildSingle)
});

compile_submatch(bcx, matches.as_slice(), [discr_datum.val], &chk, has_default);
compile_submatch(bcx, matches.as_slice(), &[discr_datum.val], &chk, has_default);

let mut arm_cxs = Vec::new();
for arm_data in arm_datas.iter() {
Expand Down
Loading