Skip to content

Commit 0a0dc5a

Browse files
committed
Add ast::ExprCompletion
1 parent c1ddcf2 commit 0a0dc5a

File tree

15 files changed

+61
-11
lines changed

15 files changed

+61
-11
lines changed

src/librustc/middle/cfg/construct.rs

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -436,6 +436,7 @@ impl<'a, 'tcx> CFGBuilder<'a, 'tcx> {
436436
ast::ExprCast(ref e, _) |
437437
ast::ExprUnary(_, ref e) |
438438
ast::ExprParen(ref e) |
439+
ast::ExprCompletion(ref e) |
439440
ast::ExprField(ref e, _) |
440441
ast::ExprTupField(ref e, _) => {
441442
self.straightline(expr, pred, Some(&**e).into_iter())

src/librustc/middle/dead.rs

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -277,6 +277,7 @@ impl<'a, 'tcx, 'v> Visitor<'v> for MarkSymbolVisitor<'a, 'tcx> {
277277
ast::ExprTupField(ref lhs, idx) => {
278278
self.handle_tup_field_access(&**lhs, idx.node);
279279
}
280+
ast::ExprCompletion(..) => return,
280281
_ => ()
281282
}
282283

src/librustc/middle/expr_use_visitor.rs

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -421,8 +421,8 @@ impl<'d,'t,'tcx,TYPER:mc::Typer<'tcx>> ExprUseVisitor<'d,'t,'tcx,TYPER> {
421421
self.walk_adjustment(expr);
422422

423423
match expr.node {
424-
ast::ExprParen(ref subexpr) => {
425-
self.walk_expr(&**subexpr)
424+
ast::ExprParen(ref e) | ast::ExprCompletion(ref e) => {
425+
self.walk_expr(&e)
426426
}
427427

428428
ast::ExprPath(_) | ast::ExprQPath(_) => { }

src/librustc/middle/liveness.rs

Lines changed: 4 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -505,7 +505,7 @@ fn visit_expr(ir: &mut IrMaps, expr: &Expr) {
505505
ast::ExprBlock(..) | ast::ExprAssign(..) | ast::ExprAssignOp(..) |
506506
ast::ExprMac(..) | ast::ExprStruct(..) | ast::ExprRepeat(..) |
507507
ast::ExprParen(..) | ast::ExprInlineAsm(..) | ast::ExprBox(..) |
508-
ast::ExprRange(..) => {
508+
ast::ExprRange(..) | ast::ExprCompletion(..) => {
509509
visit::walk_expr(ir, expr);
510510
}
511511
}
@@ -1189,7 +1189,8 @@ impl<'a, 'tcx> Liveness<'a, 'tcx> {
11891189
ast::ExprAddrOf(_, ref e) |
11901190
ast::ExprCast(ref e, _) |
11911191
ast::ExprUnary(_, ref e) |
1192-
ast::ExprParen(ref e) => {
1192+
ast::ExprParen(ref e) |
1193+
ast::ExprCompletion(ref e) => {
11931194
self.propagate_through_expr(&**e, succ)
11941195
}
11951196

@@ -1468,7 +1469,7 @@ fn check_expr(this: &mut Liveness, expr: &Expr) {
14681469
ast::ExprBlock(..) | ast::ExprMac(..) | ast::ExprAddrOf(..) |
14691470
ast::ExprStruct(..) | ast::ExprRepeat(..) | ast::ExprParen(..) |
14701471
ast::ExprClosure(..) | ast::ExprPath(..) | ast::ExprBox(..) |
1471-
ast::ExprRange(..) | ast::ExprQPath(..) => {
1472+
ast::ExprRange(..) | ast::ExprQPath(..) | ast::ExprCompletion(..) => {
14721473
visit::walk_expr(this, expr);
14731474
}
14741475
ast::ExprIfLet(..) => {

src/librustc/middle/mem_categorization.rs

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -548,7 +548,8 @@ impl<'t,'tcx,TYPER:Typer<'tcx>> MemCategorizationContext<'t,TYPER> {
548548
ast::ExprBlock(..) | ast::ExprLoop(..) | ast::ExprMatch(..) |
549549
ast::ExprLit(..) | ast::ExprBreak(..) | ast::ExprMac(..) |
550550
ast::ExprAgain(..) | ast::ExprStruct(..) | ast::ExprRepeat(..) |
551-
ast::ExprInlineAsm(..) | ast::ExprBox(..) => {
551+
ast::ExprInlineAsm(..) | ast::ExprBox(..) |
552+
ast::ExprCompletion(..) => {
552553
Ok(self.cat_rvalue_node(expr.id(), expr.span(), expr_ty))
553554
}
554555

src/librustc/middle/ty.rs

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -4617,7 +4617,9 @@ pub fn expr_kind(tcx: &ctxt, expr: &ast::Expr) -> ExprKind {
46174617
}
46184618
}
46194619

4620-
ast::ExprParen(ref e) => expr_kind(tcx, &**e),
4620+
ast::ExprParen(ref e) | ast::ExprCompletion(ref e) => {
4621+
expr_kind(tcx, &e)
4622+
}
46214623

46224624
ast::ExprMac(..) => {
46234625
tcx.sess.span_bug(

src/librustc_back/svh.rs

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -293,6 +293,7 @@ mod svh_visitor {
293293
ExprIfLet(..) => unreachable!(),
294294
ExprWhileLet(..) => unreachable!(),
295295
ExprMac(..) => unreachable!(),
296+
ExprCompletion(..) => unreachable!(),
296297
}
297298
}
298299

src/librustc_privacy/lib.rs

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -954,6 +954,7 @@ impl<'a, 'tcx, 'v> Visitor<'v> for PrivacyVisitor<'a, 'tcx> {
954954
_ => {}
955955
}
956956
}
957+
ast::ExprCompletion(_) => return,
957958
_ => {}
958959
}
959960

src/librustc_trans/trans/debuginfo.rs

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -3491,7 +3491,8 @@ fn create_scope_map(cx: &CrateContext,
34913491
ast::ExprAddrOf(_, ref sub_exp) |
34923492
ast::ExprField(ref sub_exp, _) |
34933493
ast::ExprTupField(ref sub_exp, _) |
3494-
ast::ExprParen(ref sub_exp) =>
3494+
ast::ExprParen(ref sub_exp) |
3495+
ast::ExprCompletion(ref sub_exp) =>
34953496
walk_expr(cx, &**sub_exp, scope_stack, scope_map),
34963497

34973498
ast::ExprBox(ref place, ref sub_expr) => {

src/librustc_typeck/check/mod.rs

Lines changed: 17 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -3679,6 +3679,23 @@ fn check_expr_with_unifier<'a, 'tcx, F>(fcx: &FnCtxt<'a, 'tcx>,
36793679
lvalue_pref);
36803680
fcx.write_ty(id, fcx.expr_ty(&**a));
36813681
}
3682+
ast::ExprCompletion(ref e) => {
3683+
fcx.write_ty(e.id, fcx.infcx().next_diverging_ty_var());
3684+
fcx.write_ty(id, fcx.infcx().next_diverging_ty_var());
3685+
if let ast::ExprField(ref base, _) = e.node {
3686+
check_expr_with_lvalue_pref(fcx, &base, lvalue_pref);
3687+
let expr_t = structurally_resolved_type(fcx, base.span, fcx.expr_ty(&base));
3688+
match expr_t.sty {
3689+
ty::ty_struct(base_id, _) => {
3690+
let fields = ty::lookup_struct_fields(tcx, base_id);
3691+
for field in fields.iter() {
3692+
println!("{}", field.name);
3693+
}
3694+
}
3695+
_ => ()
3696+
}
3697+
}
3698+
}
36823699
ast::ExprAssign(ref lhs, ref rhs) => {
36833700
check_expr_with_lvalue_pref(fcx, &**lhs, PreferMutLvalue);
36843701

0 commit comments

Comments
 (0)