about summary refs log tree commit diff
path: root/src/libsyntax/parse/parser.rs
AgeCommit message (Collapse)AuthorLines
2018-10-05Rollup merge of #54833 - abonander:issue-54441, r=petrochenkovPietro Albini-12/+11
make `Parser::parse_foreign_item()` return a foreign item or error Fixes `Parser::parse_foreign_item()` to follow the convention of `parse_trait_item()` and `parse_impl_item()` in that it *must* parse an item or return an error, and then the caller is responsible for detecting the closing delimiter. This prevents it from looping endlessly on an unexpected token in `ext/expand.rs` where it was also leaking memory by continually pushing to `Parser::expected_tokens` via `Parser::check_keyword()`. closes #54441 r? @petrochenkov cc @dtolnay
2018-10-05add suggestion for inverted function parametersAndy Russell-1/+20
Fixes #54065.
2018-10-05make `Parser::parse_foreign_item()` return a foreign item or errorAustin Bonander-12/+11
closes #54441
2018-09-27Auto merge of #52319 - tinco:issue_12590, r=pnkfelixbors-5/+12
Track whether module declarations are inline (fixes #12590) To track whether module declarations are inline I added a field `inline: bool` to `ast::Mod`. The main use case is for pretty to know whether it should render the items associated with the module, but perhaps there are use cases for this information to not be forgotten in the AST.
2018-09-23Fixed off-by-one span.David Wood-1/+1
Fixes the off-by-one span issue where closure argument spans were pointing to the token after the argument.
2018-09-22Rollup merge of #54415 - petrochenkov:norollback, r=estebankPietro Albini-36/+26
parser: Tweak function parameter parsing to avoid rollback on succesfull path Since rollback is not perfect and may e.g. leave non-fatal errors after it, we need to make sure compilation fails if it happens. So in particular case of `fn parse_arg_general` we need to parse the "good" `TYPE` first and only then rollback and recover erroneous `PAT: TYPE` if necessary. Found when working on https://github.com/rust-lang/rfcs/pull/2544#issuecomment-423293222. r? @ghost
2018-09-22Rollup merge of #54409 - estebank:remove-in, r=pnkfelixPietro Albini-9/+25
Detect `for _ in in bar {}` typo Fix #36611, #52964, without modifying the parsing of emplacement `in` to avoid further problems like #50832.
2018-09-22Rollup merge of #54261 - varkor:dyn-keyword-2018, r=petrochenkovPietro Albini-2/+3
Make `dyn` a keyword in the 2018 edition Proposed in https://github.com/rust-lang/rust/issues/44662#issuecomment-421596088.
2018-09-20Detect `for _ in in bar {}` typoEsteban Küber-9/+25
2018-09-21parser: Tweak function parameter parsing to avoid rollback on succesfull pathVadim Petrochenkov-36/+26
2018-09-17Whitespace fix again.Vitaly _Vi Shukela-5/+5
2018-09-17Fill in suggestions Applicability according to @estebankVitaly _Vi Shukela-5/+6
Also fix some formatting along the way.
2018-09-16Treat `dyn` as a keyword in the 2018 editionvarkor-2/+3
2018-09-16Remove usages of span_suggestion without ApplicabilityVitaly _Vi Shukela-1/+5
Use Applicability::Unspecified for all of them instead.
2018-09-15issue 54109: use short suggestionsVitaly _Vi Shukela-4/+4
2018-09-13Use span_suggestion_with_applicability for "and/or" hinterVitaly _Vi Shukela-4/+24
Advised by @estebank.
2018-09-13Suggest && and || instead of 'and' and 'or'Vitaly _Vi Shukela-0/+13
Closes #54109.
2018-09-10pretty=expanded should expand mod declarationsTinco Andringa-3/+3
2018-09-10Track whether module declarations are inline (fixes #12590)Tinco Andringa-5/+12
2018-09-09Auto merge of #53902 - dtolnay:group, r=petrochenkovbors-10/+12
proc_macro::Group::span_open and span_close Before this addition, every delimited group like `(`...`)` `[`...`]` `{`...`}` has only a single Span that covers the full source location from opening delimiter to closing delimiter. This makes it impossible for a procedural macro to trigger an error pointing to just the opening or closing delimiter. The Rust compiler does not seem to have the same limitation: ```rust mod m { type T = } ``` ```console error: expected type, found `}` --> src/main.rs:3:1 | 3 | } | ^ ``` On that same input, a procedural macro would be forced to trigger the error on the last token inside the block, on the entire block, or on the next token after the block, none of which is really what you want for an error like above. This commit adds `group.span_open()` and `group.span_close()` which access the Span associated with just the opening delimiter and just the closing delimiter of the group. Relevant to Syn as we implement real error messages for when parsing fails in a procedural macro: https://github.com/dtolnay/syn/issues/476. ```diff impl Group { fn span(&self) -> Span; + fn span_open(&self) -> Span; + fn span_close(&self) -> Span; } ``` Fixes #48187 r? @alexcrichton
2018-09-08Track distinct spans for open and close delimiterDavid Tolnay-10/+12
2018-09-04Move #[test_case] to a syntax extensionJohn Renner-1/+0
2018-09-02Replace check() + bump() with eat()Seiichi Uchida-20/+10
2018-09-01Auto merge of #53815 - F001:if-let-guard, r=petrochenkovbors-2/+2
refactor match guard This is the first step to implement RFC 2294: if-let-guard. Tracking issue: https://github.com/rust-lang/rust/issues/51114 The second step should be introducing another variant `IfLet` in the Guard enum. I separated them into 2 PRs for the convenience of reviewers. r? @petrochenkov
2018-08-30Rollup merge of #53655 - jcpst:with_applicability, r=estebankPietro Albini-2/+12
set applicability Update a few more calls as described in #50723 r? @estebank
2018-08-30introduce Guard enumF001-2/+2
2018-08-25call span_suggestion with applicabilityJoseph Post-2/+12
2018-08-24fix compile errorMark Mansi-1/+1
2018-08-24Remove anon trait params from 2018 and beyondMark Mansi-1/+7
2018-08-24Rollup merge of #53563 - matthiaskrgr:String, r=varkorkennytm-7/+7
use String::new() instead of String::from(""), "".to_string(), "".to_owned() or "".into()
2018-08-23Auto merge of #52602 - scottmcm:tryblock-expr, r=nikomatsakisbors-10/+30
Implement try block expressions I noticed that `try` wasn't a keyword yet in Rust 2018, so... ~~Fix​es https://github.com/rust-lang/rust/issues/52604~~ That was fixed by PR https://github.com/rust-lang/rust/pull/53135 cc https://github.com/rust-lang/rust/issues/31436 https://github.com/rust-lang/rust/issues/50412
2018-08-23use String::new() instead of String::from(""), "".to_string(), "".to_owned() ↵Matthias Krüger-7/+7
or "".into()
2018-08-22Rollup merge of #53585 - dtolnay:comment, r=Mark-SimulacrumGuillaume Gomez-2/+0
Remove super old comment on function that parses items This comment was added more than 5 years ago in ab03c1e4221. As far as anyone reading this comment today needs to know, the function has never parsed items from inside an extern crate.
2018-08-22Rollup merge of #53544 - estebank:issue-53534, r=varkorGuillaume Gomez-7/+8
Point at the trait argument when using unboxed closure Fix #53534. r? @varkor
2018-08-21Remove super old comment on function that parses itemsDavid Tolnay-2/+0
This comment was added more than 5 years ago in ab03c1e4221. As far as anyone reading this comment today needs to know, the function has never parsed items from inside an extern crate.
2018-08-21Rollup merge of #53496 - matthiaskrgr:codespell_08_2018, r=varkorkennytm-5/+5
Fix typos found by codespell.
2018-08-20Point at the trait argument when using unboxed closureEsteban Küber-7/+8
2018-08-19Switch out another use of `do catch`Scott McMurray-1/+9
2018-08-19Suggest `try` if someone uses `do catch`Scott McMurray-0/+12
2018-08-19Parse try blocks with the try keyword instead of do catch placeholderScott McMurray-11/+11
2018-08-19Rename `Catch` variants to `TryBlock`Scott McMurray-1/+1
(Not `Try` since `QuestionMark` is using that.)
2018-08-19mv codemap source_mapDonato Sciarra-3/+3
2018-08-19mv codemap() source_map()Donato Sciarra-19/+19
2018-08-19mv (mod) codemap source_mapDonato Sciarra-10/+10
2018-08-19mv CodeMap SourceMapDonato Sciarra-2/+2
2018-08-19Fix typos found by codespell.Matthias Krüger-5/+5
2018-08-17Rollup merge of #53360 - PramodBisht:issue/51602, r=estebankkennytm-1/+7
Addressed #51602 Fixed #51602 r? @estebank here I have addressed the case where `in` was not expected right after `if` block. Speaking of `type ascription` I am not sure if this the best approach which I have implemented. Plus I think one more test case can be added to test `type-ascription` case, though I don't have any at this point of time. I will ping you again if all existing testcases pass.
2018-08-15syntax: Enforce attribute grammar in the parserVadim Petrochenkov-1/+1
2018-08-14Adddressed #51602Pramod Bisht-1/+7
2018-08-13Move SmallVec and ThinVec out of libsyntaxljedrz-1/+1