about summary refs log tree commit diff
path: root/src/libsyntax/parse/parser
AgeCommit message (Collapse)AuthorLines
2019-09-29Rollup merge of #64894 - Centril:fix-64682, r=petrochenkovMazdak Farrokhzad-26/+18
syntax: fix dropping of attribute on first param of non-method assocated fn Fixes #64682. The general idea is that we bake parsing of `self` into `parse_param_general` and then we just use standard list parsing. Overall, this simplifies the parsing and makes it more consistent. r? @petrochenkov cc @c410-f3r
2019-09-29syntax: fix #64682.Mazdak Farrokhzad-26/+18
Fuse parsing of `self` into `parse_param_general`.
2019-09-29syntax: recover trailing `|` in or-patterns.Mazdak Farrokhzad-26/+79
2019-09-28syntax: don't keep a redundant c_variadic flag in the AST.Eduard-Mihai Burtescu-5/+2
2019-09-26Rename `MetaItem.node` to `MetaItem.kind`varkor-1/+1
2019-09-26Rename `ForeignItem.node` to `ForeignItem.kind`varkor-4/+4
2019-09-26Rename `Item.node` to `Item.kind`varkor-2/+2
2019-09-26Rename `Stmt.node` to `Stmt.kind`varkor-11/+11
2019-09-26Rename `Ty.node` to `Ty.kind`varkor-8/+8
2019-09-26Rename `TraitItem.node` to `TraitItem.kind`varkor-2/+2
2019-09-26Rename `ImplItem.node` to `ImplItem.kind`varkor-4/+4
2019-09-26Rename `Pat.node` to `Pat.kind`varkor-7/+7
2019-09-26Rename `Expr.node` to `Expr.kind`varkor-6/+6
For both `ast::Expr` and `hir::Expr`.
2019-09-23Add parser recovery for `const $ident = $expr;`.Mazdak Farrokhzad-3/+44
Then use the diagnostics-stealing API to stash parser errors and enrich them with type information in typeck.
2019-09-23Auto merge of #64272 - Mark-Simulacrum:parallel-handler, r=estebankbors-3/+3
Refactor librustc_errors::Handler API This should be reviewed by-commit. The last commit moves all fields into an inner struct behind a single lock; this is done to prevent possible deadlocks in a multi-threaded compiler, as well as inconsistent state observation.
2019-09-23Auto merge of #64695 - Centril:rollup-t1xnl2c, r=Centrilbors-38/+61
Rollup of 7 pull requests Successful merges: - #64294 (Fix `Stdio::piped` example code and lint) - #64670 (Cleanup syntax::ext::build) - #64674 (Propagate `types.err` in locals further to avoid spurious knock-down errors) - #64676 (Parse assoc type bounds in generic params and provide custom diagnostic) - #64677 (remove outdated comment) - #64679 (Infer consts more consistently) - #64688 (Clarify the "since" tidy check) Failed merges: r? @ghost
2019-09-23Rollup merge of #64676 - estebank:assoc-type-bound-in-generic, r=petrochenkovMazdak Farrokhzad-38/+61
Parse assoc type bounds in generic params and provide custom diagnostic Fix #26271.
2019-09-22review commentsEsteban Küber-1/+1
2019-09-22Point at correct span for parenthesized typesEsteban Küber-6/+7
2019-09-21review comments: wordingEsteban Küber-1/+1
2019-09-21Parse assoc type bounds in generic params and provide custom diagnosticEsteban Küber-38/+61
2019-09-21Rollup merge of #64342 - glorv:master, r=varkorMazdak Farrokhzad-7/+6
factor out pluralisation remains after #64280 there are two case that doesn't not match the original macro pattern at [here](https://github.com/rust-lang/rust/blob/master/src/librustc_lint/unused.rs#L146) and [here](https://github.com/rust-lang/rust/blob/master/src/libsyntax/parse/diagnostics.rs#L539) as the provided param is already a bool or the check condition is not `x != 1`, so I change the macro accept a boolean expr instead of number to fit all the cases. @Centril please review Fixes #64238.
2019-09-21Rollup merge of #64136 - crgl:doc-from-parser-lhs, r=CentrilMazdak Farrokhzad-0/+7
Document From trait for LhsExpr in parser Add doc for From trait for converting P<Expr> and Option<ThinVec<Attribute>> to LhsExpr As part of issue rust-lang#51430 (cc @skade). Both of these should just be moving an address and setting a discriminant in an enum. The main thing I'm not sure about is whether it's worth documenting the branch in the From<Option<ThinVec<Attribute>>. As far as I can tell it doesn't seem like it is optimized away (although if the discriminant happened to work out you could just copy the pointer and the discriminant which might be cheaper, but that's not guaranteed). So it seems like if it's being called often, it's doubling the number of possible branch mispredictions on this Option, which could be a significant cost. Let me know if there's anything that needs fixing and I'll get to it as soon as possible!
2019-09-21Rollup merge of #64010 - c410-f3r:stabilize-attrs-fn, r=CentrilMazdak Farrokhzad-1/+1
Stabilize `param_attrs` in Rust 1.39.0 # Stabilization proposal I propose that we stabilize `#![feature(param_attrs)]`. Tracking issue: #60406 Version: 1.39 (2019-09-26 => beta, 2019-11-07 => stable). ## What is stabilized It is now possible to add outer attributes like `#[cfg(..)]` on formal parameters of functions, closures, and function pointer types. For example: ```rust fn len( #[cfg(windows)] slice: &[u16], #[cfg(not(windows))] slice: &[u8], ) -> usize { slice.len() } ``` ## What isn't stabilized * Documentation comments like `/// Doc` on parameters. * Code expansion of a user-defined `#[proc_macro_attribute]` macro used on parameters. * Built-in attributes other than `cfg`, `cfg_attr`, `allow`, `warn`, `deny`, and `forbid`. Currently, only the lints `unused_variables` and `unused_mut` have effect and may be controlled on parameters. ## Motivation The chief motivations for stabilizing `param_attrs` include: * Finer conditional compilation with `#[cfg(..)]` and linting control of variables. * Richer macro DSLs created by users. * External tools and compiler internals can take advantage of the additional information that the parameters provide. For more examples, see the [RFC][rfc motivation]. ## Reference guide In the grammar of function and function pointer, the grammar of variadic tails (`...`) and parameters are changed respectively from: ```rust FnParam = { pat:Pat ":" }? ty:Type; VaradicTail = "..."; ``` into: ```rust FnParam = OuterAttr* { pat:Pat ":" }? ty:Type; VaradicTail = OuterAttr* "..."; ``` The grammar of a closure parameter is changed from: ```rust ClosureParam = pat:Pat { ":" ty:Type }?; ``` into: ```rust ClosureParam = OuterAttr* pat:Pat { ":" ty:Type }?; ``` More generally, where there's a list of formal (value) parameters separated or terminated by `,` and delimited by `(` and `)`. Each parameter in that list may optionally be prefixed by `OuterAttr+`. Note that in all cases, `OuterAttr*` applies to the whole parameter and not just the pattern. This distinction matters in pretty printing and in turn for macros. ## History * On 2018-10-15, @Robbepop proposes [RFC 2565][rfc], "Attributes in formal function parameter position". * On 2019-04-30, [RFC 2565][rfc] is merged and the tracking issue is made. * On 2019-06-12, a partial implementation was completed. The implementation was done in [#60669][60669] by @c410-f3r and the PR was reviewed by @petrochenkov and @Centril. * On 2019-07-29, [#61238][61238] was fixed in [#61856][61856]. The issue fixed was that lint attributes on function args had no effect. The PR was written by @c410-f3r and reviewed by @matthewjasper, @petrochenkov, and @oli-obk. * On 2019-08-02, a bug [#63210][63210] was filed wherein the attributes on formal parameters would not be passed to macros. The issue was about forgetting to call the relevant method in `fn print_arg` in the pretty printer. In [#63212][63212], written by @Centril on 2019-08-02 and reviewed by @davidtwco, the issue aforementioned was fixed. * This PR stabilizes `param_attrs`. ## Tests * [On Rust 2018, attributes aren't permitted on function parameters without a pattern in trait definitions.](https://github.com/rust-lang/rust/blob/master/src/test/ui/rfc-2565-param-attrs/param-attrs-2018.rs) * [All attributes that should be allowed. This includes `cfg`, `cfg_attr`, and lints check attributes.](https://github.com/rust-lang/rust/blob/master/src/test/ui/rfc-2565-param-attrs/param-attrs-allowed.rs) * [Built-in attributes, which should be forbidden, e.g., `#[test]`, are.](https://github.com/rust-lang/rust/blob/master/src/test/ui/rfc-2565-param-attrs/param-attrs-builtin-attrs.rs) * [`cfg` and `cfg_attr` are properly evaluated.](https://github.com/rust-lang/rust/blob/master/src/test/ui/rfc-2565-param-attrs/param-attrs-cfg.rs) * [`unused_mut`](https://github.com/rust-lang/rust/blob/46f405ec4d7c6bf16fc2eaafe7541019f1da2996/src/test/ui/rfc-2565-param-attrs/param-attrs-cfg.rs) and [`unused_variables`](https://github.com/rust-lang/rust/blob/master/src/test/ui/lint/lint-unused-variables.rs) are correctly applied to parameter patterns. * [Pretty printing takes formal parameter attributes into account.](https://github.com/rust-lang/rust/blob/master/src/test/ui/rfc-2565-param-attrs/param-attrs-pretty.rs) ## Possible future work * Custom attributes inside function parameters aren't currently supported but it is something being worked on internally. * Since documentation comments are syntactic sugar for `#[doc(...)]`, it is possible to allow literal `/// Foo` comments on function parameters. [rfc motivation]: https://github.com/rust-lang/rfcs/blob/master/text/2565-formal-function-parameter-attributes.md#motivation [rfc]: https://github.com/rust-lang/rfcs/pull/2565 [60669]: https://github.com/rust-lang/rust/pull/60669 [61856]: https://github.com/rust-lang/rust/pull/61856 [63210]: https://github.com/rust-lang/rust/issues/63210 [61238]: https://github.com/rust-lang/rust/issues/61238 [63212]: https://github.com/rust-lang/rust/pull/63212 This report is a collaborative work with @Centril.
2019-09-20factor out pluralisation remains after #64280gaolei-7/+6
2019-09-17Remove Handler::cancelMark Rousskov-3/+3
2019-09-16Document `From` trait for `LhsExpr`Charles Gleason-0/+7
2019-09-15Give more `Idents` spansMatthew Jasper-1/+1
2019-09-11Stabilize `param_attrs` in Rust 1.39.0Caio-1/+1
2019-09-09Resolve attributes in several placesCaio-3/+14
Arm, Field, FieldPat, GenericParam, Param, StructField and Variant
2019-09-07Apply suggestions from code reviewAlexander Regueiro-6/+6
2019-09-07Aggregation of cosmetic changes made during work on REPL PRs: libsyntaxAlexander Regueiro-166/+164
2019-09-07Rollup merge of #64192 - estebank:turbofish-madness, r=petrochenkovMazdak Farrokhzad-1/+1
Bail out when encountering likely missing turbofish in parser When encountering a likely intended turbofish without `::`, bubble up the diagnostic instead of emitting it to allow the parser to recover more gracefully and avoid uneccessary type errors that are likely to be wrong. Fix #61329.
2019-09-06Rollup merge of #64202 - alexreg:rush-pr-1, r=CentrilMazdak Farrokhzad-2/+2
Fixed grammar/style in some error messages Factored out from hacking on rustc for work on the REPL. r? @Centril
2019-09-06Fixed grammar/style in error messages and reblessed tests.Alexander Regueiro-2/+2
2019-09-05Bail out when encountering likely missing turbofish in parserEsteban Küber-1/+1
When encountering a likely intended turbofish without `::`, bubble up the diagnostic instead of emitting it to allow the parser to recover more gracefully and avoid uneccessary type errors that are likely to be wrong.
2019-09-05or-patterns: syntax: adjust parser removing a hack.Mazdak Farrokhzad-15/+3
Fuse `parse_top_pat` and `parse_top_pat_unpack` into just `parse_top_pat`.
2019-09-03Move path parsing earlier.Nicholas Nethercote-26/+30
It's a hot enough path that moving it slightly earlier gives a tiny but easy speedup.
2019-08-29Rollup merge of #63945 - Centril:recover-mut-pat, r=estebankMazdak Farrokhzad-30/+127
Recover `mut $pat` and other improvements - Recover on e.g. `mut Foo(x, y)` and suggest `Foo(mut x, mut y)`. Fixes https://github.com/rust-lang/rust/issues/63764. - Recover on e.g. `let mut mut x;` - Recover on e.g. `let keyword` and `let keyword(...)`. - Cleanups in `token.rs` with `fn is_non_raw_ident_where` and friends.
2019-08-29Rollup merge of #63938 - tshepang:typo, r=CentrilMazdak Farrokhzad-1/+1
or-pattern: fix typo in error message cc https://github.com/rust-lang/rust/issues/54883.
2019-08-28or-pattern: fix typo in error messageTshepang Lekhonkhobe-1/+1
2019-08-27Improve 'mut ' diagnostic.Mazdak Farrokhzad-20/+34
2019-08-27Ensure 'let mut ;' where ':pat' is banned.Mazdak Farrokhzad-0/+9
2019-08-27Cleanup: Consistently use `Param` instead of `Arg` #62426Kevin Per-12/+12
2019-08-27recover on 'mut ' and improve recovery for keywords.Mazdak Farrokhzad-31/+105
2019-08-27Simplify with Symbol/Token::is_book_lit.Mazdak Farrokhzad-1/+1
2019-08-26parser: fix span for leading vert.Mazdak Farrokhzad-1/+2
2019-08-25parser: TopLevel -> RecoverComma.Mazdak Farrokhzad-10/+10
2019-08-25parser: gracefully handle `fn foo(A | B: type)`.Mazdak Farrokhzad-10/+40
2019-08-25parser: 'while parsing this or-pattern...'Mazdak Farrokhzad-1/+4