Commit Graph

1356 Commits

Author SHA1 Message Date
Erick Tryzelaar
74807b1594 syntax: match variants use 4 space indent by default 2013-04-10 16:08:22 -07:00
Brian Anderson
23e44a529b Bump version to 0.7-pre 2013-04-10 13:12:53 -07:00
John Clements
9deb2f2dfa libsyntax comments only 2013-04-10 09:15:08 -07:00
John Clements
09bcd3837c unneccessary since tjc's commit 78ec6fe30c, fixing #2804 2013-04-10 09:15:08 -07:00
John Clements
27700472b9 removed eval.rs: dead code
@brson confirms that eval.rs is now dead code
2013-04-10 09:15:08 -07:00
John Clements
48e7bda826 path -> Path 2013-04-10 09:15:04 -07:00
bors
92e265cdea auto merge of #5802 : nikomatsakis/rust/issue-4183-trait-substs, r=nikomatsakis
Cleanup substitutions and treatment of generics around traits in a number of ways

- In a TraitRef, use the self type consistently to refer to the Self type:
  - trait ref in `impl Trait<A,B,C> for S` has a self type of `S`.
  - trait ref in `A:Trait` has the self type `A`
  - trait ref associated with a trait decl has self type `Self`
  - trait ref associated with a supertype has self type `Self`
  - trait ref in an object type `@Trait` has no self type

- Rewrite `each_bound_traits_and_supertraits` to perform
  substitutions as it goes, and thus yield a series of trait refs
  that are always in the same 'namespace' as the type parameter
  bound given as input.  Before, we left this to the caller, but
  this doesn't work because the caller lacks adequare information
  to perform the type substitutions correctly.

- For provided methods, substitute the generics involved in the provided
  method correctly.

- Introduce TypeParameterDef, which tracks the bounds declared on a type
  parameter and brings them together with the def_id and (in the future)
  other information (maybe even the parameter's name!).

- Introduce Subst trait, which helps to cleanup a lot of the
  repetitive code involved with doing type substitution.

- Introduce Repr trait, which makes debug printouts far more convenient.

Fixes #4183.  Needed for #5656.

r? @catamorphism
2013-04-09 17:12:58 -07:00
Brian Anderson
23251b2438 Bump version to 0.7-pre 2013-04-09 10:59:32 -07:00
Niko Matsakis
9963bd2413 Cleanup substitutions and treatment of generics around traits in a number of ways.
- In a TraitRef, use the self type consistently to refer to the Self type:
  - trait ref in `impl Trait<A,B,C> for S` has a self type of `S`.
  - trait ref in `A:Trait` has the self type `A`
  - trait ref associated with a trait decl has self type `Self`
  - trait ref associated with a supertype has self type `Self`
  - trait ref in an object type `@Trait` has no self type

- Rewrite `each_bound_traits_and_supertraits` to perform
  substitutions as it goes, and thus yield a series of trait refs
  that are always in the same 'namespace' as the type parameter
  bound given as input.  Before, we left this to the caller, but
  this doesn't work because the caller lacks adequare information
  to perform the type substitutions correctly.

- For provided methods, substitute the generics involved in the provided
  method correctly.

- Introduce TypeParameterDef, which tracks the bounds declared on a type
  parameter and brings them together with the def_id and (in the future)
  other information (maybe even the parameter's name!).

- Introduce Subst trait, which helps to cleanup a lot of the
  repetitive code involved with doing type substitution.

- Introduce Repr trait, which makes debug printouts far more convenient.

Fixes #4183.  Needed for #5656.
2013-04-09 08:06:10 -07:00
bors
30dbbe17c9 auto merge of #5787 : alexcrichton/rust/less-mut-fields, r=catamorphism
This removes some of the easier instances of mutable fields where the explicit self can just become `&mut self` along with removing some unsafe blocks which aren't necessary any more now that purity is gone.

Most of #4568 is done, except for [one case](https://github.com/alexcrichton/rust/blob/less-mut-fields/src/libcore/vec.rs#L1754) where it looks like it has to do with it being a `const` vector. Removing the unsafe block yields:

```
/Users/alex/code/rust2/src/libcore/vec.rs:1755:12: 1755:16 error: illegal borrow unless pure: creating immutable alias to const vec content
/Users/alex/code/rust2/src/libcore/vec.rs:1755         for self.each |e| {
                                                           ^~~~
/Users/alex/code/rust2/src/libcore/vec.rs:1757:8: 1757:9 note: impure due to access to impure function
/Users/alex/code/rust2/src/libcore/vec.rs:1757         }
                                                       ^
error: aborting due to previous error
```

I also didn't delve too much into removing mutable fields with `Cell` or `transmute` and friends.
2013-04-08 18:36:57 -07:00
Alex Crichton
255193cc1a Removing no longer needed unsafe blocks 2013-04-08 17:50:25 -04:00
Huon Wilson
0c2ceb1a2e libsyntax: fail lexing with an error message on an int literal larger than 2^64.
Stops an ICE.

Closes #5544.
2013-04-08 16:40:40 +10:00
Niko Matsakis
2a44a1bd97 Fix various warnings, NOTEs, etc 2013-04-05 05:36:03 -04:00
Niko Matsakis
d28f734412 Refactor so that references to traits are not represented using a type with a
bare function store (which is not in fact a kind of value) but rather
ty::TraitRef.  Removes many uses of fail!() and other telltale signs of
type-semantic mismatch.

cc #4183 (not a fix, but related)
2013-04-05 05:36:02 -04:00
Niko Matsakis
569596573a Compute a ty::method for methods that appear in impls as well 2013-04-05 05:36:02 -04:00
Niko Matsakis
007abe9352 Rather than storing a list of ty::method per trait, store one ty::method
per method and list of def-ids per trait.
2013-04-05 05:36:02 -04:00
bors
5b933aeba2 auto merge of #5696 : thestinger/rust/hashmap, r=sanxiyn
This naming is free now that `oldmap` has finally been removed, so this is a search-and-replace to take advantage of that. It might as well be called `HashMap` instead of being named after the specific implementation, since there's only one.

SipHash distributes keys so well that I don't think there will ever be much need to use anything but a simple hash table with open addressing. If there *is* a better way to do it, it will probably be better in all cases and can just be the default implementation. 

A cuckoo-hashing implementation combining a weaker hash with SipHash could be useful, but that won't be as general purpose - you would need to write a separate fast hash function specialized for the type to really take advantage of it (like taking a page from libstdc++/libc++ and just using the integer value as the "hash"). I think a more specific naming for a truly alternative implementation like that would be fine, with the nice naming reserved for the general purpose container.
2013-04-03 14:04:07 -07:00
bors
6153aae809 auto merge of #5559 : jbclements/rust/change-to-tt-based-parsing, r=jbclements
Changes the parser to parse all streams into token-trees before hitting the parser proper, in preparation for hygiene.  As an added bonus, it appears to speed up the parser (albeit by a totally imperceptible 1%).

Also, many comments in the parser.
Also, field renaming in token-trees (readme->forest, cur->stack).
2013-04-03 11:31:03 -07:00
Daniel Micay
cc148b58ff rename Linear{Map,Set} => Hash{Map,Set} 2013-04-03 10:30:36 -04:00
Daniel Micay
44029a5bbc hashmap: rm linear namespace 2013-04-03 10:30:18 -04:00
Brian Anderson
e3327d3833 Fix warnings 2013-03-31 20:22:47 -07:00
Luqman Aden
02700e0e8d libsyntax: Update abi constants. Fixes #5423. 2013-03-30 19:28:50 -07:00
bors
6dd20c8186 auto merge of #5630 : erickt/rust/serial, r=erickt
@nikomatsakis and I were talking about how the serializers were a bit too complicated. None of the users of With the `emit_option` and `read_option` functions, the serializers are now moving more high level. This patch series continues that trend. I've removed support for emitting specific string and vec types, and added support for emitting mapping types.
2013-03-30 15:42:43 -07:00
Erick Tryzelaar
f364cf5463 syntax: fix auto_encode test. 2013-03-30 13:24:52 -07:00
Niko Matsakis
6965fe4bce Add AbiSet and integrate it into the AST.
I believe this patch incorporates all expected syntax changes from extern
function reform (#3678). You can now write things like:

    extern "<abi>" fn foo(s: S) -> T { ... }
    extern "<abi>" mod { ... }
    extern "<abi>" fn(S) -> T

The ABI for foreign functions is taken from this syntax (rather than from an
annotation).  We support the full ABI specification I described on the mailing
list.  The correct ABI is chosen based on the target architecture.

Calls by pointer to C functions are not yet supported, and the Rust type of
crust fns is still *u8.
2013-03-29 18:36:20 -07:00
Erick Tryzelaar
0de7635f53 Merge remote-tracking branch 'remotes/origin/incoming' into serial 2013-03-29 17:48:44 -07:00
Erick Tryzelaar
529ae38605 Merge remote-tracking branch 'remotes/origin/incoming' into serial 2013-03-29 17:41:32 -07:00
Patrick Walton
1e91595520 librustc: Remove fail_unless! 2013-03-29 16:39:08 -07:00
John Clements
f2e47cddf8 change to parsing using tts
also, updates test cases a bit
2013-03-29 10:53:00 -07:00
John Clements
556143c488 commenting parser 2013-03-29 10:53:00 -07:00
John Clements
2b07f0fb00 field renaming 2013-03-29 10:53:00 -07:00
Erick Tryzelaar
31563f53d9 Merge remote-tracking branch 'remotes/origin/incoming' into serial 2013-03-29 09:06:36 -07:00
Erick Tryzelaar
d1a83e6986 std: add Encoder::emit_map and Decoder::read_map 2013-03-29 09:04:35 -07:00
Erick Tryzelaar
90b3658cd6 std: remove Encoder::read_rec and Decoder::emit_rec 2013-03-29 07:05:54 -07:00
Erick Tryzelaar
e99cdcfba8 std: remove Encoder::emit_tup{,_elt} and Decoder::read_tup{,_elt} 2013-03-29 07:05:54 -07:00
Erick Tryzelaar
590bbcebe9 std: remove Encoder::emit_{owned,managed}_vec and Decoder::read_{owned,managed}_vec 2013-03-29 07:05:54 -07:00
Erick Tryzelaar
63fc88757f std: remove Encoder::emit_{owned,managed} and Decoder::read_{owned,managed} 2013-03-29 07:05:54 -07:00
Erick Tryzelaar
8b43c620b9 std: remove Encoder::emit_{owned,managed}_str and Decoder::read_{owned,managed}_str 2013-03-29 07:05:54 -07:00
bors
5da9e12778 auto merge of #5570 : alexcrichton/rust/fix-unused-imports, r=sanxiyn
Before it wouldn't warn about unused imports in the list if something in the list was used. These commits fix that case, add a test, and remove all unused imports in lists of imports throughout the compiler.
2013-03-29 05:57:44 -07:00
bors
a985bc52cd auto merge of #5616 : pcwalton/rust/parenthesized-trait, r=brson
r? @brson
2013-03-28 23:00:50 -07:00
Alex Crichton
be57d745d2 Removing unused imports 2013-03-28 23:56:46 -04:00
Patrick Walton
36909c7575 libsyntax: Don't allow impl (Trait) for Type (with the parentheses). 2013-03-28 18:56:36 -07:00
bors
f81459211d auto merge of #5593 : luqmana/rust/inline-asm, r=catamorphism
Clean things up a bit. Also, allow selecting intel syntax in addition to the default AT&T dialect.
2013-03-28 18:18:46 -07:00
Patrick Walton
0a002d79b4 librustc: Remove common fields and nested enums from the language 2013-03-28 11:30:01 -07:00
bors
09dc38eda5 auto merge of #5596 : luqmana/rust/unit-struct, r=catamorphism
Fixes #5449.
2013-03-28 06:12:47 -07:00
bors
d31053277a auto merge of #5586 : pcwalton/rust/expr-repeat-vstore, r=graydon
r? @graydon
2013-03-28 01:33:48 -07:00
bors
84ddff3909 auto merge of #5578 : erickt/rust/incoming, r=jbclements,erickt
Hey folks,

This patch series does some work on the json decoder, specifically with auto decoding of enums. Previously, we would take this code:

```
enum A {
    B,
    C(~str, uint)
}
```

and would encode a value of this enum to either `["B", []]` or `["C", ["D", 123]]`. I've changed this to `"B"` or `["C", "D", 123]`. This matches the style of the O'Caml json library [json-wheel](http://mjambon.com/json-wheel.html). I've added tests to make sure all this work.

In order to make this change, I added passing a `&[&str]` vec to `Decode::emit_enum_variant` so the json decoder can convert the name of a variant into it's position. I also changed the impl of `Encodable` for `Option<T>` to have the right upper casing.

I also did some work on the parser, which allows for `fn foo<T: ::cmp::Eq>() { ... }` statements (#5572), fixed the pretty printer properly expanding `debug!("...")` expressions, and removed `ast::expr_vstore_fixed`, which doesn't appear to be used anymore.
2013-03-27 21:51:53 -07:00
Andrew Paseltiner
f02ee42a86 derive Eq and Clone impls where applicable 2013-03-27 22:04:23 -04:00
Luqman Aden
09255dbe2d libsyntax: error on struct Foo {}. 2013-03-27 18:17:58 -07:00
Luqman Aden
b867fe41de libsyntax: Allow selecting intel style asm. 2013-03-27 15:41:58 -07:00
Luqman Aden
203d691a6b libsyntax: use a struct for inline asm in ast. 2013-03-27 15:41:58 -07:00
Patrick Walton
e5dda811a9 librustc: Allow expr_repeat to be used with any vstore 2013-03-27 13:53:03 -07:00
bors
995425badb auto merge of #5558 : nikomatsakis/rust/issue-4920-autoref-index-operator, r=nikomatsakis
Per discussion on IRC.

r? @pcwalton
2013-03-27 13:27:58 -07:00
Niko Matsakis
2a74fda316 Fix pretty-printer test failure by carrying the bound lifetime names through
the types.  Initially I thought it would be necessary to thread this data
through not only the AST but the types themselves, but then I remembered that
the pretty printer only cares about the AST.  Regardless, I have elected to
leave the changes to the types intact since they will eventually be needed.  I
left a few FIXMEs where it didn't seem worth finishing up since the code wasn't
crucial yet.
2013-03-27 11:35:04 -07:00
Erick Tryzelaar
83e831bc22 syntax: Remove deprecated expr_vstore_fixed 2013-03-27 07:04:16 -07:00
Erick Tryzelaar
7a199d41a9 syntax: fix pretty printing __log stmts 2013-03-27 07:04:15 -07:00
Erick Tryzelaar
2e0b363a7f syntax: Remove dead code from the parser 2013-03-27 07:04:15 -07:00
Erick Tryzelaar
b26ae289d0 syntax: Fix parsing global generics (Closes #5572) 2013-03-27 07:04:14 -07:00
Erick Tryzelaar
4d6dcefcbb std: Decode::read_enum_variant should pass in the variant names
Because the json::Decoder uses the string variant name, we need a
way to correlate the string to the enum index. This passes in a
static &[&str] to read_enum_variant, which allows the json::Decoder
to know which branch it's trying to process.
2013-03-27 07:04:13 -07:00
Erick Tryzelaar
478e4498b7 std: add option type directly to serialize::{En,De}code 2013-03-27 07:04:12 -07:00
Erick Tryzelaar
4d995e66a2 std: change default json enum encoder to use strings or a flat vec 2013-03-27 07:04:12 -07:00
Erick Tryzelaar
b10b8c3ee4 std: Add tests for json decoding options 2013-03-27 07:04:11 -07:00
Erick Tryzelaar
bd77e9433f syntax: pass some values around by reference 2013-03-27 07:01:45 -07:00
Erick Tryzelaar
2f1ab3a7fa syntax: Add new values that can be used with the quasiquoter 2013-03-27 06:49:39 -07:00
Niko Matsakis
2c17ff7dbc Simplify and remove unnecessary use of ast_map 2013-03-27 07:10:04 -04:00
Niko Matsakis
aa67deff33 remove sty_by_ref, though traces still remain due to dtors 2013-03-27 07:09:16 -04:00
Patrick Walton
0a4d0f37ca librustc: Enforce that extern mod directives come first, then use directives, then items.
Resolve them in this order as well.
2013-03-26 21:30:17 -07:00
Patrick Walton
8b56a8380b librustc: Modify all code to use new lifetime binder syntax 2013-03-26 21:30:17 -07:00
Patrick Walton
a376f46862 librustc: Stop parsing [T * N]. 2013-03-26 21:29:35 -07:00
Patrick Walton
142dbd65da librustc: Remove all uses of the old [T * N] fixed-length vector syntax 2013-03-26 21:29:34 -07:00
Patrick Walton
46d4cc12d1 libsyntax: Stop parsing [const T]. 2013-03-26 21:29:34 -07:00
Daniel Micay
34c5a09ce3 option: rm functions that duplicate methods 2013-03-26 22:44:40 -04:00
Alex Crichton
dbe1354321 Move ast_map::map to LinearMap 2013-03-26 19:21:05 -04:00
Alex Crichton
e4c3d805a4 syntax: Removing uses of HashMap 2013-03-26 19:20:02 -04:00
Alex Crichton
fa7772893a Remove unused imports throughout 2013-03-26 19:20:02 -04:00
bors
3d588c5286 auto merge of #5555 : Kimundi/rust/str-dealloc-3, r=catamorphism
- Most functions that used to return `~[~str]` for a list of substrings got turned into iterators over `&str` slices
- Some cleanup of apis, docs and code layout
2013-03-26 15:07:07 -07:00
Niko Matsakis
e11d13f3de Rip out old code that still structured method calls as a
expr_call(expr_field(...)) rather than an expr_method_call.
There is probably more such code in trans that should be removed.
2013-03-26 15:16:58 -04:00
Marvin Löbel
b9de2b5787 Switched over a bunch of splitting funktions to non-allocating iterators 2013-03-26 14:59:17 +01:00
Seo Sanghyeon
585c57234f rustdoc: Show purity 2013-03-25 15:02:42 +09:00
Patrick Walton
8aee0a6a29 libsyntax: Fix static in pretty printer. rs=burningtree 2013-03-23 10:28:24 -07:00
Patrick Walton
e2fde83ce4 libsyntax: Stop parsing old lifetime syntax 2013-03-22 22:24:36 -07:00
Patrick Walton
6d81307a9b librustc: Add explicit lifetime binders and new lifetime notation in core/std/syntax/rustc 2013-03-22 22:24:35 -07:00
Patrick Walton
68cb53672b libsyntax: Stop parsing const. 2013-03-22 22:24:35 -07:00
Patrick Walton
85c9fc6f8f librustc: Remove the const declaration form everywhere 2013-03-22 22:24:35 -07:00
Patrick Walton
eba3367404 libsyntax: Introduce the new assert! macro; make assert no longer a keyword 2013-03-22 22:24:34 -07:00
Patrick Walton
fa70709e07 libsyntax: Stop parsing pure and static 2013-03-22 22:24:33 -07:00
bors
e9b077c0e9 auto merge of #5488 : pcwalton/rust/depure, r=pcwalton 2013-03-22 13:00:56 -07:00
Patrick Walton
e7c60c141b librustc: Remove pure from libsyntax and librustc. 2013-03-22 12:57:27 -07:00
bors
b6f9aa1fd7 auto merge of #5483 : pcwalton/rust/static-syntax, r=graydon
r? @nikomatsakis
2013-03-22 11:21:48 -07:00
Patrick Walton
4634f7edae librustc: Remove all uses of static from functions. rs=destatic 2013-03-22 10:27:39 -07:00
Alex Crichton
e93654c96d Pass the fmt! buffer to each conversion method
Achieves a little more speedup and avoids allocations around some strings in
conv_str
2013-03-22 11:49:45 -04:00
Alex Crichton
1a0d212dd9 Build up the result of fmt! in a buffer instead of a vector 2013-03-22 11:49:45 -04:00
Andrew Paseltiner
999e7ef9a9 syntax: make old #[deriving_foo] attribute obsolete 2013-03-22 07:15:13 -04:00
Andrew Paseltiner
e2abecd3ab syntax: replace uses of old deriving attribute with new one 2013-03-22 06:30:59 -04:00
bors
d52408d46a auto merge of #5480 : pcwalton/rust/at-const, r=pcwalton
r? @catamorphism
2013-03-21 20:39:51 -07:00
bors
5f2d4102c5 auto merge of #5479 : Kimundi/rust/str-dealloc, r=z0w0
This makes the `trim` and `substr` functions return a slice instead of an `~str`, and removes the unnecessary `Trimmable` trait (`StrSlice` already contains the same functionality).

Also moves the `ToStr` implementations for the three str types into the str module in anticipation of further untangling.
2013-03-21 19:39:53 -07:00
Patrick Walton
94327d00c6 librustc: Replace the &static bound with 'static 2013-03-21 17:31:35 -07:00
Patrick Walton
02c49b32ca libsyntax: Remove @const from the language 2013-03-21 17:31:35 -07:00
Patrick Walton
d4fee24c7c librustc: Forbid destructors from being attached to any structs that might contain non-Owned fields. r=nmatsakis 2013-03-21 17:31:34 -07:00
bors
ec8345b18a auto merge of #5407 : jbclements/rust/add-assert-eq-macro, r=jbclements
Adds an assert_eq! macro that asserts that its two arguments are equal. Error messages can therefore be somewhat more informative than a simple assert, because the error message includes "expected" and "given" values.
2013-03-21 15:24:54 -07:00
Marvin Löbel
0a47cd5ef1 Un-renamed trim and substr functions. 2013-03-21 23:06:05 +01:00
Marvin Löbel
ee2f3d9673 Switched over substr and trim functions in str to be non-allocating, temporary renamed them to better track use-sites 2013-03-21 23:06:04 +01:00
Marvin Löbel
9d9a209e9a back-renamed slice_DBG_BRWD, slice_V_DBG_BRWD -> slice, slice_DBG_UNIQ -> slice_unique 2013-03-21 14:05:57 +01:00
Marvin Löbel
a7d296f24c renamed str::view -> slice_DBG_BRWD
renamed str::slice -> slice_DBG_UNIQ
changed vec slice method -> to_owned()
renamed vec view method  -> slice_V_DBG_BRWD
2013-03-21 01:50:32 +01:00
John Clements
3cd65c233d change some uses of fail_unless to assert_eq 2013-03-20 16:05:59 -07:00
Patrick Walton
9c4d804cfe libsyntax: Never use ::<> in the type grammar 2013-03-20 13:54:25 -07:00
John Clements
ab8e46b066 add assert_eq! macro
the assert_eq! macro compares its arguments and fails if they're not
equal. It's more informative than fail_unless!, because it explicitly
writes the given and expected arguments on failure.
2013-03-20 13:27:45 -07:00
bors
63a292fd86 auto merge of #5434 : apasel422/rust/deriving, r=nikomatsakis
This is the first step in refactoring the deriving code in libsyntax. No code is changed, just rearranged.
2013-03-20 06:45:51 -07:00
Niko Matsakis
00f97b9fb0 Refactor the self-info so that the def-id is carried in ty_self()
and the fn_ctxt doesn't need any self_info field at all.

Step towards fixing `fn(&self)` (cc #4846) to have a distinct
lifetime.
2013-03-20 06:14:53 -04:00
bors
db4dc1ffe2 auto merge of #5443 : alexcrichton/rust/less-bad-copy, r=catamorphism
Removes a lot of instances of `/*bad*/ copy` throughout libsyntax/librustc. On the plus side, this shaves about 2s off of the runtime when compiling `librustc` with optimizations.

Ideally I would have run a profiler to figure out which copies are the most critical to remove, but in reality there was a liberal amount of `git grep`s along with some spot checking and removing the easy ones.
2013-03-20 00:09:47 -07:00
bors
f3c879fdd8 auto merge of #5442 : pcwalton/rust/extern-block-restriction, r=pcwalton
r? @graydon
2013-03-19 21:57:49 -07:00
Alex Crichton
cd7f3ad22e syntax: Removing some bad copies 2013-03-20 00:33:15 -04:00
Patrick Walton
e6f53c091e libsyntax: Forbid use (and most other things) within extern { ... } blocks 2013-03-19 18:00:18 -07:00
Andrew Paseltiner
3042321b3b syntax: split deriving module into submodules for each trait 2013-03-19 18:44:41 -04:00
bors
bc211f5032 auto merge of #5436 : alexcrichton/rust/assert-message, r=pcwalton
This would close #2761. I figured that if you're supplying your own custom message, you probably don't mind the stringification of the condition to not be in the message.
2013-03-19 15:43:02 -07:00
Andrew Paseltiner
18a594f49a syntax: move ext/deriving.rs to ext/deriving/mod.rs 2013-03-19 18:41:19 -04:00
Patrick Walton
b0bea10898 libsyntax: Accept the new [T, ..N] style for vec. 2013-03-19 15:40:04 -07:00
Patrick Walton
049e1f9a1f libsyntax: Accept static instead of const for globals 2013-03-19 14:46:27 -07:00
Patrick Walton
2e7ec80bcc librustc: Enforce privacy for static methods.
This starts moving a bunch of privacy checks into the privacy
checking phase and out of resolve.
2013-03-19 13:40:48 -07:00
bors
e1888948c6 auto merge of #5426 : nikomatsakis/rust/issue-4846-lifetimes-in-expl-self, r=pcwalton
(this will be needed for snapshotting at some point)

r? @pcwalton
2013-03-19 12:43:14 -07:00
Alex Crichton
14df844744 Allow custom messages on assert statements 2013-03-19 14:07:00 -04:00
bors
58209910bd auto merge of #5433 : lucab/rust/lucab/cfgspec, r=graydon
All current meta items types (word, name-value, list) are now
properly parsed by rustc --cfg command line. Fixes #2399
2013-03-19 10:43:24 -07:00
Luca Bruno
0a34a3f0f5 Make driver::driver::parse_cfgspecs parse any variety of meta_item
All current meta items types (word, name-value, list) are now
properly parsed by rustc --cfg command line. Fixes #2399

Signed-off-by: Luca Bruno <lucab@debian.org>
2013-03-19 14:02:59 +01:00
Luqman Aden
da64994f18 Fix pretty printer for fixed length vectors. 2013-03-18 17:31:42 -07:00
Luqman Aden
787f5bb0db Now actually allow using constants in those constant expressions for [T * n]. 2013-03-18 17:31:41 -07:00
Luqman Aden
42f95d055c Allow constant expressions in [Type * n]. 2013-03-18 17:31:41 -07:00
Patrick Walton
e78f2e2ac5 librustc: Make the compiler ignore purity.
For bootstrapping purposes, this commit does not remove all uses of
the keyword "pure" -- doing so would cause the compiler to no longer
bootstrap due to some syntax extensions ("deriving" in particular).
Instead, it makes the compiler ignore "pure". Post-snapshot, we can
remove "pure" from the language.

There are quite a few (~100) borrow check errors that were essentially
all the result of mutable fields or partial borrows of `@mut`. Per
discussions with Niko I think we want to allow partial borrows of
`@mut` but detect obvious footguns. We should also improve the error
message when `@mut` is erroneously reborrowed.
2013-03-18 17:21:16 -07:00
Patrick Walton
c4db4faefa libsyntax: Stop parsing old lifetimes, except for the ones on data type declarations. 2013-03-18 17:21:15 -07:00
Patrick Walton
352c070365 librustc: Convert all uses of old lifetime notation to new lifetime notation. rs=delifetiming 2013-03-18 17:21:14 -07:00
Niko Matsakis
a6187c62e9 Make &self permit explicit lifetimes, but don't really use them
(this will be needed for snapshotting at some point).
2013-03-18 15:03:37 -04:00
bors
f54adca7c9 auto merge of #5374 : z0w0/rust/rustdoc-explicit-self, r=z0w0 2013-03-16 18:57:43 -07:00
Zack Corr
d597a19b30 syntax: Fix fun_to_str test 2013-03-16 17:36:39 +10:00
bors
dc5ad5070d auto merge of #5359 : luqmana/rust/inline-asm, r=pcwalton
Continuation of #5317. Actually use operands properly now, including any number of output operands.

Which means you can do things like call printf:
```Rust
fn main() {
    unsafe {
        do str::as_c_str(~"The answer is %d.\n") |c| {
            let a = 42;
            asm!("mov $0, %rdi\n\t\
                  mov $1, %rsi\n\t\
                  xorl %eax, %eax\n\t\
                  call _printf"
                 :
                 : "r"(c), "r"(a)
                 : "rdi", "rsi", "eax"
                 : "volatile","alignstack"
                 );
        }
    }
}
```

```
% rustc foo.rs
% ./foo
The answer is 42.
```

Or just add 2 numbers:
```Rust
fn add(a: int, b: int) -> int {
    let mut c = 0;
    unsafe {
        asm!("add $2, $0"
             : "=r"(c)
             : "0"(a), "r"(b)
             );
    }
    c
}

fn main() {
    io::println(fmt!("%d", add(1, 2)));
}
```

```
% rustc foo.rs
% ./foo
3
```

Multiple outputs!
```Rust
fn addsub(a: int, b: int) -> (int, int) {
    let mut c = 0;
    let mut d = 0;
    unsafe {
        asm!("add $4, $0\n\t\
              sub $4, $1"
             : "=r"(c), "=r"(d)
             : "0"(a), "1"(a), "r"(b)
             );
    }
    (c, d)
}

fn main() {
    io::println(fmt!("%?", addsub(5, 1)));
}
```
```
% rustc foo.rs
% ./foo
(6, 4)
```

This also classifies inline asm as RvalueStmtExpr instead of the somewhat arbitrary kind I made it initially. There are a few XXX's regarding what to do in the liveness and move passes.
2013-03-15 21:15:46 -07:00
bors
6f1e8ef71a auto merge of #5404 : bstrie/rust/decopy, r=pcwalton
Also turn `copy` into `.clone()` in much of run-pass.
2013-03-15 20:15:44 -07:00
Luqman Aden
83f2d4ab3d Fix type_use for inline asm. 2013-03-15 18:57:19 -07:00
Luqman Aden
3d56936be3 Tidy. 2013-03-15 18:55:44 -07:00
Luqman Aden
9ead7dad93 Implicitly use addr_of for output operands in asm. 2013-03-15 18:55:44 -07:00
Luqman Aden
6d078db952 Actually pass inline asm operands around. 2013-03-15 18:55:43 -07:00
Ben Striegel
748c2c9ebc impl Clone for ~T, ~[T], ~str 2013-03-15 18:26:59 -04:00
John Clements
4bd26481c4 Update test case to conform to new restrictions on casting 2013-03-15 09:17:49 -07:00
John Clements
b5ace4df45 Test case fixup (old one tested the old bad behavior). 2013-03-15 08:44:21 -07:00
John Clements
fdf8543cf6 add nonempty encoding for spans
Before this change, encoding an object containing a codemap::span
using the JSON encodeng produced invalid JSON, for instance:
[{"span":,"global":false,"idents":["abc"]}]
Since the decoder for codemap::span's ignores its argument, I
conjecture that this will not damage decoding, and should improve
it for many decoders.
2013-03-15 08:44:21 -07:00
Zack Corr
4f238503d8 rustdoc: Document explicit self in methods. Closes #5254 2013-03-14 16:43:17 +10:00
Patrick Walton
50d99e0194 libsyntax: Remove a use of deprecated Encodable from libsyntax. rs=burningtree 2013-03-13 21:54:51 -07:00
Patrick Walton
58f248d923 test: Fix tests. rs=tests 2013-03-13 20:08:35 -07:00
Patrick Walton
2ccc6e0a57 librustc: Don't require the "static" keyword to define a static method 2013-03-13 20:07:11 -07:00
Patrick Walton
8fa66e8e07 librustc: Remove implicit self from the language, except for old-style drop blocks. 2013-03-13 20:07:10 -07:00
Patrick Walton
a410652bc9 librustc: Remove "base types" from the language. 2013-03-13 20:07:09 -07:00
Patrick Walton
b85158e23a librustc: Remove overloaded operator autoderef. 2013-03-13 20:07:09 -07:00
Patrick Walton
b1c699815d librustc: Don't accept as Trait anymore; fix all occurrences of it. 2013-03-13 20:07:09 -07:00
Niko Matsakis
852619d5d7 Remove ++ mode from the compiler (it is parsed as + mode)
and obsolete `-` mode altogether (it *was* parsed as `+` mode).
2013-03-13 17:00:09 -04:00
bors
695e9fd13c auto merge of #5293 : brson/rust/logging, r=brson
r? @graydon

This removes `log` from the language. Because we can't quite implement it as a syntax extension (probably need globals at the least) it simply renames the keyword to `__log` and hides it behind macros.

After this the only way to log is with `debug!`, `info!`, etc. I figure that if there is demand for `log!` we can add it back later.

I am not sure that we ever agreed on this course of action, though I *think* there is consensus that `log` shouldn't be a statement.
2013-03-13 10:40:07 -07:00
bors
a9643d39f8 auto merge of #5320 : apasel422/rust/metaderive, r=graydon
This is the first in a series of patches I'm working on to clean up the code related to `deriving`. This patch allows

```
#[deriving_eq]
#[deriving_iter_bytes]
#[deriving_clone]
struct Foo { bar: uint }
```
to be replaced with:
```
#[deriving(Eq, IterBytes, Clone)]
struct Foo { bar: uint }
```
It leaves the old attributes alone for the time being.

Eventually I'd like to incorporate the new closest-match-suggestion infrastructure for mistyped trait names, and also pass the sub-attributes to the deriving code, so that the following will be possible:
```
#[deriving(TotalOrd(qux, bar))]
struct Foo { bar: uint, baz: char, qux: int }
```
This says to derive an `impl` in which the objects' `qux` fields are compared first, followed by `bar`, while `baz` is ignored in the comparison. If no fields are specified explicitly, all fields will be compared in the order they're defined in the `struct`. This might also be useful for `Eq`. Coming soon.
2013-03-12 10:09:55 -07:00
Andrew Paseltiner
24efea7208 syntax: implement #[deriving] meta-attribute 2013-03-12 12:52:39 -04:00
Luqman Aden
18b71a7831 Add alignstack option for inline asm. 2013-03-12 01:03:35 -07:00
Luqman Aden
7f500ab4c1 Keep everything tidy. 2013-03-12 01:03:34 -07:00
Luqman Aden
5aa734d6a1 Parse operands properly and add a way to indicate volatile asm. 2013-03-12 01:03:34 -07:00
Luqman Aden
885d0d3d33 Stop parsing __asm__. 2013-03-12 01:03:34 -07:00
Luqman Aden
666e1b4636 Create asm! syntax extension. 2013-03-12 01:03:34 -07:00
Luqman Aden
ecccc0d649 Parse inline assembly. 2013-03-12 01:03:34 -07:00
Brian Anderson
9c7e16e48d Remove the log keyword (by renaming it to __log)
We can't quite remove logging from the language, but this hides the
keyword.
2013-03-11 23:19:42 -07:00
Brian Anderson
cb37d09f50 core: Remove logging constants 2013-03-11 23:19:42 -07:00
Brian Anderson
82f190355b Remove uses of log 2013-03-11 23:19:42 -07:00
bors
9b9ffd5b41 auto merge of #5304 : jld/rust/const-adjustments, r=graydon
These changes make const translation use adjustments (autodereference, autoreference, bare-fn-to-closure), like normal code does, replacing some ad-hoc logic that wasn't always right.

As a convenient side-effect, explicit dereference (both of pointers and of newtypes) is also supported in const expressions.

There is also a “bonus fix” for a bug in the pretty-printer exposed by one of the added tests.
2013-03-11 21:12:43 -07:00
Patrick Walton
08c840205e librustc: Lint the old drop destructor notation off 2013-03-11 09:36:00 -07:00
Patrick Walton
a34749c289 libsyntax: Stop parsing newtype enums 2013-03-11 09:36:00 -07:00
Patrick Walton
7538450b8d libsyntax: Remove newtype enums from libsyntax. rs=deenum 2013-03-11 09:35:59 -07:00
Patrick Walton
bd2d17e4a1 libsyntax: Stop parsing bare functions in preparation for switching them over 2013-03-11 09:35:58 -07:00
Patrick Walton
d18f785457 librustc: Replace all uses of fn() with &fn(). rs=defun 2013-03-11 09:35:58 -07:00
Seo Sanghyeon
9e85589ad3 Implement vector destructuring from tail 2013-03-11 19:01:51 +09:00
Jed Davis
5066bc9ff4 Don't print addr_of(addr_of(e)) as &&e, which means something else. 2013-03-09 17:40:59 -08:00
Niko Matsakis
7cbd4b20ee Remove @ast::Region and replace with @ast::Lifetime.
Modify pretty-printer to emit lifetimes and fix a few minor
parser bugs that this uncovered.
2013-03-09 19:43:59 -05:00
bors
eaed16cea6 auto merge of #5278 : brson/rust/logplusplus, r=brson
r?

`log` can  polymorphically log anything, but debug!, etc. requires a format string. With this patch you can equivalently write `debug!(foo)` or `debug!("%?", foo)`.

I'm doing this because I was trying to remove `log` (replacing it with nothing, at least temporarily), but there are a number of logging statements that just want to print an arbitrary value and don't care about the format string.

I'm not entirely convinced this is a good change, since it overloads the implementation of these macros and makes their usage slightly more nuanced.
2013-03-08 12:27:39 -08:00
Alex Crichton
62651df2b4 Fix dvec-related fallout in tests 2013-03-08 09:56:52 -05:00
Alex Crichton
7f99a02ddb syntax: Remove uses of DVec 2013-03-08 09:54:20 -05:00
Patrick Walton
d661711cc2 test: Fix tests. 2013-03-07 22:37:58 -08:00
Patrick Walton
9a17ef9b52 librustc: Stop parsing assert. 2013-03-07 22:37:57 -08:00
Patrick Walton
d7e74b5e91 librustc: Convert all uses of assert over to fail_unless! 2013-03-07 22:37:57 -08:00
Patrick Walton
0ea031bcb8 librustc: Remove record patterns from the compiler 2013-03-07 22:37:03 -08:00
Patrick Walton
954ae9c975 libsyntax: Remove struct literal expressions from the compiler 2013-03-07 22:32:55 -08:00
Patrick Walton
4e3dbfe052 librustc: Remove structural record types from the compiler 2013-03-07 22:32:54 -08:00
Patrick Walton
239e64242c libsyntax: Stop parsing structural record types 2013-03-07 22:32:52 -08:00
Brian Anderson
dd4d45062d Make debug!, etc. macros not require a format string
The one thing `log` can still do is polymorphically log anything,
but debug!, etc. require a format string. With this patch
you can equivalently write `debug!(foo)` or `debug!("%?", foo)`
2013-03-07 18:45:22 -08:00
John Clements
a040b8005f add deriving_eq for tokens 2013-03-07 14:46:46 -08:00
bors
b269ce2782 auto merge of #5255 : jbclements/rust/remove-parse-value-ident, r=graydon
After the removal of the "restricted keyword" feature in 0c82c00dc4 , there's no longer any difference between parse_ident() and parse_value_ident(), and therefore no difference between parse parse_path_without_tps() and parse_value_path().  I've collapsed all of these, removing the redundant functions and eliminating the need for two higher-order arguments.
2013-03-06 17:48:39 -08:00
Niko Matsakis
7e4ed28fa5 patch up pretty printing of things with both lifetime and type parameters 2013-03-06 15:12:58 -05:00
Niko Matsakis
3280e5a33d Improve error messages when illegal lifetimes are used 2013-03-06 15:12:58 -05:00
Niko Matsakis
4077d7b8b7 Permit either foo/&self or foo<'self> 2013-03-06 15:12:57 -05:00
Niko Matsakis
3168fe06ff Add manual &self/ and &static/ and /&self declarations that
are currently inferred.  New rules are coming that will require
them to be explicit.  All add some explicit self declarations.
2013-03-06 15:12:57 -05:00
Niko Matsakis
704cd648ac Fix a bug with region-parameterized enums etc where trans considered
them to be non-monomorphic.  Merely having lifetime parameters
is not enough to qualify for that status.  Fixes #5243.
2013-03-06 13:01:16 -05:00
John Clements
8bb537e68d finish removing parse_value_ident 2013-03-06 09:41:52 -08:00
John Clements
88451878f8 removed unused abstraction over paths and value_paths 2013-03-06 09:41:47 -08:00
Erick Tryzelaar
743cfce703 core: convert vec::{last,last_opt} to return references 2013-03-05 19:39:18 -08:00
bors
dec599f652 auto merge of #5234 : pcwalton/rust/equiv, r=pcwalton
r? @nikomatsakis
2013-03-05 12:12:50 -08:00
Patrick Walton
6d4ed5283c libsyntax: Separate multiple inherited traits with + 2013-03-05 10:18:35 -08:00
bors
e94465c053 auto merge of #5231 : jbclements/rust/better-macro-error-message, r=graydon
Macro invocations with path separators (e.g. foo::bar!()) now produce a sensible error message, rather than an assertion failure. Also added compile-fail test case.

Fixes #5218 ?
2013-03-05 10:06:50 -08:00
Niko Matsakis
cbfd88a486 Update region inference for traits so that a method with
explicit self doesn't incorrectly cause the entire trait to
be tagged as being region-parameterized.

Fixes #5224.
2013-03-05 08:46:23 -05:00
bors
eddefbc893 auto merge of #5212 : thestinger/rust/iter, r=graydon
A small step towards fixing #2827
2013-03-05 02:06:50 -08:00
bors
75c5bc90d2 auto merge of #5179 : alexcrichton/rust/default-warn-unused-import, r=graydon
I've found that unused imports can often start cluttering a project after a long time, and it's very useful to keep them under control. I don't like how Go forces a compiler error by default and it can't be changed, but I certainly want to know about them so I think that a warn is a good default.

Now that the `unused_imports` lint option is a bit smarter, I think it's possible to change the default level to warn. This commit also removes all unused imports throughout the compiler and libraries (500+).

The only odd things that I ran into were that some `use` statements had to have `#[cfg(notest)]` or `#[cfg(test)]` based on where they were. The ones with `notest` were mostly in core for modules like `cmp` whereas `cfg(test)` was for tests that weren't part of a normal `mod test` module.
2013-03-05 00:57:46 -08:00
John Clements
a191babbe5 simplified msg (TMI on old one) 2013-03-04 16:50:52 -08:00