Commit Graph

72 Commits

Author SHA1 Message Date
Tim Chevalier
8d7765be82 Resolve bounds in iface types
Closes #2311
2012-05-29 16:50:21 -07:00
Michael Sullivan
8668d06400 Get rid of many implicit copies as a preliminary to Issue #2448. 2012-05-25 16:39:35 -07:00
Niko Matsakis
9773a22119 shuffle error messages in borrowck, and prevent it from spewing too many
also, fix a few minor issues it complains about
2012-05-23 12:01:27 -07:00
Brian Anderson
4756556748 rustc: Move new_def_hash to ast_util 2012-05-23 00:43:02 -07:00
Brian Anderson
9aa18c2852 rustc: Move ast_map to the syntax crate 2012-05-21 23:39:27 -07:00
Brian Anderson
47bb1185f2 rustc: Move walk_pat to ast_util
This will allow ast_map to move to the syntax crate
2012-05-21 23:22:08 -07:00
Brian Anderson
85d67723ee rustc: Move path_to_ident to ast_util 2012-05-21 22:41:59 -07:00
Niko Matsakis
34b42eeb65 change list so that it must be used in a purely boxed fashion
The old way was inconsistent---the head was unboxed but the
tail was boxed.  This resulted in numerous needless copies and
also made the borrow check unhappy, because the head tended to be
stored in mutable memory.
2012-05-21 09:37:34 -07:00
Niko Matsakis
8e73bb6ea0 detect and report shadows in nested bindings 2012-05-21 09:37:22 -07:00
Niko Matsakis
774ea145ec make more code use dvec 2012-05-18 20:00:51 -07:00
Niko Matsakis
35f6f37453 avoid modifying the variable we are alting over 2012-05-18 20:00:50 -07:00
Tim Chevalier
5428a22b95 First cut at dtors for classes
Classes with dtors should compile now. Haven't yet tested
whether they actually run correctly.

Beginnings of support for #2295, though that won't be done until
there's more test cases and resources are removed.
2012-05-14 14:26:10 -07:00
Marijn Haverbeke
b619954457 Start parsing pub/priv on regular items
Issue #1893
2012-05-08 16:09:40 +02:00
Tim Chevalier
4f105e4025 In resolve, visit the path in an iface ref
Necessary to resolve any type arguments in a ref to a parameterized
iface. This meant that, for example:

class A implements B<int> { ...

didn't work before, because the "int" in B's argument wasn't getting
visited, and thus wasn't getting resolved. Now it works.

Partially addresses Issue #2288, but I also want to check that class
ty params can appear as the type arguments to ifaces (for example,

class A<T> implements B<T> {...

should work.)
2012-05-07 14:43:31 -07:00
Niko Matsakis
8a9df5aa38 make it illegal to implicitly capture mutable variables
this is the final part of #1273
2012-05-07 13:22:42 -07:00
Niko Matsakis
50ec6bd2c3 new cap clause syntax 2012-05-04 12:33:08 -07:00
Tim Chevalier
29b807be2a Removed unused import of std::deque 2012-05-03 15:37:02 -07:00
Graydon Hoare
b12e27595e Error message reformatting, close #2309. 2012-05-02 14:47:33 -07:00
Tim Chevalier
3d4ef74c9b Encode the ifaces a class implements in metadata
This lets you use class A as if it had type B if A implements B,
and A and B are in different crates from your own.

Closes #2285
2012-05-02 13:38:56 -07:00
Tim Chevalier
46425af8a5 Remove code that was accidentally committed
This was a workaround for the bug that was actually fixed in
164039e867
2012-05-01 08:48:25 -07:00
Tim Chevalier
164039e867 Don't re-export a glob-imported ID when the same ID is defined within
a module

See the test case I added (issue-2316-c) for a concrete example.
issue-2316 also contains the originally reported test case. resolve
was using bitwise or instead of logical or when checking exports,
resulting in excessively eager evaluation. A one-line fix that took
six hours to isolate ;-)
2012-05-01 08:43:17 -07:00
Niko Matsakis
825fd1808e lots of work to make iface/impls parameterized by regions
- paths can now take region parameters, replacing the dirty hack
  I was doing before of abusing vstores.  vstores are now a bit
  of a hack though.

- fix various small bugs:
  - we never checked that iface types were compatible when casting
    to an iface with `as`
  - we allowed nonsense like int<int>
  - and more! (actually that may be it)
2012-04-25 19:26:56 -07:00
Marijn Haverbeke
9f99c3263b Rewrite exhaustiveness checker
Issue #2111
2012-04-25 09:15:17 +02:00
Tim Chevalier
f7641286b2 Allow classes to be cast to ifaces that are in the same crate
I had to xfail one existing test case (class-implements-int) because,
I think, of the same bug described in #2272.
2012-04-23 21:15:03 -07:00
Marijn Haverbeke
9053f54498 Move map iface over to more for-friendly iteration methods 2012-04-23 15:18:19 +02:00
Marijn Haverbeke
a872a99bfe Simplify representation of ast::path 2012-04-23 13:04:46 +02:00
Marijn Haverbeke
587d8a5d4f Misc code cleanups using list::each for list iteration 2012-04-23 12:13:59 +02:00
Niko Matsakis
3c995fb8f3 make nominal types optionally parameterized by a self region.
Issue #2201.
2012-04-19 21:01:11 -07:00
Tim Chevalier
b0074c5a92 Disallow rebinding / matching against consts in alts
As per Issue #1193. Closes #1193.

I had to rename a few variables ("info" and "epsilon") to avoid
clashing with in-scope constants, which is responsible for all the
changes other than resolve and issue-1193.rs.
2012-04-19 16:21:15 -07:00
Tim Chevalier
1adc26d5e7 Annotate FIXMEs in syntax::ast and syntax::ast_util
The main non-comment change was to change simple_path to path,
as per a FIXME in ast.
2012-04-13 01:46:56 -07:00
Graydon Hoare
8a7fd4a04f Support general warnings and errors in lint pass via flags and attrs. Close #1543. 2012-04-12 17:31:49 -07:00
Brian Anderson
891dc84be2 rustc: Long lines 2012-04-11 21:32:05 -07:00
Brian Anderson
e7409859ce rustc: Fix typo in error message 2012-04-11 21:25:32 -07:00
Tim Chevalier
5c12cd72f4 Allow classes to implement ifaces
Introduce syntax like:

iface animal { ... }
class cat implements animal { ... }

to allow classes to implement ifaces. Casting classes to ifaces
is *not* yet supported. ifaces that a class implements are not
yet included in metadata.

The syntax is subject to change, and may go away completely if we
decide to use duck typing to relate classes with ifaces (see
http://smallcultfollowing.com/babysteps/blog/2012/04/10/declared-vs-duckish-typing/ )
2012-04-11 16:20:01 -07:00
Tim Chevalier
fd26743bed Generic classes and generic class methods work cross-crate
Classes can have ty params now. So can methods inside classes.
That was probably true before, but now it should still work if you
call methods in a class that's defined in a different crate. Yay!
2012-04-10 11:01:36 -07:00
Tim Chevalier
9d274ec5f2 Re-rename option functions
get_with_default (nee from_maybe) => get_default
with_option (nee maybe) => map_default
with_option_do (nee may) => iter

As per discussion of 21be1379d5
2012-04-06 12:20:13 -07:00
Marijn Haverbeke
fc202ca034 Remove support for old-style for
Closes #1619
2012-04-06 20:38:23 +02:00
Marijn Haverbeke
c902eafa14 Convert old-style for loops to new-style
Most could use the each method, but because of the hack used to
disambiguate old- and new-style loops, some had to use vec::each.

(This hack will go away soon.)

Issue #1619
2012-04-06 20:38:23 +02:00
Marijn Haverbeke
90d3f0fb5e Ensure method names in iface and impl items are unique
Closes #2114
2012-04-03 16:37:28 +02:00
Tim Chevalier
21be1379d5 Rename some core::option functions
from_maybe => get_with_default
maybe => with_option
may => with_option_do

I know these names are kind of ridiculous, but it's the best I could think of.
Feel free to bikeshed. Closes #2081
2012-04-02 16:12:49 -07:00
Brian Anderson
0e87039348 rustc: Remove the rustsyntax::attr wrapper in front 2012-03-29 14:42:31 -07:00
Tim Chevalier
c7082ce8e8 Require "self" as base expression for intra-class method or field references
All field or method references within a class must begin with "self." now.
A bare reference to a field or method in the same class will no longer
typecheck.
2012-03-29 12:22:01 -07:00
Tim Chevalier
f7bbe537c1 Allow explicit self-calls within classes
Allow writing self.f() within a class that has a method f. In a future
commit, this syntax will be required. For now, you can write either
self.f() or f().

I added a "privacy" field to all methods (whether class methods or not),
which allowed me to refactor the AST somewhat (getting rid of the
class_item type; now there's just class_member).
2012-03-28 20:30:07 -07:00
Tim Chevalier
ca6636d6b6 Allow references to "self" within classes
Allow writing self.f within a class that has a field f. Currently,
the compiler accepts either self.f or f. In a future commit I'll
require writing self.f and not f.

Not sure whether self.f() works if f is a method (making sure that
works next).
2012-03-28 14:19:00 -07:00
Graydon Hoare
6e6798c4e1 Bulk-edit mutable -> mut. 2012-03-26 18:35:18 -07:00
Marijn Haverbeke
87e097a853 Disallow ret inside of block functions
Also adds proper checking for cont/break being inside a loop.

Closes #1854
Issue #1619
2012-03-26 12:45:47 +02:00
Tim Chevalier
8bbd78075f Handle self correctly when translating classes
This change uses the same code for handling the "self" reference for
classes as is already used for impls/ifaces. This allows removing the
extra maybe_self_id argument (which was just for classes) to trans_closure
that I added before. I also rewrote the translation for class ctors so
that it doesn't generate new AST nodes (instead translating directly).

Also changed visit so that it visits class ctors correctly with visit_fn,
and changed typestate to not do return-checking when visiting a class ctor.
2012-03-23 20:37:50 -07:00
Patrick Walton
7931a61ebb rustc: Redo region inference to be a bit less broken 2012-03-23 12:22:58 -07:00
Marijn Haverbeke
5cfbbbc9ed Revert resolve kludge that was working around #2049 2012-03-23 13:32:00 +01:00
Marijn Haverbeke
c704d5a5d3 Clean up some confused shuffling of def_ids in resolve.rs 2012-03-23 12:38:36 +01:00