Commit Graph

2192 Commits

Author SHA1 Message Date
Kevin Ballard
c01a97b7a9 path2: Remove .with_display_str and friends
Rewrite these methods as methods on Display and FilenameDisplay. This
turns

  do path.with_display_str |s| { ... }

into

  do path.display().with_str |s| { ... }
2013-10-15 22:19:53 -07:00
Kevin Ballard
d6d9b92683 path2: Adjust the API to remove all the _str mutation methods
Add a new trait BytesContainer that is implemented for both byte vectors
and strings.

Convert Path::from_vec and ::from_str to one function, Path::new().

Remove all the _str-suffixed mutation methods (push, join, with_*,
set_*) and modify the non-suffixed versions to use BytesContainer.
2013-10-15 22:18:30 -07:00
Kevin Ballard
73d3d00ec4 path2: Replace the path module outright
Remove the old path.
Rename path2 to path.
Update all clients for the new path.

Also make some miscellaneous changes to the Path APIs to help the
adoption process.
2013-10-15 21:56:54 -07:00
Steve Klabnik
16fc6a694c Remove unused abi attributes.
They've been replaced by putting the name on the extern block.

  #[abi = "foo"]

goes to

  extern "foo" { }

Closes #9483.
2013-10-14 13:10:36 +02:00
Alex Crichton
b70306158f Remove named extern blocks from the AST
There's currently a fair amount of code which is being ignored on unnamed blocks
(which are the default now), and I opted to leave it commented out for now. I
intend on very soon revisiting on how we perform linking with extern crates in
an effort to support static linking.
2013-10-10 18:04:58 -07:00
bors
34d123db4e auto merge of #9783 : huonw/rust/macro-items, r=bstrie
Fixes #4471.
2013-10-09 21:56:20 -07:00
Huon Wilson
4e0822e253 syntax: allow macros to expand to items with attributes.
Fixes #4471.
2013-10-10 09:57:37 +11:00
Daniel Micay
6a90e80b62 option: rewrite the API to use composition 2013-10-09 09:17:29 -04:00
bors
3a70df1d3c auto merge of #9753 : alexcrichton/rust/macro-attrs, r=brson
It's unclear to me why these currently aren't allowed, and my best guess is that
a long time ago we didn't strip the ast of cfg nodes before syntax expansion.
Now that this is done, I'm not certain that we should continue to prohibit this
functionality.

This is a step in the right direction towards #5605, because now we can add an
empty `std::macros` module to the documentation with a bunch of empty macros
explaining how they're supposed to be used.
2013-10-08 19:26:35 -07:00
Alex Crichton
252d17a07c Allow attributes on macros
It's unclear to me why these currently aren't allowed, and my best guess is that
a long time ago we didn't strip the ast of cfg nodes before syntax expansion.
Now that this is done, I'm not certain that we should continue to prohibit this
functionality.

This is a step in the right direction towards #5605, because now we can add an
empty `std::macros` module to the documentation with a bunch of empty macros
explaining how they're supposed to be used.
2013-10-08 19:12:30 -07:00
bors
6db889996b auto merge of #9771 : alexcrichton/rust/snapshots, r=thestinger
Still building locally, we'll see if anything dies...
2013-10-08 13:01:49 -07:00
Alex Crichton
0cca359da6 Register new snapshots 2013-10-08 09:30:03 -07:00
bors
8db52a5c0e auto merge of #9756 : catamorphism/rust/issue-2354, r=alexcrichton
r? anybody It's more helpful to list the span of each open delimiter seen so far
than to print out an error with the span of the last position in the file.

Closes #2354
2013-10-08 09:11:35 -07:00
Felix S. Klock II
580adc9ad3 Add bindings for start and ends of keyword ranges; use bindings in match arms. 2013-10-08 14:45:02 +02:00
bors
c9196290af auto merge of #9674 : ben0x539/rust/raw-str, r=alexcrichton
This branch parses raw string literals as in #9411.
2013-10-07 23:01:39 -07:00
Benjamin Herr
9d7b130041 add new enum ast::StrStyle as field to ast::lit_str
For the benefit of the pretty printer we want to keep track of how
string literals in the ast were originally represented in the source
code.

This commit changes parser functions so they don't extract strings from
the token stream without at least also returning what style of string
literal it was. This is stored in the resulting ast node for string
literals, obviously, for the package id in `extern mod = r"package id"`
view items, for the inline asm in `asm!()` invocations.

For `asm!()`'s other arguments or for `extern "Rust" fn()` items, I just
the style of string, because it seemed disproportionally cumbersome to
thread that information through the string processing that happens with
those string literals, given the limited advantage raw string literals
would provide in these positions.

The other syntax extensions don't seem to store passed string literals
in the ast, so they also discard the style of strings they parse.
2013-10-08 03:43:28 +02:00
Tim Chevalier
77d9ac37fc syntax: Remove unnecessary @ 2013-10-07 18:37:36 -07:00
Tim Chevalier
bed669cba6 syntax: Display spans for open delimiters when a file ends prematurely
It's more helpful to list the span of each open delimiter seen so far
than to print out an error with the span of the last position in the file.

Closes #2354
2013-10-07 18:06:30 -07:00
Benjamin Herr
9787872553 add token::LIT_STR_RAW(ident, num of # symbols)
Treat it as a synonym for LIT_STR for now.
2013-10-08 01:44:05 +02:00
Benjamin Herr
904c6c43c4 lex raw string literals, like r#"blah"#
Raw string literals are lexed into regular string literals. This is okay
for them to "work" and be usable/testable, but the pretty-printer does
not know about them yet and will just emit regular string literals.
2013-10-08 01:44:05 +02:00
Benjamin Herr
e007f94747 pp: print spaces around '=' in 'extern mod blah = "blah"' 2013-10-08 01:44:05 +02:00
Alex Crichton
de7d143176 Fix existing privacy/visibility violations
This commit fixes all of the fallout of the previous commit which is an attempt
to refine privacy. There were a few unfortunate leaks which now must be plugged,
and the most horrible one is the current `shouldnt_be_public` module now inside
`std::rt`. I think that this either needs a slight reorganization of the
runtime, or otherwise it needs to just wait for the external users of these
modules to get replaced with their `rt` implementations.

Other fixes involve making things pub which should be pub, and otherwise
updating error messages that now reference privacy instead of referencing an
"unresolved name" (yay!).
2013-10-07 13:00:52 -07:00
Alex Crichton
439e2770be Extract privacy checking from name resolution
This commit is the culmination of my recent effort to refine Rust's notion of
privacy and visibility among crates. The major goals of this commit were to
remove privacy checking from resolve for the sake of sane error messages, and to
attempt a much more rigid and well-tested implementation of visibility
throughout rust. The implemented rules for name visibility are:

1. Everything pub from the root namespace is visible to anyone
2. You may access any private item of your ancestors.

"Accessing a private item" depends on what the item is, so for a function this
means that you can call it, but for a module it means that you can look inside
of it. Once you look inside a private module, any accessed item must be "pub
from the root" where the new root is the private module that you looked into.
These rules required some more analysis results to get propagated from trans to
privacy in the form of a few hash tables.

I added a new test in which my goal was to showcase all of the privacy nuances
of the language, and I hope to place any new bugs into this file to prevent
regressions.

Overall, I was unable to completely remove the notion of privacy from resolve.
One use of privacy is for dealing with glob imports. Essentially a glob import
can only import *public* items from the destination, and because this must be
done at namespace resolution time, resolve must maintain the notion of "what
items are public in a module". There are some sad approximations of privacy, but
I unfortunately can't see clear methods to extract them outside.

The other use case of privacy in resolve now is one that must stick around
regardless of glob imports. When dealing with privacy, checking a private path
needs to know "what the last private thing was" when looking at a path. Resolve
is the only compiler pass which knows the answer to this question, so it
maintains the answer on a per-path resolution basis (works similarly to the
def_map generated).

Closes #8215
2013-10-07 13:00:52 -07:00
Alex Crichton
dd98f7089f Implement feature-gating for the compiler
A few features are now hidden behind various #[feature(...)] directives. These
include struct-like enum variants, glob imports, and macro_rules! invocations.

Closes #9304
Closes #9305
Closes #9306
Closes #9331
2013-10-05 20:19:33 -07:00
bors
2733b189ac auto merge of #9250 : erickt/rust/num, r=erickt
This PR solves one of the pain points with c-style enums. Simplifies writing a fn to convert from an int/uint to an enum. It does this through a `#[deriving(FromPrimitive)]` syntax extension.

Before this is committed though, we need to discuss if `ToPrimitive`/`FromPrimitive` has the right design (cc #4819). I've changed all the `.to_int()` and `from_int()` style functions to return `Option<int>` so we can handle partial functions. For this PR though only enums and `extra::num::bigint::*` take advantage of returning None for unrepresentable values. In the long run it'd be better if `i64.to_i8()` returned `None` if the value was too large, but I'll save this for a future PR.

Closes #3868.
2013-10-05 14:26:44 -07:00
Benjamin Herr
fa411500f9 Remove specific errors for very old obsolete syntax
Replaces existing tests for removed obsolete-syntax errors with tests
for the resulting regular errors, adds a test for each of the removed
parser errors to make sure that obsolete forms don't start working
again, removes some obsolete/superfluous tests that were now failing.

Deletes some amount of dead code in the parser, also includes some small
changes to parser error messages to accomodate new tests.
2013-10-04 07:09:28 +02:00
Alex Crichton
c0388cd691 Rewrite lint passes with less visitor cruft
This purges about 500 lines of visitor cruft from lint passes. All lints are
handled in a much more sane way at this point. The other huge bonus of this
commit is that there are no more @-boxes in the lint passes, fixing the 500MB
memory regression seen when the lint passes were refactored.

Closes #8589
2013-10-03 10:25:14 -07:00
Erick Tryzelaar
9de7ad2d8c std: Swap {To,From}Primitive to use the 64bit as the unimplemented version
One downside with this current implementation is that since BigInt's
default is now 64 bit, we can convert larger BigInt's to a primitive,
however the current implementation on 32 bit architectures does not
take advantage of this fact.
2013-10-02 07:55:42 -07:00
Erick Tryzelaar
8f8cc061d9 syntax: swap from .span_fatal to .span_err in #[deriving(FromPrimitive)] 2013-10-02 07:55:41 -07:00
Erick Tryzelaar
0feaccf526 syntax: Add #[deriving(FromPrimitive)] syntax extension
Right now this only works for c-style enums.
2013-10-02 07:55:41 -07:00
bors
d616603c84 auto merge of #9673 : huonw/rust/macros, r=catamorphism
That is, only a single expression or item gets parsed, so if there are
any extra tokens (e.g. the start of another item/expression) the user
should be told, rather than silently dropping them.

An example:

    macro_rules! foo {
        () => {
            println("hi");
            println("bye);
        }
    }

would expand to just `println("hi")`, which is almost certainly not
what the programmer wanted.

Fixes #8012.
2013-10-02 04:21:26 -07:00
bors
d00c9269dc auto merge of #9665 : alexcrichton/rust/snapshot, r=brson
Uses the new snapshots to kill the old `loop` and introduce the new `continue`.
2013-10-02 02:31:29 -07:00
Huon Wilson
8284df9e7c syntax: indicate an error when a macro ignores trailing tokens.
That is, only a single expression or item gets parsed, so if there are
any extra tokens (e.g. the start of another item/expression) the user
should be told, rather than silently dropping them.

An example:

    macro_rules! foo {
        () => {
            println("hi");
            println("bye);
        }
    }

would expand to just `println("hi")`, which is almost certainly not
what the programmer wanted.

Fixes #8012.
2013-10-02 14:43:15 +10:00
Huon Wilson
bbbafc4e46 syntax: remove some dead code. 2013-10-02 11:43:10 +10:00
Alex Crichton
4f67dcb24a Migrate users of 'loop' to 'continue'
Closes #9467
2013-10-01 15:53:13 -07:00
Alex Crichton
4af849bc12 Obsolete parsing 'loop' as 'continue' 2013-10-01 15:52:41 -07:00
bors
fe4e7478c5 auto merge of #9560 : pcwalton/rust/xc-tuple-structs, r=pcwalton
r? @thestinger
2013-10-01 15:06:25 -07:00
Patrick Walton
76d92c5472 librustc: Inline cross-crate tuple struct constructors 2013-10-01 14:24:34 -07:00
bors
08b510c351 auto merge of #9519 : thestinger/rust/float, r=catamorphism
It is simply defined as `f64` across every platform right now.

A use case hasn't been presented for a `float` type defined as the
highest precision floating point type implemented in hardware on the
platform. Performance-wise, using the smallest precision correct for the
use case greatly saves on cache space and allows for fitting more
numbers into SSE/AVX registers.

If there was a use case, this could be implemented as simply a type
alias or a struct thanks to `#[cfg(...)]`.

Closes #6592

The mailing list thread, for reference:

https://mail.mozilla.org/pipermail/rust-dev/2013-July/004632.html
2013-10-01 13:01:28 -07:00
Daniel Micay
c9d4ad07c4 remove the float type
It is simply defined as `f64` across every platform right now.

A use case hasn't been presented for a `float` type defined as the
highest precision floating point type implemented in hardware on the
platform. Performance-wise, using the smallest precision correct for the
use case greatly saves on cache space and allows for fitting more
numbers into SSE/AVX registers.

If there was a use case, this could be implemented as simply a type
alias or a struct thanks to `#[cfg(...)]`.

Closes #6592

The mailing list thread, for reference:

https://mail.mozilla.org/pipermail/rust-dev/2013-July/004632.html
2013-10-01 14:54:10 -04:00
bors
c8cdabc32f auto merge of #9633 : alexcrichton/rust/issue-9631, r=huonw
Closes #9631
2013-10-01 11:26:27 -07:00
Alex Crichton
62855e2c08 Fix usage of the old debug! macros 2013-10-01 10:01:14 -07:00
Alex Crichton
eafbcfb73c Change the format! statics to be all-caps
This lets them get past the non_uppercase_statics lint mode (if it's turned on)

Closes #9631
2013-10-01 09:26:15 -07:00
Huon Wilson
6f166894ba Fix typo with format migration: s/oldformat/oldfmt/. 2013-10-01 19:45:17 +10:00
Alex Crichton
af3b132285 syntax: Remove usage of fmt! 2013-09-30 23:21:19 -07:00
Alex Crichton
aaf6cc3a84 Prevent leakage of fmt! into the compiler
We're not outright removing fmt! just yet, but this prevents it from leaking
into the compiler further (it's still turned on by default for all other code).
2013-09-30 23:21:18 -07:00
Alex Crichton
d29b3ac8a7 Expand tidy to prevent binaries from being checked
Closes #9621
2013-09-30 10:15:47 -07:00
Alex Crichton
7b18976f08 Remove all usage of @ast::Crate 2013-09-29 16:21:25 -07:00
bors
67394f20eb auto merge of #9552 : brson/rust/0.9-pre, r=alexcrichton 2013-09-27 13:51:07 -07:00
bors
78c3fac852 auto merge of #9535 : alexcrichton/rust/no-format-default, r=thestinger
As mentioned in #9456, the format! syntax extension would previously consider an
empty format as a 'Unknown' format which could then also get coerced into a
different style of format on another argument.

This is unusual behavior because `{}` is a very common format and if you have
`{0} {0:?}` you wouldn't expect them both to be coereced to the `Poly`
formatter. This commit removes this coercion, but still retains the requirement
that each argument has exactly one format specified for it (an empty format now
counts as well).

Perhaps at a later date we can add support for multiple formats of one argument,
but this puts us in at least a backwards-compatible situation if we decide to do
that.
2013-09-27 09:41:07 -07:00
Alex Crichton
b74663e027 Remove the notion of an "unknown format"
As mentioned in #9456, the format! syntax extension would previously consider an
empty format as a 'Unknown' format which could then also get coerced into a
different style of format on another argument.

This is unusual behavior because `{}` is a very common format and if you have
`{0} {0:?}` you wouldn't expect them both to be coereced to the `Poly`
formatter. This commit removes this coercion, but still retains the requirement
that each argument has exactly one format specified for it (an empty format now
counts as well).

Perhaps at a later date we can add support for multiple formats of one argument,
but this puts us in at least a backwards-compatible situation if we decide to do
that.
2013-09-27 09:39:05 -07:00
bors
10e7f12daf auto merge of #9550 : alexcrichton/rust/remove-printf, r=thestinger
The 0.8 release was cut, down with printf!
2013-09-27 08:21:23 -07:00
bors
74dfd93bad auto merge of #9540 : alexcrichton/rust/more-rustdoc-improvements, r=brson
Commit messages have the details, mostly just knocking out more low-hanging-fruit type issues.
2013-09-27 04:51:13 -07:00
bors
eb3ebb7ebd auto merge of #9525 : klutzy/rust/obsolete-span-fix, r=alexcrichton 2013-09-26 22:11:14 -07:00
bors
a94158ce64 auto merge of #9504 : brson/rust/continue, r=alexcrichton 2013-09-26 18:46:10 -07:00
Brian Anderson
99c1fb8c66 Update version numbers to 0.9-pre 2013-09-26 18:18:42 -07:00
bors
1434b4bfca auto merge of #9261 : alexcrichton/rust/logging, r=huonw
This lifts various restrictions on the runtime, for example the character limit
when logging a message. Right now the old debug!-style macros still involve
allocating (because they use fmt! syntax), but the new debug2! macros don't
involve allocating at all (unless the formatter for a type requires allocation.
2013-09-26 17:11:13 -07:00
Alex Crichton
409182de6d Update the compiler to not use printf/printfln 2013-09-26 17:05:59 -07:00
Alex Crichton
09a5338197 Remove the printf{,ln}! macros
These are deprecated in favor of print{,ln}!
2013-09-26 17:03:31 -07:00
Brian Anderson
88272a4f24 Add 'continue' as a synonym for 'loop' 2013-09-26 15:04:13 -07:00
Alex Crichton
42bcf638b0 rustdoc: Render stability attributes
Closes #8965
2013-09-26 13:39:06 -07:00
Alex Crichton
ca697d3705 rustdoc: Generate documentation for foreign items
This slurps up everything inside of an 'extern' block into the enclosing module
in order to document them. The documentation must be on the items themselves,
and they'll show up next to everything else on the module index pages.

Closes #5953
2013-09-26 11:57:25 -07:00
klutzy
fc44a9c7dd syntax: Fix wrong span on trait fn visibility
Fixes #9348.
2013-09-26 22:48:21 +09:00
klutzy
a56e2eecf5 syntax: Fix wrong span on ObsoleteMode 2013-09-26 22:47:43 +09:00
klutzy
d96dfc9a59 syntax: Fix wrong span on ObsoleteEmptyImpl 2013-09-26 22:47:33 +09:00
Alex Crichton
eb2b25dd6d Refactor the logging system for fewer allocations
This lifts various restrictions on the runtime, for example the character limit
when logging a message. Right now the old debug!-style macros still involve
allocating (because they use fmt! syntax), but the new debug2! macros don't
involve allocating at all (unless the formatter for a type requires allocation.
2013-09-25 16:30:05 -07:00
Alex Crichton
bcc7daa6bc rustdoc: Improve comment stripping
There is less implicit removal of various comment styles, and it also removes
extraneous stars occasionally found in docblock comments. It turns out that the
bug for getops was just a differently formatted block.

Closes #9425
Closes #9417
2013-09-25 14:27:42 -07:00
Alex Crichton
3585c64d09 rustdoc: Change all code-blocks with a script
find src -name '*.rs' | xargs sed -i '' 's/~~~.*{\.rust}/```rust/g'
    find src -name '*.rs' | xargs sed -i '' 's/ ~~~$/ ```/g'
    find src -name '*.rs' | xargs sed -i '' 's/^~~~$/ ```/g'
2013-09-25 14:27:42 -07:00
bors
f6c9ff392b auto merge of #9481 : jbclements/rust/minor-cleanup, r=cmr
Small stuff... might as well get it into the tree. One new test case, some issue # cleanup, remove some unused imports.
2013-09-25 02:15:59 -07:00
bors
4531184614 auto merge of #9432 : alexcrichton/rust/correct-item-visibility, r=pcwalton
This fixes private statics and functions from being usable cross-crates, along
with some bad privacy error messages. This is a reopening of #8365 with all the
privacy checks in privacy.rs instead of resolve.rs (where they should be
anyway).

These maps of exported items will hopefully get used for generating
documentation by rustdoc

Closes #8592
2013-09-25 00:55:53 -07:00
bors
512f7781fe auto merge of #9335 : alexcrichton/rust/issue-7945, r=thestinger
As documented in issue #7945, these literal identifiers are all accepted by rust
today, but they should probably be disallowed (especially `'''`). This changes
all escapable sequences to being *required* to be escaped.

Closes #7945

I wanted to write the tests with more exact spans, but I think #9308 will be fixing that?
2013-09-24 19:06:01 -07:00
Alex Crichton
2661b633c5 Disallow char literals which should be escaped
As documented in issue #7945, these literal identifiers are all accepted by rust
today, but they should probably be disallowed (especially `'''`). This changes
all escapable sequences to being *required* to be escaped.

Closes #7945
2013-09-24 17:56:42 -07:00
John Clements
0269850cc2 added test case for tokenization of macro_rules 2013-09-24 16:00:58 -07:00
bors
a7d68adbdd auto merge of #9336 : alexcrichton/rust/issue-7981, r=catamorphism
Progress on #7981

This doesn't completely close the issue because `struct A;` is still allowed, and it's a much larger change to disallow that. I'm also not entirely sure that we want to disallow that. Regardless, punting that discussion to the issue instead.
2013-09-24 15:45:57 -07:00
John Clements
0322832763 renumbered due to bug shuffling 2013-09-24 14:48:04 -07:00
Alex Crichton
4b266f1c0d Stop accepting 'impl ...;', require {} instead
Progress on #7981
2013-09-24 14:12:02 -07:00
John Clements
876fce2751 cleanup 2013-09-24 12:31:24 -07:00
John Clements
32f97cc891 comment changes only 2013-09-24 12:02:56 -07:00
Alex Crichton
10a583ce1a Correctly encode item visibility in metadata
This fixes private statics and functions from being usable cross-crates, along
with some bad privacy error messages. This is a reopening of #8365 with all the
privacy checks in privacy.rs instead of resolve.rs (where they should be
anyway).

These maps of exported items will hopefully get used for generating
documentation by rustdoc

Closes #8592
2013-09-24 09:57:25 -07:00
Patrick Walton
3b1d3e5bf8 librustc: Fix merge fallout. 2013-09-23 18:23:23 -07:00
Patrick Walton
90d3da9711 test: Fix rustdoc and tests. 2013-09-23 18:23:22 -07:00
Patrick Walton
68ea9aed96 librustc: Remove @fn managed closures from the language. 2013-09-23 18:23:21 -07:00
Patrick Walton
9a4de3f305 libsyntax: Introduce routines and remove all @fns from libsyntax save the old visitor 2013-09-23 18:23:21 -07:00
Patrick Walton
e95996399f libsyntax: Remove some more @fns from the macro expander 2013-09-23 18:23:21 -07:00
Patrick Walton
6a8169db0a libsyntax: Remove some more @fn uses 2013-09-23 18:23:20 -07:00
Patrick Walton
6ecbd75843 librustc: Change the ID visitor to use traits instead of garbage-collected functions. 2013-09-23 18:23:20 -07:00
Patrick Walton
37c32e2495 librustc: Remove the remaining direct uses of @fn from librustc. 2013-09-23 18:23:20 -07:00
Patrick Walton
15ce791ff5 librustc: Port the pretty printer annotation infrastructure to use traits instead of garbage collected functions. 2013-09-23 18:23:18 -07:00
Patrick Walton
3e5de06135 librustc: Change fold to use traits instead of @fn. 2013-09-23 18:23:17 -07:00
bors
cd2da7d5f3 auto merge of #9389 : poiru/rust/issue-9333, r=alexcrichton
Closes #9333.
2013-09-22 12:45:52 -07:00
Birunthan Mohanathas
2ab278f130 Reserve the alignof, offsetof, and sizeof keywords
Closes #9333.
2013-09-22 10:47:36 +03:00
Brian Anderson
695cb9fc2b Update version numbers to 0.8 2013-09-21 16:25:08 -07:00
Alex Crichton
4fd061c426 Implement a web backend for rustdoc_ng
This large commit implements and `html` output option for rustdoc_ng. The
executable has been altered to be invoked as "rustdoc_ng html <crate>" and
it will dump everything into the local "doc" directory. JSON can still be
generated by changing 'html' to 'json'.

This also fixes a number of bugs in rustdoc_ng relating to comment stripping,
along with some other various issues that I found along the way.

The `make doc` command has been altered to generate the new documentation into
the `doc/ng/$(CRATE)` directories.
2013-09-20 22:49:03 -07:00
Alex Crichton
833a64d76e Invert --cfg debug to --cfg ndebug
Many people will be very confused that their debug! statements aren't working
when they first use rust only to learn that they should have been building with
`--cfg debug` the entire time. This inverts the meaning of the flag to instead
of enabling debug statements, now it disables debug statements.

This way the default behavior is a bit more reasonable, and requires less
end-user configuration. Furthermore, this turns on debug by default when
building the rustc compiler.
2013-09-20 12:10:04 -07:00
bors
7f826cb25a auto merge of #9308 : ben0x539/rust/lexer-error-spans, r=alexcrichton
Previously, the lexer calling `rdr.fatal(...)` would report the span of
the last complete token, instead of a span within the erroneous token
(besides one span fixed in 1ac90bb).

This branch adds wrappers around `rdr.fatal(...)` that sets the span
explicilty, so that all fatal errors in `libsyntax/parse/lexer.rs` now
report the offending code more precisely. A number of tests try to
verify that, though the `compile-fail` testing setup can only check that
the spans are on the right lines, and the "unterminated string/block
comment" errors can't have the line marked at all, so that's incomplete.

This closes #9149.

Also, the lexer errors now report the offending code in the error message,
not just via the span, just like other errors do.
2013-09-19 21:46:45 -07:00
Benjamin Herr
567c567b2d lexer: further slight improvements to lexer errors 2013-09-19 23:08:06 +02:00
bors
755f6229da auto merge of #9279 : erickt/rust/master, r=alexcrichton
`Some(5).or_{default,zero}` can be easily replaced with `Some(Some(5).unwrap_or_default())`.
2013-09-19 09:55:59 -07:00
Benjamin Herr
8009c97a55 lexer: report problematic chars verbatim or as escape sequence
... instead of giving their numeric codepoint, following the lead of
fdaae34. So the error message for, say, '\_' mentions _ instead of 95,
and '\●' now mentions \u25cf.
2013-09-19 16:58:49 +02:00
Benjamin Herr
1019177958 lexer: show correct span on lexical errors
Previously, the lexer calling `rdr.fatal(...)` would report the span of
the last complete token, instead of a span within the erroneous token
(besides one span fixed in 1ac90bb).

This commit adds a wrapper around `rdr.fatal(...)` that sets the span
explicilty, so that all fatal errors in `libsyntax/parse/lexer.rs` now
report the offending code more precisely. A number of tests try to
verify that, though the `compile-fail` testing setup can only check that
the spans are on the right lines, and the "unterminated string/block
comment" errors can't have the line marked at all, so that's incomplete.

Closes #9149.
2013-09-19 16:58:11 +02:00
bors
da29a8e6be auto merge of #9299 : alexcrichton/rust/fmt-trailing-comma, r=huonw
This is more consistent with other parts of the language and it also makes it
easier to use in situations where format string is massive.
2013-09-19 07:06:04 -07:00
bors
a7cf7b7b0b auto merge of #9291 : jzelinskie/rust/remove-cond, r=alexcrichton
This is my first contribution, so please point out anything that I may have missed.

I consulted IRC and settled on `match () { ... }` for most of the replacements.
2013-09-19 00:31:05 -07:00
Alex Crichton
040f1c06bc Allow trailing commas in format!
This is more consistent with other parts of the language and it also makes it
easier to use in situations where format string is massive.
2013-09-18 13:51:07 -07:00
Alex Crichton
817576ee70 Register new snapshots 2013-09-18 11:07:22 -07:00
Jimmy Zelinskie
4757631369 Remove and replace cond! Closes #9282. 2013-09-18 07:34:02 -04:00
bors
b8d3496528 auto merge of #9264 : ben0x539/rust/pp-work, r=alexcrichton
Since 3b6314c the pretty printer seems to only print trait bounds for `ast::ty_path(...)`s that have a generics arguments list. That seems wrong, so let's always print them.

Closes #9253, un-xfails test for #7673.
2013-09-18 04:15:56 -07:00
Erick Tryzelaar
1a90f24bbd extra: minor cleanup of Zero and Default syntax extension 2013-09-17 21:02:17 -07:00
Daniel Rosenwasser
604667fa82 Added support for a \0 escape sequence.
This commit adds support for `\0` escapes in character and string literals.

Since `\0` is equivalent to `\x00`, this is a direct translation to the latter
escape sequence. Future builds will be able to compile using `\0` directly.

Also updated the grammar specification and added a test for NUL characters.
2013-09-17 23:52:29 -04:00
Benjamin Herr
823ebb14ba pp: also print bounds in paths with no generic params
Since 3b6314c3 the pretty printer seems to only print trait bounds for
`ast::ty_path(...)`s that have a generics arguments list. That seems
wrong, so let's always print them.

Closes #9253, un-xfails test for #7673.
2013-09-17 23:41:42 +02:00
Benjamin Herr
aa406c151e pp: typo in comment 2013-09-17 22:27:12 +02:00
bors
72e7c62ec4 auto merge of #9245 : kballard/rust/bytes-span, r=catamorphism
This constrains the span to the appropriate argument, so you know which
one caused the problem. Instead of

    foo.rs:2:4: 2:21 error: Too large integer literal in bytes!
    foo.rs:2    bytes!(1, 256, 2)
                ^~~~~~~~~~~~~~~~~

it will say

    foo.rs:2:14 2:17 error: Too large integer literal in bytes!
    foo.rs:2    bytes!(1, 256, 2)
                          ^~~
2013-09-17 08:45:44 -07:00
bors
29cdf58861 auto merge of #9244 : thestinger/rust/drop, r=catamorphism
This doesn't close any bugs as the goal is to convert the parameter to by-value, but this is a step towards being able to make guarantees about `&T` pointers (where T is Freeze) to LLVM.
2013-09-17 07:15:42 -07:00
Daniel Micay
4e161a4d40 switch Drop to &mut self 2013-09-16 22:19:23 -04:00
Kevin Ballard
b0647feab0 Limit spans in bytes!() error messages to the argument in question
This constrains the span to the appropriate argument, so you know which
one caused the problem. Instead of

  foo.rs:2:4: 2:21 error: Too large integer literal in bytes!
  foo.rs:2    bytes!(1, 256, 2)
              ^~~~~~~~~~~~~~~~~

it will say

  foo.rs:2:14 2:17 error: Too large integer literal in bytes!
  foo.rs:2    bytes!(1, 256, 2)
                        ^~~
2013-09-16 18:55:56 -07:00
Corey Richardson
d0e0c336d0 Update syntax test 2013-09-16 19:12:54 -04:00
Corey Richardson
bb4d4d7eb9 Fix hardcoded string in libsyntax 2013-09-16 17:12:53 -04:00
bors
b05dccacae auto merge of #9187 : lkuper/rust/no-simplevisitor, r=catamorphism
We don't seem to be using `SimpleVisitor` anywhere in rustc.  Is there any reason to keep it around?

r? anyone
2013-09-16 00:15:52 -07:00
bors
29032cda8c auto merge of #9168 : michaelwoerister/rust/traits, r=jdm
This pull request finally adds support for recursive type definitions and provides a stub implementation for object pointers.
2013-09-15 11:55:49 -07:00
blake2-ppc
8522341274 Remove {uint,int,u64,i64,...}::from_str,from_str_radix
Remove these in favor of the two traits themselves and the wrapper
function std::from_str::from_str.

Add the function std::num::from_str_radix in the corresponding role for
the FromStrRadix trait.
2013-09-15 14:29:16 +02:00
Michael Woerister
bf37de9fc6 debuginfo: Basic support for trait objects. 2013-09-15 12:28:25 +02:00
Alex Crichton
640613892f Fix expand_stmt as well as expand_expr to use the correct span
The same fix as before is still relevant, I just forgot to update the
expand_stmt macro expansion site. The tests for format!() suffice as tests for
this change.
2013-09-15 01:47:02 -07:00
Alex Crichton
cfe3db810b Reduce the amount of complexity in format!
This renames the syntax-extension file to format from ifmt, and it also reduces
the amount of complexity inside by defining all other macros in terms of
format_args!
2013-09-15 01:09:00 -07:00
Lindsey Kuper
6ba2cb88a6 These impls, at least, can be avoided by deriving Ord. 2013-09-14 19:38:22 -04:00
Lindsey Kuper
653ffa845d Kill off method impls made redundant by default methods. 2013-09-14 19:38:22 -04:00
bors
524c190565 auto merge of #9183 : alexcrichton/rust/issue-5794, r=catamorphism
Closes #5794
2013-09-14 12:30:54 -07:00
bors
5f2f952dbc auto merge of #9181 : lkuper/rust/libsyntax-default-methods-refactor, r=alexcrichton
I'm getting the three `make check` failures mentioned in issue #9127, which I also get building master.
2013-09-14 10:05:51 -07:00
bors
1c26513ef9 auto merge of #9180 : blake2-ppc/rust/reduce-either, r=catamorphism
Work a bit towards #9157 "Remove Either". These instances don't need to use Either and are better expressed in other ways (removing allocations and simplifying types).
2013-09-14 08:50:50 -07:00
bors
2aa578efd9 auto merge of #9115 : erickt/rust/master, r=erickt
This is a series of patches to modernize option and result. The highlights are:

* rename `.unwrap_or_default(value)` and etc to `.unwrap_or(value)`
* add `.unwrap_or_default()` that uses the `Default` trait
* add `Default` implementations for vecs, HashMap, Option
* add  `Option.and(T) -> Option<T>`, `Option.and_then(&fn() -> Option<T>) -> Option<T>`, `Option.or(T) -> Option<T>`, and `Option.or_else(&fn() -> Option<T>) -> Option<T>`
* add `option::ToOption`, `option::IntoOption`, `option::AsOption`, `result::ToResult`, `result::IntoResult`, `result::AsResult`, `either::ToEither`, and `either::IntoEither`, `either::AsEither`
* renamed `Option::chain*` and `Result::chain*` to `and_then` and `or_else` to avoid the eventual collision with `Iterator.chain`.
* Added a bunch of impls of `Default`
* Added a `#[deriving(Default)]` syntax extension
* Removed impls of `Zero` for `Option<T>` and vecs.
2013-09-14 00:01:04 -07:00
Lindsey Kuper
940a86b760 Get rid of unused SimpleVisitor stuff. 2013-09-14 02:00:04 -04:00
Alex Crichton
6c4c5f5631 Pass a more proper span to the syntax expanders
Closes #5794
2013-09-13 20:54:52 -07:00
blake2-ppc
92c4c077a0 syntax: Remove use of Either in parse.rs
The arg or capture type alias was actually never used for the capture
case, so the code is simplified with `Either<arg, ()>` replaced by `arg`
2013-09-14 04:07:43 +02:00
Lindsey Kuper
ade7df43d6 Refactor libsyntax Visitor impls to use default methods. 2013-09-13 20:48:58 -04:00
Brian Anderson
c62919f607 Work around a compiler crash folding labeled break. #9129
Servo is hitting this problem, so this is a workaround for a lack of a real solution.
2013-09-13 16:00:18 -07:00
Erick Tryzelaar
a0e123eb6e syntax: add #[deriving(Default)] syntax extension 2013-09-12 18:54:13 -07:00
Erick Tryzelaar
38f97ea103 std: Rename {Option,Result}::chain{,_err}* to {and_then,or_else} 2013-09-12 18:54:13 -07:00
Erick Tryzelaar
e6c11313c8 std: Add Option.{result_or_default,or_default} that uses Default 2013-09-12 18:54:12 -07:00
Erick Tryzelaar
f1374a7044 libsyntax: add Default implementation to OptVec 2013-09-12 18:54:12 -07:00
Erick Tryzelaar
45c62c08f9 std: rename Option::unwrap_or_default() to unwrap_or() 2013-09-12 18:54:11 -07:00
bors
248765a746 auto merge of #9135 : jbclements/rust/let-var-hygiene, r=erickt
Fixes issue #9110, changes field_ty element to Name, adds test case, improves fail error message
2013-09-12 09:51:02 -07:00
Alex Crichton
9a5f95a82c Implement a format_args!() macro
The purpose of this macro is to further reduce the number of allocations which
occur when dealing with formatting strings. This macro will perform all of the
static analysis necessary to validate that a format string is safe, and then it
will wrap up the "format string" into an opaque struct which can then be passed
around.

Two safe functions are added (write/format) which take this opaque argument
structure, unwrap it, and then call the unsafe version of write/format (in an
unsafe block). Other than these two functions, it is not intended for anyone to
ever look inside this opaque struct.

The macro looks a bit odd, but mostly because of rvalue lifetimes this is the
only way for it to be safe that I know of.

Example use-cases of this are:

* third-party libraries can use the default formatting syntax without any
  forced allocations
* the fail!() macro can avoid allocating the format string
* the logging macros can avoid allocation any strings
2013-09-12 00:36:54 -07:00
John Clements
b9a8b3700b more helpful error message for ident comparison failure 2013-09-11 22:18:45 -07:00
bors
62166611e7 auto merge of #9061 : jakub-/rust/pretty-print-empty-impl, r=huonw 2013-09-11 19:16:00 -07:00
SiegeLord
8c5402fd36 Properly encode/decode structural variants. 2013-09-11 14:49:09 -04:00
bors
f8cbf41064 auto merge of #9093 : pnkfelix/rust/fsk-remove-oldvisit, r=alexcrichton 2013-09-11 01:46:07 -07:00
Alex Crichton
11e9c48353 Flag unsafe blocks from format! as compiler-generated 2013-09-11 00:13:41 -07:00
Alex Crichton
19a6fabad8 Implement the notion of a "generated unsafe block"
This way syntax extensions can generate unsafe blocks without worrying about
them generating unnecessary unsafe warnings. Perhaps a special keyword could be
added to be used in macros, but I don't think that's the best solution.
2013-09-11 00:13:22 -07:00
John Clements
422cf1adc5 change type of ExprLoop and ExprBreak elts from ident->name.
Lots of downstream changes in librustc, should be infinitesimally faster.
2013-09-10 14:12:54 -07:00
bors
753d8c226c auto merge of #9088 : nikomatsakis/rust/issue-6304-AST-tree-not-DAG, r=catamorphism
Ensures that each AST node has a unique id. Fixes numerous bugs in macro expansion and deriving. Add two
representative tests.

Fixes #7971
Fixes #6304
Fixes #8367
Fixes #8754
Fixes #8852
Fixes #2543
Fixes #7654
2013-09-10 03:10:59 -07:00
Niko Matsakis
a5ad4c3794 Delay assignment of node ids until after expansion. Ensures that each AST node
has a unique id. Fixes numerous bugs in macro expansion and deriving. Add two
representative tests.

Fixes #7971
Fixes #6304
Fixes #8367
Fixes #8754
Fixes #8852
Fixes #2543
Fixes #7654
2013-09-10 05:45:12 -04:00
bors
96da35611f auto merge of #9090 : jbclements/rust/let-var-hygiene, r=luqmana
This appears to fix issue #9049. It also re-enables the ICE check on comparing idents for equality; it appears that ICEs are better than seg faults.
2013-09-10 01:06:00 -07:00
Felix S. Klock II
8b00004871 Remove oldvisit.rs (yay!); part of #7081 refactoring. 2013-09-10 09:00:53 +02:00
bors
7820fb5ca9 auto merge of #9062 : blake2-ppc/rust/vec-iterator, r=alexcrichton
Visit the free functions of std::vec and reimplement or remove some. Most prominently, remove `each_permutation` and replace with two iterators, ElementSwaps and Permutations.

Replace unzip, unzip_slice with an updated `unzip` that works with an iterator argument.

Replace each_permutation with a Permutation iterator. The new permutation iterator is more efficient since it uses an algorithm that produces permutations in an order where each is only one element swap apart, including swapping back to the original state with one swap at the end.

Unify the seldomly used functions `build`, `build_sized`, `build_sized_opt` into just one function `build`.

Remove `equal_sizes`
2013-09-09 21:31:03 -07:00
John Clements
57f7abaf19 undo cowardly hiding of eq-check
I've reversed my thinking on this restrictive definition of eq after
two separate bugs were hidden by commenting it out; it's better to
get ICEs than SIGSEGV's, any day.

RE-ENABLING ICE MACHINE!
2013-09-09 20:50:41 -07:00
blake2-ppc
c11ee0fb67 std::at_vec and vec: Unify build_sized, build_sized_opt into build
These functions have very few users since they are mostly replaced by
iterator-based constructions.

Convert a few remaining users in-tree, and reduce the number of
functions by basically renaming build_sized_opt to build, and removing
the other two. This for both the vec and the at_vec versions.
2013-09-10 05:50:11 +02:00
bors
8c7c0b41d7 auto merge of #9034 : catamorphism/rust/rustpkg-workcache, r=metajack
r? @metajack or @brson - This pull request makes rustpkg use the workcache library to avoid recompilation.
2013-09-09 20:16:02 -07:00
bors
059cbaadfa auto merge of #9005 : alexcrichton/rust/rusty-log, r=brson
Also redefine all of the standard logging macros to use more rust code instead
of custom LLVM translation code. This makes them a bit easier to understand, but
also more flexibile for future types of logging.

Additionally, this commit removes the LogType language item in preparation for
changing how logging is performed.
2013-09-09 10:41:05 -07:00
Tim Chevalier
02a0fb94ee rustpkg: Use workcache
rustpkg now uses the workcache library to avoid recompilation.
Hooray!
2013-09-08 20:05:12 -07:00
Jakub
7173b9d1b8 Fix pretty-printing of empty impl items 2013-09-08 22:44:24 +00:00
Huon Wilson
14183114e1 syntax: aesthetic improvements to the for desugaring. 2013-09-08 23:00:05 +10:00
Huon Wilson
07351b44c6 syntax: implement labelled breaks for for.
`for` desugars to `loop` so it is trivial to just desugar to `loop` while
retaining any label.
2013-09-08 22:08:01 +10:00
bors
b609d022c4 auto merge of #9035 : alexcrichton/rust/fewer-clownshoes, r=huonw
This removes another large chunk of this odd 'clownshoes' identifier showing up
in symbol names. These all originated from external crates because the encoded
items were encoded independently of the paths calculated in ast_map. The
encoding of these paths now uses the helper function in ast_map to calculate the
"pretty name" for an impl block.

Unfortunately there is still no information about generics in the symbol name,
but it's certainly vastly better than before

    hash::__extensions__::write::_version::v0.8

becomes

    hash::Writer$SipState::write::hversion::v0.8

This also fixes bugs in which lots of methods would show up as `meth_XXX`, they
now only show up as `meth` and throw some extra characters onto the version
string.
2013-09-08 01:05:59 -07:00
Alex Crichton
13d33064a6 Remove even more usage of clownshoes in symbols
This removes another large chunk of this odd 'clownshoes' identifier showing up
in symbol names. These all originated from external crates because the encoded
items were encoded independently of the paths calculated in ast_map. The
encoding of these paths now uses the helper function in ast_map to calculate the
"pretty name" for an impl block.

Unfortunately there is still no information about generics in the symbol name,
but it's certainly vastly better than before

    hash::__extensions__::write::_version::v0.8

becomes

    hash::Writer$SipState::write::hversion::v0.8

This also fixes bugs in which lots of methods would show up as `meth_XXX`, they
now only show up as `meth` and throw some extra characters onto the version
string.
2013-09-06 23:56:17 -07:00
John Clements
eabeba3ef3 added index to test cases, more debugging output 2013-09-06 13:35:14 -07:00
John Clements
1ecc1e51c0 quote_* macros no longer need to be capturing
This is actually almost a problem, because those were my poster-child
macros for "here's how to implement a capturing macro." Following this
change, there will be no macros that use capturing; this will probably
make life unpleasant for the first person that wants to implement a
capturing macro. I should probably create a dummy_capturing macro,
just to show how it works.
2013-09-06 13:35:14 -07:00
John Clements
4664d3320d comment fix 2013-09-06 13:35:14 -07:00
John Clements
6c294ba538 add test case, cleanup 2013-09-06 13:35:13 -07:00
John Clements
fe1d21caec add display_sctable fn to ast_util 2013-09-06 13:35:13 -07:00
John Clements
8330411688 fixed a bug that caused double-expand-traversal of macros that expand into modules. 2013-09-06 13:35:13 -07:00
John Clements
fddc815ada WIP: adding mark-cancelling for macro_rules 2013-09-06 13:35:13 -07:00
John Clements
e681e7843e added string_to_tts 2013-09-06 13:35:13 -07:00
John Clements
985a92ec12 comments 2013-09-06 13:35:13 -07:00
John Clements
1a06584117 comment on hygienic context extension train fns 2013-09-06 13:35:13 -07:00
John Clements
dc7f3df27f awesome new bug! added test case 2013-09-06 13:35:12 -07:00
John Clements
7b548e7180 expose mtwt_marksof for testing 2013-09-06 13:35:12 -07:00
John Clements
7dca301cf4 ident->name 2013-09-06 13:35:12 -07:00
John Clements
dbf4e19ea5 remove unneeded imports, clean up unused var warnings 2013-09-06 13:35:12 -07:00
John Clements
60562ac9f8 whitespace, reindentation, and comments only 2013-09-06 13:35:12 -07:00
John Clements
ec0a64def5 memoization for resolve 2013-09-06 13:35:12 -07:00
John Clements
0954e66442 uncomment mtwt_resolve calls 2013-09-06 13:35:11 -07:00
John Clements
9ab2cfdae6 added utility function 2013-09-06 13:35:11 -07:00
John Clements
bc2a44daf1 fix one remaining token comparison, refactor token comparison to avoid == check 2013-09-06 13:35:11 -07:00
John Clements
e29d25338d remove dead code 2013-09-06 13:35:11 -07:00
John Clements
b9bb4abcb6 capturing macros now implemented 2013-09-06 13:35:11 -07:00
John Clements
2c51e262f3 add fold_mac clause to fun_to_ctxt_folder 2013-09-06 13:35:11 -07:00
John Clements
dfa04cecca add fold_mac field to fold.rs 2013-09-06 13:35:10 -07:00
John Clements
3261b6eece WIP: adding context to macros 2013-09-06 13:35:10 -07:00
John Clements
34f31e2961 rework fold so that fold_tts takes an ast_fold rather than a thunk, stop using closures in ident traversal 2013-09-06 13:35:10 -07:00
John Clements
09e6dda4f2 add temporarily unused ctxt field to mac_invoc_tt 2013-09-06 13:35:10 -07:00
John Clements
3621c674cc comments 2013-09-06 13:35:10 -07:00
John Clements
0c31c930ff add test case for macro token comparison 2013-09-06 13:35:10 -07:00
John Clements
963dab5dcb marking on both input and output from macros. nice shiny new test case framework 2013-09-06 13:35:10 -07:00
John Clements
58e7598c2e added gensym_copy mechanism to ensure sharing of pointers in the interner
this makes comparisons constant-time, and enables spelling-comparison
of identifiers, crucial in many parts of resolve.
2013-09-06 13:35:10 -07:00
John Clements
9d33001a90 added test for ptr_eq on fresh_name-generated idents 2013-09-06 13:35:09 -07:00
John Clements
cd4e637ae4 fixed bug in fold's traversal of cast exprs 2013-09-06 13:35:09 -07:00
John Clements
d876a721d2 new test that uncovers bug in fold 2013-09-06 13:35:09 -07:00
John Clements
015ba31c02 test case support fns, remove debugging test case 2013-09-06 13:35:09 -07:00
John Clements
62fee04ae9 test case work 2013-09-06 13:35:09 -07:00
John Clements
1f8e856430 re-add lost call to expand_block_elts 2013-09-06 13:35:09 -07:00
John Clements
9071ac60b6 re-add debug version 2013-09-06 13:35:09 -07:00
John Clements
7a9af098f0 test case work 2013-09-06 13:35:09 -07:00
John Clements
f5ab867119 use empty_ctxt to simplify downstream 2013-09-06 13:35:09 -07:00