Skip to content

Commit 4b439f5

Browse files
author
Tohava
committed
---
yaml --- r: 478 b: refs/heads/master c: ce79b0e h: refs/heads/master v: v3
1 parent 37f3687 commit 4b439f5

File tree

11 files changed

+237
-65
lines changed

11 files changed

+237
-65
lines changed

[refs]

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,2 +1,2 @@
11
---
2-
refs/heads/master: 0f53d0313912b56be77b267f98daa2569ebb37ea
2+
refs/heads/master: ce79b0e492f1583debbce3c8155da3536c684d9a

trunk/src/Makefile

Lines changed: 9 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -489,6 +489,7 @@ TEST_XFAILS_LLVM := $(TASK_XFAILS) \
489489
obj-recursion.rs \
490490
obj-return-polytypes.rs \
491491
obj-with-vec.rs \
492+
operator-associativity.rs \
492493
output-slot-variants.rs \
493494
pred.rs \
494495
preempt.rs \
@@ -576,10 +577,18 @@ RFAIL_RS := $(wildcard test/run-fail/*.rs)
576577
CFAIL_RC := $(wildcard test/compile-fail/*.rc)
577578
CFAIL_RS := $(wildcard test/compile-fail/*.rs)
578579

580+
ifdef CHECK_XFAILS
581+
TEST_RPASS_CRATES_X86 := $(filter $(TEST_XFAILS_X86), $(RPASS_RC))
582+
TEST_RPASS_CRATES_LLVM := $(filter $(TEST_XFAILS_LLVM), $(RPASS_RC))
583+
TEST_RPASS_SOURCES_X86 := $(filter $(TEST_XFAILS_X86), $(RPASS_RS))
584+
TEST_RPASS_SOURCES_LLVM := $(filter $(TEST_XFAILS_LLVM), $(RPASS_RS))
585+
else
579586
TEST_RPASS_CRATES_X86 := $(filter-out $(TEST_XFAILS_X86), $(RPASS_RC))
580587
TEST_RPASS_CRATES_LLVM := $(filter-out $(TEST_XFAILS_LLVM), $(RPASS_RC))
581588
TEST_RPASS_SOURCES_X86 := $(filter-out $(TEST_XFAILS_X86), $(RPASS_RS))
582589
TEST_RPASS_SOURCES_LLVM := $(filter-out $(TEST_XFAILS_LLVM), $(RPASS_RS))
590+
endif
591+
583592
TEST_RPASS_EXTRAS := $(wildcard test/run-pass/*/*.rs)
584593
TEST_RPASS_EXES_X86 := \
585594
$(TEST_RPASS_CRATES_X86:.rc=.x86$(CFG_EXE_SUFFIX)) \

trunk/src/boot/fe/pexp.ml

Lines changed: 86 additions & 36 deletions
Original file line numberDiff line numberDiff line change
@@ -718,142 +718,192 @@ and parse_negation_pexp (ps:pstate) : pexp =
718718

719719
(* Binops are all left-associative, *)
720720
(* so we factor out some of the parsing code here. *)
721-
and binop_rhs
721+
and binop_build
722722
(ps:pstate)
723723
(name:string)
724724
(apos:pos)
725-
(lhs:pexp)
726725
(rhs_parse_fn:pstate -> pexp)
726+
(lhs:pexp)
727+
(step_fn:pexp -> pexp)
727728
(op:Ast.binop)
728729
: pexp =
729730
bump ps;
730731
let rhs = (ctxt (name ^ " rhs") rhs_parse_fn ps) in
731732
let bpos = lexpos ps in
732-
span ps apos bpos (PEXP_binop (op, lhs, rhs))
733+
let node = span ps apos bpos (PEXP_binop (op, lhs, rhs)) in
734+
step_fn node
733735

734736

735737
and parse_factor_pexp (ps:pstate) : pexp =
736738
let name = "factor pexp" in
737739
let apos = lexpos ps in
738740
let lhs = ctxt (name ^ " lhs") parse_negation_pexp ps in
741+
let build = binop_build ps name apos parse_negation_pexp in
742+
let rec step accum =
739743
match peek ps with
740-
STAR -> binop_rhs ps name apos lhs parse_factor_pexp Ast.BINOP_mul
741-
| SLASH -> binop_rhs ps name apos lhs parse_factor_pexp Ast.BINOP_div
742-
| PERCENT -> binop_rhs ps name apos lhs parse_factor_pexp Ast.BINOP_mod
743-
| _ -> lhs
744+
STAR -> build accum step Ast.BINOP_mul
745+
| SLASH -> build accum step Ast.BINOP_div
746+
| PERCENT -> build accum step Ast.BINOP_mod
747+
| _ -> accum
748+
in
749+
step lhs
744750

745751

746752
and parse_term_pexp (ps:pstate) : pexp =
747753
let name = "term pexp" in
748754
let apos = lexpos ps in
749755
let lhs = ctxt (name ^ " lhs") parse_factor_pexp ps in
756+
let build = binop_build ps name apos parse_factor_pexp in
757+
let rec step accum =
750758
match peek ps with
751-
PLUS -> binop_rhs ps name apos lhs parse_term_pexp Ast.BINOP_add
752-
| MINUS -> binop_rhs ps name apos lhs parse_term_pexp Ast.BINOP_sub
753-
| _ -> lhs
759+
PLUS -> build accum step Ast.BINOP_add
760+
| MINUS -> build accum step Ast.BINOP_sub
761+
| _ -> accum
762+
in
763+
step lhs
754764

755765

756766
and parse_shift_pexp (ps:pstate) : pexp =
757767
let name = "shift pexp" in
758768
let apos = lexpos ps in
759769
let lhs = ctxt (name ^ " lhs") parse_term_pexp ps in
770+
let build = binop_build ps name apos parse_term_pexp in
771+
let rec step accum =
760772
match peek ps with
761-
LSL -> binop_rhs ps name apos lhs parse_shift_pexp Ast.BINOP_lsl
762-
| LSR -> binop_rhs ps name apos lhs parse_shift_pexp Ast.BINOP_lsr
763-
| ASR -> binop_rhs ps name apos lhs parse_shift_pexp Ast.BINOP_asr
764-
| _ -> lhs
773+
LSL -> build accum step Ast.BINOP_lsl
774+
| LSR -> build accum step Ast.BINOP_lsr
775+
| ASR -> build accum step Ast.BINOP_asr
776+
| _ -> accum
777+
in
778+
step lhs
765779

766780

767781
and parse_and_pexp (ps:pstate) : pexp =
768782
let name = "and pexp" in
769783
let apos = lexpos ps in
770784
let lhs = ctxt (name ^ " lhs") parse_shift_pexp ps in
785+
let build = binop_build ps name apos parse_shift_pexp in
786+
let rec step accum =
771787
match peek ps with
772-
AND -> binop_rhs ps name apos lhs parse_and_pexp Ast.BINOP_and
773-
| _ -> lhs
788+
AND -> build accum step Ast.BINOP_and
789+
| _ -> accum
790+
in
791+
step lhs
774792

775793

776794
and parse_xor_pexp (ps:pstate) : pexp =
777795
let name = "xor pexp" in
778796
let apos = lexpos ps in
779797
let lhs = ctxt (name ^ " lhs") parse_and_pexp ps in
798+
let build = binop_build ps name apos parse_and_pexp in
799+
let rec step accum =
780800
match peek ps with
781-
CARET -> binop_rhs ps name apos lhs parse_xor_pexp Ast.BINOP_xor
782-
| _ -> lhs
801+
CARET -> build accum step Ast.BINOP_xor
802+
| _ -> accum
803+
in
804+
step lhs
783805

784806

785807
and parse_or_pexp (ps:pstate) : pexp =
786808
let name = "or pexp" in
787809
let apos = lexpos ps in
788810
let lhs = ctxt (name ^ " lhs") parse_xor_pexp ps in
811+
let build = binop_build ps name apos parse_xor_pexp in
812+
let rec step accum =
789813
match peek ps with
790-
OR -> binop_rhs ps name apos lhs parse_or_pexp Ast.BINOP_or
791-
| _ -> lhs
814+
OR -> build accum step Ast.BINOP_or
815+
| _ -> accum
816+
in
817+
step lhs
792818

793819

794820
and parse_relational_pexp (ps:pstate) : pexp =
795821
let name = "relational pexp" in
796822
let apos = lexpos ps in
797823
let lhs = ctxt (name ^ " lhs") parse_or_pexp ps in
824+
let build = binop_build ps name apos parse_or_pexp in
825+
let rec step accum =
798826
match peek ps with
799-
LT -> binop_rhs ps name apos lhs parse_relational_pexp Ast.BINOP_lt
800-
| LE -> binop_rhs ps name apos lhs parse_relational_pexp Ast.BINOP_le
801-
| GE -> binop_rhs ps name apos lhs parse_relational_pexp Ast.BINOP_ge
802-
| GT -> binop_rhs ps name apos lhs parse_relational_pexp Ast.BINOP_gt
803-
| _ -> lhs
827+
LT -> build accum step Ast.BINOP_lt
828+
| LE -> build accum step Ast.BINOP_le
829+
| GE -> build accum step Ast.BINOP_ge
830+
| GT -> build accum step Ast.BINOP_gt
831+
| _ -> accum
832+
in
833+
step lhs
804834

805835

806836
and parse_equality_pexp (ps:pstate) : pexp =
807837
let name = "equality pexp" in
808838
let apos = lexpos ps in
809839
let lhs = ctxt (name ^ " lhs") parse_relational_pexp ps in
840+
let build = binop_build ps name apos parse_relational_pexp in
841+
let rec step accum =
810842
match peek ps with
811-
EQEQ -> binop_rhs ps name apos lhs parse_equality_pexp Ast.BINOP_eq
812-
| NE -> binop_rhs ps name apos lhs parse_equality_pexp Ast.BINOP_ne
813-
| _ -> lhs
843+
EQEQ -> build accum step Ast.BINOP_eq
844+
| NE -> build accum step Ast.BINOP_ne
845+
| _ -> accum
846+
in
847+
step lhs
814848

815849

816850
and parse_andand_pexp (ps:pstate) : pexp =
817851
let name = "andand pexp" in
818852
let apos = lexpos ps in
819853
let lhs = ctxt (name ^ " lhs") parse_equality_pexp ps in
854+
let rec step accum =
820855
match peek ps with
821856
ANDAND ->
822857
bump ps;
823-
let rhs = parse_andand_pexp ps in
858+
let rhs = parse_equality_pexp ps in
824859
let bpos = lexpos ps in
825-
span ps apos bpos (PEXP_lazy_and (lhs, rhs))
860+
let node = span ps apos bpos (PEXP_lazy_and (accum, rhs)) in
861+
step node
826862

827-
| _ -> lhs
863+
| _ -> accum
864+
in
865+
step lhs
828866

829867

830868
and parse_oror_pexp (ps:pstate) : pexp =
831869
let name = "oror pexp" in
832870
let apos = lexpos ps in
833871
let lhs = ctxt (name ^ " lhs") parse_andand_pexp ps in
872+
let rec step accum =
834873
match peek ps with
835874
OROR ->
836875
bump ps;
837-
let rhs = parse_oror_pexp ps in
876+
let rhs = parse_andand_pexp ps in
838877
let bpos = lexpos ps in
839-
span ps apos bpos (PEXP_lazy_or (lhs, rhs))
878+
let node = span ps apos bpos (PEXP_lazy_or (accum, rhs)) in
879+
step node
880+
881+
| _ -> accum
882+
in
883+
step lhs
840884

841-
| _ -> lhs
842885

843886
and parse_as_pexp (ps:pstate) : pexp =
844887
let apos = lexpos ps in
845888
let pexp = ctxt "as pexp" parse_oror_pexp ps in
889+
let rec step accum =
846890
match peek ps with
847891
AS ->
848892
bump ps;
849893
let tapos = lexpos ps in
850894
let t = parse_ty ps in
851895
let bpos = lexpos ps in
852896
let t = span ps tapos bpos t in
897+
let node =
853898
span ps apos bpos
854-
(PEXP_unop ((Ast.UNOP_cast t), pexp))
899+
(PEXP_unop ((Ast.UNOP_cast t), accum))
900+
in
901+
step node
902+
903+
| _ -> accum
904+
in
905+
step pexp
855906

856-
| _ -> pexp
857907

858908
and parse_pexp (ps:pstate) : pexp =
859909
parse_as_pexp ps

trunk/src/boot/me/type.ml

Lines changed: 16 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -472,6 +472,7 @@ let check_stmt (cx:Semant.ctxt) : (fn_ctx -> Ast.stmt -> unit) =
472472
and internal_check_outer_lval
473473
~mut:(mut:Ast.mutability)
474474
~deref:(deref:bool)
475+
~fn_args:(fn_args:(Ast.ty array) option)
475476
(infer:Ast.ty option)
476477
(lval:Ast.lval)
477478
: (Ast.ty * int) =
@@ -485,11 +486,15 @@ let check_stmt (cx:Semant.ctxt) : (fn_ctx -> Ast.stmt -> unit) =
485486
demand expected actual;
486487
yield_ty actual
487488
| None, (LTYPE_poly _ as lty) ->
488-
Common.err
489-
None
490-
"not enough context to automatically instantiate the polymorphic \
491-
type '%a'; supply type parameters explicitly"
492-
sprintf_ltype lty
489+
begin
490+
match fn_args with
491+
None ->
492+
Common.err None
493+
"can't auto-instantiate %a" sprintf_ltype lty
494+
| Some args ->
495+
Common.err None "can't auto-instantiate %a on %d args"
496+
sprintf_ltype lty (Array.length args)
497+
end
493498
| Some _, (LTYPE_poly _) ->
494499
(* FIXME: auto-instantiate *)
495500
Common.unimpl
@@ -502,6 +507,7 @@ let check_stmt (cx:Semant.ctxt) : (fn_ctx -> Ast.stmt -> unit) =
502507
and generic_check_lval
503508
~mut:(mut:Ast.mutability)
504509
~deref:(deref:bool)
510+
~fn_args:(fn_args:(Ast.ty array) option)
505511
(infer:Ast.ty option)
506512
(lval:Ast.lval)
507513
: Ast.ty =
@@ -521,7 +527,7 @@ let check_stmt (cx:Semant.ctxt) : (fn_ctx -> Ast.stmt -> unit) =
521527
| Some t -> Fmt.fmt_to_str Ast.fmt_ty t))
522528
in
523529
let (lval_ty, n_boxes) =
524-
internal_check_outer_lval ~mut:mut ~deref:deref infer lval
530+
internal_check_outer_lval ~mut ~deref ~fn_args infer lval
525531
in
526532
let _ =
527533
iflog cx
@@ -563,9 +569,10 @@ let check_stmt (cx:Semant.ctxt) : (fn_ctx -> Ast.stmt -> unit) =
563569
and check_lval
564570
?mut:(mut=Ast.MUT_immutable)
565571
?deref:(deref=false)
572+
?fn_args:(fn_args=None)
566573
(lval:Ast.lval)
567574
: Ast.ty =
568-
generic_check_lval ~mut:mut ~deref:deref None lval
575+
generic_check_lval ~fn_args ~mut ~deref None lval
569576

570577
and check_atom ?deref:(deref=false) (atom:Ast.atom) : Ast.ty =
571578
match atom with
@@ -582,7 +589,7 @@ let check_stmt (cx:Semant.ctxt) : (fn_ctx -> Ast.stmt -> unit) =
582589
(ty:Ast.ty)
583590
(lval:Ast.lval)
584591
: unit =
585-
ignore (generic_check_lval ?mut:mut ~deref:false
592+
ignore (generic_check_lval ~mut ~deref:false ~fn_args:None
586593
(Some (Ast.TY_mutable ty)) lval)
587594
in
588595

@@ -636,7 +643,7 @@ let check_stmt (cx:Semant.ctxt) : (fn_ctx -> Ast.stmt -> unit) =
636643
* returns the return type. *)
637644
let check_fn (callee:Ast.lval) (args:Ast.atom array) : Ast.ty =
638645
let arg_tys = Array.map check_atom args in
639-
let callee_ty = check_lval callee in
646+
let callee_ty = check_lval callee ~fn_args:(Some arg_tys) in
640647
demand_fn (Array.map (fun ty -> Some ty) arg_tys) callee_ty
641648
in
642649

0 commit comments

Comments
 (0)