about summary refs log tree commit diff
path: root/src/libsyntax/parse
AgeCommit message (Collapse)AuthorLines
2019-10-14Rollup merge of #65362 - Centril:extract_fun, r=petrochenkovMazdak Farrokhzad-487/+491
syntax: consolidate function parsing in item.rs Extracted from https://github.com/rust-lang/rust/pull/65324. r? @estebank
2019-10-14Use `TokenStream::default()` in more places.Nicholas Nethercote-2/+2
2019-10-14Remove the `Option` in `TokenStream`.Nicholas Nethercote-1/+1
It means an allocation is required to create an empty `TokenStream`, but all other operations are simpler and marginally faster due to not having to check for `None`. Overall it simplifies the code for a negligible performance effect. The commit also removes `TokenStream::empty` by implementing `Default`, which is now possible.
2019-10-13token: extract Nonterminal::to_tokenstream to parser.Mazdak Farrokhzad-138/+137
2019-10-13syntax: consolidate function parsing in `item.rs`Mazdak Farrokhzad-487/+491
2019-10-13Rollup merge of #65359 - Centril:sil, r=davidtwcoMazdak Farrokhzad-9/+6
simplify integer_lit Extracted from https://github.com/rust-lang/rust/pull/65324. r? @davidtwco
2019-10-13Collect occurrences of for mismatched braces diagnosticwangxiangqing-1/+4
Change-Id: I20ba0b62308370ee961141fa1aefc4b9c9f0cb3a
2019-10-13Collect occurrences of for mismatched braces diagnosticwangxiangqing-3/+17
Change-Id: I20ba0b62308370ee961141fa1aefc4b9c9f0cb3a
2019-10-13ast: remove implicit pprust dependency via Display.Mazdak Farrokhzad-5/+10
Instead just use `pprust::path_to_string(..)` where needed. This has two benefits: a) The AST definition is now independent of printing it. (Therefore we get closer to extracting a data-crate.) b) Debugging should be easier as program flow is clearer.
2019-10-13simplify integer_litMazdak Farrokhzad-9/+6
2019-10-13syntax: simplify maybe_annotate_with_ascriptionMazdak Farrokhzad-9/+11
2019-10-07syntax: refactor with new `fn parse_use_tree_glob_or_nested`.Mazdak Farrokhzad-10/+11
2019-10-07syntax: use `parse_extern_abi` more.Mazdak Farrokhzad-8/+1
2019-10-07syntax: unify and simplify fn signature parsing.Mazdak Farrokhzad-91/+74
2019-10-07syntax: unify trait parsing a bit.Mazdak Farrokhzad-17/+12
2019-10-07syntax: further item parsing cleanupMazdak Farrokhzad-24/+35
2019-10-07syntax: de-dups in item parsing.Mazdak Farrokhzad-50/+44
2019-10-07syntax: cleanup associated const parsing.Mazdak Farrokhzad-32/+39
2019-10-07Auto merge of #64906 - Aaron1011:feature/extern-const-fn, r=Centrilbors-19/+45
Add support for `const unsafe? extern fn` This works just as you might expect - an `const extern fn` is a `const fn` that is callable from foreign code. Currently, panicking is not allowed in `const`s. When https://github.com/rust-lang/rfcs/pull/2345 (https://github.com/rust-lang/rust/issues/51999) is stabilized, then panicking in an `const extern fn` will produce a compile-time error when invoked at compile time, and an abort when invoked at runtime. Since this is extending the language (we're allowing the `const` keyword in a new context), I believe that this will need an FCP. However, it's a very minor change, so I didn't think that filing an RFC was necessary. This will allow libc (and other FFI crates) to make many functions `const`, without having to give up on making them `extern` as well. Tracking issue: https://github.com/rust-lang/rust/issues/64926.
2019-10-05Rollup merge of #65123 - Centril:mac-invoc-in-mut-pat, r=estebankTyler Mandry-1/+5
Account for macro invocation in `let mut $pat` diagnostic. Fixes https://github.com/rust-lang/rust/issues/65122. r? @estebank
2019-10-05Rollup merge of #64909 - estebank:turbofish-reloaded, r=CentrilTyler Mandry-14/+153
When encountering chained operators use heuristics to recover from bad turbofish
2019-10-05Account for macro invocation in `let mut $pat` diagnostic.Mazdak Farrokhzad-1/+5
2019-10-03review commentsEsteban Küber-25/+32
2019-10-03review commentsEsteban Küber-20/+17
2019-10-03review commentsEsteban Küber-36/+43
2019-10-03Account for missing turbofish in paths tooEsteban Küber-4/+43
2019-10-03review commentsEsteban Küber-38/+49
2019-10-03When encountering chained operators use heuristics to recover from bad turbofishEsteban Küber-13/+91
2019-10-02syntax: improve parameter without type suggestionsDavid Wood-8/+25
This commit improves the suggestions provided when function parameters do not have types: - A new suggestion is added for arbitrary self types, which suggests adding `self: ` before the type. - Existing suggestions are now provided when a `<` is found where a `:` was expected (previously only `,` and `)` or trait items), this gives suggestions in the case where the unnamed parameter type is generic in a free function. - The suggestion that a type name be provided (e.g. `fn foo(HashMap<u32>)` -> `fn foo(HashMap: TypeName<u32>)`) will no longer occur when a `<` was found instead of `:`. - The ident will not be used for recovery when a `<` was found instead of `:`. Signed-off-by: David Wood <david@davidtw.co>
2019-10-02Add missing 'bump'Aaron Hill-0/+1
2019-10-02Add support for 'extern const fn'Aaron Hill-19/+44
This works just as you might expect - an 'extern const fn' is a 'const fn' that is callable from foreign code. Currently, panicking is not allowed in consts. When RFC 2345 is stabilized, then panicking in an 'extern const fn' will produce a compile-time error when invoked at compile time, and an abort when invoked at runtime. Since this is extending the language (we're allowing the `const` keyword in a new context), I believe that this will need an FCP. However, it's a very minor change, so I didn't think that filing an RFC was necessary. This will allow libc (and other FFI crates) to make many functions `const`, without having to give up on making them `extern` as well.
2019-10-01Rollup merge of #64910 - Centril:params-cleanup, r=petrochenkovMazdak Farrokhzad-563/+495
syntax: cleanup param, method, and misc parsing Do some misc cleanup of the parser: - Method and parameter parsing is refactored. - A parser for `const | mut` is introduced that https://github.com/rust-lang/rust/pull/64588 can reuse. - Some other misc parsing. Next up in a different PR: - ~Implementing https://github.com/rust-lang/rust/issues/64252.~ -- maybe some other time... - Heavily restructuring up `item.rs` which is a mess (hopefully, no promises ^^). r? @petrochenkov
2019-10-01Rollup merge of #64907 - alexreg:tidy-up, r=Mark-SimulacrumMazdak Farrokhzad-1/+1
A small amount of tidying-up factored out from PR #64648 As requested by @Mark-Simulacrum, I put this in a separate commit to make it easier to review. (As far as I can tell, no violations of the policy here, and they are simply in a separate PR because they're not directly related to the import of that PR.) r? @Mark-Simulacrum
2019-10-01Rollup merge of #64887 - Centril:recover-trailing-vert, r=estebankMazdak Farrokhzad-26/+79
syntax: recover trailing `|` in or-patterns Fixes https://github.com/rust-lang/rust/issues/64879. For example (this also shows that we are sensitive to the typo `||`): ``` error: a trailing `|` is not allowed in an or-pattern --> $DIR/remove-leading-vert.rs:33:11 | LL | A || => {} | - ^^ help: remove the `||` | | | while parsing this or-pattern starting here | = note: alternatives in or-patterns are separated with `|`, not `||` ``` r? @estebank
2019-10-01syntax: reformat passing of `FnHeader` to `parse_item_fn`.Mazdak Farrokhzad-12/+16
2019-10-01syntax: de-closure-ify `check_or_expected`.Mazdak Farrokhzad-7/+7
2019-10-01syntax: merge things back into `parse_visibility`.Mazdak Farrokhzad-37/+25
2019-10-01syntax: put helpers of `parse_self_param` in the method.Mazdak Farrokhzad-58/+57
2019-10-01syntax: document some methods.Mazdak Farrokhzad-2/+6
2019-10-01Address review commentsVadim Petrochenkov-2/+2
2019-09-30syntax: Support modern attribute syntax in the `meta` matcherVadim Petrochenkov-17/+22
2019-09-30syntax: Split `ast::Attribute` into container and inner partsVadim Petrochenkov-2/+1
2019-09-30syntax: reduce repetition in fn parsing.Mazdak Farrokhzad-26/+21
2019-09-30syntax: stylistic cleanup in item parsing.Mazdak Farrokhzad-107/+47
2019-09-30syntax: fuse more code paths together.Mazdak Farrokhzad-48/+51
2019-09-30syntax: extract `error_on_invalid_abi`.Mazdak Farrokhzad-14/+17
2019-09-30syntax: cleanup `parse_visibility`.Mazdak Farrokhzad-53/+69
2019-09-30syntax: misc cleanupMazdak Farrokhzad-44/+30
2019-09-30syntax: cleanup `parse_fn_decl`.Mazdak Farrokhzad-6/+3
2019-09-30syntax: reorder param parsing to make more sense.Mazdak Farrokhzad-153/+153