about summary refs log tree commit diff
path: root/src/libsyntax/parse
AgeCommit message (Collapse)AuthorLines
2014-07-16librustc: Implement the fully-expanded, UFCS form of explicit self.Patrick Walton-6/+24
This makes two changes to region inference: (1) it allows region inference to relate early-bound regions; and (2) it allows regions to be related before variance runs. The former is needed because there is no relation between the two regions before region substitution happens, while the latter is needed because type collection has to run before variance. We assume that, before variance is inferred, that lifetimes are invariant. This is a conservative overapproximation. This relates to #13885. This does not remove `~self` from the language yet, however. [breaking-change]
2014-07-16obsolete.rs: fix typo in messagePhilipp Gesang-1/+1
2014-07-15Deprecate `str::from_utf8_owned`Adolfo Ochagavía-1/+1
Use `String::from_utf8` instead [breaking-change]
2014-07-13auto merge of #15646 : jbclements/rust/method-macros, r=cmrbors-26/+43
This patch adds support for macros in method position. It follows roughly the template for Item macros, where an outer `Method` wrapper contains a `Method_` enum which can either be a macro invocation or a standard macro definition. One note; adding support for macros that expand into multiple methods is not included here, but should be a simple parser change, since this patch updates the type of fold_macro to return a smallvector of methods. For reviewers, please pay special attention to the parser changes; these are the ones I'm most concerned about. Because of the small change to the interface of fold_method, this is a ... [breaking change]
2014-07-13macro in method position parsingJohn Clements-13/+42
2014-07-13refactor Method definition to make space for macrosJohn Clements-14/+2
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-13auto merge of #15621 : sfackler/rust/attr-span, r=cmrbors-1/+1
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-12auto merge of #15601 : jbclements/rust/disable-default-macro-behavior, ↵bors-1/+2
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-11Fix spans for attributesSteven Fackler-1/+1
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-11use side table to store exported macrosJohn Clements-1/+2
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-11Add scaffolding for assigning alpha-numeric codes to rustc diagnosticsJakub Wieczorek-2/+2
2014-07-09Fix all the test falloutCorey Richardson-9/+19
2014-07-09ast: make Name its own typeCorey Richardson-80/+95
2014-07-09lexer: lex WS/COMMENT/SHEBANG rather than skippingCorey Richardson-62/+118
Now, the lexer will categorize every byte in its input according to the grammar. The parser skips over these while parsing, thus avoiding their presence in the input to syntax extensions.
2014-07-09syntax: don't parse numeric literals in the lexerCorey Richardson-225/+287
This removes a bunch of token types. Tokens now store the original, unaltered numeric literal (that is still checked for correctness), which is parsed into an actual number later, as needed, when creating the AST. This can change how syntax extensions work, but otherwise poses no visible changes. [breaking-change]
2014-07-09syntax: don't process string/char/byte/binary litsCorey Richardson-76/+307
This shuffles things around a bit so that LIT_CHAR and co store an Ident which is the original, unaltered literal in the source. When creating the AST, unescape and postprocess them. This changes how syntax extensions can work, slightly, but otherwise poses no visible changes. To get a useful value out of one of these tokens, call `parse::{char_lit, byte_lit, bin_lit, str_lit}` [breaking-change]
2014-07-09lexer: add ident_from and ident_from_to methodsCorey Richardson-0/+14
2014-07-09lexer: shuffle around some functionsCorey Richardson-99/+100
2014-07-09syntax: use a better Show impl for IdentCorey Richardson-1/+1
Rather than just dumping the id in the interner, which is useless, actually print the interned string. Adjust the lexer logging to use Show instead of Poly.
2014-07-09token: replace ast::Ident with just IdentCorey Richardson-18/+19
2014-07-09syntax: doc comments all the thingsCorey Richardson-284/+288
2014-07-08carry self ident forward through re-parsingJohn Clements-30/+42
formerly, the self identifier was being discarded during parsing, which stymies hygiene. The best fix here seems to be to attach a self identifier to ExplicitSelf_, a change that rippled through the rest of the compiler, but without any obvious damage.
2014-07-08remove outdated commentJohn Clements-12/+0
I believe this comment is now irrelevant, as a result of commit 6757053cffb585249105fbd76f
2014-07-08replace idents with namesJohn Clements-0/+5
2014-07-08get rid of keyword idents, replace with namesJohn Clements-8/+8
should prevent future bugs
2014-07-08preserve context in parsing of `self` varrefJohn Clements-9/+11
2014-07-08remove unused fn, make SELF_KEYWORD_NAME publicJohn Clements-5/+1
2014-07-08change if/else to matchJohn Clements-179/+197
2014-07-08auto merge of #15493 : brson/rust/tostr, r=pcwaltonbors-52/+52
This updates https://github.com/rust-lang/rust/pull/15075. Rename `ToStr::to_str` to `ToString::to_string`. The naive renaming ends up with two `to_string` functions defined on strings in the prelude (the other defined via `collections::str::StrAllocating`). To remedy this I removed `StrAllocating::to_string`, making all conversions from `&str` to `String` go through `Show`. This has a measurable impact on the speed of this conversion, but the sense I get from others is that it's best to go ahead and unify `to_string` and address performance for all `to_string` conversions in `core::fmt`. `String::from_str(...)` still works as a manual fast-path. Note that the patch was done with a script, and ended up renaming a number of other `*_to_str` functions, particularly inside of rustc. All the ones I saw looked correct, and I didn't notice any additional API breakage. Closes #15046.
2014-07-08std: Rename the `ToStr` trait to `ToString`, and `to_str` to `to_string`.Richo Healey-52/+52
[breaking-change]
2014-07-08Change DST syntax: type -> Sized?Nick Cameron-18/+47
closes #13367 [breaking-change] Use `Sized?` to indicate a dynamically sized type parameter or trait (used to be `type`). E.g., ``` trait Tr for Sized? {} fn foo<Sized? X: Share>(x: X) {} ```
2014-07-05auto merge of #15428 : phildawes/rust/master, r=huonwbors-2/+3
Fix small bug introduced in e38cb972dcf: PatIdent span was incorrect because self.last_span was being used before the ident token was parsed.
2014-07-05auto merge of #15427 : aochagavia/rust/parse, r=pcwaltonbors-16/+2
2014-07-05auto merge of #15425 : jbclements/rust/hygiene-for-3-kinds-of-args, r=cmrbors-1/+1
This pull request adds hygiene for 3 kinds of argument bindings: - arguments to item fns, - arguments to `ExprFnBlock`s, and - arguments to `ExprProc`s It also adds a bunch of unit tests, fixes a few macro uses to be non-capturing, and has a few cleanup items. local `make check` succeeds.
2014-07-04Parser: fix PatIdent span bugPhil Dawes-2/+3
Fix small bug introduced in e38cb972dcf: PatIdent span was incorrect because self.last_span was being used before the ident token was parsed.
2014-07-04Removed unnecessary method in testAdolfo Ochagavía-16/+2
2014-07-04new_mark -> apply_mark, new_rename -> apply_renameJohn Clements-1/+1
2014-07-04librustc: Remove the `&LIFETIME EXPR` production from the language.Patrick Walton-1/+0
This was parsed by the parser but completely ignored; not even stored in the AST! This breaks code that looks like: static X: &'static [u8] = &'static [1, 2, 3]; Change this code to the shorter: static X: &'static [u8] = &[1, 2, 3]; Closes #15312. [breaking-change]
2014-07-03Fix ICE with nested macro_rules!-style macrosKevin Ballard-2/+2
Fixes #10536.
2014-07-03Simplify PatIdent to contain an Ident rather than a PathJohn Clements-44/+32
Rationale: for what appear to be historical reasons only, the PatIdent contains a Path rather than an Ident. This means that there are many places in the code where an ident is artificially promoted to a path, and---much more problematically--- a bunch of elements from a path are simply thrown away, which seems like an invitation to some really nasty bugs. This commit replaces the Path in a PatIdent with a SpannedIdent, which just contains an ident and a span.
2014-07-01rustc: Remove `&str` indexing from the language.Brian Anderson-2/+2
Being able to index into the bytes of a string encourages poor UTF-8 hygiene. To get a view of `&[u8]` from either a `String` or `&str` slice, use the `as_bytes()` method. Closes #12710. [breaking-change]
2014-06-28auto merge of #15208 : alexcrichton/rust/snapshots, r=pcwaltonbors-1/+5
This change registers new snapshots, allowing `*T` to be removed from the language. This is a large breaking change, and it is recommended that if compiler errors are seen that any FFI calls are audited to determine whether they should be actually taking `*mut T`.
2014-06-28auto merge of #15233 : jbclements/rust/match-var-hygiene-etc, r=cmrbors-0/+1
This PR includes two big things and a bunch of little ones. 1) It enables hygiene for variables bound by 'match' expressions. 2) It fixes a bug discovered indirectly (#15221), wherein fold traversal failed to visit nonterminal nodes. 3) It fixes a small bug in the macro tutorial. It also adds tests for the first two, and makes a bunch of small comment improvements and cleanup.
2014-06-27comments onlyJohn Clements-0/+1
2014-06-26Remove unnecessary to_string callsPiotr Jawniak-1/+1
This commit removes superfluous to_string calls from various places
2014-06-25Register new snapshotsAlex Crichton-1/+5
This change starts denying `*T` in the parser. All code using `*T` should ensure that the FFI call does indeed take `const T*` on the other side before renaming the type to `*const T`. Otherwise, all code can rename `*T` to `*const T`. [breaking-change]
2014-06-25auto merge of #15160 : alexcrichton/rust/remove-f128, r=brsonbors-8/+1
The f128 type has very little support in the compiler and the feature is basically unusable today. Supporting half-baked features in the compiler can be detrimental to the long-term development of the compiler, and hence this feature is being removed.
2014-06-24Make parse_expr_res publicKeegan McAllister-1/+1
2014-06-24librustc: Remove the fallback to `int` from typechecking.Niko Matsakis-4/+2
This breaks a fair amount of code. The typical patterns are: * `for _ in range(0, 10)`: change to `for _ in range(0u, 10)`; * `println!("{}", 3)`: change to `println!("{}", 3i)`; * `[1, 2, 3].len()`: change to `[1i, 2, 3].len()`. RFC #30. Closes #6023. [breaking-change]
2014-06-24Remove the quad_precision_float feature gateAlex Crichton-8/+1
The f128 type has very little support in the compiler and the feature is basically unusable today. Supporting half-baked features in the compiler can be detrimental to the long-term development of the compiler, and hence this feature is being removed.