AST refactor: make the place in ExprBox an option.
This is to allow us to migrate away from UnUniq in a followup commit, and thus unify the code paths related to all forms of `box`.
This commit is contained in:
parent
41f5907fa6
commit
7d4e7f0795
11 changed files with 35 additions and 25 deletions
|
|
@ -3658,22 +3658,25 @@ fn check_expr_with_unifier<'a, 'tcx, F>(fcx: &FnCtxt<'a, 'tcx>,
|
|||
let tcx = fcx.ccx.tcx;
|
||||
let id = expr.id;
|
||||
match expr.node {
|
||||
ast::ExprBox(ref place, ref subexpr) => {
|
||||
check_expr(fcx, &**place);
|
||||
ast::ExprBox(ref opt_place, ref subexpr) => {
|
||||
opt_place.as_ref().map(|place|check_expr(fcx, &**place));
|
||||
check_expr(fcx, &**subexpr);
|
||||
|
||||
let mut checked = false;
|
||||
if let ast::ExprPath(ref path) = place.node {
|
||||
// FIXME(pcwalton): For now we hardcode the two permissible
|
||||
// places: the exchange heap and the managed heap.
|
||||
let definition = lookup_def(fcx, path.span, place.id);
|
||||
let def_id = definition.def_id();
|
||||
let referent_ty = fcx.expr_ty(&**subexpr);
|
||||
if tcx.lang_items.exchange_heap() == Some(def_id) {
|
||||
fcx.write_ty(id, ty::mk_uniq(tcx, referent_ty));
|
||||
checked = true
|
||||
opt_place.as_ref().map(|place| match place.node {
|
||||
ast::ExprPath(ref path) => {
|
||||
// FIXME(pcwalton): For now we hardcode the two permissible
|
||||
// places: the exchange heap and the managed heap.
|
||||
let definition = lookup_def(fcx, path.span, place.id);
|
||||
let def_id = definition.def_id();
|
||||
let referent_ty = fcx.expr_ty(&**subexpr);
|
||||
if tcx.lang_items.exchange_heap() == Some(def_id) {
|
||||
fcx.write_ty(id, ty::mk_uniq(tcx, referent_ty));
|
||||
checked = true
|
||||
}
|
||||
}
|
||||
}
|
||||
_ => {}
|
||||
});
|
||||
|
||||
if !checked {
|
||||
span_err!(tcx.sess, expr.span, E0066,
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue