about summary refs log tree commit diff
path: root/src/libsyntax/parse
AgeCommit message (Collapse)AuthorLines
2016-09-26Rollup merge of #36669 - jseyfried:refactor_tok_result, r=nrcJonathan Turner-11/+0
Unify `TokResult` and `ResultAnyMacro` Fixes #36641. r? @nrc
2016-09-26Rollup merge of #36662 - jseyfried:parse_macro_invoc_paths, r=nrcJonathan Turner-252/+222
parser: support paths in bang macro invocations (e.g. `path::to::macro!()`) r? @nrc
2016-09-26Move `ensure_complete_parse` into `expand.rs`.Jeffrey Seyfried-14/+0
2016-09-26add unstable_features to ParseSessTim Neumann-0/+3
2016-09-26Refactor `ensure_complete_parse`.Jeffrey Seyfried-9/+12
2016-09-23Added tests and fixed corner case for trailing attributes with no attached ↵Felix S. Klock II-1/+16
binding in generics.
2016-09-23Add attribute support to generic lifetime and type parameters.Felix S. Klock II-9/+38
I am using `ThinAttributes` rather than a vector for attributes attached to generics, since I expect almost all lifetime and types parameters to not carry any attributes.
2016-09-23Fix indents.Jeffrey Seyfried-141/+131
2016-09-23Cleanup.Jeffrey Seyfried-40/+17
2016-09-23Parse paths in item, trait item, and impl item macro invocations.Jeffrey Seyfried-21/+6
2016-09-23Parse paths in statement and pattern macro invocations.Jeffrey Seyfried-31/+46
2016-09-22Auto merge of #36154 - nrc:proc-macro-init, r=@jseyfriedbors-13/+49
Adds a `ProcMacro` form of syntax extension This commit adds syntax extension forms matching the types for procedural macros 2.0 (RFC #1566), these still require the usual syntax extension boiler plate, but this is a first step towards proper implementation and should be useful for macros 1.1 stuff too. Supports both attribute-like and function-like macros. Note that RFC #1566 has not been accepted yet, but I think there is consensus that we want to head in vaguely that direction and so this PR will be useful in any case. It is also fairly easy to undo and does not break any existing programs. This is related to #35957 in that I hope it can be used in the implementation of macros 1.1, however, there is no direct overlap and is more of a complement than a competing proposal. There is still a fair bit of work to do before the two can be combined. r? @jseyfried cc @alexcrichton, @cgswords, @eddyb, @aturon
2016-09-23reviewer comments and rebasingNick Cameron-37/+20
2016-09-22Rollup merge of #36539 - mikhail-m1:36530, r=jonathandturnerJonathan Turner-1/+1
fix top level attr spans issue #36530 ?r @jonathandturner
2016-09-22Refactor out `parse_struct_expr`.Jeffrey Seyfried-45/+48
2016-09-22Adds a `ProcMacro` form of syntax extensionNick Cameron-6/+59
This commit adds syntax extension forms matching the types for procedural macros 2.0 (RFC #1566), these still require the usual syntax extension boiler plate, but this is a first step towards proper implementation and should be useful for macros 1.1 stuff too. Supports both attribute-like and function-like macros.
2016-09-19Auto merge of #36471 - nnethercote:rm-to_binop, r=sanxiynbors-26/+1
Remove unused Token::to_binop function Just some dead code removal.
2016-09-18Auto merge of #36527 - nnethercote:last_token_kind, r=jseyfriedbors-43/+39
Optimize the parser's last token handling. The parser currently makes a heap copy of the last token in four cases: identifiers, paths, doc comments, and commas. The identifier and interpolation cases are unused, and for doc comments and commas we only need to record their presence, not their value. This commit consolidates the last token handling and avoids the unnecessary copies by replacing `last_token`, `last_token_eof`, and `last_token_interpolated` with a new field `last_token_kind`. This simplifies the parser slightly and speeds up parsing on some files by 3--4%.
2016-09-17Auto merge of #36502 - TimNN:correct-cancel, r=jseyfriedbors-5/+11
correctly cancel some errors Fixes #36499. I also (proactively) changed all other calls in `parser.rs` to use `Handler::cancel`.
2016-09-17Auto merge of #36485 - nnethercote:char_lit-2, r=nagisabors-43/+28
Overhaul char_lit() This commit does the following. - Removes parsing support for '\X12', '\u123456' and '\U12345678' char literals. These are no longer valid Rust and rejected by the lexer. (This strange-sounding situation occurs because the parser rescans char literals to compute their value.) - Rearranges the function so that all the escaped values are handled in a single `match`. The error-handling strategy is based on the one used by byte_lit().
2016-09-16Auto merge of #36482 - jseyfried:dont_load_unconfigured_noninline_modules, r=nrcbors-9/+18
Avoid loading and parsing unconfigured non-inline modules. For example, `#[cfg(any())] mod foo;` will always compile after this PR, even if `foo.rs` and `foo/mod.rs` do not exist or do not contain valid Rust. Fixes #36478 and fixes #27873. r? @nrc
2016-09-16fix top level attr spansMikhail Modin-1/+1
2016-09-16Optimize the parser's last token handling.Nicholas Nethercote-43/+39
The parser currently makes a heap copy of the last token in four cases: identifiers, paths, doc comments, and commas. The identifier and interpolation cases are unused, and for doc comments and commas we only need to record their presence, not their value. This commit consolidates the last token handling and avoids the unnecessary copies by replacing `last_token`, `last_token_eof`, and `last_token_interpolated` with a new field `last_token_kind`. This simplifies the parser slightly and speeds up parsing on some files by 3--4%.
2016-09-16Overhaul char_lit().Nicholas Nethercote-43/+28
This commit does the following. - Removes parsing support for '\X12', '\u123456' and '\U12345678' char literals. These are no longer valid Rust and rejected by the lexer. (This strange-sounding situation occurs because the parser rescans char literals to compute their value.) - Rearranges the function so that all the escaped values are handled in a single `match`, and changes the error-handling to use vanilla assert!() and unwrap().
2016-09-15correctly cancel some errorsTim Neumann-5/+11
2016-09-15Avoid loading and parsing unconfigured non-inline modules.Jeffrey Seyfried-9/+18
2016-09-14Remove unused Token::to_binop function.Nicholas Nethercote-26/+1
2016-09-13Remove parsing of obsolete pre-1.0 syntaxesVadim Petrochenkov-44/+4
2016-09-12Auto merge of #36354 - mikhail-m1:master, r=jonathandturnerbors-5/+5
fix span for errors E0537, E0535 & E0536 fix #36182 as part of #35233
2016-09-12Lazily construct panic messages in char_lit().Nicholas Nethercote-5/+7
This reduces the time taken to run `rustc -Zparse-only rustc-benchmarks/issue-32278-big-array-of-strings` from 0.18s to 0.15s on my machine, and reduces the number of instructions (as measured by Cachegrind) from 1.34B to 1.01B. With the change applied, the time to fully compile that benchmark is 1.96s, so this is a 1.5% improvement.
2016-09-12Avoid an unnecessary intermediate value in char_lit().Nicholas Nethercote-14/+9
This makes the function more concise and easier to understand.
2016-09-10fix span for errors E0537, E0535 & E0536Mikhail Modin-5/+5
2016-09-05In `Parser` and `ExtCtxt`, replace fields `filename` and `mod_path_stack`Jeffrey Seyfried-26/+16
with a single field `directory: PathBuf`.
2016-09-04Replace `_, _` with `..`Vadim Petrochenkov-3/+3
2016-09-03Check fields in union patters/expressionsVadim Petrochenkov-1/+3
Make parsing of union items backward compatible Add some tests
2016-09-03Lower unions from AST to HIR and from HIR to typesVadim Petrochenkov-0/+31
Parse union items and add a feature for them
2016-08-28Rollup merge of #35917 - jseyfried:remove_attr_ext_traits, r=nrcJeffrey Seyfried-1/+1
syntax: Remove traits `AttrMetaMethods`, `AttributeMethods`, and `AttrNestedMetaItemMethods`
2016-08-28Rollup merge of #35850 - SergioBenitez:master, r=nrcJeffrey Seyfried-16/+48
Implement RFC#1559: allow all literals in attributes Implemented rust-lang/rfcs#1559, tracked by #34981.
2016-08-28Rollup merge of #35480 - KiChjang:e0379-bonus, r=nikomatsakisJeffrey Seyfried-10/+28
Move E0379 check from typeck to ast validation Part of #35233. Extension of #35338, #35364. Fixes #35404.
2016-08-28Rollup merge of #35618 - jseyfried:ast_view_path_refactor, r=eddybJeffrey Seyfried-6/+9
Refactor `PathListItem`s This refactors away variant `Mod` of `ast::PathListItemKind` and refactors the remaining variant `Ident` to a struct `ast::PathListItem_`.
2016-08-28Rollup merge of #35591 - GuillaumeGomez:generics_span, r=jntrmrJeffrey Seyfried-5/+8
Add Span field for Generics structs
2016-08-27Change Constness to Spanned<Constness>Keith Yeung-10/+28
2016-08-25Refactor away `AttrMetaMethods`.Jeffrey Seyfried-1/+1
2016-08-25Implement RFC#1559: allow all literals in attributes.Sergio Benitez-16/+48
2016-08-23Improve error message when failing to parse a blockJames Miller-3/+24
We want to catch this error: ``` if (foo) bar; ``` as it's valid syntax in other languages, and say how to fix it. Unfortunately it didn't care if the suggestion made sense and just highlighted the unexpected token. Now it attempts to parse a statement, and if it succeeds, it shows the help message. Fixes #35907
2016-08-21Refactor away variant `ast::PathListItemKind::Mod`Jeffrey Seyfried-6/+9
and refactor `ast::PathListItemKind::Ident` -> `ast::PathListItem_`.
2016-08-19Auto merge of #33922 - estebank:doc-comment, r=alexcrichtonbors-17/+45
Specific error message for missplaced doc comments Identify when documetation comments have been missplaced in the following places: * After a struct element: ```rust // file.rs: struct X { a: u8 /** document a */, } ``` ```bash $ rustc file.rs file.rs:2:11: 2:28 error: found documentation comment that doesn't document anything file.rs:2 a: u8 /** document a */, ^~~~~~~~~~~~~~~~~ file.rs:2:11: 2:28 help: doc comments must come before what they document, maybe a comment was intended with `//`? ``` * As the last line of a struct: ```rust // file.rs: struct X { a: u8, /// incorrect documentation } ``` ```bash $ rustc file.rs file.rs:3:5: 3:27 error: found a documentation comment that doesn't document anything file.rs:3 /// incorrect documentation ^~~~~~~~~~~~~~~~~~~~~~ file.rs:3:5: 3:27 help: doc comments must come before what they document, maybe a comment was intended with `//`? ``` * As the last line of a `fn`: ```rust // file.rs: fn main() { let x = 1; /// incorrect documentation } ``` ```bash $ rustc file.rs file.rs:3:5: 3:27 error: found a documentation comment that doesn't document anything file.rs:3 /// incorrect documentation ^~~~~~~~~~~~~~~~~~~~~~ file.rs:3:5: 3:27 help: doc comments must come before what they document, maybe a comment was intended with `//`? ``` Fix #27429, #30322
2016-08-18Add Span field for Generics structsGuillaume Gomez-5/+8
2016-08-16Auto merge of #35162 - canndrew:bang_type_coerced, r=nikomatsakisbors-5/+3
Implement the `!` type This implements the never type (`!`) and hides it behind the feature gate `#[feature(never_type)]`. With the feature gate off, things should build as normal (although some error messages may be different). With the gate on, `!` is usable as a type and diverging type variables (ie. types that are unconstrained by anything in the code) will default to `!` instead of `()`.
2016-08-14Rollup merge of #35491 - sanxiyn:pub-restricted-span, r=nikomatsakisEduard-Mihai Burtescu-9/+10
Correct span for pub_restricted field Fix #35435.