about summary refs log tree commit diff
path: root/compiler/rustc_parse/src/parser/path.rs
AgeCommit message (Collapse)AuthorLines
2022-11-17Use `ThinVec` in `ast::Path`.Nicholas Nethercote-4/+5
2022-11-17Box `ExprKind::{Closure,MethodCall}`, and `QSelf` in expressions, types, and ↵Nicholas Nethercote-2/+2
patterns.
2022-11-11Introduce `ExprKind::IncludedBytes`clubby789-1/+3
2022-09-01Always import all tracing macros for the entire crate instead of piecemeal ↵Oli Scherer-1/+0
by module
2022-08-16Avoid unnecessary cloning in `Parser::get_ident_from_generic_arg`.Nicholas Nethercote-9/+5
2022-08-15Simplify attribute handling in `parse_bottom_expr`.Nicholas Nethercote-6/+1
`Parser::parse_bottom_expr` currently constructs an empty `attrs` and then passes it to a large number of other functions. This makes the code harder to read than it should be, because it's not clear that many `attrs` arguments are always empty. This commit removes `attrs` and the passing, simplifying a lot of functions. The commit also renames `Parser::mk_expr` (which takes an `attrs` argument) as `mk_expr_with_attrs`, and introduces a new `mk_expr` which creates an expression with no attributes, which is the more common case.
2022-06-14Rollup merge of #95211 - terrarier2111:improve-parser, r=compiler-errorsYuki Okushi-4/+16
Improve parser diagnostics This pr fixes https://github.com/rust-lang/rust/issues/93867 and contains a couple of diagnostics related changes to the parser. Here is a short list with some of the changes: - don't suggest the same thing that is the current token - suggest removing the current token if the following token is one of the suggestions (maybe incorrect) - tell the user to put a type or lifetime after where if there is none (as a warning) - reduce the amount of tokens suggested (via the new eat_noexpect and check_noexpect methods) If any of these changes are undesirable, i can remove them, thanks!
2022-06-13remove unnecessary `to_string` and `String::new`Takayuki Maeda-6/+6
2022-06-12Improves parser diagnostics, fixes #93867threadexception-4/+16
2022-04-28rustc_ast: Harmonize delimiter naming with `proc_macro::Delimiter`Vadim Petrochenkov-5/+6
2022-04-10better error for binder on associated type boundMichael Goulet-12/+36
2022-04-07Shrink `Nonterminal`.Nicholas Nethercote-1/+1
By heap allocating the argument within `NtPath`, `NtVis`, and `NtStmt`. This slightly reduces cumulative and peak allocation amounts, most notably on `deep-vector`.
2022-03-27Handle `,` to `;` substitution in arg paramsEsteban Kuber-0/+17
2022-03-27Provide suggestion for missing `>` in a type parameter listEsteban Kuber-1/+17
When encountering an inproperly terminated type parameter list, provide a suggestion to close it after the last non-constraint type parameter that was successfully parsed. Fix #94058.
2022-03-22cancel a not emitted error after parsing const generic argsTakayuki Maeda-4/+8
2022-03-10replace `self.clone()` with `self.create_snapshot_for_diagnostic()`Takayuki Maeda-2/+2
2022-03-10add doc commentsTakayuki Maeda-2/+2
2022-03-09implement `SnapshotParser` structTakayuki Maeda-3/+3
2022-03-09take over unclosed_delimsTakayuki Maeda-0/+1
2022-03-09remove an unnecessary commentTakayuki Maeda-1/+0
2022-03-09implement and use `diagnostic_snapshot`Takayuki Maeda-2/+1
2022-03-09initialize unclosed_delims fieldTakayuki Maeda-0/+1
2022-03-08suggest adding `{ .. }` around a const function with argumentsTakayuki Maeda-0/+9
2022-02-284 - Make more use of `let_chains`Caio-7/+7
Continuation of #94376. cc #53667
2022-02-25Suggest {} around more bad const generic exprsMichael Goulet-2/+17
2022-02-23rustc_errors: take `self` by value in `DiagnosticBuilder::cancel`.Eduard-Mihai Burtescu-1/+1
2022-01-18Rollup merge of #91150 - dtolnay:qpath, r=davidtwcoMatthias Krüger-10/+34
Let qpath contain NtTy: `<$:ty as $:ty>::…` Example: ```rust macro_rules! m { (<$type:ty as $trait:ty>::$name:ident) => { <$type as $trait>::$name }; } fn main() { let _: m!(<str as ToOwned>::Owned); } ``` Previous behavior: ```console error: expected identifier, found `ToOwned` --> src/main.rs:3:19 | 3 | <$type as $trait>::$name | ^^^^^^ expected identifier ... 8 | let _: m!(<str as ToOwned>::Owned); | --------------------------- | | | this macro call doesn't expand to a type | in this macro invocation ``` The <code>expected identifier, found \`ToOwned\`</code> error is particularly silly. I think it should be fine to accept this code as long as $trait is of the form `TyKind::Path(None, path)`; if it is any other kind of `NtTy`, we'll keep the same behavior as before.
2022-01-17Add term to ExistentialProjectionkadmin-1/+4
Also prevent ICE when adding a const in associated const equality.
2022-01-17Use Term in ProjectionPredicatekadmin-7/+5
ProjectionPredicate should be able to handle both associated types and consts so this adds the first step of that. It mainly just pipes types all the way down, not entirely sure how to handle consts, but hopefully that'll come with time.
2022-01-17Add termkadmin-2/+4
Instead of having a separate enum variant for types and consts have one but have either a const or type.
2022-01-17add eq constraints on associated constantskadmin-20/+17
2021-11-25Reject generic arguments on mod style interpolated pathDavid Tolnay-10/+24
2021-11-25Let qpath contain NtTy: <$:ty as $:ty>::restDavid Tolnay-0/+10
2021-11-24Account for incorrect `impl Foo<const N: ty> {}` syntaxEsteban Küber-39/+49
Fix #84946
2021-09-28Improve error messages for bad type constraintsMichael Howell-11/+20
Co-authored-by: Esteban Kuber <esteban@kuber.com.ar>
2021-09-16feat(rustc_parse): recover from pre-RFC-2000 const generics syntaxMichael Howell-1/+19
Fixes #89013
2021-06-05Fix handling of unmatched angle brackets in parserFabian Wolff-37/+47
2021-02-27Fix turbofish recovery with multiple generic argsÖmer Sinan Ağacan-1/+1
check_mistyped_turbofish_with_multiple_type_params was previously expecting type arguments between angle brackets, which is not right, as we can also see const expressions. We now use generic argument parser instead of type parser. Test with one, two, and three generic arguments added to check consistentcy between 1. check_no_chained_comparison: Called after parsing a nested binop application like `x < A > ...` where angle brackets are interpreted as binary operators and `A` is an expression. 2. check_mistyped_turbofish_with_multiple_type_params: called by `parse_full_stmt` when we expect to see a semicolon after parsing an expression but don't see it. (In `T2<1, 2>::C;`, the expression is `T2 < 1`)
2021-01-26Point only at generic arguments when they are unexpectedEsteban Küber-1/+9
2021-01-22improve diagnostics for angle argsb-naber-44/+11
2021-01-10Rework diagnostics for wrong number of generic argsPatryk Wychowaniec-1/+2
2021-01-01first pass at default values for const genericsJulian Knodt-11/+18
- Adds optional default values to const generic parameters in the AST and HIR - Parses these optional default values - Adds a `const_generics_defaults` feature gate
2020-12-24use matches!() macro in more placesMatthias Krüger-4/+3
2020-12-03Gracefully handle confusing -> with : in function return typemibac138-2/+2
2020-12-01Gracefully handle mistyping -> as => in function return typemibac138-2/+3
2020-11-27Auto merge of #79266 - b-naber:gat_trait_path_parser, r=petrochenkovbors-26/+83
Generic Associated Types in Trait Paths - Ast part The Ast part of https://github.com/rust-lang/rust/pull/78978 r? `@petrochenkov`
2020-11-25ast and parserb-naber-26/+83
2020-11-18Permit standalone generic parameters as const generic arguments in macrosvarkor-0/+8
2020-10-30Fix even more clippy warningsJoshua Nelson-6/+8
2020-10-26Suggest expressions that look like const generic arguments should be ↵varkor-17/+33
enclosed in brackets Co-Authored-By: Esteban Kuber <github@kuber.com.ar>