@@ -196,7 +196,7 @@ may be the operator in a "check" expression in the source. */
196
196
type constraint = {
197
197
path: @path,
198
198
// FIXME: really only want it to be mut during collect_locals.
199
- // freeze it after that.
199
+ // freeze it after that. (#2539)
200
200
descs: @dvec < pred_args >
201
201
} ;
202
202
@@ -496,7 +496,7 @@ fn constraints(fcx: fn_ctxt) -> [norm_constraint] {
496
496
497
497
// FIXME
498
498
// Would rather take an immutable vec as an argument,
499
- // should freeze it at some earlier point.
499
+ // should freeze it at some earlier point. (#2539)
500
500
fn match_args( fcx: fn_ctxt, occs: @dvec<pred_args>,
501
501
occ: [ @constr_arg_use] ) -> uint {
502
502
#debug( "match_args: looking at %s",
@@ -715,28 +715,23 @@ fn replace(subst: subst, d: pred_args) -> [constr_arg_general_<inst>] {
715
715
}
716
716
}
717
717
_ {
718
- // #error("##");
719
718
rslt += [ c. node] ;
720
719
}
721
720
}
722
721
}
723
722
724
- /*
725
- for (constr_arg_general_<tup(ident, def_id)> p in rslt) {
726
- alt (p) {
727
- case (carg_ident(?p)) {
728
- log(error, p._0);
729
- }
730
- case (_) {}
731
- }
732
- }
733
- */
734
-
735
723
ret rslt;
736
724
}
737
725
738
726
enum if_ty { if_check, plain_if, }
739
727
728
+ fn for_constraints_mentioning( fcx: fn_ctxt, id: node_id,
729
+ f: fn ( norm_constraint) ) {
730
+ for constraints( fcx) . each { |c|
731
+ if constraint_mentions( fcx, c, id) { f( c) ; }
732
+ } ;
733
+ }
734
+
740
735
fn local_node_id_to_def_id_strict( fcx: fn_ctxt, sp: span, i: node_id) ->
741
736
def_id {
742
737
alt local_node_id_to_def( fcx, i) {
@@ -787,7 +782,6 @@ fn copy_in_postcond(fcx: fn_ctxt, parent_exp: node_id, dest: inst, src: inst,
787
782
copy_in_poststate_two( fcx, post, post, dest, src, ty) ;
788
783
}
789
784
790
- // FIXME refactor
791
785
fn copy_in_poststate( fcx: fn_ctxt, post: poststate, dest: inst, src: inst,
792
786
ty: oper_type) {
793
787
copy_in_poststate_two( fcx, post, post, dest, src, ty) ;
@@ -823,42 +817,31 @@ fn copy_in_poststate_two(fcx: fn_ctxt, src_post: poststate,
823
817
} ;
824
818
}
825
819
826
- /* FIXME should refactor this better */
827
820
fn forget_in_postcond( fcx: fn_ctxt, parent_exp: node_id, dead_v: node_id) {
828
821
// In the postcondition given by parent_exp, clear the bits
829
822
// for any constraints mentioning dead_v
830
823
let d = local_node_id_to_local_def_id( fcx, dead_v) ;
831
- alt d {
832
- some( d_id) {
833
- for constraints( fcx) . each { |c|
834
- if constraint_mentions( fcx, c, d_id) {
824
+ option:: iter( d) { |d_id|
825
+ for_constraints_mentioning( fcx, d_id) { |c|
835
826
#debug( "clearing constraint %u %s" ,
836
827
c. bit_num,
837
828
constraint_to_str( fcx. ccx. tcx, c. c) ) ;
838
829
clear_in_postcond( c. bit_num,
839
830
node_id_to_ts_ann( fcx. ccx,
840
831
parent_exp) . conditions) ;
841
- }
842
832
}
843
- }
844
- _ { }
845
- }
833
+ } ;
846
834
}
847
835
848
836
fn forget_in_poststate( fcx: fn_ctxt, p: poststate, dead_v: node_id) -> bool {
849
837
// In the poststate given by parent_exp, clear the bits
850
838
// for any constraints mentioning dead_v
851
839
let d = local_node_id_to_local_def_id( fcx, dead_v) ;
852
840
let mut changed = false ;
853
- alt d {
854
- some( d_id) {
855
- for constraints( fcx) . each { |c|
856
- if constraint_mentions( fcx, c, d_id) {
841
+ option:: iter( d) { |d_id|
842
+ for_constraints_mentioning( fcx, d_id) { |c|
857
843
changed |= clear_in_poststate_( c. bit_num, p) ;
858
- }
859
844
}
860
- }
861
- _ { }
862
845
}
863
846
ret changed;
864
847
}
@@ -876,23 +859,6 @@ fn constraint_mentions(_fcx: fn_ctxt, c: norm_constraint, v: node_id) ->
876
859
fn args_mention < T > ( args: [ @constr_arg_use] ,
877
860
q: fn ( [ T ] , node_id) -> bool,
878
861
s: [ T ] ) -> bool {
879
- /*
880
- FIXME
881
- The following version causes an assertion in trans to fail
882
- (something about type_is_tup_like)
883
- fn mentions<T>(&[T] s, &fn(&[T], def_id) -> bool q,
884
- &@constr_arg_use a) -> bool {
885
- alt (a.node) {
886
- case (carg_ident(?p1)) {
887
- auto res = q(s, p1._1);
888
- log(error, (res));
889
- res
890
- }
891
- case (_) { false }
892
- }
893
- }
894
- ret vec::any(bind mentions(s,q,_), args);
895
- */
896
862
897
863
for args. each { |a|
898
864
alt a. node { carg_ident( p1) { if q( s, p1. node) { ret true ; } } _ { } }
0 commit comments