about summary refs log tree commit diff
path: root/src/libsyntax/parse/mod.rs
AgeCommit message (Collapse)AuthorLines
2019-11-10move syntax::parse -> librustc_parseMazdak Farrokhzad-420/+0
also move MACRO_ARGUMENTS -> librustc_parse
2019-11-10move config.rs to libsyntax_expandMazdak Farrokhzad-2/+1
2019-11-09move attr meta grammar to parse::validate_atr + ast_validationMazdak Farrokhzad-0/+1
2019-11-08Rollup merge of #65785 - Centril:compat-to-error-2, r=oli-obkMazdak Farrokhzad-1/+1
Transition future compat lints to {ERROR, DENY} - Take 2 Follow up to https://github.com/rust-lang/rust/pull/63247 implementing https://github.com/rust-lang/rust/pull/63247#issuecomment-536295992. - `legacy_ctor_visibility` (ERROR) -- closes #39207 - `legacy_directory_ownership` (ERROR) -- closes #37872 - `safe_extern_static` (ERROR) -- closes #36247 - `parenthesized_params_in_types_and_modules` (ERROR) -- closes #42238 - `duplicate_macro_exports` (ERROR) - `nested_impl_trait` (ERROR) -- closes #59014 - `ill_formed_attribute_input` (DENY) -- transitions #57571 - `patterns_in_fns_without_body` (DENY) -- transitions #35203 r? @varkor cc @petrochenkov
2019-11-07move syntax::{parse::literal -> util::literal}Mazdak Farrokhzad-2/+0
2019-11-07move parse::classify -> util::classifyMazdak Farrokhzad-1/+0
2019-11-07move PResult to librustc_errorsMazdak Farrokhzad-10/+1
2019-11-07syntax::parser::token -> syntax::tokenMazdak Farrokhzad-2/+1
2019-11-07move unescape_error_reporting to lexer/Mazdak Farrokhzad-1/+0
2019-11-06Make doc comments cheaper with `AttrKind`.Nicholas Nethercote-9/+13
`AttrKind` is a new type with two variants, `Normal` and `DocComment`. It's a big performance win (over 10% in some cases) because `DocComment` lets doc comments (which are common) be represented very cheaply. `Attribute` gets some new helper methods to ease the transition: - `has_name()`: check if the attribute name matches a single `Symbol`; for `DocComment` variants it succeeds if the symbol is `sym::doc`. - `is_doc_comment()`: check if it has a `DocComment` kind. - `{get,unwrap}_normal_item()`: extract the item from a `Normal` variant; panic otherwise. Fixes #60935.
2019-11-06Remove unnecessary `Deref` impl for `Attribute`.Nicholas Nethercote-4/+4
This kind of thing just makes the code harder to read.
2019-11-06legacy_directory_ownership -> errorMazdak Farrokhzad-1/+1
2019-10-30Do not complain about missing `fn main()` in some casesEsteban Küber-2/+2
2019-10-30Reduce ammount of errors given unclosed delimiterEsteban Küber-12/+3
When in a file with a non-terminated item, catch the error and consume the block instead of trying to recover it more granularly in order to reduce the amount of unrelated errors that would be fixed after adding the missing closing brace. Also point out the possible location of the missing closing brace.
2019-10-27syntax/attr: reduce reliance on parserMazdak Farrokhzad-0/+21
2019-10-25move panictry! to where it is used.Mazdak Farrokhzad-0/+17
2019-10-16move SeqSep to parser.rsMazdak Farrokhzad-25/+1
2019-10-16move diagnostics.rs into parser/Mazdak Farrokhzad-1/+0
2019-10-16move parse::attr -> parse::parser::attrMazdak Farrokhzad-1/+0
2019-10-15syntax::parse::sess -> syntax::sessMazdak Farrokhzad-2/+1
2019-10-15syntax: extract sess.rs for ParseSessMazdak Farrokhzad-118/+7
2019-10-13token: extract Nonterminal::to_tokenstream to parser.Mazdak Farrokhzad-4/+134
2019-10-02Add support for 'extern const fn'Aaron Hill-0/+2
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-09-23Auto merge of #64272 - Mark-Simulacrum:parallel-handler, r=estebankbors-1/+1
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-21Rollup merge of #64010 - c410-f3r:stabilize-attrs-fn, r=CentrilMazdak Farrokhzad-2/+0
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-17Privatize DiagnosticBuilder constructorsMark Rousskov-1/+1
2019-09-12Box `DiagnosticBuilder`.Nicholas Nethercote-0/+7
It's a large type -- 176 bytes on 64-bit. And it's passed around and returned from a lot of functions, including within PResult. This commit boxes it, which reduces memory traffic. In particular, `PResult` shrinks to 16 bytes in the best case; this reduces instruction counts by up to 2% on various workloads.
2019-09-11Stabilize `param_attrs` in Rust 1.39.0Caio-2/+0
2019-09-07Rollup merge of #64226 - alexreg:rush-pr-3, r=centrilMazdak Farrokhzad-26/+27
Aggregation of cosmetic changes made during work on REPL PRs: libsyntax Factored out from hacking on rustc for work on the REPL. r? @Centril
2019-09-07Aggregation of cosmetic changes made during work on REPL PRs: libsyntaxAlexander Regueiro-26/+27
2019-09-05Replace diagnostic plugins with macro_rulesMark Rousskov-4/+0
2019-08-20Use dedicated type for spans in pre-expansion gating.Mazdak Farrokhzad-14/+18
2019-08-17initial implementation of or-pattern parsingDan Robertson-0/+3
Initial implementation of parsing or-patterns e.g., `Some(Foo | Bar)`. This is a partial implementation of RFC 2535.
2019-08-16Feature gate 'yield ?' pre-expansion.Mazdak Farrokhzad-0/+3
2019-08-15hygiene: `ExpnInfo` -> `ExpnData`Vadim Petrochenkov-1/+1
For naming consistency with everything else in this area
2019-08-15syntax_pos: Remove the duplicate global editionVadim Petrochenkov-1/+2
It was introduced to avoid going through `hygiene_data`, but now it's read only once, when `ParseSess` is created, so going through a lock is ok.
2019-08-02Auto merge of #63207 - petrochenkov:outest2, r=Mark-Simulacrumbors-292/+4
Unconfigure compiler unit test files during normal build I haven't touched libstd though, it had a lot of tests and I'm not sure the people maintaining it want this. Closes https://github.com/rust-lang/rust/issues/61097 r? @Mark-Simulacrum
2019-08-02libsyntax: Unconfigure tests during normal buildVadim Petrochenkov-292/+4
2019-08-02Fix typos in doc comments.Bruce Mitchener-1/+1
2019-07-27Move standard library injection into libsyntax_extVadim Petrochenkov-1/+4
2019-07-21move unescape module to rustc_lexerAleksey Kladov-1/+0
2019-07-06Rollup merge of #62329 - matklad:no-peeking, r=petrochenkovMazdak Farrokhzad-1/+1
Remove support for 1-token lookahead from the lexer `StringReader` maintained `peek_token` and `peek_span_src_raw` for look ahead. `peek_token` was used only by rustdoc syntax coloring. After moving peeking logic into highlighter, I was able to remove `peek_token` from the lexer. I tried to use `iter::Peekable`, but that wasn't as pretty as I hoped, due to buffered fatal errors. So I went with hand-rolled peeking. After that I've noticed that the only peeking behavior left was for raw tokens to test tt jointness. I've rewritten it in terms of trivia tokens, and not just spans. After that it became possible to simplify the awkward constructor of the lexer, which could return `Err` if the first peeked token contained error.
2019-07-04cleanup lexer constructorsAleksey Kladov-1/+1
2019-07-03Add separate 'async_closure' feature gate.Mazdak Farrokhzad-0/+3
2019-06-23let_chains: Move feature gating to pre-expansion.Mazdak Farrokhzad-1/+4
2019-06-12Auto merge of #60669 - c410-f3r:attrs-fn, r=petrochenkovbors-0/+2
Allow attributes in formal function parameters Implements https://github.com/rust-lang/rust/issues/60406. This is my first contribution to the compiler and since this is a large and complex project, I am not fully aware of the consequences of the changes I have made. **TODO** - [x] Forbid some built-in attributes. - [x] Expand cfg/cfg_attr
2019-06-12Rollup merge of #61654 - Electron-libre:use_slice_patterns_in_rustc, ↵Mazdak Farrokhzad-37/+27
r=oli-obk,Centril use pattern matching for slices destructuring refs #61542 Use slices pattern where it seems to make sense .
2019-06-09Allow attributes in formal function parametersCaio-0/+2
2019-06-08syntax: Remove `Deref` impl from `Token`Vadim Petrochenkov-2/+2
2019-06-08fix libsyntax testCedric-4/+4