Commit Graph

1269 Commits

Author SHA1 Message Date
Patrick Walton
e0a5460e94 libsyntax: De-@mut Parser::obsolete_set 2014-01-02 14:16:08 -08:00
Patrick Walton
4ee95cf96c libsyntax: De-@mut Parser::restriction 2014-01-02 14:16:08 -08:00
Patrick Walton
6992a5c77d libsyntax: De-@mut Parser::tokens_consumed 2014-01-02 14:16:08 -08:00
Patrick Walton
55a90f5928 libsyntax: De-@mut Parser::buffer_start and Parser::buffer_end 2014-01-02 14:16:07 -08:00
Patrick Walton
5c2c670d8f libsyntax: De-@mut Parser::buffer 2014-01-02 14:16:07 -08:00
Patrick Walton
044ad56824 libsyntax: De-@mut Parser::last_token 2014-01-02 14:16:07 -08:00
Patrick Walton
cc3e6ecbfd libsyntax: De-@mut Parser::last_span 2014-01-02 14:16:07 -08:00
Patrick Walton
0c6cee55ea libsyntax: De-@mut Parser::span 2014-01-02 14:16:07 -08:00
Patrick Walton
758d854436 libsyntax: De-@mut token in the parser 2014-01-02 14:16:07 -08:00
Patrick Walton
425a140485 libsyntax: De-@mut quote_depth in the parser 2014-01-02 14:16:07 -08:00
Patrick Walton
f499d365ad libsyntax: Make the parser mutable 2014-01-02 14:16:07 -08:00
bors
0df9b850ac auto merge of #10696 : fhahn/rust/issue9543-remove-extern-mod-foo, r=pcwalton
This patch for  #9543 throws an `obsolete syntax` error for `extern mod foo (name="bar")` . 
I was wondering if [this](https://github.com/fhahn/rust/compare/mozilla:master...fhahn:issue9543-remove-extern-mod-foo?expand=1#diff-da9d34ca1d0f6beee2838cf02e07345cR4444) is the correct place to do this?

I think the wording of the error message could probably be improved as well.

If this approach is OK, I'm going to run the whole test suite tomorrow and update the old syntax to the new one.
2014-01-02 11:32:09 -08:00
Florian Hahn
f42a36cded Remove extern mod foo (name="bar") syntax, closes #9543 2014-01-01 23:36:57 +01:00
klutzy
9cdad685a3 syntax::codemap: Add static DUMMY_SP
It replaces `dummy_sp()`.
2014-01-01 19:51:35 +09:00
klutzy
fe10c63326 syntax::diagnostic: Remove unnecessary traits
This removes trait `handler` and `span_handler`,
and renames `HandlerT` to `Handler`, `CodemapT` to `SpanHandler`.
2014-01-01 19:10:43 +09:00
bors
9d1de0b699 auto merge of #11077 : alexcrichton/rust/crate-id, r=cmr
Right now the --crate-id and related flags are all process *after* the entire
crate is parsed. This is less than desirable when used with makefiles because it
means that just to learn the output name of the crate you have to parse the
entire crate (unnecessary).

This commit changes the behavior to lift the handling of these flags much sooner
in the compilation process. This allows us to not have to parse the entire crate
and only have to worry about parsing the crate attributes themselves. The
related methods have all been updated to take an array of attributes rather than
a crate.

Additionally, this ceases duplication of the "what output are we producing"
logic in order to correctly handle things in the case of --test.

Finally, this adds tests for all of this functionality to ensure that it does
not regress.
2013-12-20 15:21:33 -08:00
Alex Crichton
87add53327 rustc: Improve crate id extraction
Right now the --crate-id and related flags are all process *after* the entire
crate is parsed. This is less than desirable when used with makefiles because it
means that just to learn the output name of the crate you have to parse the
entire crate (unnecessary).

This commit changes the behavior to lift the handling of these flags much sooner
in the compilation process. This allows us to not have to parse the entire crate
and only have to worry about parsing the crate attributes themselves. The
related methods have all been updated to take an array of attributes rather than
a crate.

Additionally, this ceases duplication of the "what output are we producing"
logic in order to correctly handle things in the case of --test.

Finally, this adds tests for all of this functionality to ensure that it does
not regress.
2013-12-20 09:10:11 -08:00
Alex Crichton
bfb760c697 Accept trailing commas in struct patterns
We decided in the 12/10/13 weekly meeting that trailing commas should be
accepted pretty much anywhere. They are currently not allowed in struct
patterns, and this commit adds support for that.

Closes #10392
2013-12-19 09:29:41 -08:00
bors
5cea7db2a5 auto merge of #10915 : alexcrichton/rust/fixes, r=ILyoan
Just a little cleanup.
2013-12-18 05:01:47 -08:00
Seo Sanghyeon
4a13364010 Remove obsolete mutability from ast::Ty 2013-12-17 03:01:40 +09:00
Alex Crichton
e2fa3c3af7 Forbid multiple imports in use statements
Closes #10911
2013-12-15 22:04:18 -08:00
Patrick Walton
775ccadd25 libsyntax: Implement the new box syntax for unique pointers. 2013-12-15 10:41:15 -08:00
bors
1b12dca7f9 auto merge of #10897 : boredomist/rust/remove-self-lifetime, r=brson
Also remove all instances of 'self within the codebase.

This fixes #10889.

To make reviewing easier the following files were modified with more than a dumb text replacement:

- `src/test/compile-fail/lifetime-no-keyword.rs`
- `src/test/compile-fail/lifetime-obsoleted-self.rs`
- `src/test/compile-fail/regions-free-region-ordering-incorrect.rs`
- `src/libsyntax/parse/lexer.rs`
2013-12-11 12:56:22 -08:00
Erik Price
5731ca3078 Make 'self lifetime illegal.
Also remove all instances of 'self within the codebase.

This fixes #10889.
2013-12-11 10:54:06 -08:00
bors
47d10c745e auto merge of #10891 : chris-morgan/rust/macroize-(or-should-that-be-macroify)-syntax--parse--token-so-that-we-don't-make-mistakes-and-to-reduce-the-maintenance-burden, r=huonw
I also renumbered things at the same time; ``in`` was shifted into its
alphabetical position and the reserved keywords were reordered (a couple
of them were out of order).

Unused special identifiers are also removed in the second part.
2013-12-11 10:36:18 -08:00
bors
fff03a5fc7 auto merge of #10808 : kballard/rust/use-braces, r=alexcrichton
This fixes #10806.
2013-12-11 01:06:21 -08:00
Kevin Ballard
bd36b06f55 Support imports of the form use {foo,bar}
This fixes #10806.
2013-12-10 23:15:19 -08:00
bors
b8516de48f auto merge of #10833 : sfackler/rust/mut-pat, r=brson
Previously, if you wanted to bind a field mutably or by ref, you had to
do something like Foo { x: ref mut x }. You can now just do
Foo { ref mut x }.

Closes #6137
2013-12-10 22:51:19 -08:00
Chris Morgan
dd042efa7e Separate strict/reserved keywords, derive bounds.
It's twenty lines longer, but makes for clearer separation of strict and
reserved keywords (probably a good thing) and removes another moving
part (the definitions of `(STRICT|RESERVED)_KEYWORD_(START|FINAL)`).
2013-12-11 15:15:55 +11:00
Chris Morgan
d4f5ae0118 Remove the following unused special identifiers:
- underscore           ("_")
- unary                ("unary")
- not_fn               ("!")
- idx_fn               ("[]")
- unary_minus_fn       ("unary-")
- item                 ("item")
- block                ("block")
- stmt                 ("stmt")
- pat                  ("pat")
- expr                 ("expr")
- ty                   ("ty")
- ident                ("ident")
- path                 ("path")
- descrim              ("descrim")
- clownshoe_stack_shim ("__rust_stack_shim")
- blk                  ("blk")
- c_abi                ("C")

(And, of course, renumber everything to match.)
2013-12-11 14:46:16 +11:00
Chris Morgan
267ac45f41 Deduplicate in syntax::parse::token with a macro.
I also renumbered things at the same time; ``in`` was shifted into its
alphabetical position and the reserved keywords were reordered (a couple
of them were out of order).
2013-12-11 09:52:05 +11:00
Steven Fackler
8240faf73a Allow ref and mut modifiers for short form field patterns
Previously, if you wanted to bind a field mutably or by ref, you had to
do something like Foo { x: ref mut x }. You can now just do
Foo { ref mut x }.

Closes #6137
2013-12-10 14:05:57 -08:00
Kiet Tran
1755408d1a Remove dead codes 2013-12-08 02:55:28 -05:00
Léo Testard
74757af096 Forbid keywords as lifetime parameters names. 2013-12-05 21:06:00 +01:00
Kevin Ballard
2c4a1b55e6 Rename extra::json::*::init() constructors to *::new() 2013-12-04 22:33:53 -08:00
Kevin Ballard
408dc5ad1b Revert "libstd: Change Path::new to Path::init."
This reverts commit c54427ddfb.

Leave the #[ignores] in that were added to rustpkg tests.

Conflicts:
	src/librustc/driver/driver.rs
	src/librustc/metadata/creader.rs
2013-12-04 22:33:53 -08:00
bors
ad58e2c31c auto merge of #10792 : kballard/rust/parse_sugary_call_expr-comments, r=alexcrichton
The comments on this function date back from when it was used for `for`
expressions in addition to `do` expressions.
2013-12-04 13:31:45 -08:00
Huon Wilson
9d64e46013 std::str: remove from_utf8.
This function had type &[u8] -> ~str, i.e. it allocates a string
internally, even though the non-allocating version that take &[u8] ->
&str and ~[u8] -> ~str are all that is necessary in most circumstances.
2013-12-04 22:35:53 +11:00
Kevin Ballard
c00837e90a Fix the comments for libsyntax::parse::parser::parse_sugary_call_expr
The comments on this function date back from when it was used for `for`
expressions in addition to `do` expressions.
2013-12-03 16:55:00 -08:00
bors
df41115213 auto merge of #10750 : Blei/rust/no-at-struct-field, r=alexcrichton 2013-12-01 05:42:06 -08:00
bors
b2aa00ba8b auto merge of #10676 : eddyb/rust/ast-box-in-enums, r=cmr
**Note**: I only tested on top of my #10670 PR, size reductions come from both change sets.

With this, [more enums are shrinked](https://gist.github.com/eddyb/08fef0dfc6ff54e890bc), the most significant one being `ast_node`, from 104 bytes (master) to 96 (#10670) and now to 32 bytes.

My own testcase requires **200MB** less when compiling (not including the other **200MB** gained in #10670), and rustc-stage2 is down by about **130MB**.

I believe there is more to gain by fiddling with the enums' layouts.
2013-12-01 03:11:58 -08:00
Philipp Brüschweiler
47ce981903 ast: Remove one @ and fix the fallout 2013-12-01 11:24:58 +01:00
Eduard Burtescu
a9c4b18b18 Box Block, fn_decl, variant and Ty in the AST, as they were inflating critical enum sizes. 2013-12-01 00:00:39 +02:00
bors
9bf62f71bc auto merge of #10727 : erickt/rust/json, r=huonw
This PR does some small modernizations to the json library. First is to remove the `@` boxes, second is to rename the constructors to `new`.
2013-11-30 06:06:42 -08:00
Erick Tryzelaar
a7b311ac61 extra: missed a couple @ in json 2013-11-29 21:26:03 -08:00
Erick Tryzelaar
6818b96a66 extra: json::Encoder should take a &mut io::Writer 2013-11-29 11:19:19 -08:00
Erick Tryzelaar
f7b739c34c extra: Rename json constructors into *::init 2013-11-29 11:19:19 -08:00
Patrick Walton
c54427ddfb libstd: Change Path::new to Path::init. 2013-11-29 10:55:13 -08:00
Alex Crichton
ab387a6838 Register new snapshots 2013-11-28 20:27:56 -08:00
Corey Richardson
b50b162884 Be more strict about doc comments
Previously, `//// foo` and `/*** foo ***/` were accepted as doc comments. This
changes that, so that only `/// foo` and `/** foo ***/` are accepted. This
confuses many newcomers and it seems weird.

Also update the manual for these changes, and modernify the EBNF for comments.

Closes #10638
2013-11-27 18:00:50 -05:00
Eduard Burtescu
f09b7b0ecd Freeze the AST by removing a couple of unused @mut ~[T] from token_tree. 2013-11-27 17:48:58 +02:00
bors
faf4c939fb auto merge of #10670 : eddyb/rust/node-u32, r=alexcrichton
### Rationale
There is no reason to support more than 2³² nodes or names at this moment, as compiling something that big (even without considering the quadratic space usage of some analysis passes) would take at least **64GB**.
Meanwhile, some can't (or barely can) compile rustc because it requires almost **1.5GB**.

### Potential problems
Can someone confirm this doesn't affect metadata (de)serialization? I can't tell myself, I know nothing about it.

### Results
Some structures have a size reduction of 25% to 50%: [before](https://gist.github.com/luqmana/3a82a51fa9c86d9191fa) - [after](https://gist.github.com/eddyb/5a75f8973d3d8018afd3).
Sadly, there isn't a massive change in the memory used for compiling stage2 librustc (it doesn't go over **1.4GB** as [before](http://huonw.github.io/isrustfastyet/mem/), but I can barely see the difference).
However, my own testcase (previously peaking at **1.6GB** in typeck) shows a reduction of **200**-**400MB**.
2013-11-26 22:07:44 -08:00
Eduard Burtescu
7ed27b5531 Shink NodeId, CrateNum, Name and Mrk down to 32 bits on x64. 2013-11-27 07:02:25 +02:00
Patrick Walton
efc512362b libsyntax: Remove all non-proc do syntax. 2013-11-26 08:24:18 -08:00
Patrick Walton
6801bc8f55 libsyntax: Remove the old-style borrowed closure type syntax from the
language.
2013-11-26 08:20:59 -08:00
Marvin Löbel
24b316a3b9 Removed unneccessary _iter suffixes from various APIs 2013-11-26 10:02:26 +01:00
bors
55201ed858 auto merge of #10628 : huonw/rust/3614, r=alexcrichton
Fixes #3614.
2013-11-25 01:12:36 -08:00
Huon Wilson
e36cb0d5c1 syntax: parse inner attributes on impls.
Fixes #3614.
2013-11-25 19:18:44 +11:00
Corey Richardson
ab19861037 Add a note for unclosed delimiters
Currently, the parser doesn't give any context when it finds an unclosed
delimiter and it's not EOF. Report the most recent unclosed delimiter, to help
the user along.

Closes #10636
2013-11-24 21:32:38 -05:00
bors
ea5d1dfb1c auto merge of #10567 : sanxiyn/rust/bytepos, r=alexcrichton 2013-11-20 23:31:27 -08:00
Seo Sanghyeon
f4c1f49049 Fix parsing tests 2013-11-21 01:32:29 +09:00
Seo Sanghyeon
5e1e487624 Make BytePos 32-bit 2013-11-20 16:51:25 +09:00
Patrick Walton
492677ec1e libsyntax: Change all uses of &fn to ||. 2013-11-19 12:40:19 -08:00
Patrick Walton
f977bedafd libsyntax: Remove ~fn() from the language 2013-11-18 18:28:10 -08:00
Brian Anderson
85f107d8cb Use '..' as slice wildcard in vectors 2013-11-18 16:19:48 -08:00
Brian Anderson
35e6c02524 Use '..' as multi-field wildcard in enums and structs. 2013-11-18 16:19:46 -08:00
bors
b0e1318164 auto merge of #10420 : sanxiyn/rust/path, r=cmr
Fix #10283.
2013-11-16 14:36:40 -08:00
Alex Crichton
49ee49296b Move std::rt::io to std::io 2013-11-11 20:44:07 -08:00
Seo Sanghyeon
2337d88339 Fix path parsing 2013-11-11 21:53:14 +09:00
Niko Matsakis
1f4faaee40 Generalize AST and ty::Generics to accept multiple lifetimes. 2013-11-08 19:42:46 -05:00
bors
f00bb2ec04 auto merge of #10243 : mattcarberry/rust/master, r=brson
Associated with Issue #6563.

Useful for Apollo Guidance Computer simulation, Unix file system permissions, and maybe one or two other things.
2013-11-07 17:26:12 -08:00
Luqman Aden
c669ccf3d3 libsyntax/librustc: Allow calling variadic foreign functions. 2013-11-04 23:53:11 -05:00
Alex Crichton
f19d083362 Fill out the remaining functionality in io::file
This adds bindings to the remaining functions provided by libuv, all of which
are useful operations on files which need to get exposed somehow.

Some highlights:

* Dropped `FileReader` and `FileWriter` and `FileStream` for one `File` type
* Moved all file-related methods to be static methods under `File`
* All directory related methods are still top-level functions
* Created `io::FilePermission` types (backed by u32) that are what you'd expect
* Created `io::FileType` and refactored `FileStat` to use FileType and
  FilePermission
* Removed the expanding matrix of `FileMode` operations. The mode of reading a
  file will not have the O_CREAT flag, but a write mode will always have the
  O_CREAT flag.

Closes #10130
Closes #10131
Closes #10121
2013-11-03 15:15:42 -08:00
Alex Crichton
9c1851019f Remove all blocking std::os blocking functions
This commit moves all thread-blocking I/O functions from the std::os module.
Their replacements can be found in either std::rt::io::file or in a hidden
"old_os" module inside of native::file. I didn't want to outright delete these
functions because they have a lot of special casing learned over time for each
OS/platform, and I imagine that these will someday get integrated into a
blocking implementation of IoFactory. For now, they're moved to a private module
to prevent bitrot and still have tests to ensure that they work.

I've also expanded the extensions to a few more methods defined on Path, most of
which were previously defined in std::os but now have non-thread-blocking
implementations as part of using the current IoFactory.

The api of io::file is in flux, but I plan on changing it in the next commit as
well.

Closes #10057
2013-11-03 15:15:42 -08:00
Matt Carberry
519b86b8a8 Added octal literal support. 2013-11-02 21:26:29 -07:00
Patrick Walton
f27272d60f librustc: Implement |A| -> B syntax for closures and make bare fn
work
2013-10-31 10:30:32 -07:00
Brian Anderson
6ef1ab99c1 syntax: Forbid non-string literals in meta items. #623 2013-10-30 14:06:22 -07:00
bors
611c94d984 auto merge of #10134 : reedlepee123/rust/priv_fields, r=brson 2013-10-29 15:11:30 -07:00
Patrick Walton
7e77bf1769 librustc: Implement the proc type as sugar for ~once fn and proc
notation for closures, and disable the feature gate for `once fn` if
used with the `~` sigil.
2013-10-29 10:34:17 -07:00
reedlepee
b5e073830b removed extra line 2013-10-29 21:16:02 +05:30
reedlepee
697813747a Indentation 2013-10-29 21:16:02 +05:30
reedlepee
33b9afac4a updated the places where the struct is created #7427 2013-10-29 21:16:02 +05:30
reedlepee
6e07377715 Changed name to non_copyable #7427 2013-10-29 21:16:02 +05:30
reedlepee
b7e9b0ce32 Added the comment #7427 2013-10-29 21:16:02 +05:30
reedlepee
83cdae63e8 Replaced empty destructors with NonCopyable #7427
closes #7427
2013-10-29 21:16:01 +05:30
Joshua Yanovski
01ab8542fb Field identifiers now include specific spans (Closes #8263). 2013-10-28 22:57:34 -07:00
Alex Crichton
72557d8312 Remove the extension traits for Readers/Writers
These methods are all excellent candidates for default methods, so there's no
need to require extra imports of various traits.
2013-10-28 10:16:45 -07:00
Luqman Aden
523a28decc libsyntax: Get rid of obsolete obsolete warning. 2013-10-25 01:50:57 -04:00
Luqman Aden
99b7662971 libsyntax: Get rid of some logic for some obsolete syntax. 2013-10-25 01:21:07 -04:00
Luqman Aden
12308db3d2 libsyntax/librustc: Allow mut qualifier in patterns. 2013-10-25 01:21:07 -04:00
Alex Crichton
6b70ddfba1 Remove io::read_error
The general idea is to remove conditions completely from I/O, so in the meantime
remove the read_error condition to mean the same thing as the io_error condition.
2013-10-24 14:21:57 -07:00
Alex Crichton
61ed2cfb55 Remove even more of std::io
Big fish fried here:

    extra::json
    most of the compiler
    extra::io_util removed
    extra::fileinput removed

Fish left to fry

    extra::ebml
2013-10-24 14:21:57 -07:00
Luqman Aden
af163579ed libsyntax/librustc: Allow specifying mut on ~self. 2013-10-22 21:22:19 -04:00
Luqman Aden
5754848f8c libsyntax/librustc: Allow specifying mut on by-value self. 2013-10-22 21:21:21 -04:00
Alex Crichton
daf5f5a4d1 Drop the '2' suffix from logging macros
Who doesn't like a massive renaming?
2013-10-22 08:09:56 -07:00
Georges Dubus
1dc3d0bf86 Add support for nested comments
Fixes #9468.
2013-10-21 21:58:34 +02:00
Kevin Ballard
bab7eb20df path2: Update based on more review feedback
Standardize the is_sep() functions to be the same in both posix and
windows, and re-export from path. Update extra::glob to use this.

Remove the usage of either, as it's going away.

Move the WindowsPath-specific methods out of WindowsPath and make them
top-level functions of path::windows instead. This way you cannot
accidentally write code that will fail to compile on non-windows
architectures without typing ::windows anywhere.

Remove GenericPath::from_c_str() and just impl BytesContainer for
CString instead.

Remove .join_path() and .push_path() and just implement BytesContainer
for Path instead.

Remove FilenameDisplay and add a boolean flag to Display instead.

Remove .each_parent(). It only had one caller, so just inline its
definition there.
2013-10-16 10:26:48 -07:00
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
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
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
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
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
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
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
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
Alex Crichton
af3b132285 syntax: Remove usage of fmt! 2013-09-30 23:21:19 -07:00
Alex Crichton
7b18976f08 Remove all usage of @ast::Crate 2013-09-29 16:21:25 -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
Brian Anderson
88272a4f24 Add 'continue' as a synonym for 'loop' 2013-09-26 15:04:13 -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
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
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
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
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
37c32e2495 librustc: Remove the remaining direct uses of @fn from librustc. 2013-09-23 18:23:20 -07:00
Birunthan Mohanathas
2ab278f130 Reserve the alignof, offsetof, and sizeof keywords
Closes #9333.
2013-09-22 10:47:36 +03: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
Benjamin Herr
567c567b2d lexer: further slight improvements to lexer errors 2013-09-19 23:08:06 +02: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
Alex Crichton
817576ee70 Register new snapshots 2013-09-18 11:07:22 -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
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
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
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