about summary refs log tree commit diff
path: root/src/libsyntax
AgeCommit message (Collapse)AuthorLines
2019-09-07Aggregation of cosmetic changes made during work on REPL PRs: libsyntaxAlexander Regueiro-524/+538
2019-09-07Rollup merge of #64243 - petrochenkov:cmdattr, r=alexcrichtonMazdak Farrokhzad-47/+14
Move injection of attributes from command line to `libsyntax_ext` Just a tiny bit of code generation that wasn't moved into `libsyntax_ext` in https://github.com/rust-lang/rust/pull/62771.
2019-09-07Rollup merge of #64236 - matklad:reduce-visibility, r=CentrilMazdak Farrokhzad-12/+12
reduce visibility
2019-09-07Rollup merge of #64233 - varkor:correct-pluralisation, r=estebankMazdak Farrokhzad-2/+7
Correct pluralisation of various diagnostic messages
2019-09-07Rollup merge of #64192 - estebank:turbofish-madness, r=petrochenkovMazdak Farrokhzad-2/+5
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-07Rollup merge of #63919 - matthewjasper:remove-gensymmed, r=petrochenkovMazdak Farrokhzad-11/+21
Use hygiene for AST passes AST passes are now able to have resolve consider their expansions as if they were opaque macros defined either in some module in the current crate, or a fake empty module with `#[no_implicit_prelude]`. * Add an ExpnKind for AST passes. * Remove gensyms in AST passes. * Remove gensyms in`#[test]`, `#[bench]` and `#[test_case]`. * Allow opaque macros to define tests. * Move tests for unit tests to their own directory. * Remove `Ident::{gensym, is_gensymed}` - `Ident::gensym_if_underscore` still exists. cc #60869, #61019 r? @petrochenkov
2019-09-06Move injection of attributes from command line to `libsyntax_ext`Vadim Petrochenkov-47/+14
2019-09-06reduce visibilityAleksey Kladov-12/+12
2019-09-06Correct pluralisation of various diagnostic messagesvarkor-2/+7
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-06Rollup merge of #64111 - Centril:ast-only-patkind-or, r=petrochenkovMazdak Farrokhzad-65/+43
or-patterns: Uniformly use `PatKind::Or` in AST & Fix/Cleanup resolve Following up on work in https://github.com/rust-lang/rust/pull/63693 and https://github.com/rust-lang/rust/pull/61708, in this PR we: - Uniformly use `PatKind::Or(...)` in AST: - Change `ast::Arm.pats: Vec<P<Pat>>` => `ast::Arm.pat: P<Pat>` - Change `ast::ExprKind::Let.0: Vec<P<Pat>>` => `ast::ExprKind::Let.0: P<Pat>` - Adjust `librustc_resolve/late.rs` to correctly handle or-patterns at any level of nesting as a result. In particular, the already-bound check which rejects e.g. `let (a, a);` now accounts for or-patterns. The consistency checking (ensures no missing bindings and binding mode consistency) also now accounts for or-patterns. In the process, a bug was found in the current compiler which allowed: ```rust enum E<T> { A(T, T), B(T) } use E::*; fn foo() { match A(0, 1) { B(mut a) | A(mut a, mut a) => {} } } ``` The new algorithms took a few iterations to get right. I tried several clever schemes but ultimately a version based on a stack of hashsets and recording product/sum contexts was chosen since it is more clearly correct. - Clean up `librustc_resolve/late.rs` by, among other things, using a new `with_rib` function to better ensure stack dicipline. - Do not push the change in AST to HIR for now to avoid doing too much in this PR. To cope with this, we introduce a temporary hack in `rustc::hir::lowering` (clearly marked in the diff). cc https://github.com/rust-lang/rust/issues/54883 cc @dlrobertson @matthewjasper r? @petrochenkov
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-2/+5
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-05Remove rustc_diagnostic_macros featureMark Rousskov-7/+0
2019-09-05Replace diagnostic plugins with macro_rulesMark Rousskov-223/+31
2019-09-05Restrict error code length to 80 columnsMark Rousskov-5/+15
The global restriction is 100, but since error codes are printed out via --explain we want to restrict them to just 80 columns.
2019-09-05Add `with_{def_site,call_site,legacy}_ctxt,` methods to `Span`Vadim Petrochenkov-7/+7
Use these to create call-site spans for AST passes when needed.
2019-09-05Fix 2018 edition expanded pretty printingMatthew Jasper-4/+8
2019-09-05Make use of hygiene in AST passesMatthew Jasper-2/+0
2019-09-05Allow ast passes to create hygienic spansMatthew Jasper-1/+9
2019-09-05Rollup merge of #64041 - matklad:token-stream-tt, r=petrochenkovMazdak Farrokhzad-45/+38
use TokenStream rather than &[TokenTree] for built-in macros That way, we don't loose the jointness info
2019-09-05Rollup merge of #62848 - matklad:xid-unicode, r=petrochenkovMazdak Farrokhzad-11/+6
Use unicode-xid crate instead of libcore This PR proposes to remove `char::is_xid_start` and `char::is_xid_continue` functions from `libcore` and use `unicode_xid` crate from crates.io (note that this crate is already present in rust-lang/rust's Cargo.lock). Reasons to do this: * removing rustc-binary-specific stuff from libcore * making sure that, across the ecosystem, there's a single definition of what rust identifier is (`unicode-xid` has almost 10 million downs, as a `proc_macro2` dependency) * making it easier to share `rustc_lexer` crate with rust-analyzer: no need to `#[cfg]` if we are building as a part of the compiler Reasons not to do this: * increased maintenance burden: we'll need to upgrade unicode version both in libcore and in unicode-xid. However, this shouldn't be a too heavy burden: just running `./unicode.py` after new unicode version. I (@matklad) am ready to be a t-compiler side maintainer of unicode-xid. Moreover, given that xid-unicode is an important dependency of syn, *someone* needs to maintain it anyway. * xid-unicode implementation is significantly slower. It uses a more compact table with binary search, instead of a trie. However, this shouldn't matter in practice, because we have fast-path for ascii anyway, and code size savings is a plus. Moreover, in #59706 not using libcore turned out to be *faster*, presumably beacause checking for whitespace with match is even faster. <details> <summary>old description</summary> Followup to #59706 r? @eddyb Note that this doesn't actually remove tables from libcore, to avoid conflict with https://github.com/rust-lang/rust/pull/62641. cc https://github.com/unicode-rs/unicode-xid/pull/11 </details>
2019-09-05or-patterns: address review comments.Mazdak Farrokhzad-5/+2
2019-09-05or-patterns: syntax: adjust derive, format, and building.Mazdak Farrokhzad-5/+5
2019-09-05or-patterns: syntax: adjust pretty printing.Mazdak Farrokhzad-13/+8
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-05or-patterns: syntax: adjust `visit` and `mut_visit`.Mazdak Farrokhzad-17/+13
2019-09-05or-patterns: syntax: simplify `Arm.pats` and `ExprKind::Let.0`.Mazdak Farrokhzad-3/+3
2019-09-05resolve: already-bound-check: account for or-patterns.Mazdak Farrokhzad-9/+11
Also document `ast::Pat::walk`.
2019-09-04flatten rustc_lexer::character_properties moduleAleksey Kladov-11/+6
On the call site, `rustc_lexer::is_whitespace` reads much better than `character_properties::is_whitespace`.
2019-09-04remove XID and Pattern_White_Space unicode tables from libcoreAleksey Kladov-2/+2
They are only used by rustc_lexer, and are not needed elsewhere. So we move the relevant definitions into rustc_lexer (while the actual unicode data comes from the unicode-xid crate) and make the rest of the compiler use it.
2019-09-03use TokenStream rather than &[TokenTree] for built-in macrosAleksey Kladov-45/+38
That way, we don't loose the jointness info
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-30Auto merge of #63402 - estebank:strip-margin, r=oli-obkbors-31/+62
Strip code to the left and right in diagnostics for long lines Fix #62999.
2019-08-30Add a "diagnostic item" schemeOliver Scherer-0/+11
This allows lints and other diagnostics to refer to items by a unique ID instead of relying on whacky path resolution schemes that may break when items are relocated.
2019-08-29Rollup merge of #63867 - petrochenkov:dhelpers, r=matthewjasperMazdak Farrokhzad-54/+86
resolve: Block expansion of a derive container until all its derives are resolved So, it turns out there's one more reason to block expansion of a `#[derive]` container until all the derives inside it are resolved, beside `Copy` (https://github.com/rust-lang/rust/pull/63248). The set of derive helper attributes registered by derives in the container also has to be known before the derives themselves are expanded, otherwise it may be too late (see https://github.com/rust-lang/rust/pull/63468#issuecomment-524550872 and the `#[stable_hasher]`-related test failures in https://github.com/rust-lang/rust/pull/63468). So, we stop our attempts to unblock the container earlier, as soon as the `Copy` status is known, and just block until all its derives are resolved. After all the derives are resolved we immediately go and process their helper attributes in the item, without delaying it until expansion of the individual derives. Unblocks https://github.com/rust-lang/rust/pull/63468 r? @matthewjasper (as a reviewer of https://github.com/rust-lang/rust/pull/63248) cc @c410-f3r
2019-08-29Rollup merge of #63945 - Centril:recover-mut-pat, r=estebankMazdak Farrokhzad-55/+149
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-28Auto merge of #63127 - kper:pr, r=nikomatsakisbors-118/+120
Cleanup: Consistently use `Param` instead of `Arg` #62426 Fixes #62426
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-118/+120
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-7/+10
2019-08-27token: refactor with is_non_raw_ident_where.Mazdak Farrokhzad-19/+13
2019-08-27Rollup merge of #63761 - petrochenkov:procattrs, r=eddybMazdak Farrokhzad-67/+86
Propagate spans and attributes from proc macro definitions Thanks to https://github.com/rust-lang/rust/pull/63269 we now have spans and attributes from proc macro definitions available in metadata. However, that PR didn't actually put them into use! This PR finishes that work. Attributes `rustc_macro_transparency`, `allow_internal_unstable`, `allow_internal_unsafe`, `local_inner_macros`, `rustc_builtin_macro`, `stable`, `unstable`, `rustc_deprecated`, `deprecated` now have effect when applied to proc macro definition functions. From those attributes only `deprecated` is both stable and supposed to be used in new code. (`#![staged_api]` still cannot be used in proc macro crates for unrelated reasons though.) `Span::def_site` from the proc macro API now returns the correct location of the proc macro definition. Also, I made a mistake in https://github.com/rust-lang/rust/pull/63269#discussion_r312702919, loaded proc macros didn't actually use the resolver cache. This PR fixes the caching issue, now proc macros go through the `Resolver::macro_map` cache as well. (Also, the first commit turns `proc_macro::quote` into a regular built-in macro to reduce the number of places where `SyntaxExtension`s need to be manually created.)
2019-08-27proc_macro: Update `Span::def_site` to use the proc macro definition locationVadim Petrochenkov-8/+8
Which is no longer dummy and is available from metadata now.
2019-08-27Respect attributes on proc macro definitionsVadim Petrochenkov-59/+78
2019-08-26Rollup merge of #63855 - killercup:refactor/feature-gates, r=CentrilMazdak Farrokhzad-302/+404
Refactor feature gates After #63824, this goes a few steps further by - parsing doc comments in the macros to extract descriptions for feature gates, and - introducing a common `Feature` type to replace the tuples used previously to improve readability. The descriptions are not yet used, but I felt like this PR is a useful enough refactoring on its own. r? @Centril