about summary refs log tree commit diff
path: root/src/libsyntax/parse/parser.rs
AgeCommit message (Collapse)AuthorLines
2019-01-24Rollup merge of #57795 - estebank:did-you-mean, r=zackmdavisMazdak Farrokhzad-3/+10
Use structured suggestion in stead of notes
2019-01-24Rollup merge of #57779 - estebank:recover-struct-fields, r=davidtwcoMazdak Farrokhzad-10/+84
Recover from parse errors in literal struct fields and incorrect float literals Fix #52496.
2019-01-23Add suggestion for incorrect field syntax.David Wood-1/+17
This commit adds a suggestion when a `=` character is used when specifying the value of a field in a struct constructor incorrectly instead of a `:` character.
2019-01-23Optimize snapshot usage.David Wood-68/+57
This commit implements a suggestion from @estebank that optimizes the use of snapshots. Instead of creating a snapshot for each recursion in `parse_path_segment` and then replacing `self` with them until the first invocation where if leading angle brackets are detected, `self` is not replaced and instead the snapshot is used to inform how parsing should continue. Now, a snapshot is created in the first invocation that acts as a backup of the parser state before any generic arguments are parsed (and therefore, before recursion starts). This backup replaces `self` if after all parsing of generic arguments has concluded we can determine that there are leading angle brackets. Parsing can then proceed from the backup state making use of the now known number of unmatched leading angle brackets to recover.
2019-01-23Suggest removing leading left angle brackets.David Wood-8/+201
This commit adds errors and accompanying suggestions as below: ``` bar::<<<<<T as Foo>::Output>(); ^^^ help: remove extra angle brackets ```
2019-01-22Corrected spelling inconsistencyMarcel Hellwig-2/+2
resolves #57773
2019-01-21Accept more invalid code that is close to correct fieldsEsteban Küber-2/+20
2019-01-22Extend trailing `>` detection for paths.David Wood-33/+61
This commit extends the trailing `>` detection to also work for paths such as `Foo::<Bar>>:Baz`. This involves making the existing check take the token that is expected to follow the path being checked as a parameter. Care is taken to ensure that this only happens on the construction of a whole path segment and not a partial path segment (during recursion). Through this enhancement, it was also observed that the ordering of right shift token and greater than tokens was overfitted to the examples being tested. In practice, given a sequence of `>` characters: `>>>>>>>>>` ..then they will be split into `>>` eagerly: `>> >> >> >> >`. ..but when a `<` is prepended, then the first `>>` is split: `<T> > >> >> >> >` ..and then when another `<` is prepended, a right shift is first again: `Vec<<T>> >> >> >> >` In the previous commits, a example that had two `<<` characters was always used and therefore it was incorrectly assumed that `>>` would always be first - but when there is a single `<`, this is not the case.
2019-01-21Pluralize error messages.David Wood-2/+9
This commit pluralizes error messages when more than a single trailing `>` character is present.
2019-01-21Add error for trailing angle brackets.David Wood-0/+97
This commit adds a error (and accompanying machine applicable suggestion) for trailing angle brackets on function calls with a turbofish.
2019-01-20Use structured suggestion in stead of notesEsteban Küber-3/+10
2019-01-21Rollup merge of #57784 - JohnTitor:improve-error-message, r=estebankMazdak Farrokhzad-4/+8
Add span for bad doc comment Fixes #57382 r? @estebank
2019-01-20Tweak field parse error recoveryEsteban Küber-19/+6
2019-01-20Extend incorrect float literal recovery to account for suffixesEsteban Küber-4/+16
2019-01-20Reword message for incorrect float literalEsteban Küber-2/+2
2019-01-21Add span for bad doc commentYuki Okushi-4/+8
2019-01-20Recover with suggestion from writing `.42` instead of `0.42`Esteban Küber-0/+26
2019-01-20Recover from parse errors in struct literal fieldsEsteban Küber-8/+39
Attempt to recover from parse errors while parsing a struct's literal fields by skipping tokens until a comma or the closing brace is found. This allows errors in other fields to be reported.
2019-01-19Suggest usage of angle bracketsEsteban Küber-1/+1
2019-01-19Rollup merge of #57699 - euclio:applicability-ify, r=petrochenkovMazdak Farrokhzad-2/+7
add applicability to remaining suggestions Fixes #50723. I noticed that the suggestion methods on `DiagnosticBuilder` weren't actually deprecated due to #57679. This PR deprecates them properly and fixes the remaining usages. There's also a PR for clippy at rust-lang/rust-clippy#3667.
2019-01-19Rollup merge of #57486 - nnethercote:simplify-TokenStream-more, r=petrochenkovMazdak Farrokhzad-12/+11
Simplify `TokenStream` some more These commits simplify `TokenStream`, remove `ThinTokenStream`, and avoid some clones. The end result is simpler code and a slight perf win on some benchmarks. r? @petrochenkov
2019-01-18Fix suggestions given mulitple bad lifetimesDan Robertson-15/+6
When given multiple lifetimes prior to type parameters in generic parameters, do not ICE and print the correct suggestion.
2019-01-17properly deprecate suggestion methodsAndy Russell-2/+7
2019-01-14Rollup merge of #57585 - estebank:trailing-semicolon, r=petrochenkovMazdak Farrokhzad-24/+35
Recover from item trailing semicolon CC https://github.com/rust-lang/rfcs/pull/2479 r? @petrochenkov
2019-01-14Rollup merge of #57572 - Centril:unaccept-extern-in-path, r=petrochenkovMazdak Farrokhzad-10/+3
Unaccept `extern_in_paths` Based on completed fcp-close in https://github.com/rust-lang/rust/issues/55600, this removes `extern_in_path` (e.g. `extern::foo::bar`) from the language. The changes are primarily reversing https://github.com/rust-lang/rust/commit/32db83b16e06cb5cca72d0e6a648a8008eda0fac. Closes https://github.com/rust-lang/rust/issues/55600 r? @petrochenkov
2019-01-14Rollup merge of #57540 - estebank:eval-more, r=petrochenkovMazdak Farrokhzad-29/+114
Modify some parser diagnostics to continue evaluating beyond the parser Continue evaluating further errors after parser errors on: - trailing type argument attribute - lifetime in incorrect location - incorrect binary literal - missing `for` in `impl Trait for Foo` - type argument in `where` clause - incorrect float literal - incorrect `..` in pattern - associated types - incorrect discriminator value variant error and others. All of these were found by making `continue-parse-after-error` `true` by default to identify errors that would need few changes. There are now only a handful of errors that have any change with `continue-parse-after-error` enabled. These changes make it so `rust` _won't_ stop evaluation after finishing parsing, enabling type checking errors to be displayed on the existing code without having to fix the parse errors. Each commit has an individual diagnostic change with their corresponding tests. CC #48724.
2019-01-13Recover from item trailing semicolonEsteban Küber-24/+35
2019-01-14Avoid some `TokenTree`-to-`TokenStream` conversions.Nicholas Nethercote-7/+6
This avoids some allocations.
2019-01-14Remove `ThinTokenStream`.Nicholas Nethercote-6/+6
`TokenStream` is now almost identical to `ThinTokenStream`. This commit removes the latter, replacing it with the former.
2019-01-13Rollup merge of #57004 - nnethercote:TS-change-Stream, r=petrochenkovMazdak Farrokhzad-1/+1
Make `TokenStream` less recursive. `TokenStream` is currently recursive in *two* ways: - the `TokenTree` variant contains a `ThinTokenStream`, which can contain a `TokenStream`; - the `TokenStream` variant contains a `Vec<TokenStream>`. The latter is not necessary and causes significant complexity. This commit replaces it with the simpler `Vec<(TokenTree, IsJoint)>`. This reduces complexity significantly. In particular, `StreamCursor` is eliminated, and `Cursor` becomes much simpler, consisting now of just a `TokenStream` and an index. The commit also removes the `Extend` impl for `TokenStream`, because it is only used in tests. (The commit also removes those tests.) Overall, the commit reduces the number of lines of code by almost 200.
2019-01-13remove extern_in_paths.Mazdak Farrokhzad-10/+3
2019-01-12Suggest correct location for lifetime parameters in useEsteban Küber-9/+43
2019-01-11Tweak incorrect discriminator value variant errorEsteban Küber-7/+13
2019-01-11Small tweaks to parser errorsEsteban Küber-7/+20
2019-01-11Tweak type argument after assoc type errorEsteban Küber-2/+9
2019-01-11Continue evaluating after finding incorrect .. in patternEsteban Küber-3/+10
2019-01-11Continue evaluating after type argument in where clauseEsteban Küber-2/+6
2019-01-11Continue evaluating after missing `for` in `impl Trait for Foo`Esteban Küber-1/+7
2019-01-11Continue parsing after lifetime in incorrect locationEsteban Küber-2/+6
2019-01-11Continue parser after trailing type argument attributeEsteban Küber-2/+6
2019-01-11stabilize top level or-pats in if/while let.Mazdak Farrokhzad-2/+3
2019-01-08Make `TokenStream` less recursive.Nicholas Nethercote-1/+1
`TokenStream` is currently recursive in *two* ways: - the `TokenTree` variant contains a `ThinTokenStream`, which can contain a `TokenStream`; - the `TokenStream` variant contains a `Vec<TokenStream>`. The latter is not necessary and causes significant complexity. This commit replaces it with the simpler `Vec<(TokenTree, IsJoint)>`. This reduces complexity significantly. In particular, `StreamCursor` is eliminated, and `Cursor` becomes much simpler, consisting now of just a `TokenStream` and an index. The commit also removes the `Extend` impl for `TokenStream`, because it is only used in tests. (The commit also removes those tests.) Overall, the commit reduces the number of lines of code by almost 200.
2019-01-02Auto merge of #57251 - petrochenkov:reregr, r=varkorbors-1/+2
syntax: Fix regression in diagnostics for patterns in trait method parameters Fixes https://github.com/rust-lang/rust/issues/55036
2019-01-01syntax: Fix regression in diagnostics for patterns in trait method parametersVadim Petrochenkov-1/+2
2018-12-31Address review commentsEsteban Küber-12/+13
- Suggest raw ident escaping in all editions - Keep primary label in all cases
2018-12-31Suggest using raw identifiers in 2018 edition when using keywordsEsteban Küber-1/+12
2018-12-27Address review comments and CI failuresVadim Petrochenkov-0/+1
2018-12-27Fix `trace_macros` and `log_syntax`Vadim Petrochenkov-1/+1
2018-12-27Get rid of `Block::recovered`Vadim Petrochenkov-6/+6
2018-12-25Remove licensesMark Rousskov-10/+0