Commit Graph

1019 Commits

Author SHA1 Message Date
Lindsey Kuper
e656261ee7 Comments, minor refactoring, clean up wording of error messages 2012-08-07 10:29:19 -07:00
Niko Matsakis
7d374bde43 add lint mode for deprecated pattern usage 2012-08-07 07:14:44 -07:00
Niko Matsakis
dbef6e593d move borrowck tests to use ref, fix a few exposed shortcomings 2012-08-07 06:11:12 -07:00
Tim Chevalier
f3b2296ee4 Auto-deref the base expr in trans_method_callee
(specifically in the method_trait case) -- if you wrote x.f()
and x has type @T for a trait T, x wasn't getting auto-deref'ed.

This was bad.

Closes #2935
2012-08-06 19:17:44 -07:00
Niko Matsakis
aacd18f4ed first shot at integrating ref/value bindings into borrowck
(more needed)
2012-08-06 19:15:39 -07:00
Patrick Walton
60f47eabe2 rustc: Parse and stub (broken) typechecking for bounded function types 2012-08-06 18:55:24 -07:00
Patrick Walton
253dfc3387 rustc: Implement pattern matching for structs 2012-08-06 17:36:24 -07:00
Tim Chevalier
5cb3a94bfb Shorten lines, fix build breakage 2012-08-06 17:33:23 -07:00
Tim Chevalier
6bd01d0ac8 In resolve, forbid duplicate value, type, and module items
Closes #3099
2012-08-06 16:37:18 -07:00
Niko Matsakis
a6a5c48c64 make ref x bindings produce region ptrs and fix various minor bugs
we now detect inconsistent modes, binding names, and various other errors.
typeck/trans integration is mostly done.

borrowck not so much.

more tests needed.
2012-08-06 16:12:40 -07:00
Brian Anderson
ecaf9e39c9 Convert alt to match. Stop parsing alt 2012-08-06 15:36:30 -07:00
Patrick Walton
bff512a90f rustc: Implement functional record update for structs 2012-08-06 13:17:42 -07:00
Brian Anderson
025d86624d Switch alts to use arrows 2012-08-05 22:08:09 -07:00
Patrick Walton
8c77536526 rustc: Normalize region-bounded string slices properly
This prevents an LLVM assertion that will bite you if you try to put a static
string in an Error.
2012-08-04 15:11:54 -07:00
Graydon Hoare
edfc79cc47 Translate const vecs, most of const slices. More for #2317. 2012-08-03 21:44:52 -07:00
Patrick Walton
f23674394f rustc: Merge fn& and fn in favor of fn&.
This is a step on the way to moving the function "proto" sigil out front.
2012-08-03 19:49:12 -07:00
Patrick Walton
51a5a4ad0e rustc: Translate repeated vector syntax 2012-08-03 18:49:44 -07:00
Graydon Hoare
488ece05b5 Implement &-expressions in consts. Part of #2317. 2012-08-03 18:07:58 -07:00
Patrick Walton
e02b1b1ec8 rustc: Parse and typecheck repeating vector expressions; e.g. [ 0, ..512 ] 2012-08-03 18:03:19 -07:00
Lindsey Kuper
fe2f3d210a Further work on default methods in traits.
And some trait-related code cleanup in typeck::collect.
2012-08-03 16:17:54 -07:00
Patrick Walton
b65dd9d090 rustc: Parse, serialize, and deserialize trait inheritance 2012-08-03 15:02:53 -07:00
Patrick Walton
a805a1fb37 rustc: Add the notion of inherited visibility 2012-08-03 15:02:53 -07:00
Patrick Walton
9e68966611 rustc: Remove fixed-length string warning 2012-08-03 12:03:15 -07:00
Patrick Walton
4e60d7e3a6 rustc: "foo" is now a static string 2012-08-03 11:51:04 -07:00
Patrick Walton
dfe1f6260e rustc: Remove all fixed-length strings from our codebase 2012-08-03 11:22:35 -07:00
Tim Chevalier
336be1d644 Fix build breakage 2012-08-02 23:53:45 -07:00
Tim Chevalier
948172b93f Make comparisons between region pointers work
Region pointers were considered a scalar type, so compare_scalar_type would
get called to compare region pointers in trans. This would fail, since
compare_scalar_type has no case for region pointers.

Changed type_is_scalar to return false for region pointers. This had the side
effect of breaking casts to types of the form &T. To ameliorate that, I added
library functions ptr::assimilate (taking a &T to a *T) and ptr::to_uint
(taking a &T to a uint), both of which use reinterpret_cast.

While I was at it, I removed ty::type_has_resources, which is dead code.
2012-08-02 23:53:45 -07:00
Niko Matsakis
31c5cec55b Purge placement new; Make borrowck know about unary move.
cc #3071
2012-08-02 22:36:36 -07:00
Tim Chevalier
c2bb2f0837 When checking loop bodies and do-expr bodies, don't require the expected type to exist
If the expected type is none (due to a type error), we shouldn't fail with an ICE, but
rather, just print out another type error. Changed the do-expr type error message to
make sense in this context (see the test case for how it works).

Closes #3044.
2012-08-02 21:44:14 -07:00
Eric Holk
c9c3a49bfc Fixing a long line 2012-08-02 19:27:07 -07:00
Patrick Walton
c076d3ccc0 rustc: Translate class literals correctly if the class has a destructor 2012-08-02 18:14:50 -07:00
Patrick Walton
16a0f72f8c rustc: Throw out some more regions when normalizing types 2012-08-02 18:14:50 -07:00
Graydon Hoare
4779d2b392 De-duplicate core::hash some, refactor the traits. 2012-08-02 18:06:33 -07:00
Lindsey Kuper
65e0e30e59 Make typeck::collect aware of provided methods in traits. 2012-08-02 17:15:36 -07:00
Michael Sullivan
2fe299d1a5 Extend ast_map to know about method declarations in traits. 2012-08-02 16:02:30 -07:00
Niko Matsakis
97452c0ca1 Remove modes from map API and replace with regions.
API is (for now) mostly by value, there are options to use it by
reference if you like.  Hash and equality functions must be pure
and by reference (forward looking to the day when something
like send_map becomes the standard map).
2012-08-02 15:53:28 -07:00
Brian Anderson
b355936b4d Convert ret to return 2012-08-01 19:16:06 -07:00
Patrick Walton
4991cc5d19 rustc: Translate by-value pattern bindings 2012-08-01 15:24:11 -07:00
Lindsey Kuper
300e2b8513 Start adding infrastructure for checking trait method bodies. 2012-08-01 11:08:47 -07:00
Lindsey Kuper
d747cd724e Rename convert_class_item to convert_field. 2012-08-01 11:08:47 -07:00
Lindsey Kuper
91bd291009 Fix bad indentation. 2012-08-01 11:08:46 -07:00
Lindsey Kuper
ac4e57c640 Introduce self_info (self_ty packaged up with a node_id). 2012-08-01 11:08:46 -07:00
Lindsey Kuper
361a9b03e6 Fix inaccurate comment. 2012-08-01 11:08:46 -07:00
Niko Matsakis
a334deb5d5 change how we print and explain region types 2012-07-31 22:00:19 -07:00
Patrick Walton
b414db041b rustc: Parse by-reference pattern bindings with the "ref" keyword 2012-07-31 19:26:25 -07:00
Brian Anderson
a841789a41 rustc: Add non_camel_case_types lint check 2012-07-31 18:58:23 -07:00
Graydon Hoare
2a3084b527 Start implementing structured constants. 2012-07-31 18:34:44 -07:00
Patrick Walton
c88933d714 rustc: Implement unary move. Closes #917. 2012-07-31 17:33:20 -07:00
Brian Anderson
7b2026bf21 Introduce 'return', 'match' and 'module' as synonyms 2012-07-31 17:22:30 -07:00
Patrick Walton
2cfe8fb357 rustc: Check self types in method lookup; allow required trait methods to have self types; write self types into metadata 2012-07-31 16:35:11 -07:00
Lindsey Kuper
439afaa329 Change remaining "iface" occurrences to "trait"; deprecate "iface" 2012-07-31 11:52:16 -07:00
Graydon Hoare
290f079474 Frontend bits for #2317, general const-expr classification. 2012-07-30 19:06:06 -07:00
Paul Stansifer
a9cc5066ee Change syntax extension syntax: #m[...] -> m!{...}. 2012-07-30 18:38:15 -07:00
Paul Stansifer
e040ab8423 Impl-ize interner. 2012-07-30 18:04:19 -07:00
Lindsey Kuper
f78776e9d8 rustc: "iface" -> "trait" in comments, error messages, and identifiers.
(Also "interface" -> "trait" in error messages.)
2012-07-30 17:26:14 -07:00
Lindsey Kuper
dbd39f868b rustc: "ifce" -> "trt" in identifiers 2012-07-30 17:26:14 -07:00
Niko Matsakis
5d32d03b89 Fix #2979: inference for lifetimes of & expressions
What we now do is to create a region variable for each &
expression (and also each borrow).  The lifetime of this
variable will be checked by borrowck to ensure it is not greater
than the lifetime of the underlying data.  This both leads to
shorter lifetimes in some cases but also longer in others,
such as taking the address to the interior of unique boxes
tht are rooted in region pointers (e.g., returning a pointer
to the interior of a sendable map).

This may lead to issue #2977 if the rvalue is not POD, because
we may drop the data in trans sooner than borrowck expects us
to.  Need to work out precisely where that fix ought to occur.
2012-07-30 14:49:28 -07:00
Patrick Walton
519deca716 rustc: Make option<&foo> no longer cause LLVM asserts by getting rid of regions in normalize_ty 2012-07-30 11:28:43 -07:00
Brian Anderson
2e231fbcb7 LONG LINES\! 2012-07-30 11:26:20 -07:00
Damian Gryski
1854a736f8 rustc: use new siphash impl instead of sha1
Updating types std::sha1::sha1 -> hash::streaming was a relatively
    small change.  Renaming the variables to reflect that things aren't
    sha1s any more touched far more lines.
2012-07-30 10:46:01 -07:00
Tim Chevalier
082d8314da Rewrite bitv to use classes and optimize its representation
Rewrote bitv as a class that uses a 32-bit int as its representation
for bit vectors of 32 bits or less, and a vector (the old representation)
otherwise. I didn't benchmark very much, but a bit of informal benchmarking
suggested this is a win.

Closes #2341
2012-07-29 18:39:15 -07:00
Patrick Walton
93c2f5e0e4 rustc: Use coherence for operator overloading.
The only use of the old-style impls is now placement new.
2012-07-27 19:35:24 -07:00
Tim Chevalier
f7382c454f Forbid duplicate fields in record types and exprs
Closes #3033
2012-07-27 17:33:05 -07:00
Tim Chevalier
a0d05844ed Correctly forbid upvars in nested impls, traits and classes
Previously, resolve was allowing impls, traits or classes that were
nested within a fn to refer to upvars, as well as referring to type
parameters bound by the fn. Fixing this required adding a new kind of
def: def_typaram_binder, which can refer to any of an impl, trait or
class that has bound ty params. resolve uses this to enforce that
methods can refer to their parent item's type parameters, but not to
outer items' type parameters; other stages ignore it. I also made
sure that impl, trait and class methods get checked inside a
MethodRibKind thing so as to forbid upvars, and changed the definition
of MethodRibKind so that its second argument is an optional node_id
(so that required trait method signatures can be checked with a
MethodRibKind as well).
2012-07-27 17:31:42 -07:00
Niko Matsakis
638491712e change region inference to not consider & that appears in a fn
type as indicating region parameterization
2012-07-27 15:49:03 -07:00
Patrick Walton
01e2471cb7 core: Trait-ify various overloaded operators 2012-07-27 14:52:46 -07:00
Tim Chevalier
b6aadf56c8 In resolve, check for duplicate pattern-bound vars
Closes #3038
2012-07-27 13:35:17 -07:00
Tim Chevalier
300f54ebc0 Make alts on uninhabited enum types typecheck and translate properly
Possibly one of the silliest Rust commits ever.

Closes #3037
2012-07-27 13:14:03 -07:00
Eric Holk
6d142c5e25 Removed the rest of the vec::view calls that were marked with #2880. Fixes #2880. 2012-07-26 17:10:48 -07:00
Eric Holk
65beca4e01 Use iteration protocol for ebml, use vec::view in more places (issue #2880) 2012-07-26 17:10:48 -07:00
Graydon Hoare
dbbaa50290 Nomenclature fixes in the lint checker. Fewer double-negatives.
New style is allow(foo), warn(foo), deny(foo) and forbid(foo),
mirrored by -A foo, -W foo, -D foo and -F foo on command line.

These replace -W no-foo, -W foo, -W err-foo, respectively.

Forbid is new, and means "deny, and you can't override it".
2012-07-26 17:08:33 -07:00
Patrick Walton
afd9a75c9e rustc: Fix cross-crate max/min-class-style constructors 2012-07-26 15:30:15 -07:00
Patrick Walton
da80bd17c3 rustc: Introduce a lang_items pass, part of coherence and operator overloading.
This will also help us remove kinds.
2012-07-25 18:37:03 -07:00
Eric Holk
e1d4bd463c 3x faster typechecking 2012-07-25 18:00:29 -07:00
Eric Holk
3aee39a6ec Add #[inline(never)], and also fixed inlining on vec::push 2012-07-25 17:30:13 -07:00
Niko Matsakis
4b8d0539f9 adjust deprecated_use not to warn about sugared closures 2012-07-25 10:19:28 -07:00
Niko Matsakis
cc8086a045 add new deprecated_mode lint pass
It will warn you if you use the default mode for something that
is expensive to copy, and it will warn you if you use any explicit
mode other than copy.  So you should migrate over to using the
default mode for most things (and borrowed pointers when you don't
want to copy) and copy mode for things you really wanted to copy.
2012-07-25 09:19:02 -07:00
Niko Matsakis
99674dc52b avoid capture of bound regions when infering types for closure
expressions. cc #2981
2012-07-25 05:45:52 -07:00
Niko Matsakis
2d3a197f0e comment various region-related things better 2012-07-25 05:45:52 -07:00
Niko Matsakis
7022ede9b3 make unique pointers inherit mutability from owner 2012-07-25 05:45:52 -07:00
Niko Matsakis
168306f11b correct treatment of mutability for deref'd components
Fixes #2980
2012-07-25 05:45:52 -07:00
Patrick Walton
587b0edbbf rustc: Don't require that structs have constructors 2012-07-24 15:29:51 -07:00
Patrick Walton
32e8429341 rustc: Translate struct literals 2012-07-24 13:59:17 -07:00
Graydon Hoare
539a160bb7 Merge pull request #3003 from elliottslaughter/free-cant-fail
Don't emit invoke instructions inside landing pads.
2012-07-24 13:49:24 -07:00
Graydon Hoare
8868b222c3 Fix whitespace. 2012-07-24 13:21:25 -07:00
Graydon Hoare
a63e0e47f0 Update some str functions to slices, merge as_buf and unpack_slice. 2012-07-24 12:35:52 -07:00
Elliott Slaughter
c341eb9052 Don't emit invoke instructions inside landing pads.
We can't throw an exception from inside a landing pad without
corrupting the exception handler, so we have no hope of dealing with
these exceptions anyway. See:

http://llvm.org/docs/ExceptionHandling.html#cleanups

Part of #2861.
2012-07-24 12:20:39 -07:00
Patrick Walton
0930b95395 rustc: Typecheck struct literals 2012-07-24 11:29:07 -07:00
Patrick Walton
b3cad86a05 rustc: Resolve struct names in struct literals 2012-07-23 18:58:57 -07:00
Graydon Hoare
7680f504c2 Merge pull request #2998 from elliottslaughter/no-landing-pads
Add debug flag to turn off landing pads.
2012-07-23 16:47:35 -07:00
Patrick Walton
df4db83ed8 rustc: Max/min classes: Add struct literal syntax 2012-07-23 16:40:05 -07:00
Tim Chevalier
4806a4f120 Merge pull request #3000 from dgryski/master
Fix formatting of multiline code blocks in asm-comments
2012-07-23 14:39:08 -07:00
Damian Gryski
9b02acbc5d Fix formatting of multi-line blocks in asm-comments 2012-07-23 23:18:12 +02:00
Patrick Walton
674dd14eec rustc: Make vtables use the coherence tables 2012-07-23 13:24:05 -07:00
Elliott Slaughter
d8c75cfbe7 Add debug flag to turn off landing pads. 2012-07-23 13:07:35 -07:00
Elliott Slaughter
d257382863 Moved malloc and free upcalls into rust runtime. 2012-07-23 10:45:58 -07:00
Elliott Slaughter
de82a9be61 Move fail upcall into rust libcore. 2012-07-23 10:45:58 -07:00
Tim Chevalier
beb2cd1658 Remove what's left of resolve1 2012-07-20 17:08:19 -07:00
Niko Matsakis
f676547c97 Fix intersection of two region params in infer, cc #2962 2012-07-19 10:14:16 -07:00
Patrick Walton
f48dcaaae3 rustc: Make vtable do duplicate-impl checking. Closes #2958. 2012-07-18 18:10:00 -07:00
Tim Chevalier
3119afc6e8 In resolve3, error on non-existent imports
Closes #2937
2012-07-18 18:02:07 -07:00
Tim Chevalier
de5d5e6eeb Remove non-existent imports 2012-07-18 18:02:07 -07:00
Patrick Walton
57e8de8917 rustc: Implement multiple-traits-per-impl for cross-crate stuff 2012-07-18 17:34:59 -07:00
Patrick Walton
635a959363 rustc: Make coherence aware of multiple-traits-per-impl 2012-07-18 17:08:42 -07:00
Patrick Walton
9d34c706b2 rustc: Move ty::impl_traits over to a multiple-traits-per-impl world 2012-07-18 16:49:55 -07:00
Patrick Walton
3c583def25 rustc: Make resolve3 multiple-trait-per-impl-aware 2012-07-18 16:28:59 -07:00
Patrick Walton
3ac5b4a86f syntax: Parse multiple trait refs in a single implementation 2012-07-18 16:05:17 -07:00
Niko Matsakis
e0ea67a2a6 prevent regions from escaping in ifaces; remove &r.T syntax 2012-07-18 11:48:58 -07:00
Niko Matsakis
4ee4a2ab31 borrow from @[] vectors (cc #2797) 2012-07-17 19:16:00 -07:00
Patrick Walton
db020ab63c rustc: Implement and enforce instance coherence 2012-07-17 15:46:43 -07:00
Tim Chevalier
b5729bd600 Support attributes on class ctors and dtors
Closes #2660
2012-07-17 12:40:59 -07:00
Tim Chevalier
cf9a9d1ae8 Remove most of old resolve
resolve has a few type definitions in it that are used, so I left
those and deleted everything else. Also, I switched rustdoc to use
resolve3 instead of the old resolve.

In a future commit I'll remove the type definitions entirely, as they're
just duplicates of types defined in resolve3.
2012-07-17 12:40:58 -07:00
Niko Matsakis
0e42004bab introduce an owned kind for data that contains no borrowed ptrs 2012-07-16 20:18:18 -07:00
Niko Matsakis
748f2e0909 improve comment 2012-07-16 13:29:00 -07:00
Niko Matsakis
3ef7ff8b89 infer the scope of borrows 2012-07-14 17:37:32 -07:00
Niko Matsakis
41a21f053c remove typestate from code, tests, and docs 2012-07-14 17:37:20 -07:00
Michael Sullivan
6822ec3eb4 Treat bare vector and string literals as fixed length vecs. Closes #2922. 2012-07-14 14:30:48 -07:00
Michael Sullivan
7b2f4755f3 Get rid of ast::ty_vstore, which was only used for fixed length. 2012-07-14 12:45:52 -07:00
Michael Sullivan
d884085f43 Tear out ty_str and ty_vec. 2012-07-14 12:19:36 -07:00
Michael Sullivan
08a4440d64 Fix a bunch of deprecated str/vec errors in code for non 64-bit linux platforms... 2012-07-14 10:05:49 -07:00
Michael Sullivan
5a7d139a38 Merge branch 'vector-reform' into incoming 2012-07-14 01:03:54 -07:00
Michael Sullivan
e2af785606 Make the new world order normative. Closes #2908. 2012-07-14 01:03:44 -07:00
Michael Sullivan
92743dc2a6 Move the world over to using the new style string literals and types. Closes #2907. 2012-07-14 01:03:43 -07:00
Michael Sullivan
5c5065e8bd Don't emit strings when the destination is ignored. 2012-07-14 00:07:24 -07:00
Michael Sullivan
eaf8b7675e Warn on old strs 2012-07-13 17:59:59 -07:00
Lindsey Kuper
1ffc0720bb Add FIXME marking where the work on #2794 has gotten to, so far. 2012-07-13 17:46:24 -07:00
Lindsey Kuper
9aa8a84766 Make an error message more grammatical. 2012-07-13 17:46:24 -07:00
Michael Sullivan
985b52be6d Support prefix notation for vstore strings. Closes #2906. 2012-07-13 17:03:49 -07:00
Lindsey Kuper
7bba0ae973 Change stray cont to again in a comment. 2012-07-13 15:45:24 -07:00
Lindsey Kuper
5a63b2100e More consistent use of backticks and "expected" in error messages.
Got some of the debug messages, here, too.  I figure it doesn't hurt
to get used to doing this even in places where users won't ever see
it.
2012-07-13 15:31:39 -07:00
Tim Chevalier
07a81ad12e Refactor how impl self types are stored
In order to avoid a confusing use of the tcache, I added an extra
node ID field to trait refs. Now trait refs have a "ref ID" (the one
that resolve3 resolves) and an "impl ID" (the one that you look up
in the tcache to get the self type).

Closes #2434
2012-07-13 14:47:04 -07:00
Lindsey Kuper
fc9c4c3245 Front-end support for default impls in traits. 2012-07-13 11:16:07 -07:00
Lindsey Kuper
d5563d732d Consistently use "allowed" rather than "permitted" in error messages. 2012-07-13 11:10:18 -07:00
Niko Matsakis
a2f60651f1 add comments to region inference 2012-07-13 10:20:50 -07:00
Zack Corr
de001dd61c Change cont out of loop error to again out of loop 2012-07-14 01:24:33 +10:00
Tim Chevalier
78ec6fe30c Obliterate the callee_id hack
Exprs that could be applications of overloaded operators
(expr_unary, expr_binary, expr_index) relied on the previous node ID
being "reserved" to carry extra typechecking info. This was
incredibly error-prone. Fixed it; now all exprs have two node IDs
(which will be wasted in some cases; future work could make this
an option instead if the extra int field ends up being a performance
problem).

Closes #2804
2012-07-12 19:02:07 -07:00
Eric Holk
aba665da32 Fix the signature on vec::view.
Due to limitations in region inference, this has the effect of making vec::view pretty much entirely unusable.
2012-07-12 18:16:00 -07:00
Brian Anderson
dac4916cec rustc: Resolve bounds of trait type parameters 2012-07-12 18:04:40 -07:00
Michael Sullivan
c84c4a8d71 Handle str/~ in patterns. 2012-07-12 16:52:26 -07:00
Michael Sullivan
2ea9c8df0f Accept prefix notation for writing the types of str/~ and friends. 2012-07-12 16:52:26 -07:00
Brian Anderson
46fba10fe8 rustc: Make all impls even more reachable
With this we write metadata for all impls so that we can properly find
reexported impls.
2012-07-12 15:09:33 -07:00
Michael Sullivan
9d2e5f3a65 Merge branch 'rt-changes' into incoming 2012-07-12 15:03:54 -07:00
Michael Sullivan
7b26503566 Make str be treated as str/~. 2012-07-12 00:21:04 -07:00
Michael Sullivan
b569bdec9f Refactor how we convert vstore ast types to ty types. 2012-07-12 00:12:13 -07:00
Niko Matsakis
b9aa9def85 infer when types are region parameterized rather than requiring /&
- removes various fields from various variants in the AST
- also update tests not to use this notation
2012-07-11 14:41:41 -07:00
Niko Matsakis
9b094c0baf new option to note where purity is req'd 2012-07-11 14:41:41 -07:00
Niko Matsakis
668285b9c8 add ability to report statistics about how borrowck is being used 2012-07-11 14:41:41 -07:00
Patrick Walton
9b7d9a9a1b rustc: Treat existential traits as base types for coherence purposes 2012-07-11 14:28:03 -07:00
Michael Sullivan
62e9ae04e2 Remove obsolete type param field from shape information. 2012-07-11 11:42:49 -07:00
Michael Sullivan
120773b2a7 Change the interface of placement new to take a tydesc as part of Issue #2831. 2012-07-11 11:42:49 -07:00