about summary refs log tree commit diff
path: root/src/libsyntax/parse
AgeCommit message (Collapse)AuthorLines
2019-02-13Rollup merge of #58387 - alexreg:fix-trait-alias-2, r=centrilMazdak Farrokhzad-1/+7
Disallow `auto` trait alias syntax See https://github.com/rust-lang/rust/issues/41517#issuecomment-462567679. r? @Centril CC @topecongiro @nikomatsakis
2019-02-13Rollup merge of #58273 - taiki-e:rename-dependency, r=matthewjasperMazdak Farrokhzad-7/+6
Rename rustc_errors dependency in rust 2018 crates I think this is a better solution than `use rustc_errors as errors` in `lib.rs` and `use crate::errors` in modules. Related: rust-lang/cargo#5653 cc #58099 r? @Centril
2019-02-13Cleanup importsTaiki Endo-5/+5
2019-02-13Rename rustc_errors dependency in rust 2018 cratesTaiki Endo-5/+4
2019-02-12Disallow `auto` trait alias syntax.Alexander Regueiro-1/+7
2019-02-10rustc: doc commentsAlexander Regueiro-194/+206
2019-02-09Auto merge of #57944 - estebank:unclosed-delim-the-quickening, r=oli-obkbors-101/+281
Deduplicate mismatched delimiter errors Delay unmatched delimiter errors until after the parser has run to deduplicate them when parsing and attempt recovering intelligently. Second attempt at #54029, follow up to #53949. Fix #31528.
2019-02-07Add fixmeEsteban Küber-1/+3
2019-02-07Make name resolution handle consts in GenericParamsFromOuterFunction properlyvarkor-1/+2
2019-02-07Parse negative literals in const generic argumentsvarkor-2/+1
2019-02-07Add warning for a parameter list with an attribute but no parametersvarkor-7/+19
2019-02-07Adjust parser generic parameter errorsvarkor-28/+26
2019-02-07Parse const genericsvarkor-178/+112
Co-Authored-By: Gabriel Smith <yodaldevoid@users.noreply.github.com>
2019-02-07add doc comment and revert angle bracket changeEsteban Küber-3/+5
2019-02-07tweak wording based on in person feedbackEsteban Küber-2/+2
2019-02-07Remove unused `match`Esteban Küber-19/+4
2019-02-07Add missing trailing newlineEsteban Küber-1/+1
2019-02-07Remove spurious complaint about missing expression for bare semicolonsEsteban Küber-1/+16
2019-02-07unify error handling to single methodEsteban Küber-34/+25
2019-02-07Deduplicate mismatched delimiter errorsEsteban Küber-102/+287
Delay unmatched delimiter errors until after the parser has run to deduplicate them when parsing and attempt recovering intelligently.
2019-02-07libsyntax => 2018Taiki Endo-143/+161
2019-02-06Auto merge of #58061 - nnethercote:overhaul-syntax-Folder, r=petrochenkovbors-2/+3
Overhaul `syntax::fold::Folder`. This PR changes `syntax::fold::Folder` from a functional style (where most methods take a `T` and produce a new `T`) to a more imperative style (where most methods take and modify a `&mut T`), and renames it `syntax::mut_visit::MutVisitor`. This makes the code faster and more concise.
2019-02-06Overhaul `syntax::fold::Folder`.Nicholas Nethercote-2/+3
This commit changes `syntax::fold::Folder` from a functional style (where most methods take a `T` and produce a new `T`) to a more imperative style (where most methods take and modify a `&mut T`), and renames it `syntax::mut_visit::MutVisitor`. The first benefit is speed. The functional style does not require any reallocations, due to the use of `P::map` and `MoveMap::move_{,flat_}map`. However, every field in the AST must be overwritten; even those fields that are unchanged are overwritten with the same value. This causes a lot of unnecessary memory writes. The imperative style reduces instruction counts by 1--3% across a wide range of workloads, particularly incremental workloads. The second benefit is conciseness; the imperative style is usually more concise. E.g. compare the old functional style: ``` fn fold_abc(&mut self, abc: ABC) { ABC { a: fold_a(abc.a), b: fold_b(abc.b), c: abc.c, } } ``` with the imperative style: ``` fn visit_abc(&mut self, ABC { a, b, c: _ }: &mut ABC) { visit_a(a); visit_b(b); } ``` (The reductions get larger in more complex examples.) Overall, the patch removes over 200 lines of code -- even though the new code has more comments -- and a lot of the remaining lines have fewer characters. Some notes: - The old style used methods called `fold_*`. The new style mostly uses methods called `visit_*`, but there are a few methods that map a `T` to something other than a `T`, which are called `flat_map_*` (`T` maps to multiple `T`s) or `filter_map_*` (`T` maps to 0 or 1 `T`s). - `move_map.rs`/`MoveMap`/`move_map`/`move_flat_map` are renamed `map_in_place.rs`/`MapInPlace`/`map_in_place`/`flat_map_in_place` to reflect their slightly changed signatures. - Although this commit renames the `fold` module as `mut_visit`, it keeps it in the `fold.rs` file, so as not to confuse git. The next commit will rename the file.
2019-02-04Add the span of attributes of the lhs to the span of the assignment expressiontopecongiro-0/+8
2019-01-30Suggest to add each of `|` and `()` when unexpected `,` is found in patternKnium_-1/+6
2019-01-26remove `_with_applicability` from suggestion fnsAndy Russell-57/+57
2019-01-26Auto merge of #57852 - davidtwco:issue-57819, r=estebankbors-8/+190
Suggest removing leading left angle brackets. Fixes #57819. This PR adds errors and accompanying suggestions as below: ``` bar::<<<<<T as Foo>::Output>(); ^^^ help: remove extra angle brackets ``` r? @estebank
2019-01-25Rollup merge of #57886 - davidtwco:issue-57385, r=estebankMazdak Farrokhzad-27/+107
Add suggestion for moving type declaration before associated type bindings in generic arguments. Fixes #57385. r? @estebank
2019-01-25Combining move lifetime and type suggestions.David Wood-30/+73
This commit combines the move lifetime and move type suggestions so that when rustfix applies them they don't conflict with each other.
2019-01-25Suggestion moving types before associated types.David Wood-15/+52
This commit extends existing suggestions to move lifetimes before types in generic arguments to also suggest moving types behind associated type bindings.
2019-01-24Auto merge of #57879 - Centril:rollup, r=Centrilbors-1/+17
Rollup of 9 pull requests Successful merges: - #57380 (Fix Instant/Duration math precision & associativity on Windows) - #57606 (Get rid of the fake stack frame for reading from constants) - #57803 (Several changes to libunwind for SGX target) - #57846 (rustdoc: fix ICE from loading proc-macro stubs) - #57860 (Add os::fortanix_sgx::ffi module) - #57861 (Don't export table by default in wasm) - #57863 (Add suggestion for incorrect field syntax.) - #57867 (Fix std::future::from_generator documentation) - #57873 (Stabilize no_panic_pow) Failed merges: r? @ghost
2019-01-24Rollup merge of #57863 - davidtwco:issue-57684, r=estebankMazdak Farrokhzad-1/+17
Add suggestion for incorrect field syntax. Fixes #57684. 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. r? @estebank
2019-01-24Auto merge of #51285 - Mark-Simulacrum:remove-quote_apis, r=Manishearthbors-25/+17
Remove quote_*! macros This deletes a considerable amount of test cases, some of which we may want to keep. I'm not entirely certain what the primary intent of many of them was; if we should keep them I can attempt to edit each case to continue compiling without the quote_*! macros involved. Fixes #46849. Fixes #12265. Fixes #12266. Fixes #26994. r? @Manishearth
2019-01-24Remove quote_*! macros and associated APIsMark Simulacrum-25/+17
2019-01-24Rollup merge of #57817 - davidtwco:issue-54521, r=estebankMazdak Farrokhzad-1/+133
Add error for trailing angle brackets. Fixes #54521. This PR adds a error (and accompanying machine applicable suggestion) for trailing angle brackets on function calls with a turbofish. r? @estebank
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-21Rollup merge of #57768 - estebank:type-args-sugg, r=zackmdavisMazdak Farrokhzad-1/+1
Continue parsing after parent type args and suggest using angle brackets ``` error[E0214]: parenthesized parameters may only be used with a trait --> $DIR/E0214.rs:2:15 | LL | let v: Vec(&str) = vec!["foo"]; | ^^^^^^ | | | only traits may use parentheses | help: use angle brackets instead: `<&str>` ``` r? @zackmdavis
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