Commit Graph

30867 Commits

Author SHA1 Message Date
John Clements
6c8bb5a68a macro in method position parsing 2014-07-13 10:10:38 -07:00
John Clements
6ee2155fe0 remove no-stmt check
nothing wrong with a statement expanding into 0 stmts, that I can see.
2014-07-13 10:10:38 -07:00
John Clements
c4cc3ba130 update fold_method to return a smallvector
This is nice for macros, to allow them to expand into multiple methods
2014-07-13 10:10:38 -07:00
John Clements
b293a6604b macro method unit test case fix 2014-07-13 10:10:27 -07:00
John Clements
c654fd1f49 test case for method macros 2014-07-13 10:10:27 -07:00
John Clements
b0b4b3122a refactor Method definition to make space for macros
This change propagates to many locations, but because of the
Macro Exterminator (or, more properly, the invariant that it
protects), macro invocations can't occur downstream of expansion.
This means that in librustc and librustdoc, extracting the
desired field can simply assume that it can't be a macro
invocation. Functions in ast_util abstract over this check.
2014-07-13 10:08:27 -07:00
bors
fbeee04f31 auto merge of #15507 : jakub-/rust/iterate, r=alexcrichton
The new iterator takes a function and produces an infinite stream
of results of repeated applications of the function, starting from
the provided seed value.
2014-07-13 15:51:27 +00:00
Jakub Wieczorek
ed54162e86 Add an iterate function to core::iter
Implementation by Kevin Ballard.

The function returns an Unfold iterator producing an infinite stream
of results of repeated applications of the function, starting from
the provided seed value.
2014-07-13 11:47:40 +02:00
bors
55cf6d723c auto merge of #15639 : supr/rust/master, r=sfackler
* Fixes a typo in the libstd documentation, referring UPD instead of UDP
2014-07-13 08:16:26 +00:00
bors
88231a9b70 auto merge of #15633 : nham/rust/hash_treeset, r=alexcrichton
cc #15294
2014-07-13 06:31:29 +00:00
nham
a54dc545c9 Implement Hash trait for TreeSet and TreeMap. 2014-07-13 01:07:02 -04:00
bors
13dc0d7938 auto merge of #15584 : alexcrichton/rust/warn-annoyances, r=cmr
* Don't warn about `#[crate_name]` if `--crate-name` is specified
* Don't warn about non camel case identifiers on `#[repr(C)]` structs
* Switch `mode` to `mode_t` in libc.
2014-07-13 04:46:31 +00:00
Corey Richardson
2dfbe7f989 Use a nicer Show impl for Name 2014-07-12 20:31:55 -07:00
bors
ad7ef8c27c auto merge of #15621 : sfackler/rust/attr-span, r=cmr
They used to be one token too long, so you'd see things like
```
rust/rust/test.rs:1:1: 2:2 warning: unused attribute,
rust/rust/test.rs:1 #![foo]
rust/rust/test.rs:2 #![bar]
```
instead of
```
test.rs:1:1: 1:8 warning: unused attribute, #[warn(unused_attribute)] on
by default
test.rs:1 #![foo]
          ^~~~~~~
```
2014-07-13 03:01:32 +00:00
bors
5d200dd60d auto merge of #15614 : lucidd/rust/#15474, r=alexcrichton
This fixes #15474
2014-07-13 01:16:34 +00:00
Prudhvi Krishna Surapaneni
2cf68ba101 Fix Documentation Typo in libstd 2014-07-12 18:06:53 -07:00
bors
f606234b70 auto merge of #15617 : aturon/rust/std-more-experimental, r=alexcrichton
The `hash` module was not included in an earlier pass that sets baseline
stability of modules within `std` to `experimental`.
2014-07-12 23:31:33 +00:00
Jakub Wieczorek
a5fe176e97 Convert a first batch of diagnostics to have error codes 2014-07-12 21:53:34 +02:00
bors
e178ebf681 auto merge of #15613 : cmr/rust/rustdoc-arg-patterns, r=alexcrichton 2014-07-12 19:51:35 +00:00
bors
f2d251d12e auto merge of #15610 : brson/rust/0.12.0, r=alexcrichton 2014-07-12 18:06:36 +00:00
bors
350f3aa856 auto merge of #15607 : lucidd/rust/master, r=pnkfelix
I used the same description rustc --help outputs.
2014-07-12 16:21:36 +00:00
bors
6323e8653c auto merge of #15605 : blake2-ppc/rust/rustdoc-const-t, r=alexcrichton
Update the formatting of raw immutable pointers to print *const T.
2014-07-12 14:36:35 +00:00
bors
da4e4e4e0a auto merge of #15602 : adrientetar/rust/name-fix, r=huonw
Not sure how I did miss that in the first place...

r? @alexcrichton
2014-07-12 12:51:38 +00:00
bors
cdd6346f45 auto merge of #15601 : jbclements/rust/disable-default-macro-behavior, r=alexcrichton
Our AST definition can include macro invocations, which can expand into all kinds of things. Macro invocations are expanded away during expansion time, and the rest of the compiler doesn't have to deal with them. However, we have no way of enforcing this.

This patch adds two protective mechanisms.

First, it adds a (quick) explicit check that ensures there are no macro invocations remaining in the AST after expansion. Second, it updates the visit and fold mechanisms so that by default, they will not traverse macro invocations. It's easy enough to add this, if desired (it's documented in the source, and examples appear, e.g. in the IdentFinder.

Along the way, I also consulted with @sfackler to refactor the macro export mechanism so that it stores macro text spans in a side table, rather than leaving them in the AST.
2014-07-12 11:06:39 +00:00
bors
767f4a7937 auto merge of #15592 : arjantop/rust/bufwriter-write-fix, r=alexcrichton
First condition is not needed and just prevents 0 length writes

Fixes #15583
2014-07-12 09:21:39 +00:00
bors
a5688ad22d auto merge of #15588 : alexcrichton/rust/issue-15478, r=cmr
If modified, you can safely unmap arbitrary memory. These fields are not
intended to be modified, so read-only accessors are the only ones that are
provided.

Closes #15478
2014-07-12 06:46:42 +00:00
Alex Crichton
ca0b65402b libc: Switch open to use a mode_t on unix
While I'm at it, export O_SYNC with the other flags that are exported.

Closes #15582
2014-07-11 22:39:40 -07:00
Alex Crichton
fb02d54b97 std: Move MemoryMap fields to methods
If modified, you can safely unmap arbitrary memory. These fields are not
intended to be modified, so read-only accessors are the only ones that are
provided.

Closes #15478
2014-07-11 22:36:32 -07:00
bors
8a2b7a5c19 auto merge of #15597 : brson/rust/ldconfig, r=pcwalton
If ldconfig fails it emits a warning. This is very possible when installing
to a non-system directory, so the warning tries to indicate that it may
not be a problem.
2014-07-12 04:16:44 +00:00
Brian Anderson
9641856964 Only run ldconfig on Linux 2014-07-11 21:13:40 -07:00
bors
5ad7286dc3 auto merge of #15589 : Denommus/rust/master, r=alexcrichton
I have noticed some errors and some absences that I considered essential to the usability of rustc in zsh, so I included them and updated some of the man page.
2014-07-12 00:31:46 +00:00
Steven Fackler
52ccab1405 Fix spans for attributes
They used to be one token too long, so you'd see things like
```
rust/rust/test.rs:1:1: 2:2 warning: unused attribute,
rust/rust/test.rs:1 #![foo]
rust/rust/test.rs:2 #![bar]
```
instead of
```
test.rs:1:1: 1:8 warning: unused attribute, #[warn(unused_attribute)] on
by default
test.rs:1 #![foo]
          ^~~~~~~
```
2014-07-11 15:26:26 -07:00
bors
1e401159c1 auto merge of #15586 : aturon/rust/stability-dashboard, r=alexcrichton
This PR adds a crate-level dashboard summarizing the stability levels of all items for all submodules of the crate.

The information is also written as a json file, intended for consumption by pages like http://huonw.github.io/isrustfastyet/

Along the way, fixes a few bugs in stability tracking and places where rustdoc was not pulling the existing stability data.

Closes #13541
2014-07-11 22:06:43 +00:00
Aaron Turon
9321fe7a7b mark std::hash experimental
The `hash` module was not included in an earlier pass that sets baseline
stability of modules within `std` to `experimental`.
2014-07-11 14:25:15 -07:00
Kevin Walter
3d2fd5ec03 rustdoc: render 1-tuples as (T,) instead of (T) 2014-07-11 22:28:52 +02:00
Corey Richardson
3c75b1e382 rustdoc: support tuple and struct patterns in function arguments 2014-07-11 11:59:18 -07:00
Brian Anderson
207b83ae2f unicode: Remove crate_id attr 2014-07-11 11:27:00 -07:00
Brian Anderson
a9cf3233f7 Bump version to 0.12.0-pre 2014-07-11 11:26:58 -07:00
Brian Anderson
fa2d220567 Update doc URLs for version bump 2014-07-11 11:21:57 -07:00
bors
75c1fb535d auto merge of #15565 : alexcrichton/rust/issue-15475, r=huonw
If a plugin registrar is available, the library must be found in dylib form, not
just in rlib form.

Closes #15475
2014-07-11 18:06:37 +00:00
John Clements
c253b3675a add Macro Exterminator
the Macro Exterminator ensures that there are no macro invocations in
an AST. This should help make later passes confident that there aren't
hidden items, methods, expressions, etc.
2014-07-11 10:32:42 -07:00
John Clements
53642eed80 make walk/visit_mac opt-in only
macros can expand into arbitrary items, exprs, etc. This
means that using a default walker or folder on an AST before
macro expansion is complete will miss things (the things that
the macros expand into). As a partial fence against this, this
commit moves the default traversal of macros into a separate
procedure, and makes the default trait implementation signal
an error. This means that Folders and Visitors can traverse
macros if they want to, but they need to explicitly add an
impl that calls the walk_mac or fold_mac procedure

This should prevent problems down the road.
2014-07-11 10:32:41 -07:00
John Clements
f1ad425199 use side table to store exported macros
Per discussion with @sfackler, refactored the expander to
change the way that exported macros are collected. Specifically,
a crate now contains a side table of spans that exported macros
go into.

This has two benefits. First, the encoder doesn't need to scan through
the expanded crate in order to discover exported macros. Second, the
expander can drop all expanded macros from the crate, with the pleasant
result that a fully expanded crate contains no macro invocations (which
include macro definitions).
2014-07-11 10:32:41 -07:00
John Clements
50d9965c25 rename one of the two confusing MacroExpanders
There were two things named MacroExpander, which was confusing. I renamed
one of them TTMacroExpander.

[breaking change]
2014-07-11 10:32:30 -07:00
bors
aeab2501d1 auto merge of #15503 : pnkfelix/rust/fsk-linear-deriving-partialord, r=huonw
Instead of generating a separate case (albeit trivial) for each of the N*N cases when comparing two instances of an enum with N variants, this `deriving` uses the strategy outlined here: https://github.com/rust-lang/rust/issues/15375#issuecomment-47994007

In particular, it generates code that looks more like this:

```rust
    match (this, that, ...) {
      (Variant1, Variant1, Variant1) => ... // delegate Matching on Variant1
      (Variant2, Variant2, Variant2) => ... // delegate Matching on Variant2
      ...
      _ => {
        let index_tup = {
          let idx_this = match this { Variant1 => 0u, Variant2 => 1u, ... };
          let idx_that = match that { Variant1 => 0u, Variant2 => 1u, ... };
          ...
          (idx_this, idx_that, ...)
        };
        ... // delegate to catch-all; it can inspect `index_tup` for its logic
      }
    }
```

While adding a new variant to the `const_nonmatching` flag (and renaming it to `on_nonmatching`) to allow expressing the above (while still allowing one to opt back into the old `O(N^2)` and in general `O(N^K)` (where `K` is the number of self arguments) code generation behavior), I had two realizations:

 1. Observation: Nothing except for the comparison derivings (`PartialOrd`, `Ord`, `PartialEq`, `Eq`) were even using the old `O(N^K)` code generator.  So after this hypothetically lands, *nothing* needs to use them, and thus that code generation strategy could be removed, under the assumption that it is very unlikely that any `deriving` mode will actually need that level of generality.
 2. Observation: The new code generator I am adding can actually be unified with all of the other code generators that just dispatch on the variant tag (they all assume that there is only one self argument).

These two observations mean that one can get rid of the `const_nonmatching` (aka `on_nonmatching`) entirely.  So I did that too in this PR.

The question is: Do we actually want to follow through on both of the above observations?  I'm pretty sure the second observation is a pure win.  But there *might* be someone out there with an example that invalidates the reasoning in the first observation.  That is, there might be a client out there with an example of hypothetical deriving mode that wants to opt into the `O(N^K)` behavior.  So, if that is true, then I can revise this PR to resurrect the `on_nonmatching` flag and provide a way to access the `O(N^K)` behavior.

The manner in which I choose to squash these commits during a post-review rebase depends on the answer to the above question.

Fix #15375.
2014-07-11 15:56:38 +00:00
Felix S. Klock II
5cee57869c Removed dead structures after changes to PartialOrd/Ord derivings.
Remove the `NonMatchesExplode` variant now that no deriving impl uses it.
Removed `EnumNonMatching` entirely.
Remove now irrelevant `on_matching` field and `HandleNonMatchingEnums` type.
Removed unused `EnumNonMatchFunc` type def.

Drive-by: revise `EnumNonMatchCollapsedFunc` doc.

Made all calls to `expand_enum_method_body` go directly to
`build_enum_match_tuple`.

Alpha-rename `enum_nonmatch_g` back to `enum_nonmatch_f` to reduce overall diff noise.
Inline sole call of `some_ordering_const`.
Inline sole call of `ordering_const`.

Removed a bunch of code that became dead after the above changes.
2014-07-11 17:32:23 +02:00
Felix S. Klock II
c8ae44682d O(n*k) code-size deriving on enums (better than previous O(n^k)).
In the above formulas, `n` is the number of variants, and `k` is the
number of self-args fed into deriving.  In the particular case of
interest (namely `PartialOrd` and `Ord`), `k` is always 2, so we are
basically comparing `O(n)` versus `O(n^2)`.

Also, the stage is set for having *all* enum deriving codes go through
`build_enum_match_tuple` and getting rid of `build_enum_match`.

Also, seriously attempted to clean up the code itself.  Added a bunch
of comments attempting to document what I learned as I worked through
the original code and adapted it to this new strategy.
2014-07-11 17:32:18 +02:00
Felix S. Klock II
5d1bdc320b Revise the const_nonmatching flag with more info about author's intent.
In particular, I want authors of deriving modes to understand what
they are opting into (namely quadratic code size or worse) when they
select NonMatchesExplode.
2014-07-11 17:01:01 +02:00
bors
b8059f730e auto merge of #15580 : pnkfelix/rust/fsk-fix-15558, r=alexcrichton
Fix #15558.
2014-07-11 13:51:39 +00:00
Kevin Walter
8fab111e79 Add rustc --pretty flowgraph to man page 2014-07-11 15:51:01 +02:00