Include all lval-writing statements in stmt_is_init calculation, not just "copy-like". Un-XFAIL generic-tag-alt.rs
This commit is contained in:
parent
7d44ee7c3c
commit
6668595ebf
@ -357,7 +357,6 @@ TEST_XFAILS_X86 := test/run-pass/bind-obj-ctor.rs \
|
||||
test/run-pass/vec-slice.rs \
|
||||
test/run-pass/fn-lval.rs \
|
||||
test/run-pass/generic-fn-infer.rs \
|
||||
test/run-pass/generic-tag-alt.rs \
|
||||
test/run-pass/generic-recursive-tag.rs \
|
||||
test/run-pass/iter-ret.rs \
|
||||
test/run-pass/mlist-cycle.rs \
|
||||
|
@ -45,7 +45,7 @@ let mutability_checking_visitor
|
||||
Ast.TY_mutable _ -> true
|
||||
| _ -> false
|
||||
in
|
||||
if (is_mutable or (Hashtbl.mem cx.ctxt_copy_stmt_is_init s.id))
|
||||
if (is_mutable or (Hashtbl.mem cx.ctxt_stmt_is_init s.id))
|
||||
then ()
|
||||
else err (Some s.id)
|
||||
"writing to non-mutable slot of type %a in statement %a"
|
||||
|
@ -129,7 +129,7 @@ type ctxt =
|
||||
ctxt_prestates: (node_id,Bits.t) Hashtbl.t;
|
||||
ctxt_poststates: (node_id,Bits.t) Hashtbl.t;
|
||||
ctxt_call_lval_params: (node_id,Ast.ty array) Hashtbl.t;
|
||||
ctxt_copy_stmt_is_init: (node_id,unit) Hashtbl.t;
|
||||
ctxt_stmt_is_init: (node_id,unit) Hashtbl.t;
|
||||
ctxt_post_stmt_slot_drops: (node_id,node_id list) Hashtbl.t;
|
||||
|
||||
(* Translation-y stuff. *)
|
||||
@ -202,7 +202,7 @@ let new_ctxt sess abi crate =
|
||||
ctxt_postconditions = Hashtbl.create 0;
|
||||
ctxt_prestates = Hashtbl.create 0;
|
||||
ctxt_poststates = Hashtbl.create 0;
|
||||
ctxt_copy_stmt_is_init = Hashtbl.create 0;
|
||||
ctxt_stmt_is_init = Hashtbl.create 0;
|
||||
ctxt_post_stmt_slot_drops = Hashtbl.create 0;
|
||||
ctxt_call_lval_params = Hashtbl.create 0;
|
||||
|
||||
|
@ -4199,7 +4199,7 @@ let trans_visitor
|
||||
|
||||
|
||||
and maybe_init (id:node_id) (action:string) (dst:Ast.lval) : bool =
|
||||
let b = Hashtbl.mem cx.ctxt_copy_stmt_is_init id in
|
||||
let b = Hashtbl.mem cx.ctxt_stmt_is_init id in
|
||||
let act = if b then ("initializing-" ^ action) else action in
|
||||
iflog
|
||||
(fun _ ->
|
||||
|
@ -1074,7 +1074,14 @@ let lifecycle_visitor
|
||||
| Ast.STMT_call (lv_dst, _, _)
|
||||
| Ast.STMT_spawn (lv_dst, _, _, _)
|
||||
| Ast.STMT_recv (lv_dst, _)
|
||||
| Ast.STMT_bind (lv_dst, _, _) ->
|
||||
| Ast.STMT_bind (lv_dst, _, _)
|
||||
| Ast.STMT_new_rec (lv_dst, _, _)
|
||||
| Ast.STMT_new_tup (lv_dst, _)
|
||||
| Ast.STMT_new_vec (lv_dst, _, _)
|
||||
| Ast.STMT_new_str (lv_dst, _)
|
||||
| Ast.STMT_new_port lv_dst
|
||||
| Ast.STMT_new_chan (lv_dst, _)
|
||||
| Ast.STMT_new_box (lv_dst, _, _) ->
|
||||
let prestate = Hashtbl.find cx.ctxt_prestates s.id in
|
||||
let poststate = Hashtbl.find cx.ctxt_poststates s.id in
|
||||
let dst_slots = lval_slots cx lv_dst in
|
||||
@ -1097,26 +1104,18 @@ let lifecycle_visitor
|
||||
log cx "noting lval %a init at stmt %a"
|
||||
Ast.sprintf_lval lv_dst Ast.sprintf_stmt s
|
||||
end;
|
||||
Hashtbl.replace cx.ctxt_copy_stmt_is_init s.id ();
|
||||
Hashtbl.replace cx.ctxt_stmt_is_init s.id ();
|
||||
mark_lval_live lv_dst
|
||||
end;
|
||||
|
||||
| Ast.STMT_decl (Ast.DECL_slot (_, sloti)) ->
|
||||
push_slot sloti.id
|
||||
|
||||
| Ast.STMT_new_rec (lv_dst, _, _)
|
||||
| Ast.STMT_new_tup (lv_dst, _)
|
||||
| Ast.STMT_new_vec (lv_dst, _, _)
|
||||
| Ast.STMT_new_str (lv_dst, _)
|
||||
| Ast.STMT_new_port lv_dst
|
||||
| Ast.STMT_new_chan (lv_dst, _)
|
||||
| Ast.STMT_new_box (lv_dst, _, _) ->
|
||||
mark_lval_live lv_dst
|
||||
|
||||
| Ast.STMT_for f ->
|
||||
log cx "noting implicit init for slot %d in for-block %d"
|
||||
(int_of_node (fst f.Ast.for_slot).id)
|
||||
(int_of_node (f.Ast.for_body.id));
|
||||
Hashtbl.replace cx.ctxt_stmt_is_init s.id ();
|
||||
htab_put implicit_init_block_slots
|
||||
f.Ast.for_body.id
|
||||
(fst f.Ast.for_slot).id
|
||||
@ -1125,6 +1124,7 @@ let lifecycle_visitor
|
||||
log cx "noting implicit init for slot %d in for_each-block %d"
|
||||
(int_of_node (fst f.Ast.for_each_slot).id)
|
||||
(int_of_node (f.Ast.for_each_body.id));
|
||||
Hashtbl.replace cx.ctxt_stmt_is_init s.id ();
|
||||
htab_put implicit_init_block_slots
|
||||
f.Ast.for_each_body.id
|
||||
(fst f.Ast.for_each_slot).id
|
||||
|
Loading…
x
Reference in New Issue
Block a user