about summary refs log tree commit diff
path: root/src/librustc_parse/parser
AgeCommit message (Collapse)AuthorLines
2020-06-23Record span of `const` kw in GenericParamKindAyaz Hafiz-3/+3
Context: this is needed to fix https://github.com/rust-lang/rustfmt/issues/4263, which currently records the span of a const generic param incorrectly because the location of the `const` kw is not known. I am not sure how to add tests for this; any guidance in how to do so would be appreciated :slightly_smiling_face:
2020-06-18Rollup merge of #73361 - estebank:non-primitive-cast, r=davidtwcoManish Goregaokar-1/+1
Tweak "non-primitive cast" error - Suggest borrowing expression if it would allow cast to work. - Suggest using `<Type>::from(<expr>)` when appropriate. - Minor tweak to `;` typo suggestion. Partily address #47136.
2020-06-18Rollup merge of #71976 - mibac138:let-recovery, r=estebankManish Goregaokar-2/+22
Improve diagnostics for `let x += 1` Fixes(?) #66736 The code responsible for the `E0404` errors is [here](https://github.com/rust-lang/rust/blob/master/src/librustc_parse/parser/ty.rs#L399-L424) which I don't think can be easily modified to prevent emitting an error in one specific case. Because of this I couldn't get rid of `E0404` and instead added `E0067` along with a help message which will fix the problem. r? @estebank
2020-06-15Tweak "non-primitive cast" errorEsteban Küber-1/+1
- Suggest borrowing expression if it would allow cast to work. - Suggest using `<Type>::from(<expr>)` when appropriate. - Minor tweak to `;` typo suggestion. Partily address #47136.
2020-06-15Always capture tokens for `macro_rules!` argumentsAaron Hill-1/+1
2020-06-11Rollup merge of #73182 - Aaron1011:feature/call-fn-span, r=matthewjasperDylan DPC-2/+4
Track span of function in method calls, and use this in #[track_caller] Fixes #69977 When we parse a chain of method calls like `foo.a().b().c()`, each `MethodCallExpr` gets assigned a span that starts at the beginning of the call chain (`foo`). While this is useful for diagnostics, it means that `Location::caller` will return the same location for every call in a call chain. This PR makes us separately record the span of the function name and arguments for a method call (e.g. `b()` in `foo.a().b().c()`). This `Span` is passed through HIR lowering and MIR building to `TerminatorKind::Call`, where it is used in preference to `Terminator.source_info.span` when determining `Location::caller`. This new span is also useful for diagnostics where we want to emphasize a particular method call - for an example, see https://github.com/rust-lang/rust/pull/72389#discussion_r436035990
2020-06-11Rollup merge of #73172 - matthiaskrgr:cl9ppy, r=Dylan-DPCDylan DPC-4/+4
Fix more clippy warnings Fixes more of: clippy::unused_unit clippy::op_ref clippy::useless_format clippy::needless_return clippy::useless_conversion clippy::bind_instead_of_map clippy::into_iter_on_ref clippy::redundant_clone clippy::nonminimal_bool clippy::redundant_closure clippy::option_as_ref_deref clippy::len_zero clippy::iter_cloned_collect clippy::filter_next r? @Dylan-DPC
2020-06-10Track span of function in method calls, and use this in #[track_caller]Aaron Hill-2/+4
Fixes #69977 When we parse a chain of method calls like `foo.a().b().c()`, each `MethodCallExpr` gets assigned a span that starts at the beginning of the call chain (`foo`). While this is useful for diagnostics, it means that `Location::caller` will return the same location for every call in a call chain. This PR makes us separately record the span of the function name and arguments for a method call (e.g. `b()` in `foo.a().b().c()`). This `Span` is passed through HIR lowering and MIR building to `TerminatorKind::Call`, where it is used in preference to `Terminator.source_info.span` when determining `Location::caller`. This new span is also useful for diagnostics where we want to emphasize a particular method call - for an example, see https://github.com/rust-lang/rust/pull/72389#discussion_r436035990
2020-06-09Fix more clippy warningsMatthias Krüger-4/+4
Fixes more of: clippy::unused_unit clippy::op_ref clippy::useless_format clippy::needless_return clippy::useless_conversion clippy::bind_instead_of_map clippy::into_iter_on_ref clippy::redundant_clone clippy::nonminimal_bool clippy::redundant_closure clippy::option_as_ref_deref clippy::len_zero clippy::iter_cloned_collect clippy::filter_next
2020-06-08Don't lose empty `where` clause when pretty-printingAaron Hill-2/+7
Previously, we would parse `struct Foo where;` and `struct Foo;` identically, leading to an 'empty' `where` clause being omitted during pretty printing. This will cause us to lose spans when proc-macros involved, since we will have a collected `where` token that does not appear in the pretty-printed item. We now explicitly track the presence of a `where` token during parsing, so that we can distinguish between `struct Foo where;` and `struct Foo;` during pretty-printing
2020-05-30Rollup merge of #72585 - Aaron1011:feature/opt-item-tokens, r=petrochenkovRalf Jung-5/+16
Only capture tokens for items with outer attributes Suggested by @petrochenkov in https://github.com/rust-lang/rust/issues/43081#issuecomment-633389225
2020-05-27improve diagnostics suggestion for missing `@` in slice id binding to rest ↵Chris Simpkins-0/+20
pattern add issue 72373 tests fmt test fix suggestion format Replacement, not insertion of suggested string implement review changes refactor to span_suggestion_verbose, improve suggestion message, change id @ pattern space formatting fmt fix diagnostics spacing between ident and @ refactor reference
2020-05-27Rollup merge of #72348 - chrissimpkins:fix-72253, r=estebankDylan DPC-0/+13
Fix confusing error message for comma typo in multiline statement Fixes #72253. Expands on the issue with a colon typo check. r? @estebank cc @ehuss
2020-05-26improve error message for unexpected comma token in multiline blockChris Simpkins-0/+13
confusing diagnostics, issue #72253 add test for confusing error message, issue-72253 remove is_multiline check, refactor to self.expect(&token:Semi) update issue-72253 tests return Ok
2020-05-25Only capture tokens for items with outer attributesAaron Hill-5/+16
Suggested by @petrochenkov in https://github.com/rust-lang/rust/issues/43081#issuecomment-633389225
2020-05-24Collect tokens for `ast::Expr`Aaron Hill-14/+35
2020-05-22Rewrite `Parser::collect_tokens`Aaron Hill-73/+113
The previous implementation did not work when called on an opening delimiter, or when called re-entrantly from the same `TokenCursor` stack depth.
2020-05-21Adjust according to petrochenkov's review commentsmibac138-43/+22
2020-05-20Adjust according to estebank's review commentsmibac138-11/+8
2020-05-20Error recovery for `let` with `+=`mibac138-33/+32
2020-05-20Expand partial error recovery for `let` with `BinOpEq`mibac138-10/+30
2020-05-20Implement partial error recovery for `let` with `BinOpEq`mibac138-2/+27
When parsing `let x: i8 += 1` the compiler interprets `i8` as a trait which makes it more complicated to do error recovery. More advanced error recovery is not implemented in this commit.
2020-05-15Remove redundant backtick in error message.Eric Huss-1/+1
The value passed in already has backticks surrounding the text.
2020-05-08Remove ast::{Ident, Name} reexports.Camille GILLOT-18/+16
2020-05-05Detect errors caused by `async` block in 2015 editionEsteban Küber-22/+36
2020-04-30Rollup merge of #71433 - antoyo:error/missing-right-operand, r=Dylan-DPCDylan DPC-0/+5
Add help message for missing right operand in condition closes #30035
2020-04-24Avoid unused Option::map resultsJosh Stone-2/+2
These are changes that would be needed if we add `#[must_use]` to `Option::map`, per #71484.
2020-04-22Rollup merge of #71256 - cuviper:must_use_replace, r=estebankDylan DPC-9/+8
Lint must_use on mem::replace This adds a hint on `mem::replace`, "if you don't need the old value, you can just assign the new value directly". This is in similar spirit to the `must_use` on `ManuallyDrop::take`.
2020-04-22Add help message for missing right operand in conditionAntoni Boucher-0/+5
2020-04-22Add error code to inner doc comment attribute errorGuillaume Gomez-3/+9
2020-04-19Dogfood more or_patterns in the compilerJosh Stone-9/+7
2020-04-18remove build warningsTshepang Lekhonkhobe-3/+5
Code blocks that are not annotated are assumed to be Rust
2020-04-17Fix unused results from mem::replaceJosh Stone-9/+8
2020-04-17Improved try_macro_suggestion functionDuddino-4/+2
2020-04-17Improved try_macro_suggestionDuddino-4/+5
2020-04-17Moved is_try check into try_macro_suggestionDuddino-4/+3
2020-04-17Account for use of `try!()` in 2018 edition and guide users in the right ↵Duddino-0/+35
direction
2020-04-14allow try as scrutinee, e.g. `match try ...`Bastian Kauschke-5/+3
2020-04-03.unwrap() less on .span_to_snippet()Mazdak Farrokhzad-3/+3
2020-04-02Rollup merge of #70421 - Centril:recover-const-async-fn-ptr, r=estebankMazdak Farrokhzad-18/+30
parse: recover on `const fn()` / `async fn()` Recover on `const fn()` and `async fn()` function pointers, suggesting to remove the qualifier. For example: ``` error: an `fn` pointer type cannot be `async` --> $DIR/recover-const-async-fn-ptr.rs:6:11 | LL | type T3 = async fn(); | -----^^^^^ | | | `async` because of this | help: remove the `async` qualifier ``` r? @estebank
2020-04-01Rollup merge of #70522 - rcoh:60762-raw-string-errors, r=petrochenkovMazdak Farrokhzad-3/+30
Improve error messages for raw strings (#60762) This diff improves error messages around raw strings in a few ways: - Catch extra trailing `#` in the parser. This can't be handled in the lexer because we could be in a macro that actually expects another # (see test) - Refactor & unify error handling in the lexer between ByteStrings and RawByteStrings - Detect potentially intended terminators (longest sequence of "#*" is suggested) Fixes #60762 cc @estebank who reviewed the original (abandoned) PR for the same ticket. r? @Centril
2020-03-30Clean up redudant conditions and match exprsRussell Cohen-11/+10
2020-03-30parse_and_disallow_postfix_after_cast: account for `ExprKind::Err`.Mazdak Farrokhzad-0/+1
2020-03-29Cleanup match expressionRussell Cohen-11/+7
2020-03-29Cleanup error messages, improve docstringsRussell Cohen-4/+7
2020-03-29Improve error messages for raw strings (#60762)Russell Cohen-1/+30
This diff improves error messages around raw strings in a few ways: - Catch extra trailing `#` in the parser. This can't be handled in the lexer because we could be in a macro that actually expects another # (see test) - Refactor & unify error handling in the lexer between ByteStrings and RawByteStrings - Detect potentially intended terminators (longest sequence of "#*" is suggested)
2020-03-27address some review commentsMazdak Farrokhzad-6/+8
2020-03-27parse: improve recovery for assoc eq constraints.Mazdak Farrokhzad-1/+43
2020-03-27extract parse_generic_argMazdak Farrokhzad-8/+14
2020-03-27parse_angle_arg: parse constraints firstMazdak Farrokhzad-4/+4