Commit Graph

201 Commits

Author SHA1 Message Date
Mazdak Farrokhzad
27f97aa468 move syntax::parse::lexer::comments -> syntax::util::comments 2019-11-07 13:59:13 +01:00
Mazdak Farrokhzad
a1571b6855 syntax::attr: remove usage of lexer 2019-11-07 13:59:13 +01:00
Mazdak Farrokhzad
255b12a8d3 move parse::classify -> util::classify 2019-11-07 13:59:13 +01:00
Mazdak Farrokhzad
3667e6248e move PResult to librustc_errors 2019-11-07 13:58:36 +01:00
Mazdak Farrokhzad
9d6768a478 syntax::parser::token -> syntax::token 2019-11-07 13:50:12 +01:00
Mazdak Farrokhzad
8fa8e02c28 syntax: simplify imports 2019-11-07 13:50:12 +01:00
Mazdak Farrokhzad
da116223c7 move parse/parser.rs -> parse/parser/mod.rs 2019-11-07 13:50:12 +01:00
Mazdak Farrokhzad
e19cb40fda
Rollup merge of #65974 - Centril:matcher-friendly-gating, r=petrochenkov
A scheme for more macro-matcher friendly pre-expansion gating

Pre-expansion gating will now avoid gating macro matchers that did not result in `Success(...)`. That is, the following is now OK despite `box 42` being a valid `expr` and that form being pre-expansion gated:

```rust
macro_rules! m {
    ($e:expr) => { 0 }; // This fails on the input below due to `, foo`.
    (box $e:expr, foo) => { 1 }; // Successful matcher, we should get `2`.
}

fn main() {
    assert_eq!(1, m!(box 42, foo));
}
```

Closes https://github.com/rust-lang/rust/issues/65846.

r? @petrochenkov
cc @Mark-Simulacrum
2019-11-07 08:51:57 +01:00
Mazdak Farrokhzad
1db4d607e7 parser: allow ABIs from literal macro fragments 2019-11-07 05:25:31 +01:00
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
Mazdak Farrokhzad
fe95cd2f4b revamp pre-expansion gating infra 2019-11-06 12:30:08 +01: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
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
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
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
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
5ff7349ef7 move report_invalid_macro_expansion_item to item.rs 2019-10-25 05:26:36 +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
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
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
Mazdak Farrokhzad
1a26fdf9b2 ui-fulldeps: make them pass again? 2019-10-16 17:21:32 +02:00
Mazdak Farrokhzad
be40bbd2fb make tidy happy 2019-10-16 11:19:39 +02:00