Commit Graph

4245 Commits

Author SHA1 Message Date
Mazdak Farrokhzad beddf67a4b parser: don't hardcode ABIs into grammar 2019-11-07 05:25:31 +01:00
Nicholas Nethercote eea6f23a0e Make doc comments cheaper with AttrKind.
`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-06 23:05:07 +11:00
Nicholas Nethercote 69bc4aba78 Remove unnecessary Deref impl for Attribute.
This kind of thing just makes the code harder to read.
2019-11-06 23:01:02 +11:00
Mazdak Farrokhzad 4f9651b854 Rollup merge of #66139 - euclio:pluralize, r=nagisa
use American spelling for `pluralize!`
2019-11-06 07:03:14 +01:00
Mazdak Farrokhzad a0b4b4dafa Rollup merge of #65776 - nnethercote:rename-LocalInternedString-and-more, r=estebank
Rename `LocalInternedString` and more

This PR renames `LocalInternedString` as `SymbolStr`, removes an unnecessary `impl` from it, improves comments, and cleans up some `SymbolStr` uses.

r? @estebank
2019-11-06 07:03:01 +01:00
Mazdak Farrokhzad 409b2bf941 Rollup merge of #66098 - estebank:path-asciption-typo, r=Centril
Detect `::` -> `:` typo when involving turbofish

Fix #65569.
2019-11-06 03:28:15 +01:00
Mazdak Farrokhzad e5da1a12e7 Rollup merge of #66054 - petrochenkov:delspan, r=estebank
syntax: Avoid span arithmetic for delimiter tokens

The +/-1 logic is from the time where the whole group had a single span and the delimiter spans had to be calculated from it.
Now the delimiters have their own spans which are constructed by lexer or proc macro API and can be used directly.
If those spans are not perfect, then it should be fixed by tweaking the corresponding lexer logic rather than by trying to add or substract `1` from the span boundaries.

Fixes https://github.com/rust-lang/rust/issues/62524
r? @estebank
2019-11-06 03:28:09 +01:00
Andy Russell ad550b8ef3 use American spelling for pluralize! 2019-11-05 15:10:24 -05:00
Esteban Küber a8ccbf5f2f Account for typo in turbofish and suggest :: 2019-11-05 10:29:54 -08:00
Pietro Albini 6ad9f56316 Rollup merge of #66025 - petrochenkov:lohi, r=eddyb
`Span` cannot represent `span.hi < span.lo`

So we can remove the corresponding checks from various code
2019-11-05 14:37:01 +01:00
Esteban Küber 3bbfc7320b Detect :: -> : typo when involving turbofish 2019-11-04 16:19:55 -08:00
bors f49f388713 Auto merge of #65838 - estebank:resilient-recovery, r=Centril
Reduce amount of errors given unclosed delimiter

When in a file with a non-terminated item, catch the error and consume
the block instead of trying to recover it on a more granular way 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.

Fix #63690.
2019-11-04 02:30:45 +00:00
Vadim Petrochenkov 90f891d8ae syntax: Avoid span arithmetics for delimiter tokens 2019-11-03 14:58:12 +03:00
Nicholas Nethercote d0db290039 Remove the AsRef impl for SymbolStr.
Because it's highly magical, which goes against the goal of keeping
`SymbolStr` simple. Plus it's only used in a handful of places that
only require minor changes.
2019-11-02 09:01:02 +11:00
Nicholas Nethercote b9cef6984b Simplify various Symbol use points.
Including removing a bunch of unnecessary `.as_str()` calls, and a bunch
of unnecessary sigils.
2019-11-02 09:01:02 +11:00
Vadim Petrochenkov ecaa96418b Span cannot represent span.hi < span.lo
So we can remove the corresponding checks from various code
2019-11-01 23:40:07 +03:00
Guillaume Gomez 5dfb167bf3 Create new error E0743 2019-10-31 10:39:38 +01:00
Esteban Küber 454e2aa8c9 Do not complain about missing fn main() in some cases 2019-10-30 12:05:26 -07:00
Esteban Küber 053a09529a Reduce ammount of errors given unclosed delimiter
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-30 12:05:17 -07:00
Esteban Küber e8016c2b13 review comments 2019-10-28 10:53:13 -07:00
Esteban Küber 1b0836df6f Tweak unexpected token wording 2019-10-28 10:53:13 -07:00
Esteban Küber d673d0ac84 Use heuristics to recover parsing of missing ;
- Detect `,` and `:` typos where `;` was intended.
- When the next token could have been the start of a new statement,
  detect a missing semicolon.
2019-10-28 10:53:13 -07:00
Mazdak Farrokhzad 83260d5c43 Rollup merge of #65792 - Centril:split-syntax-2, r=petrochenkov
rustc, rustc_passes: reduce deps on rustc_expand

Part of #65324.

r? @petrochenkov
2019-10-28 04:53:07 +01:00
Mazdak Farrokhzad 16329402bf syntax/attr: reduce reliance on parser 2019-10-27 16:54:12 +01:00
Esteban Küber 93bb780e38 review comments and tweaks 2019-10-26 15:26:08 -07:00
Mazdak Farrokhzad c0bbb4bcdc Rollup merge of #65790 - Centril:move-report-invalid, r=davidtwco
move report_invalid_macro_expansion_item to item.rs

From https://github.com/rust-lang/rust/pull/65324.

r? @Mark-Simulacrum
2019-10-25 13:12:55 +02:00
Mazdak Farrokhzad cbcbba24ac Rollup merge of #65789 - Centril:with-desugared-doc, r=davidtwco
move Attribute::with_desugared_doc to librustdoc

From https://github.com/rust-lang/rust/pull/65324.

r? @varkor
2019-10-25 13:12:54 +02:00
Mazdak Farrokhzad 0bfe483c5c Rollup merge of #65787 - Centril:panictry, r=davidtwco
move panictry! to where it is used.

From https://github.com/rust-lang/rust/pull/65324

r? @davidtwco
2019-10-25 13:12:53 +02:00
Mazdak Farrokhzad 5ff7349ef7 move report_invalid_macro_expansion_item to item.rs 2019-10-25 05:26:36 +02:00
Mazdak Farrokhzad 0a5b38f9c3 move Attribute::with_desugared_doc to librustdoc 2019-10-25 04:38:42 +02:00
Mazdak Farrokhzad d7f6ba83fc move panictry! to where it is used. 2019-10-25 04:29:37 +02:00
Mazdak Farrokhzad 15a6c09b6e pre-expansion gate type_ascription 2019-10-24 00:32:03 +02:00
Mazdak Farrokhzad e4ed886578 pre-expansion gate box_syntax 2019-10-24 00:32:03 +02:00
Mazdak Farrokhzad 137ded8ab1 pre-expansion gate label_break_value 2019-10-24 00:32:03 +02:00
Mazdak Farrokhzad 1935ba658c pre-expansion gate try_blocks 2019-10-24 00:32:03 +02:00
Mazdak Farrokhzad 665a876e30 pre-expansion gate exclusive_range_pattern 2019-10-24 00:32:03 +02:00
Mazdak Farrokhzad 2aff6b36d7 pre-expansion gate box_patterns 2019-10-24 00:32:03 +02:00
Mazdak Farrokhzad 1f470ceac2 pre-expansion gate decl_macro 2019-10-24 00:32:03 +02:00
Mazdak Farrokhzad 49cbfa1a6f pre-expansion gate const_generics 2019-10-24 00:32:03 +02:00
Mazdak Farrokhzad 04c661ba02 pre-expansion gate crate_visibility_modifier 2019-10-24 00:32:03 +02:00
Mazdak Farrokhzad c17a1fd7d0 pre-expansion gate associated_type_bounds 2019-10-24 00:32:03 +02:00
Mazdak Farrokhzad 2d182b82ce pre-expansion gate trait_alias. 2019-10-24 00:32:03 +02:00
Mazdak Farrokhzad 2e64bb2d37 syntax: reject trait Foo: Bar = Baz;.
Add test for rejecting `trait A: B1 = B2;`.
Also test rejection of `trait A: = B;`.
2019-10-24 00:31:11 +02:00
Yuki Okushi 5bac361776 Rollup merge of #65686 - yjhmelody:yjhmelody-patch-1, r=Centril
refactor and move `maybe_append`
2019-10-23 17:14:42 +09:00
yjhmelody 40f92b3b05 refactor maybe_append 2019-10-22 12:25:14 +08:00
Tyler Mandry 3850408b9b Rollup merge of #65552 - JohnTitor:use-bitwise-not, r=Dylan-DPC
Clarify diagnostics when using `~` as a unary op

It seems we prefer `bitwise not` to `bitwise negation`.
Fixes #57239

r? @estebank
2019-10-18 13:48:38 -07:00
Tyler Mandry f5f5c9e993 Rollup merge of #65455 - nnethercote:avoid-unnecessary-TokenTree-to-TokenStream-conversions, r=petrochenkov
Avoid unnecessary `TokenTree` to `TokenStream` conversions

A `TokenStream` contains any number of `TokenTrees`. Therefore, a single `TokenTree` can be promoted to a `TokenStream`. But doing so costs two allocations: one for the single-element `Vec`, and one for the `Lrc`. (An `IsJoint` value also must be added; the default is `NonJoint`.)

The current code converts `TokenTree`s to `TokenStream`s unnecessarily in a few places. This PR removes some of these unnecessary conversions, both simplifying the code and speeding it up.

r? @petrochenkov
2019-10-18 13:48:18 -07:00
Tyler Mandry 8f8a23f642 Rollup merge of #65364 - XiangQingW:master, r=estebank
Collect occurrences of empty blocks for mismatched braces diagnostic

Fix #63904
2019-10-18 13:48:16 -07:00
Yuki Okushi 9617014aa6 Clarify diagnostics when using ~ as a unary op 2019-10-18 18:15:16 +09:00
Nicholas Nethercote 212ae58f36 Change Lit::tokens() to Lit::token_tree().
Because most of the call sites have an easier time working with a
`TokenTree` instead of a `TokenStream`.
2019-10-18 13:25:17 +11:00