Skip to content

Commit 63417da

Browse files
committed
auto merge of #6885 : erickt/rust/move-callee_id, r=catamorphism
The `callee_id` in `ast::expr` in only used in a couple expression variants. This moves the `callee_id` into those branches to make it more clear when its should be used. Also, it fixes a bug in a std::run test when there is a symlink in the path rust where was checked out.
2 parents 24e85ac + 23808ef commit 63417da

Some content is hidden

Large Commits have some content hidden by default. Use the searchbox below for content that may be hidden.

41 files changed

+349
-295
lines changed

src/libfuzzer/fuzzer.rc

+3-4
Original file line numberDiff line numberDiff line change
@@ -78,7 +78,6 @@ pub fn common_exprs() -> ~[@ast::expr] {
7878
fn dse(e: ast::expr_) -> @ast::expr {
7979
@ast::expr {
8080
id: 0,
81-
callee_id: -1,
8281
node: e,
8382
span: codemap::dummy_sp(),
8483
}
@@ -94,9 +93,9 @@ pub fn common_exprs() -> ~[@ast::expr] {
9493
dse(ast::expr_lit(@dsl(ast::lit_nil))),
9594
dse(ast::expr_lit(@dsl(ast::lit_bool(false)))),
9695
dse(ast::expr_lit(@dsl(ast::lit_bool(true)))),
97-
dse(ast::expr_unary(ast::box(ast::m_imm),
96+
dse(ast::expr_unary(-1, ast::box(ast::m_imm),
9897
dse(ast::expr_lit(@dsl(ast::lit_bool(true)))))),
99-
dse(ast::expr_unary(ast::uniq(ast::m_imm),
98+
dse(ast::expr_unary(-1, ast::uniq(ast::m_imm),
10099
dse(ast::expr_lit(@dsl(ast::lit_bool(true))))))
101100
]
102101
}
@@ -128,7 +127,7 @@ pub fn safe_to_use_expr(e: @ast::expr, tm: test_mode) -> bool {
128127
//ast::expr_cast(_, _) { false }
129128

130129
// https://github.com/mozilla/rust/issues/1458
131-
ast::expr_call(_, _, _) => { false }
130+
ast::expr_call(*) => { false }
132131

133132
_ => { true }
134133
}

src/librustc/front/test.rs

-4
Original file line numberDiff line numberDiff line change
@@ -394,14 +394,12 @@ fn mk_test_descs(cx: &TestCtxt) -> @ast::expr {
394394
let sess = cx.sess;
395395
let inner_expr = @ast::expr {
396396
id: sess.next_node_id(),
397-
callee_id: sess.next_node_id(),
398397
node: ast::expr_vec(descs, ast::m_imm),
399398
span: dummy_sp(),
400399
};
401400

402401
@ast::expr {
403402
id: sess.next_node_id(),
404-
callee_id: sess.next_node_id(),
405403
node: ast::expr_vstore(inner_expr, ast::expr_vstore_slice),
406404
span: dummy_sp(),
407405
}
@@ -423,7 +421,6 @@ fn mk_test_desc_and_fn_rec(cx: &TestCtxt, test: &Test) -> @ast::expr {
423421

424422
let name_expr = @ast::expr {
425423
id: cx.sess.next_node_id(),
426-
callee_id: cx.sess.next_node_id(),
427424
node: ast::expr_lit(@name_lit),
428425
span: span
429426
};
@@ -432,7 +429,6 @@ fn mk_test_desc_and_fn_rec(cx: &TestCtxt, test: &Test) -> @ast::expr {
432429

433430
let fn_expr = @ast::expr {
434431
id: cx.sess.next_node_id(),
435-
callee_id: cx.sess.next_node_id(),
436432
node: ast::expr_path(fn_path),
437433
span: span,
438434
};

src/librustc/middle/borrowck/check_loans.rs

+8-8
Original file line numberDiff line numberDiff line change
@@ -707,29 +707,29 @@ fn check_loans_in_expr<'a>(expr: @ast::expr,
707707
}
708708
}
709709
ast::expr_assign(dest, _) |
710-
ast::expr_assign_op(_, dest, _) => {
710+
ast::expr_assign_op(_, _, dest, _) => {
711711
this.check_assignment(dest);
712712
}
713713
ast::expr_call(f, ref args, _) => {
714714
this.check_call(expr, Some(f), f.id, f.span, *args);
715715
}
716-
ast::expr_method_call(_, _, _, ref args, _) => {
717-
this.check_call(expr, None, expr.callee_id, expr.span, *args);
716+
ast::expr_method_call(callee_id, _, _, _, ref args, _) => {
717+
this.check_call(expr, None, callee_id, expr.span, *args);
718718
}
719-
ast::expr_index(_, rval) |
720-
ast::expr_binary(_, _, rval)
719+
ast::expr_index(callee_id, _, rval) |
720+
ast::expr_binary(callee_id, _, _, rval)
721721
if this.bccx.method_map.contains_key(&expr.id) => {
722722
this.check_call(expr,
723723
None,
724-
expr.callee_id,
724+
callee_id,
725725
expr.span,
726726
[rval]);
727727
}
728-
ast::expr_unary(*) | ast::expr_index(*)
728+
ast::expr_unary(callee_id, _, _) | ast::expr_index(callee_id, _, _)
729729
if this.bccx.method_map.contains_key(&expr.id) => {
730730
this.check_call(expr,
731731
None,
732-
expr.callee_id,
732+
callee_id,
733733
expr.span,
734734
[]);
735735
}

src/librustc/middle/borrowck/gather_loans/mod.rs

+7-4
Original file line numberDiff line numberDiff line change
@@ -175,7 +175,10 @@ fn gather_loans_in_expr(ex: @ast::expr,
175175
ex.id, pprust::expr_to_str(ex, tcx.sess.intr()));
176176

177177
this.id_range.add(ex.id);
178-
this.id_range.add(ex.callee_id);
178+
179+
for ex.get_callee_id().each |callee_id| {
180+
this.id_range.add(*callee_id);
181+
}
179182

180183
// If this expression is borrowed, have to ensure it remains valid:
181184
for tcx.adjustments.find(&ex.id).each |&adjustments| {
@@ -201,7 +204,7 @@ fn gather_loans_in_expr(ex: @ast::expr,
201204
visit::visit_expr(ex, this, vt);
202205
}
203206

204-
ast::expr_assign(l, _) | ast::expr_assign_op(_, l, _) => {
207+
ast::expr_assign(l, _) | ast::expr_assign_op(_, _, l, _) => {
205208
let l_cmt = this.bccx.cat_expr(l);
206209
match opt_loan_path(l_cmt) {
207210
Some(l_lp) => {
@@ -228,8 +231,8 @@ fn gather_loans_in_expr(ex: @ast::expr,
228231
visit::visit_expr(ex, this, vt);
229232
}
230233

231-
ast::expr_index(_, arg) |
232-
ast::expr_binary(_, _, arg)
234+
ast::expr_index(_, _, arg) |
235+
ast::expr_binary(_, _, _, arg)
233236
if this.bccx.method_map.contains_key(&ex.id) => {
234237
// Arguments in method calls are always passed by ref.
235238
//

src/librustc/middle/check_const.rs

+3-3
Original file line numberDiff line numberDiff line change
@@ -91,14 +91,14 @@ pub fn check_expr(sess: Session,
9191
v: visit::vt<bool>) {
9292
if is_const {
9393
match e.node {
94-
expr_unary(deref, _) => { }
95-
expr_unary(box(_), _) | expr_unary(uniq(_), _) => {
94+
expr_unary(_, deref, _) => { }
95+
expr_unary(_, box(_), _) | expr_unary(_, uniq(_), _) => {
9696
sess.span_err(e.span,
9797
"disallowed operator in constant expression");
9898
return;
9999
}
100100
expr_lit(@codemap::spanned {node: lit_str(_), _}) => { }
101-
expr_binary(_, _, _) | expr_unary(_, _) => {
101+
expr_binary(*) | expr_unary(*) => {
102102
if method_map.contains_key(&e.id) {
103103
sess.span_err(e.span, "user-defined operators are not \
104104
allowed in constant expressions");

src/librustc/middle/const_eval.rs

+6-6
Original file line numberDiff line numberDiff line change
@@ -93,12 +93,12 @@ pub fn classify(e: @expr,
9393
}
9494

9595
ast::expr_copy(inner) |
96-
ast::expr_unary(_, inner) |
96+
ast::expr_unary(_, _, inner) |
9797
ast::expr_paren(inner) => {
9898
classify(inner, tcx)
9999
}
100100

101-
ast::expr_binary(_, a, b) => {
101+
ast::expr_binary(_, _, a, b) => {
102102
join(classify(a, tcx),
103103
classify(b, tcx))
104104
}
@@ -141,7 +141,7 @@ pub fn classify(e: @expr,
141141
classify(base, tcx)
142142
}
143143

144-
ast::expr_index(base, idx) => {
144+
ast::expr_index(_, base, idx) => {
145145
join(classify(base, tcx),
146146
classify(idx, tcx))
147147
}
@@ -251,7 +251,7 @@ pub fn eval_const_expr_partial(tcx: middle::ty::ctxt, e: @expr)
251251
use middle::ty;
252252
fn fromb(b: bool) -> Result<const_val, ~str> { Ok(const_int(b as i64)) }
253253
match e.node {
254-
expr_unary(neg, inner) => {
254+
expr_unary(_, neg, inner) => {
255255
match eval_const_expr_partial(tcx, inner) {
256256
Ok(const_float(f)) => Ok(const_float(-f)),
257257
Ok(const_int(i)) => Ok(const_int(-i)),
@@ -261,15 +261,15 @@ pub fn eval_const_expr_partial(tcx: middle::ty::ctxt, e: @expr)
261261
ref err => (/*bad*/copy *err)
262262
}
263263
}
264-
expr_unary(not, inner) => {
264+
expr_unary(_, not, inner) => {
265265
match eval_const_expr_partial(tcx, inner) {
266266
Ok(const_int(i)) => Ok(const_int(!i)),
267267
Ok(const_uint(i)) => Ok(const_uint(!i)),
268268
Ok(const_bool(b)) => Ok(const_bool(!b)),
269269
_ => Err(~"Not on float or string")
270270
}
271271
}
272-
expr_binary(op, a, b) => {
272+
expr_binary(_, op, a, b) => {
273273
match (eval_const_expr_partial(tcx, a),
274274
eval_const_expr_partial(tcx, b)) {
275275
(Ok(const_float(a)), Ok(const_float(b))) => {

src/librustc/middle/dataflow.rs

+13-13
Original file line numberDiff line numberDiff line change
@@ -639,7 +639,7 @@ impl<'self, O:DataFlowOperator> PropagationContext<'self, O> {
639639
}
640640

641641
ast::expr_assign(l, r) |
642-
ast::expr_assign_op(_, l, r) => {
642+
ast::expr_assign_op(_, _, l, r) => {
643643
self.walk_expr(r, in_out, loop_scopes);
644644
self.walk_expr(l, in_out, loop_scopes);
645645
}
@@ -661,40 +661,40 @@ impl<'self, O:DataFlowOperator> PropagationContext<'self, O> {
661661
}
662662

663663
ast::expr_call(f, ref args, _) => {
664-
self.walk_call(expr.callee_id, expr.id,
664+
self.walk_call(f.id, expr.id,
665665
f, *args, in_out, loop_scopes);
666666
}
667667

668-
ast::expr_method_call(rcvr, _, _, ref args, _) => {
669-
self.walk_call(expr.callee_id, expr.id,
668+
ast::expr_method_call(callee_id, rcvr, _, _, ref args, _) => {
669+
self.walk_call(callee_id, expr.id,
670670
rcvr, *args, in_out, loop_scopes);
671671
}
672672

673-
ast::expr_index(l, r) |
674-
ast::expr_binary(_, l, r) if self.is_method_call(expr) => {
675-
self.walk_call(expr.callee_id, expr.id,
673+
ast::expr_index(callee_id, l, r) |
674+
ast::expr_binary(callee_id, _, l, r) if self.is_method_call(expr) => {
675+
self.walk_call(callee_id, expr.id,
676676
l, [r], in_out, loop_scopes);
677677
}
678678

679-
ast::expr_unary(_, e) if self.is_method_call(expr) => {
680-
self.walk_call(expr.callee_id, expr.id,
679+
ast::expr_unary(callee_id, _, e) if self.is_method_call(expr) => {
680+
self.walk_call(callee_id, expr.id,
681681
e, [], in_out, loop_scopes);
682682
}
683683

684684
ast::expr_tup(ref exprs) => {
685685
self.walk_exprs(*exprs, in_out, loop_scopes);
686686
}
687687

688-
ast::expr_binary(op, l, r) if ast_util::lazy_binop(op) => {
688+
ast::expr_binary(_, op, l, r) if ast_util::lazy_binop(op) => {
689689
self.walk_expr(l, in_out, loop_scopes);
690690
let temp = reslice(in_out).to_vec();
691691
self.walk_expr(r, in_out, loop_scopes);
692692
join_bits(&self.dfcx.oper, temp, in_out);
693693
}
694694

695695
ast::expr_log(l, r) |
696-
ast::expr_index(l, r) |
697-
ast::expr_binary(_, l, r) => {
696+
ast::expr_index(_, l, r) |
697+
ast::expr_binary(_, _, l, r) => {
698698
self.walk_exprs([l, r], in_out, loop_scopes);
699699
}
700700

@@ -708,7 +708,7 @@ impl<'self, O:DataFlowOperator> PropagationContext<'self, O> {
708708
ast::expr_loop_body(e) |
709709
ast::expr_do_body(e) |
710710
ast::expr_cast(e, _) |
711-
ast::expr_unary(_, e) |
711+
ast::expr_unary(_, _, e) |
712712
ast::expr_paren(e) |
713713
ast::expr_vstore(e, _) |
714714
ast::expr_field(e, _, _) => {

src/librustc/middle/effect.rs

+3-3
Original file line numberDiff line numberDiff line change
@@ -111,8 +111,8 @@ pub fn check_crate(tcx: ty::ctxt,
111111

112112
visit_expr: |expr, _, visitor| {
113113
match expr.node {
114-
expr_method_call(*) => {
115-
let base_type = ty::node_id_to_type(tcx, expr.callee_id);
114+
expr_method_call(callee_id, _, _, _, _, _) => {
115+
let base_type = ty::node_id_to_type(tcx, callee_id);
116116
debug!("effect: method call case, base type is %s",
117117
ppaux::ty_to_str(tcx, base_type));
118118
if type_is_unsafe_function(base_type) {
@@ -128,7 +128,7 @@ pub fn check_crate(tcx: ty::ctxt,
128128
require_unsafe(expr.span, "call to unsafe function")
129129
}
130130
}
131-
expr_unary(deref, base) => {
131+
expr_unary(_, deref, base) => {
132132
let base_type = ty::node_id_to_type(tcx, base.id);
133133
debug!("effect: unary case, base type is %s",
134134
ppaux::ty_to_str(tcx, base_type));

src/librustc/middle/kind.rs

+3-4
Original file line numberDiff line numberDiff line change
@@ -241,10 +241,9 @@ pub fn check_expr(e: @expr, cx: Context, v: visit::vt<Context>) {
241241
debug!("kind::check_expr(%s)", expr_to_str(e, cx.tcx.sess.intr()));
242242

243243
// Handle any kind bounds on type parameters
244-
let type_parameter_id = match e.node {
245-
expr_index(*)|expr_assign_op(*)|
246-
expr_unary(*)|expr_binary(*)|expr_method_call(*) => e.callee_id,
247-
_ => e.id
244+
let type_parameter_id = match e.get_callee_id() {
245+
Some(callee_id) => callee_id,
246+
None => e.id,
248247
};
249248
for cx.tcx.node_type_substs.find(&type_parameter_id).each |ts| {
250249
let type_param_defs = match e.node {

src/librustc/middle/lint.rs

+1-1
Original file line numberDiff line numberDiff line change
@@ -675,7 +675,7 @@ fn lint_type_limits() -> visit::vt<@mut Context> {
675675
visit::mk_vt(@visit::Visitor {
676676
visit_expr: |e, cx: @mut Context, vt| {
677677
match e.node {
678-
ast::expr_binary(ref binop, @ref l, @ref r) => {
678+
ast::expr_binary(_, ref binop, @ref l, @ref r) => {
679679
if is_comparison(*binop)
680680
&& !check_limits(cx, *binop, l, r) {
681681
cx.span_lint(type_limits, e.span,

src/librustc/middle/liveness.rs

+9-10
Original file line numberDiff line numberDiff line change
@@ -499,7 +499,7 @@ fn visit_expr(expr: @expr, this: @mut IrMaps, vt: vt<@mut IrMaps>) {
499499
this.add_live_node_for_node(expr.id, ExprNode(expr.span));
500500
visit::visit_expr(expr, this, vt);
501501
}
502-
expr_binary(op, _, _) if ast_util::lazy_binop(op) => {
502+
expr_binary(_, op, _, _) if ast_util::lazy_binop(op) => {
503503
this.add_live_node_for_node(expr.id, ExprNode(expr.span));
504504
visit::visit_expr(expr, this, vt);
505505
}
@@ -1138,7 +1138,7 @@ impl Liveness {
11381138
self.propagate_through_expr(r, succ)
11391139
}
11401140

1141-
expr_assign_op(_, l, r) => {
1141+
expr_assign_op(_, _, l, r) => {
11421142
// see comment on lvalues in
11431143
// propagate_through_lvalue_components()
11441144
let succ = self.write_lvalue(l, succ, ACC_WRITE|ACC_READ);
@@ -1178,11 +1178,10 @@ impl Liveness {
11781178
self.propagate_through_expr(f, succ)
11791179
}
11801180

1181-
expr_method_call(rcvr, _, _, ref args, _) => {
1181+
expr_method_call(callee_id, rcvr, _, _, ref args, _) => {
11821182
// calling a method with bot return type means that the method
11831183
// will fail, and hence the successors can be ignored
1184-
let t_ret = ty::ty_fn_ret(ty::node_id_to_type(self.tcx,
1185-
expr.callee_id));
1184+
let t_ret = ty::ty_fn_ret(ty::node_id_to_type(self.tcx, callee_id));
11861185
let succ = if ty::type_is_bot(t_ret) {self.s.exit_ln}
11871186
else {succ};
11881187
let succ = self.propagate_through_exprs(*args, succ);
@@ -1193,7 +1192,7 @@ impl Liveness {
11931192
self.propagate_through_exprs(*exprs, succ)
11941193
}
11951194

1196-
expr_binary(op, l, r) if ast_util::lazy_binop(op) => {
1195+
expr_binary(_, op, l, r) if ast_util::lazy_binop(op) => {
11971196
let r_succ = self.propagate_through_expr(r, succ);
11981197

11991198
let ln = self.live_node(expr.id, expr.span);
@@ -1204,8 +1203,8 @@ impl Liveness {
12041203
}
12051204

12061205
expr_log(l, r) |
1207-
expr_index(l, r) |
1208-
expr_binary(_, l, r) => {
1206+
expr_index(_, l, r) |
1207+
expr_binary(_, _, l, r) => {
12091208
self.propagate_through_exprs([l, r], succ)
12101209
}
12111210

@@ -1214,7 +1213,7 @@ impl Liveness {
12141213
expr_loop_body(e) |
12151214
expr_do_body(e) |
12161215
expr_cast(e, _) |
1217-
expr_unary(_, e) |
1216+
expr_unary(_, _, e) |
12181217
expr_paren(e) => {
12191218
self.propagate_through_expr(e, succ)
12201219
}
@@ -1456,7 +1455,7 @@ fn check_expr(expr: @expr, this: @Liveness, vt: vt<@Liveness>) {
14561455
visit::visit_expr(expr, this, vt);
14571456
}
14581457

1459-
expr_assign_op(_, l, _) => {
1458+
expr_assign_op(_, _, l, _) => {
14601459
this.check_lvalue(l, vt);
14611460

14621461
visit::visit_expr(expr, this, vt);

src/librustc/middle/mem_categorization.rs

+2-2
Original file line numberDiff line numberDiff line change
@@ -389,7 +389,7 @@ impl mem_categorization_ctxt {
389389

390390
let expr_ty = self.expr_ty(expr);
391391
match expr.node {
392-
ast::expr_unary(ast::deref, e_base) => {
392+
ast::expr_unary(_, ast::deref, e_base) => {
393393
if self.method_map.contains_key(&expr.id) {
394394
return self.cat_rvalue(expr, expr_ty);
395395
}
@@ -407,7 +407,7 @@ impl mem_categorization_ctxt {
407407
self.cat_field(expr, base_cmt, f_name, self.expr_ty(expr))
408408
}
409409

410-
ast::expr_index(base, _) => {
410+
ast::expr_index(_, base, _) => {
411411
if self.method_map.contains_key(&expr.id) {
412412
return self.cat_rvalue(expr, expr_ty);
413413
}

0 commit comments

Comments
 (0)