Commit graph

2607 commits

Author SHA1 Message Date
Brian Anderson
d82e9c1874 rustc: Add a FIXME to expr_alt type checking 2011-05-21 18:35:21 -04:00
Brian Anderson
420d18a448 test: Adda test that all arms of an alt may result in fail 2011-05-21 18:31:40 -04:00
Brian Anderson
4504e23a82 rustc: Remove unnecessary pushdown from check_expr in the expr_if case 2011-05-21 18:18:48 -04:00
Brian Anderson
4bcdf57d78 test: Add a test for mismatched types of if branches 2011-05-21 18:18:48 -04:00
Brian Anderson
e24d7ae967 rustc: If all if branches are _|_, then the entire if is _|_ 2011-05-21 18:18:48 -04:00
Brian Anderson
c0b4fc1846 Register new snapshots 2011-05-21 18:09:15 -04:00
Brian Anderson
085fb1a2db rustc: Remove outdated comment 2011-05-21 14:43:04 -04:00
Brian Anderson
b62bf8cede rustc: Allow if expressions to fail 2011-05-21 14:22:01 -04:00
Brian Anderson
6824f119fc rustc: Allow alt expressions to fail 2011-05-21 13:22:01 -04:00
Brian Anderson
418b4c4567 rustc: Assign ty_bot to nodes in write::bot_ty. Remove FIXME 2011-05-21 13:02:58 -04:00
Brian Anderson
779dd809d2 rustc: Blocks shouldn't try to return results for ty_bot 2011-05-21 12:56:31 -04:00
Tim Chevalier
7b4eec215c Some tests for ! annotations 2011-05-20 19:54:14 -07:00
Tim Chevalier
a1b440baaa Un-XFAIL some tests that now pass. 2011-05-20 19:54:14 -07:00
Tim Chevalier
77f56f3154 XFAIL two tests for stage0 2011-05-20 19:54:14 -07:00
Tim Chevalier
755ca8eb73 Correctly check that ! functions always diverge
Also make _|_ unify with any type.
2011-05-20 19:54:14 -07:00
Brian Anderson
699986d192 fuzzer: Begin writing main 2011-05-20 22:32:41 -04:00
Brian Anderson
01c13a3878 stdlib: Add io::writer.write_line 2011-05-20 22:32:41 -04:00
Brian Anderson
fc8b9671bb stdlib: Export only what's needed from std::bitv 2011-05-20 22:12:57 -04:00
Brian Anderson
04ce99b83c stdlib: Export only what's needed from std::sort 2011-05-20 22:12:16 -04:00
Brian Anderson
2fc0bedc83 rustc: Don't write metadata for unexported items 2011-05-20 21:32:57 -04:00
Brian Anderson
7817824205 stdlib: export ptr_eq from box, but not rustrt 2011-05-20 21:32:57 -04:00
Tim Chevalier
467b938ea8 Merge remote-tracking branch 'graydon/master' into typestate_4 2011-05-20 18:23:03 -07:00
Tim Chevalier
5de9d27fcc un-XFAIL forgot-ret and update error pattern 2011-05-20 18:20:54 -07:00
Tim Chevalier
964898eaf1 Error instead of warning for missing returns. Huzzah! 2011-05-20 18:20:54 -07:00
Tim Chevalier
fed0486c33 Annotate erroring functions in session and parser 2011-05-20 18:20:54 -07:00
Tim Chevalier
90dd6e7044 New snapshot that handles bang annotations 2011-05-20 18:20:54 -07:00
Lindsey Kuper
c3410bf927 More work on anonymous objects. 2011-05-20 17:59:56 -07:00
Tim Chevalier
c8d488b337 Change node_ann hash table to a vector in typestate 2011-05-20 16:57:37 -07:00
Tim Chevalier
9128a1bab8 rm unnecessary logging 2011-05-20 16:57:37 -07:00
Tim Chevalier
7e82f23bc0 rm unused import 2011-05-20 16:57:37 -07:00
Tim Chevalier
551fb13689 Add a "fail" after a while(true) loop in two places
(in preparation for changing the "function may not return" warning
to an error)
2011-05-20 16:57:37 -07:00
Tim Chevalier
a08a376d6e Make controlflow part of a function type
Change ty_fn to have a controlflow field. A 'controlflow' is
essentially a bit of data that says whether or not this function
never returns to the caller (if it never returns, that means it calls
"fail" or another "never-returns" function on every control path).

Also add syntax for annotating functions that never return:

fn foo() -> ! {
   fail;
}

for example. Functions marked with ! implicitly have a result type of
ty_bot, which is a new type that this commit also adds.
2011-05-20 16:57:37 -07:00
Eric Holk
3dd2877975 Using the right mode... 2011-05-20 16:51:09 -07:00
Eric Holk
0de27ce8bd Translated start_task, but it fails on spp == align_down(spp) 2011-05-20 16:51:09 -07:00
Eric Holk
d01948cd07 Called the new_task upcall. There are refcount issues though. 2011-05-20 16:51:08 -07:00
Eric Holk
41b3979990 Nicer printer of LLVM array types. 2011-05-20 16:51:08 -07:00
Eric Holk
219351e4b9 A little closure towards translating spawn. We're about ready to do the upcall, except that rustc segfaults. 2011-05-20 16:51:08 -07:00
Eric Holk
d6338a8c15 Added some comments to trans_spawn that sort of explains what needs to happen 2011-05-20 16:51:08 -07:00
Eric Holk
2b124a8140 Started working on translating spawn. It correctly generates the task name in the case that it is not provided. 2011-05-20 16:51:08 -07:00
Eric Holk
51e1ce292d Added a couple of test cases for sending messages. One works as expected, the other succeeds unexpectedly. 2011-05-20 16:51:08 -07:00
Patrick Walton
4eb476fc75 stdlib: Modify union-find to guarantee that root nodes are always less than or equal to leaf nodes; add a "prune" method 2011-05-20 15:50:43 -07:00
Graydon Hoare
36c083b14c Options fix from erickt. 2011-05-20 15:20:48 -07:00
Graydon Hoare
fa75703700 Twiddle glue inlining heuristics. ~10% win on build time. 2011-05-20 14:57:52 -07:00
Graydon Hoare
67b8501eb8 Elide a bunch of do-nothing take glue. 2011-05-20 14:50:57 -07:00
Graydon Hoare
381ba1d0ba Remove redundant secondary declaration of glue. 2011-05-20 14:48:33 -07:00
Patrick Walton
7e43a31f08 rustc: Move the interner to a new module intended to be used for general data structures 2011-05-20 13:57:53 -07:00
Brian Anderson
b6d2fe4d74 rustc: Translate else if blocks the same as other blocks. Closes #388 2011-05-19 23:32:09 -04:00
Brian Anderson
879a952a37 rustc: Find the correct outer scope in trans_block 2011-05-19 23:32:08 -04:00
Rafael Ávila de Espíndola
40b511a7c5 Revert 106216d673.
This depends on llvm's 131294.
2011-05-19 18:30:19 -07:00
Graydon Hoare
494c0c3b61 After all that, give up on "complex" version of type_has_pointers and just manually inspect. Can't calculate property during interning. 2011-05-19 18:28:09 -07:00
Eric Holk
5d09e12e15 Added two version of reverse and a swap function to the standard library. 2011-05-19 17:25:37 -07:00
Graydon Hoare
7f938f4945 Move the ty_item_table into ty::ctxt.items, move variant_info to ty, and start sketching the contains_pointer property on types. 2011-05-19 17:21:36 -07:00
Graydon Hoare
1d67ee0e88 Remove type_glue.rs, don't think it's going to work. 2011-05-19 17:21:36 -07:00
Patrick Walton
bc87ecf110 rustc: Unify variables using a single type instead of keeping a list and doing it all at the end. This will give us better error messages. 2011-05-19 16:07:12 -07:00
Patrick Walton
6b95584df5 stdlib: Add vec growth functions that use a thunk to initialize elements 2011-05-19 16:07:12 -07:00
Graydon Hoare
a4dd57705c Move type cache and node type table into type context. 2011-05-19 15:47:15 -07:00
Marijn Haverbeke
8a7b544995 Finish name collision testing.
And fix a the single screw-up in the source code it caught.
2011-05-19 21:58:57 +02:00
Graydon Hoare
31d65453d4 OptLevel changes. Accepts levels 0 to 3 only. '-O' is synonym for --OptLevel=2. 2011-05-19 12:46:10 -07:00
Graydon Hoare
0a74ffaea3 xfail vector-no-ann.rs. 2011-05-19 12:18:23 -07:00
Paul Stansifer
533d3055f3 No functional change. Largely removed the native module/non-native module distinction from resolve.rs 2011-05-19 12:13:35 -07:00
Lindsey Kuper
38b37fcbdb Checking to make sure we know what 'self' is in nested objects. 2011-05-19 11:52:27 -07:00
Tim Chevalier
b74d0d7c3d Typestate checking code no longer uses fold -- only walk. 2011-05-19 11:40:16 -07:00
Tim Chevalier
d60e08c18e Eliminate explicit recursion in tstate.states (walk does that now),
and kill dead code.
2011-05-19 11:40:16 -07:00
Tim Chevalier
e1844d2719 Add ann as an argument to visit_fn 2011-05-19 11:40:16 -07:00
Tim Chevalier
6dcd607277 make trans compile 2011-05-19 11:40:16 -07:00
Tim Chevalier
a9bc6715e7 tidy tstate.collect_locals 2011-05-19 11:40:16 -07:00
Tim Chevalier
c0f728712b Rewrite pre_postconditions to use walk instead of fold 2011-05-19 11:40:16 -07:00
Tim Chevalier
2cd769e358 Add ident as an argument to visit_fn (typestate wants it) 2011-05-19 11:40:16 -07:00
Tim Chevalier
ef5473deb1 Trim imports 2011-05-19 11:40:16 -07:00
Tim Chevalier
bb594a03a1 remove now-unused ts field from ann 2011-05-19 11:40:16 -07:00
Tim Chevalier
e16b097599 Rewrite tstate.annotate to use walk instead of fold
and various other tidying in typestate
2011-05-19 11:40:16 -07:00
Tim Chevalier
dc83c84662 Add visit_fn_pre and visit_fn_post fields to visitors
Added visit_fn_pre and visit_fn_post fields that get applied to
both regular functions and methods.
2011-05-19 11:40:16 -07:00
Tim Chevalier
ea1701de8c Add a set_all function in bitv that's the inverse of clear 2011-05-19 11:40:16 -07:00
Tim Chevalier
8cbdaf4f93 Make trans use span_err for the dreaded "ty_var in trans::type_of" error
This required quite a bit of tiresome plumbing about of spans.
On the bright side, now other errors can be converted to span_err too.

Includes test cases.
2011-05-19 11:40:16 -07:00
Tim Chevalier
0d429a7603 add a bunch more logging things 2011-05-19 11:40:16 -07:00
Tim Chevalier
f909dd114d Remove dead file (typestate_check is now a bunch of modules under middle/tstate) 2011-05-19 11:40:16 -07:00
Tim Chevalier
b624b43e47 Beginning of Operation Eliminate Folds
Started by rewriting collect_locals to use walk instead of fold
2011-05-19 11:40:16 -07:00
Tim Chevalier
4964023c5e Fix an error message that reversed the expected and actual number of arguments in a pattern 2011-05-19 11:40:16 -07:00
Patrick Walton
6417610788 rustc: Generalize variable bindings so that we can use it for locals too 2011-05-19 11:14:44 -07:00
Marijn Haverbeke
c750c520e3 Remove rustboot-related logging hacks
(Also, feel free to start adding logging to your code. Really. It's fast.)
2011-05-19 19:33:32 +02:00
Patrick Walton
df90934bf7 rustc: Split write_* in typeck into versions that will record fixups 2011-05-18 19:19:20 -07:00
Patrick Walton
d2bdfe36cf rustc: Don't inline free glue 2011-05-18 18:48:57 -07:00
Patrick Walton
c88fc06b40 rustc: Fix output name of optimized glue when --save-temps is on 2011-05-18 18:48:41 -07:00
Graydon Hoare
6f8b9e176f Factor free paths out of drop glue, into free glue as in rustboot. 2011-05-18 17:28:08 -07:00
Patrick Walton
0aee8b3bd7 rustc: Thread statement contexts through unification 2011-05-18 15:36:14 -07:00
Rafael Ávila de Espíndola
bb7d4e15a8 Remove dead code. 2011-05-18 16:33:22 -04:00
Marijn Haverbeke
28c4a5586e Start checking name collisions in modules
(And remove a boatload of duplicate imports from the typestate files.)

Name collision checking in local scopes will follow soon.
2011-05-18 22:24:20 +02:00
Rafael Ávila de Espíndola
843739ee98 A quick hack to get the bots green while I refactor this code. 2011-05-18 16:16:52 -04:00
Patrick Walton
13d9f6a264 rustc: Split out type variable fixups from unification 2011-05-18 13:08:54 -07:00
Rafael Ávila de Espíndola
96516e9ca2 One exit_task_glue to rule them all. 2011-05-18 15:43:48 -04:00
Patrick Walton
37d5dd9471 rustc: Group the variable binding machinery into a separate data structure during unification 2011-05-18 11:54:12 -07:00
Rafael Ávila de Espíndola
a795d0e5b2 And yet more dead code. 2011-05-18 14:28:08 -04:00
Rafael Ávila de Espíndola
d108bfe2ee Remove a bit more dead code. 2011-05-18 14:02:53 -04:00
Rafael Ávila de Espíndola
cebc9b359d Remove dead rustboot code. 2011-05-18 13:48:57 -04:00
Patrick Walton
f4e049c415 rustc: Thread a statement context through the typechecker; use it for generating variable IDs. 40% typechecking speedup. 2011-05-17 22:21:31 -07:00
Graydon Hoare
49b90d37ed Add mirror-all-snapshots.py script for extra crowdsourced backup power. 2011-05-17 22:06:55 -07:00
Patrick Walton
fdf8c49882 rustc: Don't rebuild the AST when typechecking statements 2011-05-17 21:09:34 -07:00
Erick Tryzelaar
4d0cbd4310 Move vim syntax file, add indent file. 2011-05-17 20:35:46 -07:00
Patrick Walton
ace8058277 rustc: Have typechecking no longer rebuild the AST 2011-05-17 20:13:04 -07:00
Patrick Walton
df9801c9f0 rustc: Fix type mismatch in lib/sha1.rs constants 2011-05-17 20:13:03 -07:00
Brian Anderson
a98ea4f3ef rustc: Run block cleanups on else if blocks
With the scheme used to translate 'else if' currently the if expression is
translated in a new (else) scope context. If that if expression wants to
result in a value that requires refcounting then it will need to drop the
refcount in the cleanups of the else block.
2011-05-17 22:25:24 -04:00
Patrick Walton
e840a37f33 rustc: Remove typeck::check_item_fn(); it's entirely superfluous! 2011-05-17 19:20:24 -07:00
Patrick Walton
87288a186d rustc: Make check_const() not rebuild the AST (although it's not called at the moment!) 2011-05-17 19:13:16 -07:00
Patrick Walton
d21741843c rustc: Make check_block not rebuild the AST 2011-05-17 19:10:24 -07:00
Patrick Walton
10503a4a02 rustc: Don't rebuild the AST when writing back locals 2011-05-17 19:00:29 -07:00
Patrick Walton
3ffe390570 rustc: Print the types of declarations in --typed-pretty mode 2011-05-17 19:00:16 -07:00
Patrick Walton
8637a4eaf3 rustc: Pull the type out of the correct expression when typechecking channel types. Puts out burning tinderbox. 2011-05-17 18:19:45 -07:00
Patrick Walton
83e1dc63c2 rustc: Fix return value of expr_spawn case in pushdown_expr. Should put out soon-to-be-burning tinderbox. 2011-05-17 17:44:30 -07:00
Patrick Walton
c6d4c31ee4 rustc: Don't rebuild the AST when typechecking expressions 2011-05-17 17:43:06 -07:00
Patrick Walton
7a3812afc3 rustc: Add a typed pretty-printing mode for debugging 2011-05-17 17:43:06 -07:00
Eric Holk
cff9a3cc2a Fixing compile problems from recent changes. 2011-05-17 14:38:32 -07:00
Eric Holk
cf02c67137 Removing the TODO comment. 2011-05-17 14:38:32 -07:00
Eric Holk
8d10594ed5 Added a few more expr_spawn cases so the spawn.rs test case gets a little further before failing. 2011-05-17 14:38:32 -07:00
Patrick Walton
37768cba92 rustc: Don't rebuild call or bind expressions during typechecking 2011-05-17 14:37:23 -07:00
Patrick Walton
f300de2963 rustc: Make return value checking warnings a little prettier. Also introduce a new "note" diagnostic level. 2011-05-17 14:12:49 -07:00
Patrick Walton
5047ab0b0c rustc: Flatten annotations 2011-05-17 13:55:32 -07:00
Marijn Haverbeke
a90df393f9 Alias-ify the parser and lexer
This only shaves a measly 19k off the rustc binary... but hey, every
little thing helps.
2011-05-17 20:45:49 +02:00
Marijn Haverbeke
09d8ef8d51 Finally rename std::_xxx to std::xxx
Except for _task, which is still a keyword.
2011-05-17 20:41:41 +02:00
Paul Stansifer
1fdc75ee7c Parser fix: 'fail' was eating the next token that came after it. 2011-05-17 05:40:17 +00:00
Marijn Haverbeke
f7df3696de Switch pretty printer to new vec syntax 2011-05-17 07:19:34 +02:00
Brian Anderson
63cf381ca1 stdlib: Remove transitional extfmt.RT module 2011-05-17 00:58:52 -04:00
Brian Anderson
fbfd8552ab Return a better result from blocks. Closes issue #377
Blocks return in a copy of the result of their ending expression, not the
direct result of the ending expression, as that may be a local variable which
gets zeroed by drop_slot.
2011-05-17 00:46:56 -04:00
Graydon Hoare
4539b3f6ab Register new snapshots. 2011-05-16 19:57:03 -07:00
Graydon Hoare
4c5e315843 Rename aux.rs to auxiliary.rs since win32 doesn't like files named "aux". Really. 2011-05-16 19:21:29 -07:00
Graydon Hoare
cc27e0f8c6 Update a couple tests that slipped through. 2011-05-16 19:08:59 -07:00
Graydon Hoare
a2e2e78103 Merge remote branch 'origin/master' into HEAD
Conflicts:
	src/comp/middle/trans.rs
2011-05-16 19:04:45 -07:00
Graydon Hoare
fbbc1a77d2 Rewrite everything to use [] instead of vec() in value position. 2011-05-16 18:21:22 -07:00
Graydon Hoare
ae030c5bf2 Begin vec() -> [] transition. 2011-05-16 17:04:12 -07:00
Tim Chevalier
41b7af9652 make the return-checker happy about pretty::pp::base_indent 2011-05-16 16:59:30 -07:00
Tim Chevalier
387a8888ee Fix get_os and get_arch
get_os and get_arch were failing to return a value in the error
case; they were also assuming that strings are indexed from 1. No
idea how they ever worked, but anyway, fixed.
2011-05-16 16:59:30 -07:00
Tim Chevalier
b42bb2cff2 Two tests that the typechecker correctly unifies type arguments in patterns with their expected tag types 2011-05-16 16:59:30 -07:00
Tim Chevalier
971b5d5151 Started adding support for return checking and non-returning function annotations
* Reorganized typestate into several modules.

* Made typestate check that any function with a non-nil return type
  returns a value. For now, the check is a warning and not an error
  (see next item).

* Added a "bot" type (prettyprinted as _|_), for constructs like be, ret, break, cont, and
  fail that don't locally return a value that can be inspected. "bot"
  is distinct from "nil". There is no concrete syntax for _|_, while
  the concrete syntax for the nil type is ().

* Added support to the parser for a ! annotation on functions whose
  result type is _|_. Such a function is required to have either a
  fail or a call to another ! function that is reached in all control
  flow paths. The point of this annotation is to mark functions like
  unimpl() and span_err(), so that an alt with a call to err() in one
  case isn't a false positive for the return-value checker. I haven't
  actually annotated anything with it yet.

* Random bugfixes:

* * Fixed bug in trans::trans_binary that was throwing away the
    cleanups for nested subexpressions of an and or or
    (tests: box-inside-if and box-inside-if2).

** In typeck, unify the expected type arguments of a tag with the
   actual specified arguments.
2011-05-16 16:59:25 -07:00
Tim Chevalier
c75125fcce Noticed that metadata::Encode::enc_sty didn't have a case for ty_task, so I added one (though this wasn't causing the problem I was seeing... 2011-05-16 16:13:11 -07:00
Patrick Walton
f74298215c rustc: Fix indentation in typeck::check_lit() 2011-05-16 15:24:32 -07:00
Patrick Walton
1fc1ad91ce rustc: Don't rebuild the call expression in typeck::replace_expr_type() 2011-05-16 15:20:11 -07:00
Patrick Walton
278d64dafc rustc: Don't unpack annotations in trans::lval_generic_fn() 2011-05-16 15:20:11 -07:00
Graydon Hoare
d577f5bdf9 Let the snapshot-file parser parse empty T lines, since they are used to start a transition. 2011-05-16 15:14:44 -07:00
Patrick Walton
3ea3d9eed6 rustc: Make the parser use the interner 2011-05-16 14:54:10 -07:00
Kelly Wilson
b91ef944c8 Replace --bitcode with the canonical --emit-llvm 2011-05-16 14:07:43 -07:00
Kelly Wilson
196351aa44 Add automatic exe generation capabilities. Add --bitcode flag to generate only an LLVM bitcode file. 2011-05-16 14:07:43 -07:00
Patrick Walton
32b8dcb97c rustc: Factor out the code that interns types into an "interner" data structure 2011-05-16 13:58:13 -07:00
Patrick Walton
3760bfab87 rustc: Don't rebuild AST patterns during typechecking 2011-05-16 11:45:00 -07:00
Patrick Walton
ca51b49c0a rustc: Replace the redundant typeck::node_ann_ty_params() with ty::ann_to_type_params() 2011-05-16 11:43:50 -07:00
Patrick Walton
3aaf02b907 rustc: Make the type collection pass no longer rebuild the AST 2011-05-16 10:34:32 -07:00
Patrick Walton
525a5c582f rustc: Fix indentation in ty_param_count_and_ty_for_def() 2011-05-16 10:32:38 -07:00
Patrick Walton
594c70f788 rustc: Add an item_ann() accessor function 2011-05-16 10:32:38 -07:00
Brian Anderson
f77c5ba512 rustc: Wait until generic glue is actually emitted to define it as internal
The verifier was not liking this when generating unoptimized bitcode. Per LLVM
docs it is not valid for function declarations to be marked internal, but
their implementations may be.
2011-05-15 19:53:06 -04:00
Brian Anderson
8eaafdaa2d rustc: Rename 'Unify' modules to 'unify' 2011-05-14 21:13:47 -04:00
Brian Anderson
f33d490032 Remove xfail-boot lines from tests 2011-05-14 21:05:22 -04:00
Patrick Walton
de421afa55 rustc: Use walk instead of fold for the first item collection pass 2011-05-14 11:03:10 -07:00